unified build scheme: adjust some scripts
authorRichard Levitte <levitte@openssl.org>
Fri, 29 Jan 2016 23:03:58 +0000 (00:03 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 9 Feb 2016 10:43:19 +0000 (11:43 +0100)
util/mkdef.pl and Makefile.shared needs to know about the source and
the build directories.

Additionally, Makefile.shared needs to know how to build shared
libraries in a directory other than the current one.

Reviewed-by: Ben Laurie <ben@openssl.org>
Makefile.shared
util/mkdef.pl

index 13129f837cf2e773b9b2c7971a347e206138c976..af2dc8ce858ea4e47d8d9e0d1fae7e040b43dd1d 100644 (file)
@@ -31,6 +31,12 @@ LIBNAME=
 #APPNAME=foo
 APPNAME=
 
+# DSTDIR is the directory where the built file should end up in.
+DSTDIR=.
+
+# SRCDIR is the top directory of the source tree.
+SRCDIR=.
+
 # OBJECTS contains all the object files to link together into the application.
 # This must contain at least one object file.
 #OBJECTS=foo.o
@@ -109,11 +115,11 @@ LINK_SO=  \
     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
     echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
          $${SHAREDCMD} $${SHAREDFLAGS} \
-            -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+            -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
             $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS; \
     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
     $${SHAREDCMD} $${SHAREDFLAGS} \
-       -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+       -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
        $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
   ) && $(SYMLINK_SO)
 
@@ -122,30 +128,30 @@ SYMLINK_SO=       \
                prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
                if [ -n "$$SHLIB_COMPAT" ]; then \
                        for x in $$SHLIB_COMPAT; do \
-                               ( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
-                                 ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
+                               ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX; \
+                                 ln -s $$prev $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX ); \
                                prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
                        done; \
                fi; \
                if [ -n "$$SHLIB_SOVER" ]; then \
-                       ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
-                         ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
+                       ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX; \
+                         ln -s $$prev $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX ); \
                fi; \
        fi
 
-LINK_SO_A=     SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
+LINK_SO_A=     SHOBJECTS="$(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
 LINK_SO_O=     SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
 
 LINK_SO_A_VIA_O=       \
-  SHOBJECTS=lib$(LIBNAME).o; \
+  SHOBJECTS=$(DSTDIR)/lib$(LIBNAME).o; \
   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
-  ( echo ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
-    ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
-  $(LINK_SO) && ( echo rm -f lib$(LIBNAME).o; rm -f lib$(LIBNAME).o )
+  ( echo ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
+    ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \
+  $(LINK_SO) && ( echo rm -f $$SHOBJECTS; rm -f $$SHOBJECTS )
 
 LINK_SO_A_UNPACKED=    \
   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
-  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
+  (cd $$UNPACKDIR; ar x ../$(DSTDIR)/lib$(LIBNAME).a) && \
   ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
   SHOBJECTS=$$UNPACKDIR/*.o; \
   $(LINK_SO) && rm -rf $$UNPACKDIR
@@ -178,7 +184,7 @@ link_app.gnu:
 
 link_a.linux-shared:
        @if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then $(DO_GNU_SO); else \
-       $(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
+       $(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
@@ -294,7 +300,7 @@ link_a.cygwin:
                esac; \
                SHLIB_SOVER=32; \
                extras="$(LIBNAME).def"; \
-               $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
+               $(PERL) $(SRCDIR)/util/mkdef.pl 32 $$SHLIB > $$extras; \
                base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
        fi; \
        dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
@@ -312,7 +318,7 @@ link_a.cygwin:
        cp -p $$dll_name test/
 link_app.cygwin:
        @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
-               LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
+               LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
                export LIBDEPS; \
        fi; \
        $(LINK_APP)
@@ -393,7 +399,7 @@ link_a.solaris:
                if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then \
                        ALLSYMSFLAGS="$${MINUSZ}allextract"; \
                else \
-                       $(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
+                       $(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
                        ALLSYMSFLAGS="$${MINUSZ}allextract,-M,$(LIBNAME).map"; \
                fi; \
                NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
index 3151800007ac4197f5ed54b64d04d07d28d8ab5d..ff68d86ecc1ceb2571181d6ec653912a50b5a8da 100755 (executable)
 
 use lib ".";
 use configdata;
+use File::Spec::Functions;
 
 my $debug=0;
 
-my $crypto_num= "util/libeay.num";
-my $ssl_num=    "util/ssleay.num";
+my $crypto_num= catfile($config{sourcedir},"util","libeay.num");
+my $ssl_num=    catfile($config{sourcedir},"util","ssleay.num");
 my $libname;
 
 my $do_update = 0;
@@ -384,8 +385,9 @@ sub do_defs
 
        foreach $file (split(/\s+/,$symhacksfile." ".$files))
                {
-               print STDERR "DEBUG: starting on $file:\n" if $debug;
-               open(IN,"<$file") || die "unable to open $file:$!\n";
+               my $fn = catfile($config{sourcedir},$file);
+               print STDERR "DEBUG: starting on $fn:\n" if $debug;
+               open(IN,"<$fn") || die "unable to open $fn:$!\n";
                my $line = "", my $def= "";
                my %tag = (
                        (map { $_ => 0 } @known_platforms),
@@ -1552,7 +1554,8 @@ sub count_parens
 #version
 sub get_openssl_version()
 {
-       open (IN, "include/openssl/opensslv.h") || die "Can't open opensslv.h";
+       my $fn = catfile($config{sourcedir},"include","openssl","opensslv.h");
+       open (IN, "$fn") || die "Can't open opensslv.h";
 
        while(<IN>) {
                if (/OPENSSL_VERSION_TEXT\s+"OpenSSL (\d\.\d\.)(\d[a-z]*)(-| )/) {