Makefile.shared 21 KB

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