]> git.ipfire.org Git - thirdparty/openssl.git/blob - util/pl/netware.pl
Updated support for NetWare, submitted by Verdon Walker <VWalker@novell.com>.
[thirdparty/openssl.git] / util / pl / netware.pl
1 # Metrowerks Codewarrior for NetWare
2 #
3
4 # The import files and other misc imports needed to link
5 if ($LIBC)
6 {
7 @import_files = ("libc.imp", "ws2nlm.imp");
8 @module_files = ("libc");
9 }
10 else
11 {
12 # clib build
13 @import_files = ("clib.imp", "ws2nlm.imp");
14 @module_files = ("clib");
15 }
16 @misc_imports = ("GetProcessSwitchCount", "RunningProcess",
17 "GetSuperHighResolutionTimer" );
18
19 # The "IMPORTS" environment variable must be set and point to the location
20 # where import files (*.imp) can be found.
21 # Example: set IMPORTS=c:\ndk\nwsdk\imports
22 $import_path = $ENV{"IMPORTS"} || die ("IMPORTS environment variable not set\n");
23
24
25 # The "PRELUDE" environment variable must be set and point to the location
26 # and name of the prelude source to link with ( nwpre.obj is recommended ).
27 # Example: set PRELUDE=c:\codewar\novell support\metrowerks support\libraries\runtime\nwpre.obj
28 $prelude = $ENV{"PRELUDE"} || die ("PRELUDE environment variable not set\n");
29
30 #$ssl= "ssleay32";
31 #$crypto="libeay32";
32
33 $o='\\\\';
34 $cp='copy >nul:';
35 $rm='del';
36
37 # C compiler
38 $cc="mwccnlm";
39
40 # Linker
41 $link="mwldnlm";
42
43 # librarian
44 $mklib="mwldnlm";
45
46 # assembler
47 if ($nw_nasm)
48 {
49 $asm="nasmw -s -f coff";
50 $afile="-o ";
51 $asm.=" -g" if $debug;
52 }
53 elsif ($nw_mwasm)
54 {
55 $asm="mwasmnlm -maxerrors 20";
56 $afile="-o ";
57 $asm.=" -g" if $debug;
58 }
59 elsif ($nw_masm)
60 {
61 # masm assembly settings - it should be possible to use masm but haven't
62 # got it working.
63 # $asm='ml /Cp /coff /c /Cx';
64 # $asm.=" /Zi" if $debug;
65 # $afile='/Fo';
66 die("Support for masm assembler not yet functional\n");
67 }
68 else
69 {
70 $asm="";
71 $afile="";
72 }
73
74
75
76 # compile flags
77 #
78 # NOTES: Several c files in the crypto subdirectory include headers from
79 # their local directories. Metrowerks wouldn't find these h files
80 # without adding individual include directives as compile flags
81 # or modifying the c files. Instead of adding individual include
82 # paths for each subdirectory a recursive include directive
83 # is used ( -ir crypto ).
84 #
85 # A similar issue exists for the engines and apps subdirectories.
86 #
87 # Turned off the "possible" warnings ( -w nopossible ). Metrowerks
88 # complained a lot about various stuff. May want to turn back
89 # on for further development.
90 $cflags="-ir crypto -ir engines -ir apps -msgstyle gcc -align 4 -processor pentium \\
91 -char unsigned -w on -w nolargeargs -w nopossible -w nounusedarg \\
92 -w noimplicitconv -relax_pointers -nosyspath -DL_ENDIAN \\
93 -DOPENSSL_SYSNAME_NETWARE -U_WIN32 -maxerrors 20 ";
94
95 # link flags
96 $lflags="-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal ";
97
98
99 # additional flags based upon debug | non-debug
100 if ($debug)
101 {
102 $cflags.=" -opt off -g -sym internal -DDEBUG";
103 }
104 else
105 {
106 # CodeWarrior compiler has a problem with optimizations for floating
107 # points - no optimizations until further investigation
108 # $cflags.=" -opt all";
109 }
110
111 # If LibC build add in NKS_LIBC define and set the entry/exit
112 # routines - The default entry/exit routines are for CLib and don't exist
113 # in LibC
114 if ($LIBC)
115 {
116 $cflags.=" -DNETWARE_LIBC";
117 $lflags.=" -entry _LibCPrelude -exit _LibCPostlude -flags pseudopreemption";
118 }
119 else
120 {
121 $cflags.=" -DNETWARE_CLIB";
122 $lflags.=" -entry _Prelude -exit _Stop";
123 }
124
125
126 # linking stuff
127 # for the output directories use the mk1mf.pl values with "_nw" appended
128 if ($shlib)
129 {
130 if ($LIBC)
131 {
132 $out_def.="_nw_libc_nlm";
133 $tmp_def.="_nw_libc_nlm";
134 $inc_def.="_nw_libc_nlm";
135 }
136 else # NETWARE_CLIB
137 {
138 $out_def.="_nw_clib_nlm";
139 $tmp_def.="_nw_clib_nlm";
140 $inc_def.="_nw_clib_nlm";
141 }
142 }
143 else
144 {
145 $libp=".lib";
146 $shlibp=".lib";
147 $lib_flags="-nodefaults -type library";
148 if ($LIBC)
149 {
150 $out_def.="_nw_libc";
151 $tmp_def.="_nw_libc";
152 $inc_def.="_nw_libc";
153 }
154 else # NETWARE_CLIB
155 {
156 $out_def.="_nw_clib";
157 $tmp_def.="_nw_clib";
158 $inc_def.="_nw_clib";
159 }
160 }
161
162 # used by mk1mf.pl
163 $obj='.obj';
164 $ofile='-o ';
165 $efile='';
166 $exep='.nlm';
167 $ex_libs='';
168
169 if (!$no_asm)
170 {
171 $bn_asm_obj="crypto${o}bn${o}asm${o}bn-nw.obj";
172 $bn_asm_src="crypto${o}bn${o}asm${o}bn-nw.asm";
173 $des_enc_obj="crypto${o}des${o}asm${o}d-nw.obj crypto${o}des${o}asm${o}y-nw.obj";
174 $des_enc_src="crypto${o}des${o}asm${o}d-nw.asm crypto${o}des${o}asm${o}y-nw.asm";
175 $bf_enc_obj="crypto${o}bf${o}asm${o}b-nw.obj";
176 $bf_enc_src="crypto${o}bf${o}asm${o}b-nw.asm";
177 $cast_enc_obj="crypto${o}cast${o}asm${o}c-nw.obj";
178 $cast_enc_src="crypto${o}cast${o}asm${o}c-nw.asm";
179 $rc4_enc_obj="crypto${o}rc4${o}asm${o}r4-nw.obj";
180 $rc4_enc_src="crypto${o}rc4${o}asm${o}r4-nw.asm";
181 $rc5_enc_obj="crypto${o}rc5${o}asm${o}r5-nw.obj";
182 $rc5_enc_src="crypto${o}rc5${o}asm${o}r5-nw.asm";
183 $md5_asm_obj="crypto${o}md5${o}asm${o}m5-nw.obj";
184 $md5_asm_src="crypto${o}md5${o}asm${o}m5-nw.asm";
185 $sha1_asm_obj="crypto${o}sha${o}asm${o}s1-nw.obj";
186 $sha1_asm_src="crypto${o}sha${o}asm${o}s1-nw.asm";
187 $rmd160_asm_obj="crypto${o}ripemd${o}asm${o}rm-nw.obj";
188 $rmd160_asm_src="crypto${o}ripemd${o}asm${o}rm-nw.asm";
189 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
190 }
191 else
192 {
193 $bn_asm_obj='';
194 $bn_asm_src='';
195 $des_enc_obj='';
196 $des_enc_src='';
197 $bf_enc_obj='';
198 $bf_enc_src='';
199 $cast_enc_obj='';
200 $cast_enc_src='';
201 $rc4_enc_obj='';
202 $rc4_enc_src='';
203 $rc5_enc_obj='';
204 $rc5_enc_src='';
205 $md5_asm_obj='';
206 $md5_asm_src='';
207 $sha1_asm_obj='';
208 $sha1_asm_src='';
209 $rmd160_asm_obj='';
210 $rmd160_asm_src='';
211 }
212
213 # create the *.def linker command files in \openssl\netware\ directory
214 sub do_def_file
215 {
216 # strip off the leading path
217 my($target) = bname(@_);
218 my($def_file);
219 my($mod_file);
220 my($i);
221
222 if ($target =~ /(.*).nlm/)
223 {
224 $target = $1;
225 }
226
227 # special case for openssl - the mk1mf.pl defines E_EXE = openssl
228 if ($target =~ /E_EXE/)
229 {
230 $target = "openssl";
231 }
232
233 # Note: originally tried to use full path ( \openssl\netware\$target.def )
234 # Metrowerks linker choked on this with an assertion failure. bug???
235 #
236 $def_file = "netware\\$target.def";
237
238 open(DEF_OUT, ">$def_file") || die("unable to open file $def_file\n");
239
240 print( DEF_OUT "# command file generated by netware.pl for Metrowerks build\n" );
241 print( DEF_OUT "#\n");
242 print( DEF_OUT "DESCRIPTION \"$target\"\n");
243
244 foreach $i (@misc_imports)
245 {
246 print( DEF_OUT "IMPORT $i\n");
247 }
248
249 foreach $i (@import_files)
250 {
251 print( DEF_OUT "IMPORT \@$import_path\\$i\n");
252 }
253
254 foreach $i (@module_files)
255 {
256 print( DEF_OUT "MODULE $i\n");
257 }
258
259 close(DEF_OUT);
260 return($def_file);
261 }
262
263 sub do_lib_rule
264 {
265 my($objs,$target,$name,$shlib)=@_;
266 my($ret);
267
268 $ret.="$target: $objs\n";
269 if (!$shlib)
270 {
271 $ret.="\t\@echo Building Lib: $name\n";
272 $ret.="\t\$(MKLIB) $lib_flags -o $target $objs\n";
273 $ret.="\t\@echo .\n"
274 }
275 else
276 {
277 die( "Building as NLM not currently supported!" );
278 }
279
280 $ret.="\n";
281 return($ret);
282 }
283
284 sub do_link_rule
285 {
286 my($target,$files,$dep_libs,$libs)=@_;
287 my($ret);
288 my($def_file);
289
290 $def_file = do_def_file($target);
291
292 # special case for openssl - the mk1mf.pl defines E_EXE = openssl
293
294 # NOTE: When building the test nlms no screen name is given
295 # which causes the console screen to be used. By using the console
296 # screen there is no "<press any key to continue>" message which
297 # requires user interaction. The test script ( tests.pl ) needs to be
298 # able to run the tests without requiring user interaction.
299 #
300 # However, the sample program "openssl.nlm" is used by the tests and is
301 # a interactive sample so a screen is desired when not be run by the
302 # tests. To solve the problem, two versions of the program are built:
303 # openssl2 - no screen used by tests
304 # openssl - default screen - use for normal interactive modes
305 #
306 if ($target =~ /E_EXE/)
307 {
308 my($target2) = $target;
309
310 $target2 =~ s/\(E_EXE\)/\(E_EXE\)2/;
311
312 $ret.="$target: $files $dep_libs\n";
313
314 # openssl
315 $ret.="\t\$(LINK) \$(LFLAGS) -screenname openssl -commandfile $def_file $files \"$prelude\" $libs -o $target\n";
316 # openssl2
317 $ret.="\t\$(LINK) \$(LFLAGS) -commandfile $def_file $files \"$prelude\" $libs -o $target2\n";
318 }
319 else
320 {
321 $ret.="$target: $files $dep_libs\n";
322 $ret.="\t\$(LINK) \$(LFLAGS) -commandfile $def_file $files \"$prelude\" $libs -o $target\n";
323 }
324
325 $ret.="\n";
326 return($ret);
327 }
328
329 1;