Make it possible to get ENGINESDIR info from OpenSSL_versions
[openssl.git] / util / mk1mf.pl
index 491a1bb276c2b0dd873788afd5635976f0fb180f..e79733d710d8beb9083f59385c29c4611dbfd6fd 100755 (executable)
@@ -9,8 +9,9 @@
 
 use Cwd;
 
-$INSTALLTOP="/usr/local/ssl";
+$INSTALLTOP="/usr/local";
 $OPENSSLDIR="/usr/local/ssl";
+$ENGINESDIR="/usr/local/lib/engines";
 $OPTIONS="";
 $ssl_version="";
 $banner="\t\@echo Building OpenSSL";
@@ -47,10 +48,11 @@ my %mf_import = (
        OPTIONS        => \$OPTIONS,
        INSTALLTOP     => \$INSTALLTOP,
        OPENSSLDIR     => \$OPENSSLDIR,
+       ENGINESDIR     => \$ENGINESDIR,
        PLATFORM       => \$mf_platform,
        CC             => \$mf_cc,
        CFLAG          => \$mf_cflag,
-       DEPFLAG        => \$mf_depflag,
+        DEPFLAG        => \$mf_depflag,
        CPUID_OBJ      => \$mf_cpuid_asm,
        BN_ASM         => \$mf_bn_asm,
        DES_ENC        => \$mf_des_asm,
@@ -83,8 +85,6 @@ while(<IN>) {
 }
 close(IN);
 
-$debug = 1 if $mf_platform =~ /^debug-/;
-
 if ($mf_fipscanisterinternal eq "y") {
        $fips = 1;
        $fipscanisterbuild = 1;
@@ -142,7 +142,11 @@ and [options] can be one of
        no-srp                                  - No SRP
        no-ec                                   - No EC
        no-engine                               - No engine
+       no-egd                                  - No EGD
        no-hw                                   - No hw
+       no-async                                - No Async (use NULL)
+       no-autoalginit                          - Don't auto load algorithms in libcrypto
+       no-autoerrinit                          - Don't auto load error strings for libcrypto or libssl
        nasm                                    - Use NASM for x86 asm
        nw-nasm                                 - Use NASM x86 asm for NetWare
        nw-mwasm                                - Use Metrowerks x86 asm for NetWare
@@ -183,6 +187,7 @@ $tmp_def="tmp";
 
 $perl="perl" unless defined $perl;
 $mkdir="-mkdir" unless defined $mkdir;
+$mv="mv" unless defined $mv;
 
 ($ssl,$crypto)=("ssl","crypto");
 $ranlib="echo ranlib";
@@ -296,6 +301,9 @@ $cflags.=" -DOPENSSL_NO_EC"   if $no_ec;
 $cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
+$cflags.=" -DOPENSSL_NO_ASYNC" if $no_async;
+$cflags.=" -DOPENSSL_NO_AUTOALGINIT" if $no_autoalginit;
+$cflags.=" -DOPENSSL_NO_AUTOERRINIT" if $no_autoerrinit;
 $cflags.=" -DOPENSSL_FIPS"    if $fips;
 $cflags.=" -DOPENSSL_NO_JPAKE"    if $no_jpake;
 $cflags.=" -DOPENSSL_NO_EC2M"    if $no_ec2m;
@@ -630,6 +638,7 @@ $defs .= $preamble if defined $preamble;
 $defs.= <<"EOF";
 INSTALLTOP=$INSTALLTOP
 OPENSSLDIR=$OPENSSLDIR
+ENGINESDIR=$ENGINESDIR
 
 # Set your compiler options
 PLATFORM=$platform
@@ -662,6 +671,7 @@ PERLASM_SCHEME=$mf_perlasm_scheme
 CP=$cp
 CP2=$cp2
 RM=$rm
+MV=$mv
 RANLIB=$ranlib
 MKDIR=$mkdir
 MKLIB=$bin_dir$mklib
@@ -752,9 +762,10 @@ headers: \$(HEADER)
 
 lib: \$(LIBS_DEP) \$(E_SHLIB)
 
-exe: apps testapps
-apps: \$(BIN_D)$o\$(E_EXE)$exep
+exe: apps tools testapps
+apps: \$(BIN_D)$o\$(E_EXE)$exep \$(BIN_D)${o}CA.pl
 testapps: \$(T_EXE)
+tools: \$(BIN_D)${o}c_rehash
 
 install: all
        \$(MKDIR) \"\$(INSTALLTOP)\"
@@ -762,6 +773,7 @@ install: all
        \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
        \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
        \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
+       \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
 $extra_install
 
 clean:
@@ -779,7 +791,7 @@ reallyclean:
 
 EOF
 
-$rules .= &do_rehash_rule("rehash.time", "certs apps");
+$rules .= &do_rehash_rule("rehash.time", "certs/demo apps tools");
 $rules .= &do_test_rule("test", "rehash.time", "run_tests.pl");
 
 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
@@ -808,7 +820,7 @@ if (open(IN,"crypto/buildinf.h"))
        }
 
 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
-printf OUT <<EOF;
+printf OUT <<"EOF";
 #ifdef $platform_cpp_symbol
   /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
   #define CFLAGS "compiler: $cc $cflags"
@@ -999,6 +1011,9 @@ if ($fips)
 
 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
 
+$rules.=&do_dofile_rule("\$(BIN_D)","c_rehash","tools/c_rehash.in");
+$rules.=&do_dofile_rule("\$(BIN_D)","CA.pl","apps/CA.pl.in");
+
 print $defs;
 
 if ($platform eq "linux-elf") {
@@ -1034,7 +1049,6 @@ sub var_add
        return("") if $no_dsa  && $dir =~ /\/dsa/;
        return("") if $no_dh   && $dir =~ /\/dh/;
        return("") if $no_ec   && $dir =~ /\/ec/;
-       return("") if $no_gost   && $dir =~ /\/ccgost/;
        return("") if $no_cms  && $dir =~ /\/cms/;
        return("") if $no_jpake  && $dir =~ /\/jpake/;
        return("") if !$fips   && $dir =~ /^fips/;
@@ -1077,8 +1091,7 @@ sub var_add
        @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
 
        @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
-       @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
-       @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
+       @a=grep(!/(^p_open$)/,@a) if $no_rsa;
 
        @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
        @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
@@ -1330,6 +1343,7 @@ sub do_copy_rule
        local($to,$files,$p)=@_;
        local($ret,$_,$n,$pp);
        
+
        $files =~ s/\//$o/g if $o ne '/';
        foreach (split(/\s+/,$files))
                {
@@ -1342,6 +1356,18 @@ sub do_copy_rule
        return($ret);
        }
 
+sub do_dofile_rule
+       {
+       (my $to, my $file, my $tmpl) = @_;
+
+       $file =~ s|/|$o|g if $o ne '/';
+       return <<"EOF";
+$to${o}$file: $tmpl
+       \$(PERL) "-I." "-Mconfigdata" util/dofile.pl "$tmpl" > "$to${o}$file.new"
+       \$(MV) "$to${o}$file.new" "$to${o}$file"
+EOF
+       }
+
 # Options picked up from the OPTIONS line in the top level Makefile
 # generated by Configure.
 
@@ -1393,7 +1419,11 @@ sub read_options
                "no-ec" => \$no_ec,
                "no-gost" => \$no_gost,
                "no-engine" => \$no_engine,
+               "no-egd" => 0,
                "no-hw" => \$no_hw,
+               "no-async" => \$no_async,
+               "no-autoalginit" => \$no_autoalginit,
+               "no-autoerrinit" => \$no_autoerrinit,
                "just-ssl" =>
                        [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
                          \$no_md2, \$no_mdc2, \$no_dsa, \$no_dh,
@@ -1402,6 +1432,7 @@ sub read_options
                "rsaref" => 0,
                "gcc" => \$gcc,
                "debug" => \$debug,
+               "--debug" => \$debug,
                "profile" => \$profile,
                "shlib" => \$shlib,
                "dll" => \$shlib,
@@ -1419,6 +1450,7 @@ sub read_options
                "no-unit-test" => 0,
                "no-deprecated" => 0,
                "no-ocb" => 0,
+               "no-crypto-mdebug" => 0,
                "fips" => \$fips,
                "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
                "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],