mk1mf.pl 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. #!/usr/local/bin/perl
  2. # A bit of an evil hack but it post processes the file ../MINFO which
  3. # is generated by `make files` in the top directory.
  4. # This script outputs one mega makefile that has no shell stuff or any
  5. # funny stuff
  6. #
  7. $INSTALLTOP="/usr/local/ssl";
  8. $OPTIONS="";
  9. $ssl_version="";
  10. $banner="\t\@echo Building OpenSSL";
  11. my $no_static_engine = 1;
  12. my $engines = "";
  13. local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
  14. local $zlib_lib = "";
  15. open(IN,"<Makefile") || die "unable to open Makefile!\n";
  16. while(<IN>) {
  17. $ssl_version=$1 if (/^VERSION=(.*)$/);
  18. $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
  19. $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
  20. }
  21. close(IN);
  22. die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
  23. $infile="MINFO";
  24. %ops=(
  25. "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
  26. "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
  27. "VC-WIN64A", "Microsoft C/C++ - Win64/x64",
  28. "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
  29. "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
  30. "Mingw32", "GNU C++ - Windows NT or 9x",
  31. "Mingw32-files", "Create files with DOS copy ...",
  32. "BC-NT", "Borland C++ 4.5 - Windows NT",
  33. "linux-elf","Linux elf",
  34. "ultrix-mips","DEC mips ultrix",
  35. "FreeBSD","FreeBSD distribution",
  36. "OS2-EMX", "EMX GCC OS/2",
  37. "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
  38. "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
  39. "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
  40. "default","cc under unix",
  41. );
  42. $platform="";
  43. my $xcflags="";
  44. foreach (@ARGV)
  45. {
  46. if (!&read_options && !defined($ops{$_}))
  47. {
  48. print STDERR "unknown option - $_\n";
  49. print STDERR "usage: perl mk1mf.pl [options] [system]\n";
  50. print STDERR "\nwhere [system] can be one of the following\n";
  51. foreach $i (sort keys %ops)
  52. { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
  53. print STDERR <<"EOF";
  54. and [options] can be one of
  55. no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
  56. no-ripemd
  57. no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
  58. no-bf no-cast no-aes
  59. no-rsa no-dsa no-dh - Skip this public key cipher
  60. no-ssl2 no-ssl3 - Skip this version of SSL
  61. just-ssl - remove all non-ssl keys/digest
  62. no-asm - No x86 asm
  63. no-krb5 - No KRB5
  64. no-ec - No EC
  65. no-ecdsa - No ECDSA
  66. no-ecdh - No ECDH
  67. no-engine - No engine
  68. no-hw - No hw
  69. nasm - Use NASM for x86 asm
  70. nw-nasm - Use NASM x86 asm for NetWare
  71. nw-mwasm - Use Metrowerks x86 asm for NetWare
  72. gaswin - Use GNU as with Mingw32
  73. no-socks - No socket code
  74. no-err - No error strings
  75. dll/shlib - Build shared libraries (MS)
  76. debug - Debug build
  77. profile - Profiling build
  78. gcc - Use Gcc (unix)
  79. Values that can be set
  80. TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
  81. -L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
  82. -<ex_cc_flags> - extra 'cc' flags,
  83. added (MS), or replace (unix)
  84. EOF
  85. exit(1);
  86. }
  87. $platform=$_;
  88. }
  89. foreach (grep(!/^$/, split(/ /, $OPTIONS)))
  90. {
  91. print STDERR "unknown option - $_\n" if !&read_options;
  92. }
  93. $no_static_engine = 0 if (!$shlib);
  94. $no_mdc2=1 if ($no_des);
  95. $no_ssl3=1 if ($no_md5 || $no_sha);
  96. $no_ssl3=1 if ($no_rsa && $no_dh);
  97. $no_ssl2=1 if ($no_md5);
  98. $no_ssl2=1 if ($no_rsa);
  99. $out_def="out";
  100. $inc_def="outinc";
  101. $tmp_def="tmp";
  102. $perl="perl" unless defined $perl;
  103. $mkdir="-mkdir" unless defined $mkdir;
  104. ($ssl,$crypto)=("ssl","crypto");
  105. $ranlib="echo ranlib";
  106. $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
  107. $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
  108. $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
  109. # $bin_dir.=$o causes a core dump on my sparc :-(
  110. $NT=0;
  111. push(@INC,"util/pl","pl");
  112. if (($platform =~ /VC-(.+)/))
  113. {
  114. $FLAVOR=$1;
  115. $NT = 1 if $1 eq "NT";
  116. require 'VC-32.pl';
  117. }
  118. elsif ($platform eq "Mingw32")
  119. {
  120. require 'Mingw32.pl';
  121. }
  122. elsif ($platform eq "Mingw32-files")
  123. {
  124. require 'Mingw32f.pl';
  125. }
  126. elsif ($platform eq "BC-NT")
  127. {
  128. $bc=1;
  129. require 'BC-32.pl';
  130. }
  131. elsif ($platform eq "FreeBSD")
  132. {
  133. require 'unix.pl';
  134. $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
  135. }
  136. elsif ($platform eq "linux-elf")
  137. {
  138. require "unix.pl";
  139. require "linux.pl";
  140. $unix=1;
  141. }
  142. elsif ($platform eq "ultrix-mips")
  143. {
  144. require "unix.pl";
  145. require "ultrix.pl";
  146. $unix=1;
  147. }
  148. elsif ($platform eq "OS2-EMX")
  149. {
  150. $wc=1;
  151. require 'OS2-EMX.pl';
  152. }
  153. elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
  154. ($platform eq "netware-libc-bsdsock"))
  155. {
  156. $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
  157. $BSDSOCK=1 if $platform eq "netware-libc-bsdsock";
  158. require 'netware.pl';
  159. }
  160. else
  161. {
  162. require "unix.pl";
  163. $unix=1;
  164. $cflags.=' -DTERMIO';
  165. }
  166. $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
  167. $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
  168. $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
  169. $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
  170. $cflags= "$xcflags$cflags" if $xcflags ne "";
  171. $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
  172. $cflags.=" -DOPENSSL_NO_AES" if $no_aes;
  173. $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
  174. $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
  175. $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
  176. $cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
  177. $cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
  178. $cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
  179. $cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
  180. $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
  181. $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
  182. $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
  183. $cflags.=" -DOPENSSL_NO_BF" if $no_bf;
  184. $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
  185. $cflags.=" -DOPENSSL_NO_DES" if $no_des;
  186. $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
  187. $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
  188. $cflags.=" -DOPENSSL_NO_DH" if $no_dh;
  189. $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
  190. $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
  191. $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
  192. $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
  193. $cflags.=" -DOPENSSL_NO_ERR" if $no_err;
  194. $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
  195. $cflags.=" -DOPENSSL_NO_EC" if $no_ec;
  196. $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
  197. $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
  198. $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
  199. $cflags.=" -DOPENSSL_NO_HW" if $no_hw;
  200. $cflags.= " -DZLIB" if $zlib_opt;
  201. $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
  202. if ($no_static_engine)
  203. {
  204. $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
  205. }
  206. else
  207. {
  208. $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
  209. }
  210. #$cflags.=" -DRSAref" if $rsaref ne "";
  211. ## if ($unix)
  212. ## { $cflags="$c_flags" if ($c_flags ne ""); }
  213. ##else
  214. { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
  215. $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
  216. %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
  217. "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
  218. if ($msdos)
  219. {
  220. $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
  221. $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
  222. $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
  223. $banner.="\t\@echo documentation for details.\n";
  224. }
  225. # have to do this to allow $(CC) under unix
  226. $link="$bin_dir$link" if ($link !~ /^\$/);
  227. $INSTALLTOP =~ s|/|$o|g;
  228. #############################################
  229. # We parse in input file and 'store' info for later printing.
  230. open(IN,"<$infile") || die "unable to open $infile:$!\n";
  231. $_=<IN>;
  232. for (;;)
  233. {
  234. chop;
  235. ($key,$val)=/^([^=]+)=(.*)/;
  236. if ($key eq "RELATIVE_DIRECTORY")
  237. {
  238. if ($lib ne "")
  239. {
  240. $uc=$lib;
  241. $uc =~ s/^lib(.*)\.a/$1/;
  242. $uc =~ tr/a-z/A-Z/;
  243. $lib_nam{$uc}=$uc;
  244. $lib_obj{$uc}.=$libobj." ";
  245. }
  246. last if ($val eq "FINISHED");
  247. $lib="";
  248. $libobj="";
  249. $dir=$val;
  250. }
  251. if ($key eq "KRB5_INCLUDES")
  252. { $cflags .= " $val";}
  253. if ($key eq "ZLIB_INCLUDE")
  254. { $cflags .= " $val" if $val ne "";}
  255. if ($key eq "LIBZLIB")
  256. { $zlib_lib = "$val" if $val ne "";}
  257. if ($key eq "LIBKRB5")
  258. { $ex_libs .= " $val" if $val ne "";}
  259. if ($key eq "TEST")
  260. { $test.=&var_add($dir,$val, 0); }
  261. if (($key eq "PROGS") || ($key eq "E_OBJ"))
  262. { $e_exe.=&var_add($dir,$val, 0); }
  263. if ($key eq "LIB")
  264. {
  265. $lib=$val;
  266. $lib =~ s/^.*\/([^\/]+)$/$1/;
  267. }
  268. if ($key eq "EXHEADER")
  269. { $exheader.=&var_add($dir,$val, 1); }
  270. if ($key eq "HEADER")
  271. { $header.=&var_add($dir,$val, 1); }
  272. if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine))
  273. { $libobj=&var_add($dir,$val, 0); }
  274. if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
  275. { $engines.=$val }
  276. if (!($_=<IN>))
  277. { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
  278. }
  279. close(IN);
  280. if ($shlib)
  281. {
  282. $extra_install= <<"EOF";
  283. \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}bin
  284. \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}bin
  285. \$(CP) \$(L_SSL) \$(INSTALLTOP)${o}lib
  286. \$(CP) \$(L_CRYPTO) \$(INSTALLTOP)${o}lib
  287. EOF
  288. if ($no_static_engine)
  289. {
  290. $extra_install .= <<"EOF"
  291. \$(MKDIR) \$(INSTALLTOP)${o}lib${o}engines
  292. \$(CP) \$(E_SHLIB) \$(INSTALLTOP)${o}lib${o}engines
  293. EOF
  294. }
  295. }
  296. else
  297. {
  298. $extra_install= <<"EOF";
  299. \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
  300. \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
  301. EOF
  302. $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
  303. }
  304. $defs= <<"EOF";
  305. # This makefile has been automatically generated from the OpenSSL distribution.
  306. # This single makefile will build the complete OpenSSL distribution and
  307. # by default leave the 'intertesting' output files in .${o}out and the stuff
  308. # that needs deleting in .${o}tmp.
  309. # The file was generated by running 'make makefile.one', which
  310. # does a 'make files', which writes all the environment variables from all
  311. # the makefiles to the file call MINFO. This file is used by
  312. # util${o}mk1mf.pl to generate makefile.one.
  313. # The 'makefile per directory' system suites me when developing this
  314. # library and also so I can 'distribute' indervidual library sections.
  315. # The one monster makefile better suits building in non-unix
  316. # environments.
  317. EOF
  318. $defs .= $preamble if defined $preamble;
  319. $defs.= <<"EOF";
  320. INSTALLTOP=$INSTALLTOP
  321. # Set your compiler options
  322. PLATFORM=$platform
  323. CC=$bin_dir${cc}
  324. CFLAG=$cflags
  325. APP_CFLAG=$app_cflag
  326. LIB_CFLAG=$lib_cflag
  327. SHLIB_CFLAG=$shl_cflag
  328. APP_EX_OBJ=$app_ex_obj
  329. SHLIB_EX_OBJ=$shlib_ex_obj
  330. # add extra libraries to this define, for solaris -lsocket -lnsl would
  331. # be added
  332. EX_LIBS=$ex_libs
  333. # The OpenSSL directory
  334. SRC_D=$src_dir
  335. LINK=$link
  336. LFLAGS=$lflags
  337. RSC=$rsc
  338. BN_ASM_OBJ=$bn_asm_obj
  339. BN_ASM_SRC=$bn_asm_src
  340. BNCO_ASM_OBJ=$bnco_asm_obj
  341. BNCO_ASM_SRC=$bnco_asm_src
  342. DES_ENC_OBJ=$des_enc_obj
  343. DES_ENC_SRC=$des_enc_src
  344. BF_ENC_OBJ=$bf_enc_obj
  345. BF_ENC_SRC=$bf_enc_src
  346. CAST_ENC_OBJ=$cast_enc_obj
  347. CAST_ENC_SRC=$cast_enc_src
  348. RC4_ENC_OBJ=$rc4_enc_obj
  349. RC4_ENC_SRC=$rc4_enc_src
  350. RC5_ENC_OBJ=$rc5_enc_obj
  351. RC5_ENC_SRC=$rc5_enc_src
  352. MD5_ASM_OBJ=$md5_asm_obj
  353. MD5_ASM_SRC=$md5_asm_src
  354. SHA1_ASM_OBJ=$sha1_asm_obj
  355. SHA1_ASM_SRC=$sha1_asm_src
  356. RMD160_ASM_OBJ=$rmd160_asm_obj
  357. RMD160_ASM_SRC=$rmd160_asm_src
  358. WHIRLPOOL_ASM_OBJ=$whirlpool_asm_obj
  359. WHIRLPOOL_ASM_SRC=$whirlpool_asm_src
  360. CPUID_ASM_OBJ=$cpuid_asm_obj
  361. CPUID_ASM_SRC=$cpuid_asm_src
  362. # The output directory for everything intersting
  363. OUT_D=$out_dir
  364. # The output directory for all the temporary muck
  365. TMP_D=$tmp_dir
  366. # The output directory for the header files
  367. INC_D=$inc_dir
  368. INCO_D=$inc_dir${o}openssl
  369. PERL=$perl
  370. CP=$cp
  371. RM=$rm
  372. RANLIB=$ranlib
  373. MKDIR=$mkdir
  374. MKLIB=$bin_dir$mklib
  375. MLFLAGS=$mlflags
  376. ASM=$bin_dir$asm
  377. ######################################################
  378. # You should not need to touch anything below this point
  379. ######################################################
  380. E_EXE=openssl
  381. SSL=$ssl
  382. CRYPTO=$crypto
  383. # BIN_D - Binary output directory
  384. # TEST_D - Binary test file output directory
  385. # LIB_D - library output directory
  386. # ENG_D - dynamic engine output directory
  387. # Note: if you change these point to different directories then uncomment out
  388. # the lines around the 'NB' comment below.
  389. #
  390. BIN_D=\$(OUT_D)
  391. TEST_D=\$(OUT_D)
  392. LIB_D=\$(OUT_D)
  393. ENG_D=\$(OUT_D)
  394. # INCL_D - local library directory
  395. # OBJ_D - temp object file directory
  396. OBJ_D=\$(TMP_D)
  397. INCL_D=\$(TMP_D)
  398. O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
  399. O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
  400. SO_SSL= $plib\$(SSL)$so_shlibp
  401. SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
  402. L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
  403. L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
  404. L_LIBS= \$(L_SSL) \$(L_CRYPTO)
  405. ######################################################
  406. # Don't touch anything below this point
  407. ######################################################
  408. INC=-I\$(INC_D) -I\$(INCL_D)
  409. APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
  410. LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
  411. SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
  412. LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
  413. #############################################
  414. EOF
  415. $rules=<<"EOF";
  416. all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
  417. banner:
  418. $banner
  419. \$(TMP_D):
  420. \$(MKDIR) \$(TMP_D)
  421. # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
  422. #\$(BIN_D):
  423. # \$(MKDIR) \$(BIN_D)
  424. #
  425. #\$(TEST_D):
  426. # \$(MKDIR) \$(TEST_D)
  427. \$(LIB_D):
  428. \$(MKDIR) \$(LIB_D)
  429. \$(INCO_D): \$(INC_D)
  430. \$(MKDIR) \$(INCO_D)
  431. \$(INC_D):
  432. \$(MKDIR) \$(INC_D)
  433. headers: \$(HEADER) \$(EXHEADER)
  434. @
  435. lib: \$(LIBS_DEP) \$(E_SHLIB)
  436. exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
  437. install: all
  438. \$(MKDIR) \$(INSTALLTOP)
  439. \$(MKDIR) \$(INSTALLTOP)${o}bin
  440. \$(MKDIR) \$(INSTALLTOP)${o}include
  441. \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
  442. \$(MKDIR) \$(INSTALLTOP)${o}lib
  443. \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
  444. \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
  445. \$(CP) apps${o}openssl.cnf \$(INSTALLTOP)
  446. $extra_install
  447. test: \$(T_EXE)
  448. cd \$(BIN_D)
  449. ..${o}ms${o}test
  450. clean:
  451. \$(RM) \$(TMP_D)$o*.*
  452. vclean:
  453. \$(RM) \$(TMP_D)$o*.*
  454. \$(RM) \$(OUT_D)$o*.*
  455. EOF
  456. my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
  457. $platform_cpp_symbol =~ s/-/_/g;
  458. if (open(IN,"crypto/buildinf.h"))
  459. {
  460. # Remove entry for this platform in existing file buildinf.h.
  461. my $old_buildinf_h = "";
  462. while (<IN>)
  463. {
  464. if (/^\#ifdef $platform_cpp_symbol$/)
  465. {
  466. while (<IN>) { last if (/^\#endif/); }
  467. }
  468. else
  469. {
  470. $old_buildinf_h .= $_;
  471. }
  472. }
  473. close(IN);
  474. open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
  475. print OUT $old_buildinf_h;
  476. close(OUT);
  477. }
  478. open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
  479. printf OUT <<EOF;
  480. #ifdef $platform_cpp_symbol
  481. /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
  482. #define CFLAGS "$cc $cflags"
  483. #define PLATFORM "$platform"
  484. EOF
  485. printf OUT " #define DATE \"%s\"\n", scalar gmtime();
  486. printf OUT "#endif\n";
  487. close(OUT);
  488. # Strip of trailing ' '
  489. foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
  490. $test=&clean_up_ws($test);
  491. $e_exe=&clean_up_ws($e_exe);
  492. $exheader=&clean_up_ws($exheader);
  493. $header=&clean_up_ws($header);
  494. # First we strip the exheaders from the headers list
  495. foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
  496. foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
  497. chop($h); $header=$h;
  498. $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
  499. $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
  500. $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
  501. $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
  502. $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
  503. $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
  504. $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
  505. $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
  506. foreach (values %lib_nam)
  507. {
  508. $lib_obj=$lib_obj{$_};
  509. local($slib)=$shlib;
  510. if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
  511. {
  512. $rules.="\$(O_SSL):\n\n";
  513. next;
  514. }
  515. if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
  516. {
  517. $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
  518. $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
  519. }
  520. if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
  521. {
  522. $lib_obj .= "\$(BNCO_ASM_OBJ)";
  523. $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
  524. }
  525. if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
  526. {
  527. $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
  528. $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
  529. $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
  530. }
  531. if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
  532. {
  533. $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
  534. $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
  535. }
  536. if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
  537. {
  538. $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
  539. $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
  540. }
  541. if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
  542. {
  543. $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
  544. $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
  545. }
  546. if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
  547. {
  548. $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
  549. $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
  550. }
  551. if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
  552. {
  553. $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
  554. $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
  555. }
  556. if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
  557. {
  558. $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
  559. $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
  560. }
  561. if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
  562. {
  563. $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
  564. $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
  565. }
  566. if (($whirlpool_asm_obj ne "") && ($_ eq "CRYPTO"))
  567. {
  568. $lib_obj =~ s/\s(\S*\/wp_dgst\S*)/ $1 \$(WHIRLPOOL_ASM_OBJ)/;
  569. $rules.=&do_asm_rule($whirlpool_asm_obj,$whirlpool_asm_src);
  570. }
  571. if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO"))
  572. {
  573. $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/;
  574. $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
  575. }
  576. $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
  577. $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
  578. $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
  579. }
  580. # hack to add version info on MSVC
  581. if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) {
  582. $rules.= <<"EOF";
  583. \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
  584. \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
  585. \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
  586. \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
  587. EOF
  588. }
  589. $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
  590. foreach (split(/\s+/,$test))
  591. {
  592. $t=&bname($_);
  593. $tt="\$(OBJ_D)${o}$t${obj}";
  594. $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  595. }
  596. $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
  597. foreach (split(/\s+/,$engines))
  598. {
  599. $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
  600. $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
  601. }
  602. $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
  603. $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
  604. $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  605. print $defs;
  606. if ($platform eq "linux-elf") {
  607. print <<"EOF";
  608. # Generate perlasm output files
  609. %.cpp:
  610. (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
  611. EOF
  612. }
  613. print "###################################################################\n";
  614. print $rules;
  615. ###############################################
  616. # strip off any trailing .[och] and append the relative directory
  617. # also remembering to do nothing if we are in one of the dropped
  618. # directories
  619. sub var_add
  620. {
  621. local($dir,$val,$keepext)=@_;
  622. local(@a,$_,$ret);
  623. return("") if $no_engine && $dir =~ /\/engine/;
  624. return("") if $no_hw && $dir =~ /\/hw/;
  625. return("") if $no_idea && $dir =~ /\/idea/;
  626. return("") if $no_aes && $dir =~ /\/aes/;
  627. return("") if $no_rc2 && $dir =~ /\/rc2/;
  628. return("") if $no_rc4 && $dir =~ /\/rc4/;
  629. return("") if $no_rc5 && $dir =~ /\/rc5/;
  630. return("") if $no_rsa && $dir =~ /\/rsa/;
  631. return("") if $no_rsa && $dir =~ /^rsaref/;
  632. return("") if $no_dsa && $dir =~ /\/dsa/;
  633. return("") if $no_dh && $dir =~ /\/dh/;
  634. return("") if $no_ec && $dir =~ /\/ec/;
  635. if ($no_des && $dir =~ /\/des/)
  636. {
  637. if ($val =~ /read_pwd/)
  638. { return("$dir/read_pwd "); }
  639. else
  640. { return(""); }
  641. }
  642. return("") if $no_mdc2 && $dir =~ /\/mdc2/;
  643. return("") if $no_sock && $dir =~ /\/proxy/;
  644. return("") if $no_bf && $dir =~ /\/bf/;
  645. return("") if $no_cast && $dir =~ /\/cast/;
  646. return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
  647. $val =~ s/^\s*(.*)\s*$/$1/;
  648. @a=split(/\s+/,$val);
  649. grep(s/\.[och]$//,@a) unless $keepext;
  650. @a=grep(!/^e_.*_3d$/,@a) if $no_des;
  651. @a=grep(!/^e_.*_d$/,@a) if $no_des;
  652. @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
  653. @a=grep(!/^e_.*_i$/,@a) if $no_aes;
  654. @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
  655. @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
  656. @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
  657. @a=grep(!/^e_.*_c$/,@a) if $no_cast;
  658. @a=grep(!/^e_rc4$/,@a) if $no_rc4;
  659. @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
  660. @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
  661. @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
  662. @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
  663. @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
  664. @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
  665. @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
  666. @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
  667. @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
  668. @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
  669. @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
  670. @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
  671. @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
  672. @a=grep(!/_dhp$/,@a) if $no_dh;
  673. @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
  674. @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
  675. @a=grep(!/_mdc2$/,@a) if $no_mdc2;
  676. @a=grep(!/^engine$/,@a) if $no_engine;
  677. @a=grep(!/^hw$/,@a) if $no_hw;
  678. @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
  679. @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
  680. @a=grep(!/^gendsa$/,@a) if $no_sha1;
  681. @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
  682. @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
  683. grep($_="$dir/$_",@a);
  684. @a=grep(!/(^|\/)s_/,@a) if $no_sock;
  685. @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
  686. $ret=join(' ',@a)." ";
  687. return($ret);
  688. }
  689. # change things so that each 'token' is only separated by one space
  690. sub clean_up_ws
  691. {
  692. local($w)=@_;
  693. $w =~ s/^\s*(.*)\s*$/$1/;
  694. $w =~ s/\s+/ /g;
  695. return($w);
  696. }
  697. sub do_defs
  698. {
  699. local($var,$files,$location,$postfix)=@_;
  700. local($_,$ret,$pf);
  701. local(*OUT,$tmp,$t);
  702. $files =~ s/\//$o/g if $o ne '/';
  703. $ret="$var=";
  704. $n=1;
  705. $Vars{$var}.="";
  706. foreach (split(/ /,$files))
  707. {
  708. $orig=$_;
  709. $_=&bname($_) unless /^\$/;
  710. if ($n++ == 2)
  711. {
  712. $n=0;
  713. $ret.="\\\n\t";
  714. }
  715. if (($_ =~ /bss_file/) && ($postfix eq ".h"))
  716. { $pf=".c"; }
  717. else { $pf=$postfix; }
  718. if ($_ =~ /BN_ASM/) { $t="$_ "; }
  719. elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
  720. elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
  721. elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
  722. elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
  723. elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
  724. elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
  725. elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
  726. elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
  727. elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
  728. elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
  729. elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
  730. else { $t="$location${o}$_$pf "; }
  731. $Vars{$var}.="$t ";
  732. $ret.=$t;
  733. }
  734. # hack to add version info on MSVC
  735. if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT")))
  736. {
  737. if ($var eq "CRYPTOOBJ")
  738. { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
  739. elsif ($var eq "SSLOBJ")
  740. { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
  741. }
  742. chomp($ret);
  743. $ret.="\n\n";
  744. return($ret);
  745. }
  746. # return the name with the leading path removed
  747. sub bname
  748. {
  749. local($ret)=@_;
  750. $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
  751. return($ret);
  752. }
  753. ##############################################################
  754. # do a rule for each file that says 'compile' to new direcory
  755. # compile the files in '$files' into $to
  756. sub do_compile_rule
  757. {
  758. local($to,$files,$ex)=@_;
  759. local($ret,$_,$n);
  760. $files =~ s/\//$o/g if $o ne '/';
  761. foreach (split(/\s+/,$files))
  762. {
  763. $n=&bname($_);
  764. $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
  765. }
  766. return($ret);
  767. }
  768. ##############################################################
  769. # do a rule for each file that says 'compile' to new direcory
  770. sub cc_compile_target
  771. {
  772. local($target,$source,$ex_flags)=@_;
  773. local($ret);
  774. $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
  775. $target =~ s/\//$o/g if $o ne "/";
  776. $source =~ s/\//$o/g if $o ne "/";
  777. $ret ="$target: \$(SRC_D)$o$source\n\t";
  778. $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
  779. return($ret);
  780. }
  781. ##############################################################
  782. sub do_asm_rule
  783. {
  784. local($target,$src)=@_;
  785. local($ret,@s,@t,$i);
  786. $target =~ s/\//$o/g if $o ne "/";
  787. $src =~ s/\//$o/g if $o ne "/";
  788. @s=split(/\s+/,$src);
  789. @t=split(/\s+/,$target);
  790. for ($i=0; $i<=$#s; $i++)
  791. {
  792. $ret.="$t[$i]: $s[$i]\n";
  793. $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n";
  794. }
  795. return($ret);
  796. }
  797. sub do_shlib_rule
  798. {
  799. local($n,$def)=@_;
  800. local($ret,$nn);
  801. local($t);
  802. ($nn=$n) =~ tr/a-z/A-Z/;
  803. $ret.="$n.dll: \$(${nn}OBJ)\n";
  804. if ($vc && $w32)
  805. {
  806. $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
  807. }
  808. $ret.="\n";
  809. return($ret);
  810. }
  811. # do a rule for each file that says 'copy' to new direcory on change
  812. sub do_copy_rule
  813. {
  814. local($to,$files,$p)=@_;
  815. local($ret,$_,$n,$pp);
  816. $files =~ s/\//$o/g if $o ne '/';
  817. foreach (split(/\s+/,$files))
  818. {
  819. $n=&bname($_);
  820. if ($n =~ /bss_file/)
  821. { $pp=".c"; }
  822. else { $pp=$p; }
  823. $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
  824. }
  825. return($ret);
  826. }
  827. sub read_options
  828. {
  829. # Many options are handled in a similar way. In particular
  830. # no-xxx sets zero or more scalars to 1.
  831. # Process these using a hash containing the option name and
  832. # reference to the scalars to set.
  833. my %valid_options = (
  834. "no-rc2" => \$no_rc2,
  835. "no-rc4" => \$no_rc4,
  836. "no-rc5" => \$no_rc5,
  837. "no-idea" => \$no_idea,
  838. "no-aes" => \$no_aes,
  839. "no-des" => \$no_des,
  840. "no-bf" => \$no_bf,
  841. "no-cast" => \$no_cast,
  842. "no-md2" => \$no_md2,
  843. "no-md4" => \$no_md4,
  844. "no-md5" => \$no_md5,
  845. "no-sha" => \$no_sha,
  846. "no-sha1" => \$no_sha1,
  847. "no-ripemd" => \$no_ripemd,
  848. "no-mdc2" => \$no_mdc2,
  849. "no-whirlpool" => \$no_whirlpool,
  850. "no-patents" =>
  851. [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
  852. "no-rsa" => \$no_rsa,
  853. "no-dsa" => \$no_dsa,
  854. "no-dh" => \$no_dh,
  855. "no-hmac" => \$no_hmac,
  856. "no-aes" => \$no_aes,
  857. "no-asm" => \$no_asm,
  858. "nasm" => \$nasm,
  859. "nw-nasm" => \$nw_nasm,
  860. "nw-mwasm" => \$nw_mwasm,
  861. "gaswin" => \$gaswin,
  862. "no-ssl2" => \$no_ssl2,
  863. "no-ssl3" => \$no_ssl3,
  864. "no-err" => \$no_err,
  865. "no-sock" => \$no_sock,
  866. "no-krb5" => \$no_krb5,
  867. "no-ec" => \$no_ec,
  868. "no-ecdsa" => \$no_ecdsa,
  869. "no-ecdh" => \$no_ecdh,
  870. "no-engine" => \$no_engine,
  871. "no-hw" => \$no_hw,
  872. "just-ssl" =>
  873. [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
  874. \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
  875. \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
  876. \$no_aes],
  877. "rsaref" => 0,
  878. "gcc" => \$gcc,
  879. "debug" => \$debug,
  880. "profile" => \$profile,
  881. "shlib" => \$shlib,
  882. "dll" => \$shlib,
  883. "shared" => 0,
  884. "no-gmp" => 0,
  885. "no-shared" => 0,
  886. "no-zlib" => 0,
  887. "no-zlib-dynamic" => 0,
  888. );
  889. if (exists $valid_options{$_})
  890. {
  891. my $r = $valid_options{$_};
  892. if ( ref $r eq "SCALAR")
  893. { $$r = 1;}
  894. elsif ( ref $r eq "ARRAY")
  895. {
  896. my $r2;
  897. foreach $r2 (@$r)
  898. {
  899. $$r2 = 1;
  900. }
  901. }
  902. }
  903. elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
  904. elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
  905. elsif (/^enable-zlib-dynamic$/)
  906. {
  907. $zlib_opt = 2;
  908. }
  909. elsif (/^no-static-engine/)
  910. {
  911. $no_static_engine = 1;
  912. }
  913. elsif (/^enable-static-engine/)
  914. {
  915. $no_static_engine = 0;
  916. }
  917. # There are also enable-xxx options which correspond to
  918. # the no-xxx. Since the scalars are enabled by default
  919. # these can be ignored.
  920. elsif (/^enable-/)
  921. {
  922. my $t = $_;
  923. $t =~ s/^enable/no/;
  924. if (exists $valid_options{$t})
  925. {return 1;}
  926. return 0;
  927. }
  928. elsif (/^--with-krb5-flavor=(.*)$/)
  929. {
  930. my $krb5_flavor = $1;
  931. if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
  932. {
  933. $xcflags="-DKRB5_HEIMDAL $xcflags";
  934. }
  935. elsif ($krb5_flavor =~ /^MIT/i)
  936. {
  937. $xcflags="-DKRB5_MIT $xcflags";
  938. if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
  939. {
  940. $xcflags="-DKRB5_MIT_OLD11 $xcflags"
  941. }
  942. }
  943. }
  944. elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
  945. elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
  946. elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
  947. { $c_flags.="$_ "; }
  948. else { return(0); }
  949. return(1);
  950. }