Makefile.shared 20 KB

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