Makefile.shared 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. #
  2. # Helper makefile to link shared libraries in a portable way.
  3. # This is much simpler than libtool, and hopefully not too error-prone.
  4. #
  5. # The following variables need to be set on the command line to build
  6. # properly
  7. # CC contains the current compiler. This one MUST be defined
  8. CC=cc
  9. CFLAGS=$(CFLAG)
  10. # LDFLAGS contains flags to be used when temporary object files (when building
  11. # shared libraries) are created, or when an application is linked.
  12. # SHARED_LDFLAGS contains flags to be used when the shared library is created.
  13. LDFLAGS=$(LDFLAG)
  14. SHARED_LDFLAGS=$(SHARED_LDFLAG)
  15. RC=windres
  16. # SHARED_RCFLAGS are flags used with windres, i.e. when build for Cygwin
  17. # or Mingw.
  18. SHARED_RCFLAGS=$(SHARED_RCFLAG)
  19. NM=nm
  20. # LIBNAME contains just the name of the library, without prefix ("lib"
  21. # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
  22. # .dll, ...). This one MUST have a value when using this makefile to
  23. # build shared libraries.
  24. # For example, to build libfoo.so, you need to do the following:
  25. #LIBNAME=foo
  26. LIBNAME=
  27. # APPNAME contains just the name of the application, without suffix (""
  28. # on Unix, ".exe" on Windows, ...). This one MUST have a value when using
  29. # this makefile to build applications.
  30. # For example, to build foo, you need to do the following:
  31. #APPNAME=foo
  32. APPNAME=
  33. # DSTDIR is the directory where the built file should end up in.
  34. DSTDIR=.
  35. # SRCDIR is the top directory of the source tree.
  36. SRCDIR=.
  37. # OBJECTS contains all the object files to link together into the application.
  38. # This must contain at least one object file.
  39. #OBJECTS=foo.o
  40. OBJECTS=
  41. # LIBEXTRAS contains extra modules to link together with the library.
  42. # For example, if a second library, say libbar.a needs to be linked into
  43. # libfoo.so, you need to do the following:
  44. #LIBEXTRAS=libbar.a
  45. # Note that this MUST be used when using the link_dso targets, to hold the
  46. # names of all object files that go into the target shared object.
  47. LIBEXTRAS=
  48. # LIBVERSION contains the current version of the library.
  49. # For example, to build libfoo.so.1.2, you need to do the following:
  50. #LIBVERSION=1.2
  51. LIBVERSION=
  52. # LIBCOMPATVERSIONS contains the compatibility versions (a list) of
  53. # the library. They MUST be in decreasing order.
  54. # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
  55. # and libfoo.so.1, you need to do the following:
  56. #LIBCOMPATVERSIONS=1.2 1
  57. # Note that on systems that use sonames, the last number will appear as
  58. # part of it.
  59. # It's also possible, for systems that support it (Tru64, for example),
  60. # to add extra compatibility info with more precision, by adding a second
  61. # list of versions, separated from the first with a semicolon, like this:
  62. #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
  63. LIBCOMPATVERSIONS=
  64. # LIBDEPS contains all the flags necessary to cover all necessary
  65. # dependencies to other libraries.
  66. LIBDEPS=
  67. #------------------------------------------------------------------------------
  68. # The rest is private to this makefile.
  69. SET_X=:
  70. #SET_X=set -x
  71. top:
  72. echo "Trying to use this makefile interactively? Don't."
  73. CALC_VERSIONS= \
  74. SHLIB_COMPAT=; SHLIB_SOVER=; \
  75. if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
  76. prev=""; \
  77. for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
  78. SHLIB_SOVER_NODOT=$$v; \
  79. SHLIB_SOVER=.$$v; \
  80. if [ -n "$$prev" ]; then \
  81. SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
  82. fi; \
  83. prev=$$v; \
  84. done; \
  85. fi
  86. LINK_APP= \
  87. ( $(SET_X); \
  88. LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
  89. LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS) $(LDFLAGS)}"; \
  90. LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
  91. LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
  92. echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
  93. $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS}; \
  94. LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
  95. $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
  96. LINK_SO= \
  97. ( $(SET_X); \
  98. LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
  99. SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
  100. SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
  101. LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
  102. LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
  103. echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
  104. $${SHAREDCMD} $${SHAREDFLAGS} \
  105. -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
  106. $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS; \
  107. LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
  108. $${SHAREDCMD} $${SHAREDFLAGS} \
  109. -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
  110. $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
  111. ) && $(SYMLINK_SO)
  112. SYMLINK_SO= \
  113. if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
  114. prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
  115. if [ -n "$$SHLIB_COMPAT" ]; then \
  116. for x in $$SHLIB_COMPAT; do \
  117. ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX; \
  118. ln -s $$prev $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX ); \
  119. prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
  120. done; \
  121. fi; \
  122. if [ -n "$$SHLIB_SOVER" ]; then \
  123. ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX; \
  124. ln -s $$prev $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX ); \
  125. fi; \
  126. fi
  127. LINK_SO_SHLIB= SHOBJECTS="$(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
  128. LINK_SO_DSO= INHIBIT_SYMLINKS=yes; SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
  129. LINK_SO_SHLIB_VIA_O= \
  130. SHOBJECTS=$(DSTDIR)/lib$(LIBNAME).o; \
  131. ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
  132. ( echo ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
  133. ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \
  134. $(LINK_SO) && ( echo rm -f $$SHOBJECTS; rm -f $$SHOBJECTS )
  135. LINK_SO_SHLIB_UNPACKED= \
  136. UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
  137. (cd $$UNPACKDIR; ar x ../$(DSTDIR)/lib$(LIBNAME).a) && \
  138. ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
  139. SHOBJECTS=$$UNPACKDIR/*.o; \
  140. $(LINK_SO) && rm -rf $$UNPACKDIR
  141. DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
  142. DO_GNU_SO_COMMON=\
  143. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
  144. DO_GNU_DSO=\
  145. SHLIB=$(LIBNAME).so; \
  146. SHLIB_SOVER=; \
  147. SHLIB_SUFFIX=; \
  148. $(DO_GNU_SO_COMMON)
  149. DO_GNU_SO=\
  150. $(CALC_VERSIONS); \
  151. SHLIB=lib$(LIBNAME).so; \
  152. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  153. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  154. $(DO_GNU_SO_COMMON)
  155. DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"
  156. #This is rather special. It's a special target with which one can link
  157. #applications without bothering with any features that have anything to
  158. #do with shared libraries, for example when linking against static
  159. #libraries. It's mostly here to avoid a lot of conditionals everywhere
  160. #else...
  161. link_app.:
  162. $(LINK_APP)
  163. link_dso.gnu:
  164. @ $(DO_GNU_DSO); $(LINK_SO_DSO)
  165. link_shlib.gnu:
  166. @ $(DO_GNU_SO); $(LINK_SO_SHLIB)
  167. link_app.gnu:
  168. @ $(DO_GNU_APP); $(LINK_APP)
  169. link_shlib.linux-shared:
  170. @$(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
  171. $(DO_GNU_SO); \
  172. ALLSYMSFLAGS='-Wl,--whole-archive,--version-script=$(LIBNAME).map'; \
  173. $(LINK_SO_SHLIB)
  174. link_dso.bsd:
  175. @if $(DETECT_GNU_LD); then $(DO_GNU_DSO); else \
  176. SHLIB=$(LIBNAME).so; \
  177. SHLIB_SUFFIX=; \
  178. LIBDEPS=" "; \
  179. ALLSYMSFLAGS=; \
  180. NOALLSYMSFLAGS=; \
  181. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
  182. fi; $(LINK_SO_DSO)
  183. link_shlib.bsd:
  184. @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
  185. $(CALC_VERSIONS); \
  186. SHLIB=lib$(LIBNAME).so; \
  187. SHLIB_SUFFIX=; \
  188. LIBDEPS=" "; \
  189. ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
  190. NOALLSYMSFLAGS=; \
  191. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
  192. fi; $(LINK_SO_SHLIB)
  193. link_app.bsd:
  194. @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
  195. LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBPATH)"; \
  196. fi; $(LINK_APP)
  197. # For Darwin AKA Mac OS/X (dyld)
  198. # Originally link_dso.darwin produced .so, because it was hard-coded
  199. # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
  200. # extension in order to allow for run-time linking with vendor-
  201. # supplied shared libraries such as libz, so that link_dso.darwin had
  202. # to be harmonized with it. This caused minor controversy, because
  203. # it was believed that dlopen can't be used to dynamically load
  204. # .dylib-s, only so called bundle modules (ones linked with -bundle
  205. # flag). The belief seems to be originating from pre-10.4 release,
  206. # where dlfcn functionality was emulated by dlcompat add-on. In
  207. # 10.4 dlopen was rewritten as native part of dyld and is documented
  208. # to be capable of loading both dynamic libraries and bundles. In
  209. # order to provide compatibility with pre-10.4 dlopen, modules are
  210. # linked with -bundle flag, which makes .dylib extension misleading.
  211. # It works, because dlopen is [and always was] extension-agnostic.
  212. # Alternative to this heuristic approach is to develop specific
  213. # MacOS X dso module relying on whichever "native" dyld interface.
  214. link_dso.darwin:
  215. @ SHLIB=$(LIBNAME); \
  216. SHLIB_SUFFIX=.dylib; \
  217. ALLSYMSFLAGS=''; \
  218. NOALLSYMSFLAGS=''; \
  219. SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
  220. $(LINK_SO_DSO)
  221. link_shlib.darwin:
  222. @ $(CALC_VERSIONS); \
  223. SHLIB=lib$(LIBNAME); \
  224. SHLIB_SUFFIX=.dylib; \
  225. ALLSYMSFLAGS='-all_load'; \
  226. NOALLSYMSFLAGS=''; \
  227. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
  228. if [ -n "$(LIBVERSION)" ]; then \
  229. SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
  230. fi; \
  231. if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
  232. SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
  233. fi; \
  234. SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
  235. $(LINK_SO_SHLIB)
  236. link_app.darwin: # is there run-path on darwin?
  237. $(LINK_APP)
  238. link_dso.cygwin:
  239. @SHLIB=$(LIBNAME); \
  240. SHLIB_SUFFIX=.dll; \
  241. ALLSYMSFLAGS=''; \
  242. NOALLSYMSFLAGS=''; \
  243. base=-Wl,--enable-auto-image-base; \
  244. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic"; \
  245. $(LINK_SO_DSO)
  246. link_shlib.cygwin:
  247. @ $(CALC_VERSIONS); \
  248. INHIBIT_SYMLINKS=yes; \
  249. SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
  250. dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
  251. echo "$(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name |" \
  252. "$(RC) $(SHARED_RCFLAGS) -o rc.o"; \
  253. $(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name | \
  254. $(RC) $(SHARED_RCFLAGS) -o rc.o; \
  255. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  256. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  257. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a rc.o"; \
  258. $(LINK_SO_SHLIB) || exit 1; \
  259. rm rc.o
  260. link_app.cygwin:
  261. $(LINK_APP)
  262. # link_dso.mingw-shared and link_app.mingw-shared are mapped to the
  263. # corresponding cygwin targets, as they do the exact same thing.
  264. link_shlib.mingw:
  265. @ $(CALC_VERSIONS); \
  266. INHIBIT_SYMLINKS=yes; \
  267. arch=; \
  268. if expr $(PLATFORM) : mingw64 > /dev/null; then arch=-x64; fi; \
  269. sover=`echo $(LIBVERSION) | sed -e 's/\./_/g'` ; \
  270. SHLIB=lib$(LIBNAME); \
  271. SHLIB_SOVER=-$$sover$$arch; \
  272. SHLIB_SUFFIX=.dll; \
  273. dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
  274. base=; [ $(LIBNAME) = "crypto" -a -n "$(FIPSCANLIB)" ] && base=-Wl,--image-base,0x63000000; \
  275. $(PERL) $(SRCDIR)/util/mkdef.pl 32 $(LIBNAME) \
  276. | sed -e 's|^\(LIBRARY *\)$(LIBNAME)32|\1'"$$dll_name"'|' \
  277. > $(LIBNAME).def; \
  278. echo "$(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name |" \
  279. "$(RC) $(SHARED_RCFLAGS) -o rc.o"; \
  280. $(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name | \
  281. $(RC) $(SHARED_RCFLAGS) -o rc.o; \
  282. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  283. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  284. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $(LIBNAME).def rc.o"; \
  285. $(LINK_SO_SHLIB) || exit 1; \
  286. rm $(LIBNAME).def rc.o
  287. link_dso.alpha-osf1:
  288. @ if $(DETECT_GNU_LD); then \
  289. $(DO_GNU_DSO); \
  290. else \
  291. SHLIB=$(LIBNAME).so; \
  292. SHLIB_SUFFIX=; \
  293. ALLSYMSFLAGS=''; \
  294. NOALLSYMSFLAGS=''; \
  295. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  296. fi; \
  297. $(LINK_SO_DSO)
  298. link_shlib.alpha-osf1:
  299. @ if $(DETECT_GNU_LD); then \
  300. $(DO_GNU_SO); \
  301. else \
  302. SHLIB=lib$(LIBNAME).so; \
  303. SHLIB_SUFFIX=; \
  304. SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
  305. if [ -n "$$SHLIB_HIST" ]; then \
  306. SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
  307. else \
  308. SHLIB_HIST="$(LIBVERSION)"; \
  309. fi; \
  310. SHLIB_SOVER=; \
  311. ALLSYMSFLAGS='-all'; \
  312. NOALLSYMSFLAGS='-none'; \
  313. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  314. if [ -n "$$SHLIB_HIST" ]; then \
  315. SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
  316. fi; \
  317. fi; \
  318. $(LINK_SO_SHLIB)
  319. link_app.alpha-osf1:
  320. @if $(DETECT_GNU_LD); then \
  321. $(DO_GNU_APP); \
  322. else \
  323. LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \
  324. fi; \
  325. $(LINK_APP)
  326. link_dso.solaris:
  327. @ if $(DETECT_GNU_LD); then \
  328. $(DO_GNU_DSO); \
  329. else \
  330. $(CALC_VERSIONS); \
  331. SHLIB=$(LIBNAME).so; \
  332. SHLIB_SUFFIX=; \
  333. ALLSYMSFLAGS=""; \
  334. NOALLSYMSFLAGS=""; \
  335. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  336. fi; \
  337. $(LINK_SO_DSO)
  338. link_shlib.solaris:
  339. @ if $(DETECT_GNU_LD); then \
  340. $(DO_GNU_SO); \
  341. else \
  342. $(CALC_VERSIONS); \
  343. SHLIB=lib$(LIBNAME).so; \
  344. SHLIB_SUFFIX=;\
  345. $(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
  346. ALLSYMSFLAGS="-Wl,-z,allextract,-M,$(LIBNAME).map"; \
  347. NOALLSYMSFLAGS="-Wl,-z,defaultextract"; \
  348. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  349. fi; \
  350. $(LINK_SO_SHLIB)
  351. link_app.solaris:
  352. @ if $(DETECT_GNU_LD); then \
  353. $(DO_GNU_APP); \
  354. else \
  355. LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \
  356. fi; \
  357. $(LINK_APP)
  358. # OpenServer 5 native compilers used
  359. link_dso.svr3:
  360. @ if $(DETECT_GNU_LD); then \
  361. $(DO_GNU_DSO); \
  362. else \
  363. $(CALC_VERSIONS); \
  364. SHLIB=$(LIBNAME).so; \
  365. SHLIB_SUFFIX=; \
  366. ALLSYMSFLAGS=''; \
  367. NOALLSYMSFLAGS=''; \
  368. SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SUFFIX"; \
  369. fi; \
  370. $(LINK_SO_DSO)
  371. link_shlib.svr3:
  372. @ if $(DETECT_GNU_LD); then \
  373. $(DO_GNU_SO); \
  374. else \
  375. $(CALC_VERSIONS); \
  376. SHLIB=lib$(LIBNAME).so; \
  377. SHLIB_SUFFIX=; \
  378. ALLSYMSFLAGS=''; \
  379. NOALLSYMSFLAGS=''; \
  380. SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  381. fi; \
  382. $(LINK_SO_SHLIB_UNPACKED)
  383. link_app.svr3:
  384. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  385. $(LINK_APP)
  386. # UnixWare 7 and OpenUNIX 8 native compilers used
  387. link_dso.svr5:
  388. @ if $(DETECT_GNU_LD); then \
  389. $(DO_GNU_DSO); \
  390. else \
  391. SHARE_FLAG='-G'; \
  392. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  393. SHLIB=$(LIBNAME).so; \
  394. SHLIB_SUFFIX=; \
  395. ALLSYMSFLAGS=''; \
  396. NOALLSYMSFLAGS=''; \
  397. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SUFFIX"; \
  398. fi; \
  399. $(LINK_SO_DSO)
  400. link_shlib.svr5:
  401. @ if $(DETECT_GNU_LD); then \
  402. $(DO_GNU_SO); \
  403. else \
  404. $(CALC_VERSIONS); \
  405. SHARE_FLAG='-G'; \
  406. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  407. SHLIB=lib$(LIBNAME).so; \
  408. SHLIB_SUFFIX=; \
  409. ALLSYMSFLAGS=''; \
  410. NOALLSYMSFLAGS=''; \
  411. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  412. fi; \
  413. $(LINK_SO_SHLIB_UNPACKED)
  414. link_app.svr5:
  415. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  416. $(LINK_APP)
  417. link_dso.irix:
  418. @ if $(DETECT_GNU_LD); then \
  419. $(DO_GNU_DSO); \
  420. else \
  421. SHLIB=$(LIBNAME).so; \
  422. SHLIB_SUFFIX=; \
  423. ALLSYMSFLAGS=""; \
  424. NOALLSYMSFLAGS=""; \
  425. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SUFFIX,-B,symbolic"; \
  426. fi; \
  427. $(LINK_SO_DSO)
  428. link_shlib.irix:
  429. @ if $(DETECT_GNU_LD); then \
  430. $(DO_GNU_SO); \
  431. else \
  432. $(CALC_VERSIONS); \
  433. SHLIB=lib$(LIBNAME).so; \
  434. SHLIB_SUFFIX=; \
  435. MINUSWL=""; \
  436. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
  437. ALLSYMSFLAGS="$${MINUSWL}-all"; \
  438. NOALLSYMSFLAGS="$${MINUSWL}-none"; \
  439. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
  440. fi; \
  441. $(LINK_SO_SHLIB)
  442. link_app.irix:
  443. @LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
  444. $(LINK_APP)
  445. # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
  446. # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
  447. # rules imply that we can only link one level down in catalog structure,
  448. # but that's what takes place for the moment of this writing. +cdp option
  449. # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
  450. # editor context only [it's simply ignored in other cases, which are all
  451. # ELFs by the way].
  452. #
  453. link_dso.hpux:
  454. @if $(DETECT_GNU_LD); then $(DO_GNU_DSO); else \
  455. SHLIB=$(LIBNAME).sl; \
  456. expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=$(LIBNAME).so; \
  457. SHLIB_SUFFIX=; \
  458. ALLSYMSFLAGS=''; \
  459. NOALLSYMSFLAGS=''; \
  460. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  461. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  462. fi; \
  463. rm -f $$SHLIB$$SHLIB_SUFFIX || :; \
  464. $(LINK_SO_DSO) && chmod a=rx $$SHLIB$$SHLIB_SUFFIX
  465. link_shlib.hpux:
  466. @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
  467. $(CALC_VERSIONS); \
  468. SHLIB=lib$(LIBNAME).sl; \
  469. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  470. SHLIB_SUFFIX=; \
  471. ALLSYMSFLAGS='-Wl,-Fl'; \
  472. NOALLSYMSFLAGS=''; \
  473. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  474. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  475. fi; \
  476. rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
  477. $(LINK_SO_SHLIB) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
  478. link_app.hpux:
  479. @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
  480. LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
  481. fi; \
  482. $(LINK_APP)
  483. link_dso.aix:
  484. @OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
  485. OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
  486. SHLIB=$(LIBNAME).so; \
  487. SHLIB_SUFFIX=; \
  488. ALLSYMSFLAGS=''; \
  489. NOALLSYMSFLAGS=''; \
  490. SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
  491. $(LINK_SO_DSO);
  492. link_shlib.aix:
  493. @ $(CALC_VERSIONS); \
  494. OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
  495. OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
  496. SHLIB=lib$(LIBNAME).so; \
  497. SHLIB_SUFFIX=; \
  498. ALLSYMSFLAGS='-bnogc'; \
  499. NOALLSYMSFLAGS=''; \
  500. SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
  501. $(LINK_SO_SHLIB_VIA_O)
  502. link_app.aix:
  503. LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
  504. $(LINK_APP)
  505. # Targets to build symbolic links when needed
  506. symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
  507. symlink.aix:
  508. @ $(CALC_VERSIONS); \
  509. SHLIB=lib$(LIBNAME).so; \
  510. $(SYMLINK_SO)
  511. symlink.darwin:
  512. @ $(CALC_VERSIONS); \
  513. SHLIB=lib$(LIBNAME); \
  514. SHLIB_SUFFIX=.dylib; \
  515. $(SYMLINK_SO)
  516. symlink.hpux:
  517. @ $(CALC_VERSIONS); \
  518. SHLIB=lib$(LIBNAME).sl; \
  519. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  520. $(SYMLINK_SO)
  521. # The following lines means those specific architectures do no symlinks
  522. symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
  523. # Compatibility targets
  524. link_dso.bsd-gcc-shared link_dso.linux-shared link_dso.gnu-shared link_dso.haiku-shared: link_dso.gnu
  525. link_shlib.bsd-gcc-shared: link_shlib.linux-shared
  526. link_shlib.gnu-shared link_shlib.haiku-shared: link_shlib.gnu
  527. link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared link_app.haiku-shared: link_app.gnu
  528. symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared symlink.haiku-shared: symlink.gnu
  529. link_dso.bsd-shared: link_dso.bsd
  530. link_shlib.bsd-shared: link_shlib.bsd
  531. link_app.bsd-shared: link_app.bsd
  532. link_dso.darwin-shared: link_dso.darwin
  533. link_shlib.darwin-shared: link_shlib.darwin
  534. link_app.darwin-shared: link_app.darwin
  535. symlink.darwin-shared: symlink.darwin
  536. link_dso.cygwin-shared: link_dso.cygwin
  537. link_shlib.cygwin-shared: link_shlib.cygwin
  538. link_app.cygwin-shared: link_app.cygwin
  539. symlink.cygwin-shared: symlink.cygwin
  540. link_dso.mingw-shared: link_dso.cygwin
  541. link_shlib.mingw-shared: link_shlib.mingw
  542. link_app.mingw-shared: link_app.cygwin
  543. symlink.mingw-shared: symlink.cygwin
  544. link_dso.alpha-osf1-shared: link_dso.alpha-osf1
  545. link_shlib.alpha-osf1-shared: link_shlib.alpha-osf1
  546. link_app.alpha-osf1-shared: link_app.alpha-osf1
  547. symlink.alpha-osf1-shared: symlink.alpha-osf1
  548. link_dso.tru64-shared: link_dso.tru64
  549. link_shlib.tru64-shared: link_shlib.tru64
  550. link_app.tru64-shared: link_app.tru64
  551. symlink.tru64-shared: symlink.tru64
  552. link_dso.tru64-shared-rpath: link_dso.tru64-rpath
  553. link_shlib.tru64-shared-rpath: link_shlib.tru64-rpath
  554. link_app.tru64-shared-rpath: link_app.tru64-rpath
  555. symlink.tru64-shared-rpath: symlink.tru64-rpath
  556. link_dso.solaris-shared: link_dso.solaris
  557. link_shlib.solaris-shared: link_shlib.solaris
  558. link_app.solaris-shared: link_app.solaris
  559. symlink.solaris-shared: symlink.solaris
  560. link_dso.svr3-shared: link_dso.svr3
  561. link_shlib.svr3-shared: link_shlib.svr3
  562. link_app.svr3-shared: link_app.svr3
  563. symlink.svr3-shared: symlink.svr3
  564. link_dso.svr5-shared: link_dso.svr5
  565. link_shlib.svr5-shared: link_shlib.svr5
  566. link_app.svr5-shared: link_app.svr5
  567. symlink.svr5-shared: symlink.svr5
  568. link_dso.irix-shared: link_dso.irix
  569. link_shlib.irix-shared: link_shlib.irix
  570. link_app.irix-shared: link_app.irix
  571. symlink.irix-shared: symlink.irix
  572. link_dso.hpux-shared: link_dso.hpux
  573. link_shlib.hpux-shared: link_shlib.hpux
  574. link_app.hpux-shared: link_app.hpux
  575. symlink.hpux-shared: symlink.hpux
  576. link_dso.aix-shared: link_dso.aix
  577. link_shlib.aix-shared: link_shlib.aix
  578. link_app.aix-shared: link_app.aix
  579. symlink.aix-shared: symlink.aix