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 cf5371b..791634f 100644 (file)
@@ -12,7 +12,7 @@
        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      => "",
@@ -34,6 +34,7 @@
        unistd          => "<unistd.h>",
        shared_target   => "",
        shared_cflag    => "",
+       shared_defines  => [],
        shared_ldflag   => "",
        shared_rcflag   => "",
        shared_extension        => "",
        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",
index 03dc56b..4372d92 100644 (file)
 
 #### 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",
         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",
         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",
index 41fbf56..8fb2969 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");
-    $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
@@ -1542,9 +1538,9 @@ EOF
 
 # 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 $obj = $_) =~ s/_asm_src$/_obj/;
+    (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/;
     ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g;
 }
 
index 79a1ea9..9912d88 100644 (file)
@@ -120,6 +120,7 @@ ASFLAG=$(CFLAG)
 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} -}
@@ -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)'       \
+               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)'     \
index 159e9ec..90290d1 100644 (file)
@@ -319,10 +319,6 @@ link_a.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:
index d49afec..956d84b 100644 (file)
@@ -15,6 +15,8 @@ PLIB_LDFLAG=
 EX_LIBS= 
 EXE_EXT= 
 
+APPS_OBJ=
+
 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
 
-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 \
index a7dcee6..d581aad 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 \
-        {- $target{apps_extra_src} -}
+        {- $target{apps_aux_src} -}
 INCLUDE[openssl]={- rel2abs(catdir($builddir,"../include")) -} .. ../include
 DEPEND[openssl]=../libssl
 
index 507e998..b360ff8 100644 (file)
@@ -21,12 +21,6 @@ crypto/buildinf.h : Makefile
 
 ##### 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) > $@