Makefile.shared 20 KB

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