mk1mf.pl 29 KB

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