netware.pl 8.5 KB

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