Rethink the uplink / applink story
authorRichard Levitte <levitte@openssl.org>
Thu, 18 Feb 2016 17:43:56 +0000 (18:43 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 19 Feb 2016 10:06:54 +0000 (11:06 +0100)
Adding uplink and applink to some builds was done by "magic", the
configuration for "mingw" only had a macro definition, the Configure
would react to its presence by adding the uplink source files to
cpuid_asm_src, and crypto/build.info inherited dance to get it
compiled, and Makefile.shared made sure applink.o would be
appropriately linked in.  That was a lot under the hood.

To replace this, we create a few template configurations in
Configurations/00-base-templates.conf, inherit one of them in the
"mingw" configuration, the rest is just about refering to the
$target{apps_aux_src} / $target{apps_obj} in the right places.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Configurations/00-base-templates.conf
Configurations/10-main.conf
Configure
Makefile.in
Makefile.shared
apps/Makefile.in
apps/build.info
crypto/build.info

index cf5371b9ff74698b7a7e3112d24eba717bae2488..791634f35281cd2df3df44f0a8319435109ecf8e 100644 (file)
@@ -12,7 +12,7 @@
        thread_cflags   => "",
        thread_defines  => [],
 
        thread_cflags   => "",
        thread_defines  => [],
 
-       apps_extra_src  => "",
+       apps_aux_src    => "",
        cpuid_asm_src   => "mem_clr.c",
        bn_asm_src      => "bn_asm.c",
        ec_asm_src      => "",
        cpuid_asm_src   => "mem_clr.c",
        bn_asm_src      => "bn_asm.c",
        ec_asm_src      => "",
@@ -34,6 +34,7 @@
        unistd          => "<unistd.h>",
        shared_target   => "",
        shared_cflag    => "",
        unistd          => "<unistd.h>",
        shared_target   => "",
        shared_cflag    => "",
+       shared_defines  => [],
        shared_ldflag   => "",
        shared_rcflag   => "",
        shared_extension        => "",
        shared_ldflag   => "",
        shared_rcflag   => "",
        shared_extension        => "",
        build_file      => "Makefile",
     },
 
        build_file      => "Makefile",
     },
 
