Back to home page

openssl Cross Reference

 
 

    


0001 #
0002 # Helper makefile to link shared libraries in a portable way.
0003 # This is much simpler than libtool, and hopefully not too error-prone.
0004 #
0005 # The following variables need to be set on the command line to build
0006 # properly
0007 
0008 # CC contains the current compiler.  This one MUST be defined
0009 CC=cc
0010 CFLAGS=$(CFLAG)
0011 # LDFLAGS contains flags to be used when temporary object files (when building
0012 # shared libraries) are created, or when an application is linked.
0013 # SHARED_LDFLAGS contains flags to be used when the shared library is created.
0014 LDFLAGS=
0015 SHARED_LDFLAGS=
0016 
0017 NM=nm
0018 
0019 # LIBNAME contains just the name of the library, without prefix ("lib"
0020 # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
0021 # .dll, ...).  This one MUST have a value when using this makefile to
0022 # build shared libraries.
0023 # For example, to build libfoo.so, you need to do the following:
0024 #LIBNAME=foo
0025 LIBNAME=
0026 
0027 # APPNAME contains just the name of the application, without suffix (""
0028 # on Unix, ".exe" on Windows, ...).  This one MUST have a value when using
0029 # this makefile to build applications.
0030 # For example, to build foo, you need to do the following:
0031 #APPNAME=foo
0032 APPNAME=
0033 
0034 # OBJECTS contains all the object files to link together into the application.
0035 # This must contain at least one object file.
0036 #OBJECTS=foo.o
0037 OBJECTS=
0038 
0039 # LIBEXTRAS contains extra modules to link together with the library.
0040 # For example, if a second library, say libbar.a needs to be linked into
0041 # libfoo.so, you need to do the following:
0042 #LIBEXTRAS=libbar.a
0043 # Note that this MUST be used when using the link_o targets, to hold the
0044 # names of all object files that go into the target library.
0045 LIBEXTRAS=
0046 
0047 # LIBVERSION contains the current version of the library.
0048 # For example, to build libfoo.so.1.2, you need to do the following:
0049 #LIBVERSION=1.2
0050 LIBVERSION=
0051 
0052 # LIBCOMPATVERSIONS contains the compatibility versions (a list) of
0053 # the library.  They MUST be in decreasing order.
0054 # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
0055 # and libfoo.so.1, you need to do the following:
0056 #LIBCOMPATVERSIONS=1.2 1
0057 # Note that on systems that use sonames, the last number will appear as
0058 # part of it.
0059 # It's also possible, for systems that support it (Tru64, for example),
0060 # to add extra compatibility info with more precision, by adding a second
0061 # list of versions, separated from the first with a semicolon, like this:
0062 #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
0063 LIBCOMPATVERSIONS=
0064 
0065 # LIBDEPS contains all the flags necessary to cover all necessary
0066 # dependencies to other libraries.
0067 LIBDEPS=
0068 
0069 #------------------------------------------------------------------------------
0070 # The rest is private to this makefile.
0071 
0072 SET_X=:
0073 #SET_X=set -x
0074 
0075 top:
0076         echo "Trying to use this makefile interactively?  Don't."
0077 
0078 CALC_VERSIONS=  \
0079         SHLIB_COMPAT=; SHLIB_SOVER=; \
0080         if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
0081                 prev=""; \
0082                 for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
0083                         SHLIB_SOVER_NODOT=$$v; \
0084                         SHLIB_SOVER=.$$v; \
0085                         if [ -n "$$prev" ]; then \
0086                                 SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
0087                         fi; \
0088                         prev=$$v; \
0089                 done; \
0090         fi
0091 
0092 LINK_APP=       \
0093   ( $(SET_X);   \
0094     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
0095     LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
0096     LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
0097     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
0098     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
0099     $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
0100 
0101 LINK_SO=        \
0102   ( $(SET_X);   \
0103     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
0104     SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
0105     SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
0106     LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
0107     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
0108     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
0109     $${SHAREDCMD} $${SHAREDFLAGS} \
0110         -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
0111         $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
0112   ) && $(SYMLINK_SO)
0113 
0114 SYMLINK_SO=     \
0115         if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
0116                 prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
0117                 if [ -n "$$SHLIB_COMPAT" ]; then \
0118                         for x in $$SHLIB_COMPAT; do \
0119                                 ( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
0120                                   ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
0121                                 prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
0122                         done; \
0123                 fi; \
0124                 if [ -n "$$SHLIB_SOVER" ]; then \
0125                         ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
0126                           ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
0127                 fi; \
0128         fi
0129 
0130 LINK_SO_A=      SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
0131 LINK_SO_O=      SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
0132 
0133 LINK_SO_A_VIA_O=        \
0134   SHOBJECTS=lib$(LIBNAME).o; \
0135   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
0136   ( $(SET_X); \
0137     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
0138   $(LINK_SO) && rm -f lib$(LIBNAME).o
0139 
0140 LINK_SO_A_UNPACKED=     \
0141   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
0142   (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
0143   ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
0144   SHOBJECTS=$$UNPACKDIR/*.o; \
0145   $(LINK_SO) && rm -rf $$UNPACKDIR
0146 
0147 DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
0148 
0149 DO_GNU_SO=$(CALC_VERSIONS); \
0150         SHLIB=lib$(LIBNAME).so; \
0151         SHLIB_SUFFIX=; \
0152         ALLSYMSFLAGS='-Wl,--whole-archive'; \
0153         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
0154         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
0155 
0156 DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"
0157 
0158 #This is rather special.  It's a special target with which one can link
0159 #applications without bothering with any features that have anything to
0160 #do with shared libraries, for example when linking against static
0161 #libraries.  It's mostly here to avoid a lot of conditionals everywhere
0162 #else...
0163 link_app.:
0164         $(LINK_APP)
0165 
0166 link_o.gnu:
0167         @ $(DO_GNU_SO); $(LINK_SO_O)
0168 link_a.gnu:
0169         @ $(DO_GNU_SO); $(LINK_SO_A)
0170 link_app.gnu:
0171         @ $(DO_GNU_APP); $(LINK_APP)
0172 
0173 DO_BEOS_SO=     SHLIB=lib$(LIBNAME).so; \
0174         SHLIB_SUFFIX=; \
0175         ALLSYMSFLAGS='-Wl,--whole-archive'; \
0176         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
0177         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SUFFIX"
0178 
0179 link_o.beos:
0180         @ $(DO_BEOS_SO); $(LINK_SO_O)
0181 link_a.beos:
0182         @ $(DO_BEOS_SO); $(LINK_SO_A)
0183 
0184 link_o.bsd:
0185         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
0186         $(CALC_VERSIONS); \
0187         SHLIB=lib$(LIBNAME).so; \
0188         SHLIB_SUFFIX=; \
0189         LIBDEPS=" "; \
0190         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
0191         NOALLSYMSFLAGS=; \
0192         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
0193         fi; $(LINK_SO_O)
0194 link_a.bsd:
0195         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
0196         $(CALC_VERSIONS); \
0197         SHLIB=lib$(LIBNAME).so; \
0198         SHLIB_SUFFIX=; \
0199         LIBDEPS=" "; \
0200         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
0201         NOALLSYMSFLAGS=; \
0202         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
0203         fi; $(LINK_SO_A)
0204 link_app.bsd:
0205         @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
0206         LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
0207         fi; $(LINK_APP)
0208 
0209 # For Darwin AKA Mac OS/X (dyld)
0210 # Originally link_o.darwin produced .so, because it was hard-coded
0211 # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
0212 # extension in order to allow for run-time linking with vendor-
0213 # supplied shared libraries such as libz, so that link_o.darwin had
0214 # to be harmonized with it. This caused minor controversy, because
0215 # it was believed that dlopen can't be used to dynamically load
0216 # .dylib-s, only so called bundle modules (ones linked with -bundle
0217 # flag). The belief seems to be originating from pre-10.4 release,
0218 # where dlfcn functionality was emulated by dlcompat add-on. In
0219 # 10.4 dlopen was rewritten as native part of dyld and is documented
0220 # to be capable of loading both dynamic libraries and bundles. In
0221 # order to provide compatibility with pre-10.4 dlopen, modules are
0222 # linked with -bundle flag, which makes .dylib extension misleading.
0223 # It works, because dlopen is [and always was] extension-agnostic.
0224 # Alternative to this heuristic approach is to develop specific
0225 # MacOS X dso module relying on whichever "native" dyld interface.
0226 link_o.darwin:
0227         @ $(CALC_VERSIONS); \
0228         SHLIB=lib$(LIBNAME); \
0229         SHLIB_SUFFIX=.dylib; \
0230         ALLSYMSFLAGS='-all_load'; \
0231         NOALLSYMSFLAGS=''; \
0232         SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
0233         if [ -n "$(LIBVERSION)" ]; then \
0234                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
0235         fi; \
0236         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
0237                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
0238         fi; \
0239         $(LINK_SO_O)
0240 link_a.darwin:
0241         @ $(CALC_VERSIONS); \
0242         SHLIB=lib$(LIBNAME); \
0243         SHLIB_SUFFIX=.dylib; \
0244         ALLSYMSFLAGS='-all_load'; \
0245         NOALLSYMSFLAGS=''; \
0246         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
0247         if [ -n "$(LIBVERSION)" ]; then \
0248                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
0249         fi; \
0250         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
0251                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
0252         fi; \
0253         SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
0254         $(LINK_SO_A)
0255 link_app.darwin:        # is there run-path on darwin?
0256         $(LINK_APP)
0257 
0258 link_o.cygwin:
0259         @ $(CALC_VERSIONS); \
0260         INHIBIT_SYMLINKS=yes; \
0261         SHLIB=cyg$(LIBNAME); \
0262         base=-Wl,--enable-auto-image-base; \
0263         deffile=; \
0264         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
0265                 SHLIB=$(LIBNAME)eay32; base=; \
0266                 if test -f $(LIBNAME)eay32.def; then \
0267                         deffile=$(LIBNAME)eay32.def; \
0268                 fi; \
0269         fi; \
0270         SHLIB_SUFFIX=.dll; \
0271         LIBVERSION="$(LIBVERSION)"; \
0272         SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
0273         ALLSYMSFLAGS='-Wl,--whole-archive'; \
0274         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
0275         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-s,-Bsymbolic"; \
0276         $(LINK_SO_O)
0277 #for mingw target if def-file is in use dll-name should match library-name
0278 link_a.cygwin:
0279         @ $(CALC_VERSIONS); \
0280         INHIBIT_SYMLINKS=yes; \
0281         SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
0282         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
0283         base=-Wl,--enable-auto-image-base; \
0284         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
0285                 case $(LIBNAME) in \
0286                         crypto) SHLIB=libeay;; \
0287                         ssl) SHLIB=ssleay;; \
0288                 esac; \
0289                 SHLIB_SOVER=32; \
0290                 extras="$(LIBNAME).def"; \
0291                 $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
0292                 base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
0293         fi; \
0294         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
0295         $(PERL) util/mkrc.pl $$dll_name | \
0296                 $(CROSS_COMPILE)windres -o rc.o; \
0297         extras="$$extras rc.o"; \
0298         ALLSYMSFLAGS='-Wl,--whole-archive'; \
0299         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
0300         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
0301         [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
0302         [ -f test/$$dll_name ] && rm test/$$dll_name; \
0303         $(LINK_SO_A) || exit 1; \
0304         rm $$extras; \
0305         cp -p $$dll_name apps/; \
0306         cp -p $$dll_name test/
0307 link_app.cygwin:
0308         @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
0309                 LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
0310                 export LIBDEPS; \
0311         fi; \
0312         $(LINK_APP)
0313 
0314 link_o.alpha-osf1:
0315         @ if $(DETECT_GNU_LD); then \
0316                 $(DO_GNU_SO); \
0317         else \
0318                 SHLIB=lib$(LIBNAME).so; \
0319                 SHLIB_SUFFIX=; \
0320                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
0321                 if [ -n "$$SHLIB_HIST" ]; then \
0322                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
0323                 else \
0324                         SHLIB_HIST="$(LIBVERSION)"; \
0325                 fi; \
0326                 SHLIB_SOVER=; \
0327                 ALLSYMSFLAGS='-all'; \
0328                 NOALLSYMSFLAGS='-none'; \
0329                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
0330                 if [ -n "$$SHLIB_HIST" ]; then \
0331                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
0332                 fi; \
0333         fi; \
0334         $(LINK_SO_O)
0335 link_a.alpha-osf1:
0336         @ if $(DETECT_GNU_LD); then \
0337                 $(DO_GNU_SO); \
0338         else \
0339                 SHLIB=lib$(LIBNAME).so; \
0340                 SHLIB_SUFFIX=; \
0341                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
0342                 if [ -n "$$SHLIB_HIST" ]; then \
0343                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
0344                 else \
0345                         SHLIB_HIST="$(LIBVERSION)"; \
0346                 fi; \
0347                 SHLIB_SOVER=; \
0348                 ALLSYMSFLAGS='-all'; \
0349                 NOALLSYMSFLAGS='-none'; \
0350                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
0351                 if [ -n "$$SHLIB_HIST" ]; then \
0352                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
0353                 fi; \
0354         fi; \
0355         $(LINK_SO_A)
0356 link_app.alpha-osf1:
0357         @if $(DETECT_GNU_LD); then \
0358                 $(DO_GNU_APP); \
0359         else \
0360                 LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
0361         fi; \
0362         $(LINK_APP)
0363 
0364 link_o.solaris:
0365         @ if $(DETECT_GNU_LD); then \
0366                 $(DO_GNU_SO); \
0367         else \
0368                 $(CALC_VERSIONS); \
0369                 MINUSZ='-z '; \
0370                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
0371                 SHLIB=lib$(LIBNAME).so; \
0372                 SHLIB_SUFFIX=; \
0373                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
0374                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
0375                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
0376         fi; \
0377         $(LINK_SO_O)
0378 link_a.solaris:
0379         @ if $(DETECT_GNU_LD); then \
0380                 $(DO_GNU_SO); \
0381         else \
0382                 $(CALC_VERSIONS); \
0383                 MINUSZ='-z '; \
0384                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
0385                 SHLIB=lib$(LIBNAME).so; \
0386                 SHLIB_SUFFIX=;\
0387                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
0388                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
0389                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
0390         fi; \
0391         $(LINK_SO_A)
0392 link_app.solaris:
0393         @ if $(DETECT_GNU_LD); then \
0394                 $(DO_GNU_APP); \
0395         else \
0396                 LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
0397         fi; \
0398         $(LINK_APP)
0399 
0400 # OpenServer 5 native compilers used
0401 link_o.svr3:
0402         @ if $(DETECT_GNU_LD); then \
0403                 $(DO_GNU_SO); \
0404         else \
0405                 $(CALC_VERSIONS); \
0406                 SHLIB=lib$(LIBNAME).so; \
0407                 SHLIB_SUFFIX=; \
0408                 ALLSYMSFLAGS=''; \
0409                 NOALLSYMSFLAGS=''; \
0410                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
0411         fi; \
0412         $(LINK_SO_O)
0413 link_a.svr3:
0414         @ if $(DETECT_GNU_LD); then \
0415                 $(DO_GNU_SO); \
0416         else \
0417                 $(CALC_VERSIONS); \
0418                 SHLIB=lib$(LIBNAME).so; \
0419                 SHLIB_SUFFIX=; \
0420                 ALLSYMSFLAGS=''; \
0421                 NOALLSYMSFLAGS=''; \
0422                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
0423         fi; \
0424         $(LINK_SO_A_UNPACKED)
0425 link_app.svr3:
0426         @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
0427         $(LINK_APP)
0428 
0429 # UnixWare 7 and OpenUNIX 8 native compilers used
0430 link_o.svr5:
0431         @ if $(DETECT_GNU_LD); then \
0432                 $(DO_GNU_SO); \
0433         else \
0434                 $(CALC_VERSIONS); \
0435                 SHARE_FLAG='-G'; \
0436                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
0437                 SHLIB=lib$(LIBNAME).so; \
0438                 SHLIB_SUFFIX=; \
0439                 ALLSYMSFLAGS=''; \
0440                 NOALLSYMSFLAGS=''; \
0441                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
0442         fi; \
0443         $(LINK_SO_O)
0444 link_a.svr5:
0445         @ if $(DETECT_GNU_LD); then \
0446                 $(DO_GNU_SO); \
0447         else \
0448                 $(CALC_VERSIONS); \
0449                 SHARE_FLAG='-G'; \
0450                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
0451                 SHLIB=lib$(LIBNAME).so; \
0452                 SHLIB_SUFFIX=; \
0453                 ALLSYMSFLAGS=''; \
0454                 NOALLSYMSFLAGS=''; \
0455                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
0456         fi; \
0457         $(LINK_SO_A_UNPACKED)
0458 link_app.svr5:
0459         @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
0460         $(LINK_APP)
0461 
0462 link_o.irix:
0463         @ if $(DETECT_GNU_LD); then \
0464                 $(DO_GNU_SO); \
0465         else \
0466                 $(CALC_VERSIONS); \
0467                 SHLIB=lib$(LIBNAME).so; \
0468                 SHLIB_SUFFIX=; \
0469                 MINUSWL=""; \
0470                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
0471                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
0472                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
0473                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
0474         fi; \
0475         $(LINK_SO_O)
0476 link_a.irix:
0477         @ if $(DETECT_GNU_LD); then \
0478                 $(DO_GNU_SO); \
0479         else \
0480                 $(CALC_VERSIONS); \
0481                 SHLIB=lib$(LIBNAME).so; \
0482                 SHLIB_SUFFIX=; \
0483                 MINUSWL=""; \
0484                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
0485                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
0486                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
0487                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
0488         fi; \
0489         $(LINK_SO_A)
0490 link_app.irix:
0491         @LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
0492         $(LINK_APP)
0493 
0494 # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
0495 # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
0496 # rules imply that we can only link one level down in catalog structure,
0497 # but that's what takes place for the moment of this writing. +cdp option
0498 # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
0499 # editor context only [it's simply ignored in other cases, which are all
0500 # ELFs by the way].
0501 #
0502 link_o.hpux:
0503         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
0504         $(CALC_VERSIONS); \
0505         SHLIB=lib$(LIBNAME).sl; \
0506         expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
0507         SHLIB_SUFFIX=; \
0508         ALLSYMSFLAGS='-Wl,-Fl'; \
0509         NOALLSYMSFLAGS=''; \
0510         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
0511         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
0512         fi; \
0513         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
0514         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
0515 link_a.hpux:
0516         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
0517         $(CALC_VERSIONS); \
0518         SHLIB=lib$(LIBNAME).sl; \
0519         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
0520         SHLIB_SUFFIX=; \
0521         ALLSYMSFLAGS='-Wl,-Fl'; \
0522         NOALLSYMSFLAGS=''; \
0523         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
0524         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
0525         fi; \
0526         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
0527         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
0528 link_app.hpux:
0529         @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
0530         LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
0531         fi; \
0532         $(LINK_APP)
0533 
0534 link_o.aix:
0535         @ $(CALC_VERSIONS); \
0536         OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
0537         OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
0538         SHLIB=lib$(LIBNAME).so; \
0539         SHLIB_SUFFIX=; \
0540         ALLSYMSFLAGS=''; \
0541         NOALLSYMSFLAGS=''; \
0542         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
0543         $(LINK_SO_O);
0544 link_a.aix:
0545         @ $(CALC_VERSIONS); \
0546         OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
0547         OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
0548         SHLIB=lib$(LIBNAME).so; \
0549         SHLIB_SUFFIX=; \
0550         ALLSYMSFLAGS='-bnogc'; \
0551         NOALLSYMSFLAGS=''; \
0552         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
0553         $(LINK_SO_A_VIA_O)
0554 link_app.aix:
0555         LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
0556         $(LINK_APP)
0557 
0558 link_o.reliantunix:
0559         @ $(CALC_VERSIONS); \
0560         SHLIB=lib$(LIBNAME).so; \
0561         SHLIB_SUFFIX=; \
0562         ALLSYMSFLAGS=; \
0563         NOALLSYMSFLAGS=''; \
0564         SHAREDFLAGS='$(CFLAGS) -G'; \
0565         $(LINK_SO_O)
0566 link_a.reliantunix:
0567         @ $(CALC_VERSIONS); \
0568         SHLIB=lib$(LIBNAME).so; \
0569         SHLIB_SUFFIX=; \
0570         ALLSYMSFLAGS=; \
0571         NOALLSYMSFLAGS=''; \
0572         SHAREDFLAGS='$(CFLAGS) -G'; \
0573         $(LINK_SO_A_UNPACKED)
0574 link_app.reliantunix:
0575         $(LINK_APP)
0576 
0577 # Targets to build symbolic links when needed
0578 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
0579 symlink.aix symlink.reliantunix:
0580         @ $(CALC_VERSIONS); \
0581         SHLIB=lib$(LIBNAME).so; \
0582         $(SYMLINK_SO)
0583 symlink.darwin:
0584         @ $(CALC_VERSIONS); \
0585         SHLIB=lib$(LIBNAME); \
0586         SHLIB_SUFFIX=.dylib; \
0587         $(SYMLINK_SO)
0588 symlink.hpux:
0589         @ $(CALC_VERSIONS); \
0590         SHLIB=lib$(LIBNAME).sl; \
0591         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
0592         $(SYMLINK_SO)
0593 # The following lines means those specific architectures do no symlinks
0594 symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath symlink.beos:
0595 
0596 # Compatibility targets
0597 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
0598 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
0599 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
0600 symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
0601 link_o.bsd-shared: link_o.bsd
0602 link_a.bsd-shared: link_a.bsd
0603 link_app.bsd-shared: link_app.bsd
0604 link_o.darwin-shared: link_o.darwin
0605 link_a.darwin-shared: link_a.darwin
0606 link_app.darwin-shared: link_app.darwin
0607 symlink.darwin-shared: symlink.darwin
0608 link_o.cygwin-shared: link_o.cygwin
0609 link_a.cygwin-shared: link_a.cygwin
0610 link_app.cygwin-shared: link_app.cygwin
0611 symlink.cygwin-shared: symlink.cygwin
0612 link_o.alpha-osf1-shared: link_o.alpha-osf1
0613 link_a.alpha-osf1-shared: link_a.alpha-osf1
0614 link_app.alpha-osf1-shared: link_app.alpha-osf1
0615 symlink.alpha-osf1-shared: symlink.alpha-osf1
0616 link_o.tru64-shared: link_o.tru64
0617 link_a.tru64-shared: link_a.tru64
0618 link_app.tru64-shared: link_app.tru64
0619 symlink.tru64-shared: symlink.tru64
0620 link_o.tru64-shared-rpath: link_o.tru64-rpath
0621 link_a.tru64-shared-rpath: link_a.tru64-rpath
0622 link_app.tru64-shared-rpath: link_app.tru64-rpath
0623 symlink.tru64-shared-rpath: symlink.tru64-rpath
0624 link_o.solaris-shared: link_o.solaris
0625 link_a.solaris-shared: link_a.solaris
0626 link_app.solaris-shared: link_app.solaris
0627 symlink.solaris-shared: symlink.solaris
0628 link_o.svr3-shared: link_o.svr3
0629 link_a.svr3-shared: link_a.svr3
0630 link_app.svr3-shared: link_app.svr3
0631 symlink.svr3-shared: symlink.svr3
0632 link_o.svr5-shared: link_o.svr5
0633 link_a.svr5-shared: link_a.svr5
0634 link_app.svr5-shared: link_app.svr5
0635 symlink.svr5-shared: symlink.svr5
0636 link_o.irix-shared: link_o.irix
0637 link_a.irix-shared: link_a.irix
0638 link_app.irix-shared: link_app.irix
0639 symlink.irix-shared: symlink.irix
0640 link_o.hpux-shared: link_o.hpux
0641 link_a.hpux-shared: link_a.hpux
0642 link_app.hpux-shared: link_app.hpux
0643 symlink.hpux-shared: symlink.hpux
0644 link_o.aix-shared: link_o.aix
0645 link_a.aix-shared: link_a.aix
0646 link_app.aix-shared: link_app.aix
0647 symlink.aix-shared: symlink.aix
0648 link_o.reliantunix-shared: link_o.reliantunix
0649 link_a.reliantunix-shared: link_a.reliantunix
0650 link_app.reliantunix-shared: link_app.reliantunix
0651 symlink.reliantunix-shared: symlink.reliantunix
0652 link_o.beos-shared: link_o.beos
0653 link_a.beos-shared: link_a.beos
0654 link_app.beos-shared: link_app.gnu
0655 symlink.beos-shared: symlink.beos