1194206Ssimon# Metrowerks Codewarrior or gcc / nlmconv for NetWare
2160814Ssimon#
3160814Ssimon
4194206Ssimon$version_header = "crypto/opensslv.h";
5194206Ssimonopen(IN, "$version_header") or die "Couldn't open $version_header: $!";
6194206Ssimonwhile (<IN>) {
7194206Ssimon  if (/^#define[\s\t]+OPENSSL_VERSION_NUMBER[\s\t]+0x(\d)(\d{2})(\d{2})(\d{2})/)
8194206Ssimon  {
9194206Ssimon    # die "OpenSSL version detected: $1.$2.$3.$4\n";
10194206Ssimon    #$nlmvernum = "$1,$2,$3";
11194206Ssimon    $nlmvernum = "$1,".($2*10+$3).",".($4*1);
12194206Ssimon    #$nlmverstr = "$1.".($2*1).".".($3*1).($4?(chr(96+$4)):"");
13194206Ssimon    break;
14194206Ssimon  }
15194206Ssimon}
16194206Ssimonclose(IN) or die "Couldn't close $version_header: $!";
17194206Ssimon
18194206Ssimon$readme_file = "README";
19194206Ssimonopen(IN, $readme_file) or die "Couldn't open $readme_file: $!";
20194206Ssimonwhile (<IN>) {
21194206Ssimon  if (/^[\s\t]+OpenSSL[\s\t]+(\d)\.(\d{1,2})\.(\d{1,2})([a-z])(.*)/)
22194206Ssimon  {
23194206Ssimon    #$nlmvernum = "$1,$2,$3";
24194206Ssimon    #$nlmvernum = "$1,".($2*10+$3).",".($4*1);
25194206Ssimon    $nlmverstr = "$1.$2.$3$4$5";
26194206Ssimon  }
27194206Ssimon  elsif (/^[\s\t]+(Copyright \(c\) \d{4}\-\d{4} The OpenSSL Project)$/)
28194206Ssimon  {
29194206Ssimon    $nlmcpystr = $1;
30194206Ssimon  }
31194206Ssimon  break if ($nlmvernum && $nlmcpystr);
32194206Ssimon}
33194206Ssimonclose(IN) or die "Couldn't close $readme_file: $!";
34194206Ssimon
35194206Ssimon# Define stacksize here
36194206Ssimon$nlmstack = "32768";
37194206Ssimon
38194206Ssimon# some default settings here in case we failed to find them in README
39194206Ssimon$nlmvernum = "1,0,0" if (!$nlmvernum);
40194206Ssimon$nlmverstr = "OpenSSL" if (!$nlmverstr);
41194206Ssimon$nlmcpystr = "Copyright (c) 1998-now The OpenSSL Project" if (!$nlmcpystr);
42194206Ssimon
43194206Ssimon# die "OpenSSL copyright: $nlmcpystr\nOpenSSL verstring: $nlmverstr\nOpenSSL vernumber: $nlmvernum\n";
44194206Ssimon
45160814Ssimon# The import files and other misc imports needed to link
46194206Ssimon@misc_imports = ("GetProcessSwitchCount", "RunningProcess",
47160814Ssimon                 "GetSuperHighResolutionTimer");
48160814Ssimonif ($LIBC)
49160814Ssimon{
50160814Ssimon   @import_files = ("libc.imp");
51160814Ssimon   @module_files = ("libc");
52194206Ssimon   $libarch = "LIBC";
53160814Ssimon}
54160814Ssimonelse
55160814Ssimon{
56160814Ssimon   # clib build
57160814Ssimon   @import_files = ("clib.imp");
58194206Ssimon   push(@import_files, "socklib.imp") if ($BSDSOCK);
59160814Ssimon   @module_files = ("clib");
60194206Ssimon   # push(@misc_imports, "_rt_modu64%16", "_rt_divu64%16");
61194206Ssimon   $libarch = "CLIB";
62160814Ssimon}
63194206Ssimonif ($BSDSOCK)
64160814Ssimon{
65194206Ssimon   $libarch .= "-BSD";
66194206Ssimon}
67194206Ssimonelse
68194206Ssimon{
69194206Ssimon   $libarch .= "-WS2";
70160814Ssimon   push(@import_files, "ws2nlm.imp");
71160814Ssimon}
72160814Ssimon
73160814Ssimon# The "IMPORTS" environment variable must be set and point to the location
74160814Ssimon# where import files (*.imp) can be found.
75160814Ssimon# Example:  set IMPORTS=c:\ndk\nwsdk\imports
76160814Ssimon$import_path = $ENV{"IMPORTS"} || die ("IMPORTS environment variable not set\n");
77160814Ssimon
78160814Ssimon
79160814Ssimon# The "PRELUDE" environment variable must be set and point to the location
80160814Ssimon# and name of the prelude source to link with ( nwpre.obj is recommended ).
81160814Ssimon# Example: set PRELUDE=c:\codewar\novell support\metrowerks support\libraries\runtime\nwpre.obj
82160814Ssimon$prelude = $ENV{"PRELUDE"} || die ("PRELUDE environment variable not set\n");
83160814Ssimon
84194206Ssimon# The "INCLUDES" environment variable must be set and point to the location
85194206Ssimon# where import files (*.imp) can be found.
86194206Ssimon$include_path = $ENV{"INCLUDE"} || die ("INCLUDES environment variable not set\n");
87194206Ssimon$include_path =~ s/\\/\//g;
88194206Ssimon$include_path = join(" -I", split(/;/, $include_path));
89194206Ssimon
90194206Ssimon# check for gcc compiler
91194206Ssimon$gnuc = $ENV{"GNUC"};
92194206Ssimon
93160814Ssimon#$ssl=   "ssleay32";
94160814Ssimon#$crypto="libeay32";
95160814Ssimon
96194206Ssimonif ($gnuc)
97194206Ssimon{
98194206Ssimon   # C compiler
99194206Ssimon   $cc='gcc';
100194206Ssimon   # Linker
101194206Ssimon   $link='nlmconv';
102194206Ssimon   # librarian
103194206Ssimon   $mklib='ar';
104194206Ssimon   $o='/';
105194206Ssimon   # cp command
106194206Ssimon   $cp='cp -af';
107194206Ssimon   # rm command
108194206Ssimon   $rm='rm -f';
109194206Ssimon   # mv command
110194206Ssimon   $mv='mv -f';
111194206Ssimon   # mkdir command
112194206Ssimon   $mkdir='gmkdir';
113194206Ssimon   #$ranlib='ranlib';
114194206Ssimon}
115194206Ssimonelse
116194206Ssimon{
117194206Ssimon   # C compiler
118194206Ssimon   $cc='mwccnlm';
119194206Ssimon   # Linker
120194206Ssimon   $link='mwldnlm';
121194206Ssimon   # librarian
122194206Ssimon   $mklib='mwldnlm';
123194206Ssimon   # Path separator
124194206Ssimon   $o='\\';
125194206Ssimon   # cp command
126194206Ssimon   $cp='copy >nul:';
127194206Ssimon   # rm command
128194206Ssimon   $rm='del /f /q';
129194206Ssimon}
130160814Ssimon
131194206Ssimon# assembler
132194206Ssimonif ($nw_nasm)
133160814Ssimon{
134238405Sjkim   $asm=(`nasm -v 2>NUL` gt `nasmw -v 2>NUL`?"nasm":"nasmw");
135194206Ssimon   if ($gnuc)
136194206Ssimon   {
137238405Sjkim      $asm.=" -s -f elf";
138194206Ssimon   }
139194206Ssimon   else
140194206Ssimon   {
141238405Sjkim      $asm.=" -s -f coff -d __coff__";
142194206Ssimon   }
143160814Ssimon   $afile="-o ";
144160814Ssimon   $asm.=" -g" if $debug;
145160814Ssimon}
146194206Ssimonelsif ($nw_mwasm)
147160814Ssimon{
148160814Ssimon   $asm="mwasmnlm -maxerrors 20";
149160814Ssimon   $afile="-o ";
150160814Ssimon   $asm.=" -g" if $debug;
151160814Ssimon}
152160814Ssimonelsif ($nw_masm)
153160814Ssimon{
154194206Ssimon# masm assembly settings - it should be possible to use masm but haven't
155160814Ssimon# got it working.
156160814Ssimon# $asm='ml /Cp /coff /c /Cx';
157160814Ssimon# $asm.=" /Zi" if $debug;
158160814Ssimon# $afile='/Fo';
159160814Ssimon   die("Support for masm assembler not yet functional\n");
160160814Ssimon}
161194206Ssimonelse
162160814Ssimon{
163160814Ssimon   $asm="";
164160814Ssimon   $afile="";
165160814Ssimon}
166160814Ssimon
167160814Ssimon
168160814Ssimon
169194206Ssimonif ($gnuc)
170194206Ssimon{
171194206Ssimon   # compile flags for GNUC
172194206Ssimon   # additional flags based upon debug | non-debug
173194206Ssimon   if ($debug)
174194206Ssimon   {
175194206Ssimon      $cflags="-g -DDEBUG";
176194206Ssimon   }
177194206Ssimon   else
178194206Ssimon   {
179194206Ssimon      $cflags="-O2";
180194206Ssimon   }
181194206Ssimon   $cflags.=" -nostdinc -I$include_path \\
182194206Ssimon         -fno-builtin -fpcc-struct-return -fno-strict-aliasing \\
183194206Ssimon         -funsigned-char -Wall -Wno-unused -Wno-uninitialized";
184160814Ssimon
185194206Ssimon   # link flags
186194206Ssimon   $lflags="-T";
187160814Ssimon}
188160814Ssimonelse
189160814Ssimon{
190194206Ssimon   # compile flags for CodeWarrior
191194206Ssimon   # additional flags based upon debug | non-debug
192194206Ssimon   if ($debug)
193194206Ssimon   {
194194206Ssimon      $cflags="-opt off -g -sym internal -DDEBUG";
195194206Ssimon   }
196194206Ssimon   else
197194206Ssimon   {
198194206Ssimon   # CodeWarrior compiler has a problem with optimizations for floating
199194206Ssimon   # points - no optimizations until further investigation
200194206Ssimon   #      $cflags="-opt all";
201194206Ssimon   }
202194206Ssimon
203194206Ssimon   # NOTES: Several c files in the crypto subdirectory include headers from
204194206Ssimon   #        their local directories.  Metrowerks wouldn't find these h files
205194206Ssimon   #        without adding individual include directives as compile flags
206194206Ssimon   #        or modifying the c files.  Instead of adding individual include
207194206Ssimon   #        paths for each subdirectory a recursive include directive
208194206Ssimon   #        is used ( -ir crypto ).
209194206Ssimon   #
210194206Ssimon   #        A similar issue exists for the engines and apps subdirectories.
211194206Ssimon   #
212194206Ssimon   #        Turned off the "possible" warnings ( -w nopossible ).  Metrowerks
213194206Ssimon   #        complained a lot about various stuff.  May want to turn back
214194206Ssimon   #        on for further development.
215276861Sjkim   $cflags.=" -nostdinc -ir crypto -ir ssl -ir engines -ir apps -I$include_path \\
216194206Ssimon         -msgstyle gcc -align 4 -processor pentium -char unsigned \\
217194206Ssimon         -w on -w nolargeargs -w nopossible -w nounusedarg -w nounusedexpr \\
218194206Ssimon         -w noimplicitconv -relax_pointers -nosyspath -maxerrors 20";
219194206Ssimon
220194206Ssimon   # link flags
221194206Ssimon   $lflags="-msgstyle gcc -zerobss -nostdlib -sym internal -commandfile";
222160814Ssimon}
223160814Ssimon
224194206Ssimon# common defines
225194206Ssimon$cflags.=" -DL_ENDIAN -DOPENSSL_SYSNAME_NETWARE -U_WIN32";
226194206Ssimon
227160814Ssimon# If LibC build add in NKS_LIBC define and set the entry/exit
228160814Ssimon# routines - The default entry/exit routines are for CLib and don't exist
229160814Ssimon# in LibC
230160814Ssimonif ($LIBC)
231160814Ssimon{
232160814Ssimon   $cflags.=" -DNETWARE_LIBC";
233194206Ssimon   $nlmstart = "_LibCPrelude";
234194206Ssimon   $nlmexit = "_LibCPostlude";
235194206Ssimon   @nlm_flags = ("pseudopreemption", "flag_on 64");
236160814Ssimon}
237160814Ssimonelse
238160814Ssimon{
239160814Ssimon   $cflags.=" -DNETWARE_CLIB";
240194206Ssimon   $nlmstart = "_Prelude";
241194206Ssimon   $nlmexit = "_Stop";
242160814Ssimon}
243160814Ssimon
244160814Ssimon# If BSD Socket support is requested, set a define for the compiler
245160814Ssimonif ($BSDSOCK)
246160814Ssimon{
247160814Ssimon   $cflags.=" -DNETWARE_BSDSOCK";
248194206Ssimon   if (!$LIBC)
249194206Ssimon   {
250194206Ssimon      $cflags.=" -DNETDB_USE_INTERNET";
251194206Ssimon   }
252160814Ssimon}
253160814Ssimon
254160814Ssimon
255160814Ssimon# linking stuff
256160814Ssimon# for the output directories use the mk1mf.pl values with "_nw" appended
257160814Ssimonif ($shlib)
258160814Ssimon{
259160814Ssimon   if ($LIBC)
260160814Ssimon   {
261160814Ssimon      $out_def.="_nw_libc_nlm";
262160814Ssimon      $tmp_def.="_nw_libc_nlm";
263160814Ssimon      $inc_def.="_nw_libc_nlm";
264160814Ssimon   }
265160814Ssimon   else  # NETWARE_CLIB
266160814Ssimon   {
267160814Ssimon      $out_def.="_nw_clib_nlm";
268160814Ssimon      $tmp_def.="_nw_clib_nlm";
269160814Ssimon      $inc_def.="_nw_clib_nlm";
270160814Ssimon   }
271160814Ssimon}
272160814Ssimonelse
273160814Ssimon{
274194206Ssimon   if ($gnuc) # GNUC Tools
275194206Ssimon   {
276194206Ssimon      $libp=".a";
277194206Ssimon      $shlibp=".a";
278194206Ssimon      $lib_flags="-cr";
279194206Ssimon   }
280194206Ssimon   else       # CodeWarrior
281194206Ssimon   {
282194206Ssimon      $libp=".lib";
283194206Ssimon      $shlibp=".lib";
284194206Ssimon      $lib_flags="-nodefaults -type library -o";
285194206Ssimon   }
286160814Ssimon   if ($LIBC)
287160814Ssimon   {
288160814Ssimon      $out_def.="_nw_libc";
289160814Ssimon      $tmp_def.="_nw_libc";
290160814Ssimon      $inc_def.="_nw_libc";
291160814Ssimon   }
292194206Ssimon   else  # NETWARE_CLIB
293160814Ssimon   {
294160814Ssimon      $out_def.="_nw_clib";
295160814Ssimon      $tmp_def.="_nw_clib";
296160814Ssimon      $inc_def.="_nw_clib";
297160814Ssimon   }
298160814Ssimon}
299160814Ssimon
300160814Ssimon# used by mk1mf.pl
301194206Ssimon$obj='.o';
302160814Ssimon$ofile='-o ';
303160814Ssimon$efile='';
304160814Ssimon$exep='.nlm';
305160814Ssimon$ex_libs='';
306160814Ssimon
307160814Ssimonif (!$no_asm)
308160814Ssimon{
309194206Ssimon   $bn_asm_obj="\$(OBJ_D)${o}bn-nw${obj}";
310160814Ssimon   $bn_asm_src="crypto${o}bn${o}asm${o}bn-nw.asm";
311194206Ssimon   $bnco_asm_obj="\$(OBJ_D)${o}co-nw${obj}";
312194206Ssimon   $bnco_asm_src="crypto${o}bn${o}asm${o}co-nw.asm";
313194206Ssimon   $aes_asm_obj="\$(OBJ_D)${o}a-nw${obj}";
314194206Ssimon   $aes_asm_src="crypto${o}aes${o}asm${o}a-nw.asm";
315194206Ssimon   $des_enc_obj="\$(OBJ_D)${o}d-nw${obj} \$(OBJ_D)${o}y-nw${obj}";
316160814Ssimon   $des_enc_src="crypto${o}des${o}asm${o}d-nw.asm crypto${o}des${o}asm${o}y-nw.asm";
317194206Ssimon   $bf_enc_obj="\$(OBJ_D)${o}b-nw${obj}";
318160814Ssimon   $bf_enc_src="crypto${o}bf${o}asm${o}b-nw.asm";
319194206Ssimon   $cast_enc_obj="\$(OBJ_D)${o}c-nw${obj}";
320160814Ssimon   $cast_enc_src="crypto${o}cast${o}asm${o}c-nw.asm";
321194206Ssimon   $rc4_enc_obj="\$(OBJ_D)${o}r4-nw${obj}";
322160814Ssimon   $rc4_enc_src="crypto${o}rc4${o}asm${o}r4-nw.asm";
323194206Ssimon   $rc5_enc_obj="\$(OBJ_D)${o}r5-nw${obj}";
324160814Ssimon   $rc5_enc_src="crypto${o}rc5${o}asm${o}r5-nw.asm";
325194206Ssimon   $md5_asm_obj="\$(OBJ_D)${o}m5-nw${obj}";
326160814Ssimon   $md5_asm_src="crypto${o}md5${o}asm${o}m5-nw.asm";
327238405Sjkim   $sha1_asm_obj="\$(OBJ_D)${o}s1-nw${obj} \$(OBJ_D)${o}sha256-nw${obj} \$(OBJ_D)${o}sha512-nw${obj}";
328238405Sjkim   $sha1_asm_src="crypto${o}sha${o}asm${o}s1-nw.asm crypto${o}sha${o}asm${o}sha256-nw.asm crypto${o}sha${o}asm${o}sha512-nw.asm";
329194206Ssimon   $rmd160_asm_obj="\$(OBJ_D)${o}rm-nw${obj}";
330160814Ssimon   $rmd160_asm_src="crypto${o}ripemd${o}asm${o}rm-nw.asm";
331238405Sjkim   $whirlpool_asm_obj="\$(OBJ_D)${o}wp-nw${obj}";
332238405Sjkim   $whirlpool_asm_src="crypto${o}whrlpool${o}asm${o}wp-nw.asm";
333194206Ssimon   $cpuid_asm_obj="\$(OBJ_D)${o}x86cpuid-nw${obj}";
334194206Ssimon   $cpuid_asm_src="crypto${o}x86cpuid-nw.asm";
335238405Sjkim   $cflags.=" -DOPENSSL_CPUID_OBJ -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DMD5_ASM -DWHIRLPOOL_ASM";
336238405Sjkim   $cflags.=" -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM";
337194206Ssimon   $cflags.=" -DAES_ASM -DRMD160_ASM";
338160814Ssimon}
339160814Ssimonelse
340160814Ssimon{
341160814Ssimon   $bn_asm_obj='';
342160814Ssimon   $bn_asm_src='';
343194206Ssimon   $bnco_asm_obj='';
344194206Ssimon   $bnco_asm_src='';
345194206Ssimon   $aes_asm_obj='';
346194206Ssimon   $aes_asm_src='';
347160814Ssimon   $des_enc_obj='';
348160814Ssimon   $des_enc_src='';
349160814Ssimon   $bf_enc_obj='';
350160814Ssimon   $bf_enc_src='';
351160814Ssimon   $cast_enc_obj='';
352160814Ssimon   $cast_enc_src='';
353160814Ssimon   $rc4_enc_obj='';
354160814Ssimon   $rc4_enc_src='';
355160814Ssimon   $rc5_enc_obj='';
356160814Ssimon   $rc5_enc_src='';
357160814Ssimon   $md5_asm_obj='';
358160814Ssimon   $md5_asm_src='';
359160814Ssimon   $sha1_asm_obj='';
360160814Ssimon   $sha1_asm_src='';
361160814Ssimon   $rmd160_asm_obj='';
362160814Ssimon   $rmd160_asm_src='';
363238405Sjkim   $whirlpool_asm_obj='';
364238405Sjkim   $whirlpool_asm_src='';
365194206Ssimon   $cpuid_asm_obj='';
366194206Ssimon   $cpuid_asm_src='';
367160814Ssimon}
368160814Ssimon
369160814Ssimon# create the *.def linker command files in \openssl\netware\ directory
370160814Ssimonsub do_def_file
371160814Ssimon{
372160814Ssimon   # strip off the leading path
373194206Ssimon   my($target) = bname(shift);
374160814Ssimon   my($i);
375160814Ssimon
376160814Ssimon   if ($target =~ /(.*).nlm/)
377160814Ssimon   {
378160814Ssimon      $target = $1;
379160814Ssimon   }
380160814Ssimon
381160814Ssimon   # special case for openssl - the mk1mf.pl defines E_EXE = openssl
382160814Ssimon   if ($target =~ /E_EXE/)
383160814Ssimon   {
384194206Ssimon      $target =~ s/\$\(E_EXE\)/openssl/;
385160814Ssimon   }
386160814Ssimon
387160814Ssimon   # Note: originally tried to use full path ( \openssl\netware\$target.def )
388160814Ssimon   # Metrowerks linker choked on this with an assertion failure. bug???
389160814Ssimon   #
390194206Ssimon   my($def_file) = "netware${o}$target.def";
391160814Ssimon
392160814Ssimon   open(DEF_OUT, ">$def_file") || die("unable to open file $def_file\n");
393160814Ssimon
394194206Ssimon   print( DEF_OUT "# command file generated by netware.pl for NLM target.\n" );
395194206Ssimon   print( DEF_OUT "# do not edit this file - all your changes will be lost!!\n" );
396160814Ssimon   print( DEF_OUT "#\n");
397194206Ssimon   print( DEF_OUT "DESCRIPTION \"$target ($libarch) - OpenSSL $nlmverstr\"\n");
398194206Ssimon   print( DEF_OUT "COPYRIGHT \"$nlmcpystr\"\n");
399194206Ssimon   print( DEF_OUT "VERSION $nlmvernum\n");
400194206Ssimon   print( DEF_OUT "STACK $nlmstack\n");
401194206Ssimon   print( DEF_OUT "START $nlmstart\n");
402194206Ssimon   print( DEF_OUT "EXIT $nlmexit\n");
403194206Ssimon
404194206Ssimon   # special case for openssl
405194206Ssimon   if ($target eq "openssl")
406194206Ssimon   {
407194206Ssimon      print( DEF_OUT "SCREENNAME \"OpenSSL $nlmverstr\"\n");
408194206Ssimon   }
409194206Ssimon   else
410194206Ssimon   {
411194206Ssimon      print( DEF_OUT "SCREENNAME \"DEFAULT\"\n");
412194206Ssimon   }
413194206Ssimon
414160814Ssimon   foreach $i (@misc_imports)
415160814Ssimon   {
416160814Ssimon      print( DEF_OUT "IMPORT $i\n");
417160814Ssimon   }
418194206Ssimon
419160814Ssimon   foreach $i (@import_files)
420160814Ssimon   {
421194206Ssimon      print( DEF_OUT "IMPORT \@$import_path${o}$i\n");
422160814Ssimon   }
423194206Ssimon
424160814Ssimon   foreach $i (@module_files)
425160814Ssimon   {
426160814Ssimon      print( DEF_OUT "MODULE $i\n");
427160814Ssimon   }
428160814Ssimon
429194206Ssimon   foreach $i (@nlm_flags)
430194206Ssimon   {
431194206Ssimon      print( DEF_OUT "$i\n");
432194206Ssimon   }
433194206Ssimon
434194206Ssimon   if ($gnuc)
435194206Ssimon   {
436194206Ssimon      if ($target =~ /openssl/)
437194206Ssimon      {
438194206Ssimon         print( DEF_OUT "INPUT ${tmp_def}${o}openssl${obj}\n");
439194206Ssimon         print( DEF_OUT "INPUT ${tmp_def}${o}openssl${libp}\n");
440194206Ssimon      }
441194206Ssimon      else
442194206Ssimon      {
443194206Ssimon         print( DEF_OUT "INPUT ${tmp_def}${o}${target}${obj}\n");
444194206Ssimon      }
445194206Ssimon      print( DEF_OUT "INPUT $prelude\n");
446194206Ssimon      print( DEF_OUT "INPUT ${out_def}${o}${ssl}${libp} ${out_def}${o}${crypto}${libp}\n");
447194206Ssimon      print( DEF_OUT "OUTPUT $target.nlm\n");
448194206Ssimon   }
449194206Ssimon
450160814Ssimon   close(DEF_OUT);
451160814Ssimon   return($def_file);
452160814Ssimon}
453160814Ssimon
454160814Ssimonsub do_lib_rule
455160814Ssimon{
456160814Ssimon   my($objs,$target,$name,$shlib)=@_;
457160814Ssimon   my($ret);
458160814Ssimon
459160814Ssimon   $ret.="$target: $objs\n";
460160814Ssimon   if (!$shlib)
461160814Ssimon   {
462160814Ssimon      $ret.="\t\@echo Building Lib: $name\n";
463194206Ssimon      $ret.="\t\$(MKLIB) $lib_flags $target $objs\n";
464160814Ssimon      $ret.="\t\@echo .\n"
465160814Ssimon   }
466160814Ssimon   else
467160814Ssimon   {
468160814Ssimon      die( "Building as NLM not currently supported!" );
469160814Ssimon   }
470160814Ssimon
471160814Ssimon   $ret.="\n";
472160814Ssimon   return($ret);
473160814Ssimon}
474160814Ssimon
475160814Ssimonsub do_link_rule
476160814Ssimon{
477160814Ssimon   my($target,$files,$dep_libs,$libs)=@_;
478160814Ssimon   my($ret);
479194206Ssimon   my($def_file) = do_def_file($target);
480160814Ssimon
481194206Ssimon   $ret.="$target: $files $dep_libs\n";
482160814Ssimon
483160814Ssimon   # NOTE:  When building the test nlms no screen name is given
484160814Ssimon   #  which causes the console screen to be used.  By using the console
485160814Ssimon   #  screen there is no "<press any key to continue>" message which
486194206Ssimon   #  requires user interaction.  The test script ( do_tests.pl ) needs
487194206Ssimon   #  to be able to run the tests without requiring user interaction.
488160814Ssimon   #
489160814Ssimon   #  However, the sample program "openssl.nlm" is used by the tests and is
490160814Ssimon   #  a interactive sample so a screen is desired when not be run by the
491160814Ssimon   #  tests.  To solve the problem, two versions of the program are built:
492160814Ssimon   #    openssl2 - no screen used by tests
493160814Ssimon   #    openssl - default screen - use for normal interactive modes
494160814Ssimon   #
495194206Ssimon
496194206Ssimon   # special case for openssl - the mk1mf.pl defines E_EXE = openssl
497160814Ssimon   if ($target =~ /E_EXE/)
498160814Ssimon   {
499160814Ssimon      my($target2) = $target;
500160814Ssimon
501160814Ssimon      $target2 =~ s/\(E_EXE\)/\(E_EXE\)2/;
502160814Ssimon
503194206Ssimon      # openssl2
504194206Ssimon      my($def_file2) = do_def_file($target2);
505160814Ssimon
506194206Ssimon      if ($gnuc)
507194206Ssimon      {
508194206Ssimon         $ret.="\t\$(MKLIB) $lib_flags \$(TMP_D)${o}\$(E_EXE).a \$(filter-out \$(TMP_D)${o}\$(E_EXE)${obj},$files)\n";
509296279Sjkim         $ret.="\t\$(LINK_CMD) \$(LFLAGS) $def_file2\n";
510194206Ssimon         $ret.="\t\@$mv \$(E_EXE)2.nlm \$(TEST_D)\n";
511194206Ssimon      }
512194206Ssimon      else
513194206Ssimon      {
514296279Sjkim         $ret.="\t\$(LINK_CMD) \$(LFLAGS) $def_file2 $files \"$prelude\" $libs -o $target2\n";
515194206Ssimon      }
516160814Ssimon   }
517194206Ssimon   if ($gnuc)
518194206Ssimon   {
519296279Sjkim      $ret.="\t\$(LINK_CMD) \$(LFLAGS) $def_file\n";
520194206Ssimon      $ret.="\t\@$mv \$(\@F) \$(TEST_D)\n";
521194206Ssimon   }
522160814Ssimon   else
523160814Ssimon   {
524296279Sjkim      $ret.="\t\$(LINK_CMD) \$(LFLAGS) $def_file $files \"$prelude\" $libs -o $target\n";
525160814Ssimon   }
526160814Ssimon
527160814Ssimon   $ret.="\n";
528160814Ssimon   return($ret);
529194206Ssimon
530160814Ssimon}
531160814Ssimon
532160814Ssimon1;
533