+    uplink_common => {
+       template        => 1,
+       apps_aux_src    => add(" ","../ms/applink.c"),
+       cpuid_asm_src   => add(" ","../ms/uplink.c"),
+       shared_defines  => add(undef, "OPENSSL_USE_APPLINK"),
+    },
+    x86_uplink => {
+       inherit_from    => [ "uplink_common" ],
+       template        => 1,
+       cpuid_asm_src   => add(" ","uplink-x86.s"),
+    },
+    x86_64_uplink => {
+       inherit_from    => [ "uplink_common" ],
+       template        => 1,
+       cpuid_asm_src   => add(" ","uplink-x86_64.s"),
+    },
+    ia64_uplink => {
+       inherit_from    => [ "uplink_common" ],
+       template        => 1,
+       cpuid_asm_src   => add(" ","uplink-ia64.s"),
+    },
+
     x86_asm => {
        template        => 1,
        cpuid_asm_src   => "x86cpuid.s",
     x86_asm => {
        template        => 1,
        cpuid_asm_src   => "x86cpuid.s",
index 03dc56bde1a7fb9b547a076ec97d6658ffd3e597..4372d92614cf35c6e5feb5359d08dd4841e6f4d5 100644 (file)
 
 #### MinGW
     "mingw" => {
 
 #### MinGW
     "mingw" => {
-        inherit_from     => [ asm("x86_asm") ],
+        inherit_from     => [ asm("x86_asm"),
+                              sub { $config{no_shared} ? () : "x86_uplink" } ],
         cc               => "gcc",
         cflags           => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
         debug_cflags     => "-g -O0",
         cc               => "gcc",
         cflags           => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
         debug_cflags     => "-g -O0",
         perlasm_scheme   => "coff",
         dso_scheme       => "win32",
         shared_target    => "cygwin-shared",
         perlasm_scheme   => "coff",
         dso_scheme       => "win32",
         shared_target    => "cygwin-shared",
-        shared_cflag     => "-D_WINDLL -DOPENSSL_USE_APPLINK",
+        shared_cflag     => add(" ", "-D_WINDLL"),
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-i386",
         shared_extension => ".dll",
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-i386",
         shared_extension => ".dll",
         perlasm_scheme   => "mingw64",
         dso_scheme       => "win32",
         shared_target    => "cygwin-shared",
         perlasm_scheme   => "mingw64",
         dso_scheme       => "win32",
         shared_target    => "cygwin-shared",
-        shared_cflag     => "-D_WINDLL",
+        shared_cflag     => add(" ", "-D_WINDLL"),
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-x86-64",
         shared_extension => ".dll",
         shared_ldflag    => "-static-libgcc",
         shared_rcflag    => "--target=pe-x86-64",
         shared_extension => ".dll",
index 41fbf56eab27b5f4e48997752c3ce7354a2e4be5..8fb2969a96d8402be8952bce6c5a1869bc165346 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1013,10 +1013,6 @@ if ($target{ranlib} eq "")
 
 if (!$no_asm) {
     $target{cpuid_asm_src}=$table{BASE}->{cpuid_asm_src} if ($config{processor} eq "386");
 
 if (!$no_asm) {
     $target{cpuid_asm_src}=$table{BASE}->{cpuid_asm_src} if ($config{processor} eq "386");
-    $target{cpuid_asm_src}.=" uplink.c uplink-x86.s"
-        if (grep { $_ eq "OPENSSL_USE_APPLINK"} @{$config{defines}}
-            or $config{cflags} =~ /(?:^|\s)-DOPENSSL_USE_APPLINK(?:\s|$)/);
-
     $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m}));
 
     # bn-586 is the only one implementing bn_*_part_words
     $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m}));
 
     # bn-586 is the only one implementing bn_*_part_words
@@ -1542,9 +1538,9 @@ EOF
 
 # For the schemes that need it, we provide the old *_obj configs
 # from the *_asm_obj ones
 
 # For the schemes that need it, we provide the old *_obj configs
 # from the *_asm_obj ones
