Fix for Win32 dynamic engine loading.
[openssl.git] / Makefile.shared
index 6d68761..ef1bfe1 100644 (file)
@@ -91,7 +91,7 @@ LINK_APP=     \
   ( $(SET_X);   \
     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
     LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
-    LIBPATH=`for x in $(LIBDEPS); do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
+    LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
     $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
@@ -196,12 +196,17 @@ link_app.bsd:
        fi; $(LINK_APP)
 
 # For Darwin AKA Mac OS/X (dyld)
+# link_o.darwin produces .so, because we let it use dso_dlfcn module,
+# which has .so extension hard-coded. One can argue that one should
+# develop special dso module for MacOS X. At least manual encourages
+# to use native NSModule(3) API and refers to dlfcn as termporary hack.
 link_o.darwin:
        @ $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME); \
-       SHLIB_SUFFIX=.dylib; \
+       SHLIB_SUFFIX=.so; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
        fi; \
@@ -215,12 +220,14 @@ link_a.darwin:
        SHLIB_SUFFIX=.dylib; \
        ALLSYMSFLAGS='-all_load'; \
        NOALLSYMSFLAGS=''; \
+       SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
        if [ -n "$(LIBVERSION)" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
        fi; \
        if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
                SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
        fi; \
+       SHAREDFLAGS="$$SHAREDFLAGS -install_name ${INSTALLTOP}/lib/$$SHLIB${SHLIB_EXT}"; \
        $(LINK_SO_A)
 link_app.darwin:       # is there run-path on darwin?
        $(LINK_APP)
@@ -273,7 +280,7 @@ link_o.alpha-osf1:
                NOALLSYMSFLAGS='-none'; \
                SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
                if [ -n "$$SHLIB_HIST" ]; then \
-                       SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+                       SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
                fi; \
        fi; \
        $(LINK_SO_O)
@@ -294,7 +301,7 @@ link_a.alpha-osf1:
                NOALLSYMSFLAGS='-none'; \
                SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
                if [ -n "$$SHLIB_HIST" ]; then \
-                       SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
+                       SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
                fi; \
        fi; \
        $(LINK_SO_A)
@@ -448,13 +455,14 @@ link_o.hpux:
        @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
        $(CALC_VERSIONS); \
        SHLIB=lib$(LIBNAME).sl; \
-       expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
+       expr "$(CFLAGS)" : 'DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        SHLIB_SUFFIX=; \
        ALLSYMSFLAGS='-Wl,-Fl'; \
        NOALLSYMSFLAGS=''; \
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
        SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
        fi; \
+       rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
        $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_a.hpux:
        @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
@@ -467,6 +475,7 @@ link_a.hpux:
        expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
        SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
        fi; \
+       rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
        $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
 link_app.hpux:
        @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
@@ -495,7 +504,7 @@ link_a.aix:
        SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE'; \
        $(LINK_SO_A_VIA_O)
 link_app.aix:
-       LDFLAGS="$(CFLAGS) -blibpath:$(LIBRPATH)"; \
+       LDFLAGS="$(CFLAGS) -blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
        $(LINK_APP)
 
 link_o.reliantunix:
@@ -534,7 +543,7 @@ symlink.hpux:
        expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
        $(SYMLINK_SO)
 # The following lines means those specific architectures do no symlinks
-symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
+symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
 
 # Compatibility targets
 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu