Makefile.shared 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
  133. ld $(LDFLAGS) -r -o $$SHOBJECTS $$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)"
  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)"; \
  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. $(PERL) $(SRCDIR)/util/mkdef.pl 32 $(LIBNAME) \
  275. | sed -e 's|^\(LIBRARY *\)$(LIBNAME)32|\1'"$$dll_name"'|' \
  276. > $(LIBNAME).def; \
  277. echo "$(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name |" \
  278. "$(RC) $(SHARED_RCFLAGS) -o rc.o"; \
  279. $(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name | \
  280. $(RC) $(SHARED_RCFLAGS) -o rc.o; \
  281. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  282. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  283. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $(LIBNAME).def rc.o"; \
  284. $(LINK_SO_SHLIB) || exit 1; \
  285. rm $(LIBNAME).def rc.o
  286. link_dso.alpha-osf1:
  287. @ if $(DETECT_GNU_LD); then \
  288. $(DO_GNU_DSO); \
  289. else \
  290. SHLIB=$(LIBNAME).so; \
  291. SHLIB_SUFFIX=; \
  292. ALLSYMSFLAGS=''; \
  293. NOALLSYMSFLAGS=''; \
  294. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  295. fi; \
  296. $(LINK_SO_DSO)
  297. link_shlib.alpha-osf1:
  298. @ if $(DETECT_GNU_LD); then \
  299. $(DO_GNU_SO); \
  300. else \
  301. SHLIB=lib$(LIBNAME).so; \
  302. SHLIB_SUFFIX=; \
  303. SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
  304. if [ -n "$$SHLIB_HIST" ]; then \
  305. SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
  306. else \
  307. SHLIB_HIST="$(LIBVERSION)"; \
  308. fi; \
  309. SHLIB_SOVER=; \
  310. ALLSYMSFLAGS='-all'; \
  311. NOALLSYMSFLAGS='-none'; \
  312. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  313. if [ -n "$$SHLIB_HIST" ]; then \
  314. SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
  315. fi; \
  316. fi; \
  317. $(LINK_SO_SHLIB)
  318. link_app.alpha-osf1:
  319. @if $(DETECT_GNU_LD); then \
  320. $(DO_GNU_APP); \
  321. else \
  322. LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
  323. fi; \
  324. $(LINK_APP)
  325. link_dso.solaris:
  326. @ if $(DETECT_GNU_LD); then \
  327. $(DO_GNU_DSO); \
  328. else \
  329. $(CALC_VERSIONS); \
  330. SHLIB=$(LIBNAME).so; \
  331. SHLIB_SUFFIX=; \
  332. ALLSYMSFLAGS=""; \
  333. NOALLSYMSFLAGS=""; \
  334. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  335. fi; \
  336. $(LINK_SO_DSO)
  337. link_shlib.solaris:
  338. @ if $(DETECT_GNU_LD); then \
  339. $(DO_GNU_SO); \
  340. else \
  341. $(CALC_VERSIONS); \
  342. SHLIB=lib$(LIBNAME).so; \
  343. SHLIB_SUFFIX=;\
  344. $(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
  345. ALLSYMSFLAGS="-Wl,-z,allextract,-M,$(LIBNAME).map"; \
  346. NOALLSYMSFLAGS="-Wl,-z,defaultextract"; \
  347. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  348. fi; \
  349. $(LINK_SO_SHLIB)
  350. link_app.solaris:
  351. @ if $(DETECT_GNU_LD); then \
  352. $(DO_GNU_APP); \
  353. else \
  354. LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
  355. fi; \
  356. $(LINK_APP)
  357. # OpenServer 5 native compilers used
  358. link_dso.svr3:
  359. @ if $(DETECT_GNU_LD); then \
  360. $(DO_GNU_DSO); \
  361. else \
  362. $(CALC_VERSIONS); \
  363. SHLIB=$(LIBNAME).so; \
  364. SHLIB_SUFFIX=; \
  365. ALLSYMSFLAGS=''; \
  366. NOALLSYMSFLAGS=''; \
  367. SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SUFFIX"; \
  368. fi; \
  369. $(LINK_SO_DSO)
  370. link_shlib.svr3:
  371. @ if $(DETECT_GNU_LD); then \
  372. $(DO_GNU_SO); \
  373. else \
  374. $(CALC_VERSIONS); \
  375. SHLIB=lib$(LIBNAME).so; \
  376. SHLIB_SUFFIX=; \
  377. ALLSYMSFLAGS=''; \
  378. NOALLSYMSFLAGS=''; \
  379. SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  380. fi; \
  381. $(LINK_SO_SHLIB_UNPACKED)
  382. link_app.svr3:
  383. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  384. $(LINK_APP)
  385. # UnixWare 7 and OpenUNIX 8 native compilers used
  386. link_dso.svr5:
  387. @ if $(DETECT_GNU_LD); then \
  388. $(DO_GNU_DSO); \
  389. else \
  390. SHARE_FLAG='-G'; \
  391. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  392. SHLIB=$(LIBNAME).so; \
  393. SHLIB_SUFFIX=; \
  394. ALLSYMSFLAGS=''; \
  395. NOALLSYMSFLAGS=''; \
  396. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SUFFIX"; \
  397. fi; \
  398. $(LINK_SO_DSO)
  399. link_shlib.svr5:
  400. @ if $(DETECT_GNU_LD); then \
  401. $(DO_GNU_SO); \
  402. else \
  403. $(CALC_VERSIONS); \
  404. SHARE_FLAG='-G'; \
  405. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  406. SHLIB=lib$(LIBNAME).so; \
  407. SHLIB_SUFFIX=; \
  408. ALLSYMSFLAGS=''; \
  409. NOALLSYMSFLAGS=''; \
  410. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  411. fi; \
  412. $(LINK_SO_SHLIB_UNPACKED)
  413. link_app.svr5:
  414. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  415. $(LINK_APP)
  416. link_dso.irix:
  417. @ if $(DETECT_GNU_LD); then \
  418. $(DO_GNU_DSO); \
  419. else \
  420. SHLIB=$(LIBNAME).so; \
  421. SHLIB_SUFFIX=; \
  422. ALLSYMSFLAGS=""; \
  423. NOALLSYMSFLAGS=""; \
  424. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SUFFIX,-B,symbolic"; \
  425. fi; \
  426. $(LINK_SO_DSO)
  427. link_shlib.irix:
  428. @ if $(DETECT_GNU_LD); then \
  429. $(DO_GNU_SO); \
  430. else \
  431. $(CALC_VERSIONS); \
  432. SHLIB=lib$(LIBNAME).so; \
  433. SHLIB_SUFFIX=; \
  434. MINUSWL=""; \
  435. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
  436. ALLSYMSFLAGS="$${MINUSWL}-all"; \
  437. NOALLSYMSFLAGS="$${MINUSWL}-none"; \
  438. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
  439. fi; \
  440. $(LINK_SO_SHLIB)
  441. link_app.irix:
  442. @LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
  443. $(LINK_APP)
  444. # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
  445. # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
  446. # rules imply that we can only link one level down in catalog structure,
  447. # but that's what takes place for the moment of this writing. +cdp option
  448. # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
  449. # editor context only [it's simply ignored in other cases, which are all
  450. # ELFs by the way].
  451. #
  452. link_dso.hpux:
  453. @if $(DETECT_GNU_LD); then $(DO_GNU_DSO); else \
  454. SHLIB=$(LIBNAME).sl; \
  455. expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=$(LIBNAME).so; \
  456. SHLIB_SUFFIX=; \
  457. ALLSYMSFLAGS=''; \
  458. NOALLSYMSFLAGS=''; \
  459. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  460. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  461. fi; \
  462. rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX || :; \
  463. $(LINK_SO_DSO) && chmod a=rx $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX
  464. link_shlib.hpux:
  465. @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
  466. $(CALC_VERSIONS); \
  467. SHLIB=lib$(LIBNAME).sl; \
  468. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  469. SHLIB_SUFFIX=; \
  470. ALLSYMSFLAGS='-Wl,-Fl'; \
  471. NOALLSYMSFLAGS=''; \
  472. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  473. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  474. fi; \
  475. rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
  476. $(LINK_SO_SHLIB) && chmod a=rx $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
  477. link_app.hpux:
  478. @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
  479. LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:"; \
  480. fi; \
  481. $(LINK_APP)
  482. link_dso.aix:
  483. @OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
  484. OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
  485. SHLIB=$(LIBNAME).so; \
  486. SHLIB_SUFFIX=; \
  487. ALLSYMSFLAGS=''; \
  488. NOALLSYMSFLAGS=''; \
  489. SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
  490. rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER 2>&1 > /dev/null ; \
  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. rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER 2>&1 > /dev/null ; \
  502. $(LINK_SO_SHLIB_VIA_O)
  503. link_app.aix:
  504. LDFLAGS="$(CFLAGS) -Wl,-bsvr4 $(LDFLAGS)"; \
  505. $(LINK_APP)
  506. # Targets to build symbolic links when needed
  507. symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
  508. symlink.aix:
  509. @ $(CALC_VERSIONS); \
  510. SHLIB=lib$(LIBNAME).so; \
  511. $(SYMLINK_SO)
  512. symlink.darwin:
  513. @ $(CALC_VERSIONS); \
  514. SHLIB=lib$(LIBNAME); \
  515. SHLIB_SUFFIX=.dylib; \
  516. $(SYMLINK_SO)
  517. symlink.hpux:
  518. @ $(CALC_VERSIONS); \
  519. SHLIB=lib$(LIBNAME).sl; \
  520. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  521. $(SYMLINK_SO)
  522. # The following lines means those specific architectures do no symlinks
  523. symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
  524. # Compatibility targets
  525. link_dso.bsd-gcc-shared link_dso.linux-shared link_dso.gnu-shared: link_dso.gnu
  526. link_shlib.bsd-gcc-shared: link_shlib.linux-shared
  527. link_shlib.gnu-shared: link_shlib.gnu
  528. link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
  529. symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
  530. link_dso.bsd-shared: link_dso.bsd
  531. link_shlib.bsd-shared: link_shlib.bsd
  532. link_app.bsd-shared: link_app.bsd
  533. link_dso.darwin-shared: link_dso.darwin
  534. link_shlib.darwin-shared: link_shlib.darwin
  535. link_app.darwin-shared: link_app.darwin
  536. symlink.darwin-shared: symlink.darwin
  537. link_dso.cygwin-shared: link_dso.cygwin
  538. link_shlib.cygwin-shared: link_shlib.cygwin
  539. link_app.cygwin-shared: link_app.cygwin
  540. symlink.cygwin-shared: symlink.cygwin
  541. link_dso.mingw-shared: link_dso.cygwin
  542. link_shlib.mingw-shared: link_shlib.mingw
  543. link_app.mingw-shared: link_app.cygwin
  544. symlink.mingw-shared: symlink.cygwin
  545. link_dso.alpha-osf1-shared: link_dso.alpha-osf1
  546. link_shlib.alpha-osf1-shared: link_shlib.alpha-osf1
  547. link_app.alpha-osf1-shared: link_app.alpha-osf1
  548. symlink.alpha-osf1-shared: symlink.alpha-osf1
  549. link_dso.tru64-shared: link_dso.tru64
  550. link_shlib.tru64-shared: link_shlib.tru64
  551. link_app.tru64-shared: link_app.tru64
  552. symlink.tru64-shared: symlink.tru64
  553. link_dso.tru64-shared-rpath: link_dso.tru64-rpath
  554. link_shlib.tru64-shared-rpath: link_shlib.tru64-rpath
  555. link_app.tru64-shared-rpath: link_app.tru64-rpath
  556. symlink.tru64-shared-rpath: symlink.tru64-rpath
  557. link_dso.solaris-shared: link_dso.solaris
  558. link_shlib.solaris-shared: link_shlib.solaris
  559. link_app.solaris-shared: link_app.solaris
  560. symlink.solaris-shared: symlink.solaris
  561. link_dso.svr3-shared: link_dso.svr3
  562. link_shlib.svr3-shared: link_shlib.svr3
  563. link_app.svr3-shared: link_app.svr3
  564. symlink.svr3-shared: symlink.svr3
  565. link_dso.svr5-shared: link_dso.svr5
  566. link_shlib.svr5-shared: link_shlib.svr5
  567. link_app.svr5-shared: link_app.svr5
  568. symlink.svr5-shared: symlink.svr5
  569. link_dso.irix-shared: link_dso.irix
  570. link_shlib.irix-shared: link_shlib.irix
  571. link_app.irix-shared: link_app.irix
  572. symlink.irix-shared: symlink.irix
  573. link_dso.hpux-shared: link_dso.hpux
  574. link_shlib.hpux-shared: link_shlib.hpux
  575. link_app.hpux-shared: link_app.hpux
  576. symlink.hpux-shared: symlink.hpux
  577. link_dso.aix-shared: link_dso.aix
  578. link_shlib.aix-shared: link_shlib.aix
  579. link_app.aix-shared: link_app.aix
  580. symlink.aix-shared: symlink.aix