-foreach (grep /_asm_src$/, keys %target) {
+foreach (grep /_(asm|aux)_src$/, keys %target) {
     my $src = $_;
     my $src = $_;
-    (my $obj = $_) =~ s/_asm_src$/_obj/;
+    (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/;
     ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g;
 }
 
     ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g;
 }
 
index 79a1ea95ebfbbbc53229e2feeeedb5dbb974d4e5..9912d8868a7be092d0db0aee17f620b4dd9713e7 100644 (file)
@@ -120,6 +120,7 @@ ASFLAG=$(CFLAG)
 PROCESSOR= {- $config{processor} -}
 
 # CPUID module collects small commonly used assembler snippets
 PROCESSOR= {- $config{processor} -}
 
 # CPUID module collects small commonly used assembler snippets
+APPS_OBJ={- $target{apps_obj} -}
 CPUID_OBJ= {- $target{cpuid_obj} -}
 BN_ASM= {- $target{bn_obj} -}
 EC_ASM= {- $target{ec_obj} -}
 CPUID_OBJ= {- $target{cpuid_obj} -}
 BN_ASM= {- $target{bn_obj} -}
 EC_ASM= {- $target{ec_obj} -}
@@ -260,6 +261,7 @@ BUILDENV=   LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
                SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
                LDFLAG='$(LDFLAG)'                              \
                PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'       \
                SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
                LDFLAG='$(LDFLAG)'                              \
                PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'       \
+               APPS_OBJ='$(APPS_OBJ)'                          \
                CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
                EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
                AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
                CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'     \
                EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'         \
                AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'     \
index 159e9ecc0eab62c5129f20b64856e9cb4e09a212..90290d188393f8b70a34d2eba21dfca314b09eaa 100644 (file)
@@ -319,10 +319,6 @@ link_a.cygwin:
        $(LINK_SO_A) || exit 1; \
        rm $$extras
 link_app.cygwin:
        $(LINK_SO_A) || exit 1; \
        rm $$extras
 link_app.cygwin:
-       @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
-               LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
-               export LIBDEPS; \
-       fi; \
        $(LINK_APP)
 
 link_o.alpha-osf1:
        $(LINK_APP)
 
 link_o.alpha-osf1:
index d49afece363d8f6629de4b32c7908089c55874ff..956d84b4d75664ac7664800971cf9e2d22abdc3e 100644 (file)
@@ -15,6 +15,8 @@ PLIB_LDFLAG=
 EX_LIBS= 
 EXE_EXT= 
 
 EX_LIBS= 
 EXE_EXT= 
 
+APPS_OBJ=
+
 SHLIB_TARGET=
 
 CFLAGS= $(INCLUDES) $(CFLAG)
 SHLIB_TARGET=
 
 CFLAGS= $(INCLUDES) $(CFLAG)
@@ -52,7 +54,7 @@ SRC   = \
        s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c \
        srp.c ts.c verify.c version.c x509.c rehash.c
 
        s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c \
        srp.c ts.c verify.c version.c x509.c rehash.c
 
-EXE_OBJ        = openssl.o $(OBJ) $(EXTRA_OBJ) $(RAND_OBJ)
+EXE_OBJ        = openssl.o $(OBJ) $(EXTRA_OBJ) $(RAND_OBJ) $(APPS_OBJ)
 EXE_SRC = openssl.c $(SRC) $(EXTRA_SRC) $(RAND_SRC)
 
 HEADER=        apps.h progs.h s_apps.h \
 EXE_SRC = openssl.c $(SRC) $(EXTRA_SRC) $(RAND_SRC)
 
 HEADER=        apps.h progs.h s_apps.h \
index a7dcee6e1a5c7f9a61c57d1c526d064f812b3a5a..d581aad4bf1557f7218a42b943deb2e994da02c6 100644 (file)
@@ -10,7 +10,7 @@ SOURCE[openssl]=\
         srp.c ts.c verify.c version.c x509.c rehash.c \
         apps.c opt.c s_cb.c s_socket.c \
         app_rand.c \
         srp.c ts.c verify.c version.c x509.c rehash.c \
         apps.c opt.c s_cb.c s_socket.c \
         app_rand.c \
-        {- $target{apps_extra_src} -}
+        {- $target{apps_aux_src} -}
 INCLUDE[openssl]={- rel2abs(catdir($builddir,"../include")) -} .. ../include
 DEPEND[openssl]=../libssl
 
 INCLUDE[openssl]={- rel2abs(catdir($builddir,"../include")) -} .. ../include
 DEPEND[openssl]=../libssl
 
index 507e998fc5c5241713c3278b1d2cbffc8a9451e4..b360ff876e7a43b96b3f0da0c3707489d1cf2cbc 100644 (file)
@@ -21,12 +21,6 @@ crypto/buildinf.h : Makefile
 
 ##### APPLINK, UPLINK and CPUID assembler implementations
 
 
 ##### APPLINK, UPLINK and CPUID assembler implementations
 
-{- $builddir -}/applink.o:     $(SRCDIR)/ms/applink.c
-       $(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/ms/applink.c
-
-{- $builddir -}/uplink.o:      $(SRCDIR)/ms/uplink.c {- $builddir -}/applink.o
-       $(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/ms/uplink.c
-
 {- $builddir -}/uplink-x86.s:  $(SRCDIR)/ms/uplink-x86.pl
        CC="$(CC)" $(PERL) $(SRCDIR)/ms/uplink-x86.pl $(PERLASM_SCHEME) > $@
 
 {- $builddir -}/uplink-x86.s:  $(SRCDIR)/ms/uplink-x86.pl
        CC="$(CC)" $(PERL) $(SRCDIR)/ms/uplink-x86.pl $(PERLASM_SCHEME) > $@