Makefile.shared 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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 lib$(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. # Originally link_o.darwin produced .so, because it was hard-coded
  183. # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
  184. # extension in order to allow for run-time linking with vendor-
  185. # supplied shared libraries such as libz, so that link_o.darwin had
  186. # to be harmonized with it. This caused minor controversy, because
  187. # it was believed that dlopen can't be used to dynamically load
  188. # .dylib-s, only so called bundle modules (ones linked with -bundle
  189. # flag). The belief seems to be originating from pre-10.4 release,
  190. # where dlfcn functionality was emulated by dlcompat add-on. In
  191. # 10.4 dlopen was rewritten as native part of dyld and is documented
  192. # to be capable of loading both dynamic libraries and bundles. In
  193. # order to provide compatibility with pre-10.4 dlopen, modules are
  194. # linked with -bundle flag, which makes .dylib extension misleading.
  195. # It works, because dlopen is [and always was] extension-agnostic.
  196. # Alternative to this heuristic approach is to develop specific
  197. # MacOS X dso module relying on whichever "native" dyld interface.
  198. link_o.darwin:
  199. @ $(CALC_VERSIONS); \
  200. SHLIB=lib$(LIBNAME); \
  201. SHLIB_SUFFIX=.dylib; \
  202. ALLSYMSFLAGS='-all_load'; \
  203. NOALLSYMSFLAGS=''; \
  204. SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
  205. if [ -n "$(LIBVERSION)" ]; then \
  206. SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
  207. fi; \
  208. if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
  209. SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
  210. fi; \
  211. $(LINK_SO_O)
  212. link_a.darwin:
  213. @ $(CALC_VERSIONS); \
  214. SHLIB=lib$(LIBNAME); \
  215. SHLIB_SUFFIX=.dylib; \
  216. ALLSYMSFLAGS='-all_load'; \
  217. NOALLSYMSFLAGS=''; \
  218. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
  219. if [ -n "$(LIBVERSION)" ]; then \
  220. SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
  221. fi; \
  222. if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
  223. SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
  224. fi; \
  225. SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
  226. $(LINK_SO_A)
  227. link_app.darwin: # is there run-path on darwin?
  228. $(LINK_APP)
  229. link_o.cygwin:
  230. @ $(CALC_VERSIONS); \
  231. INHIBIT_SYMLINKS=yes; \
  232. SHLIB=cyg$(LIBNAME); \
  233. base=-Wl,--enable-auto-image-base; \
  234. deffile=; \
  235. if expr $(PLATFORM) : 'mingw' > /dev/null; then \
  236. SHLIB=$(LIBNAME)eay32; base=; \
  237. if test -f $(LIBNAME)eay32.def; then \
  238. deffile=$(LIBNAME)eay32.def; \
  239. fi; \
  240. fi; \
  241. SHLIB_SUFFIX=.dll; \
  242. LIBVERSION="$(LIBVERSION)"; \
  243. SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
  244. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  245. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  246. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-Bsymbolic"; \
  247. $(LINK_SO_O)
  248. #for mingw target if def-file is in use dll-name should match library-name
  249. link_a.cygwin:
  250. @ $(CALC_VERSIONS); \
  251. INHIBIT_SYMLINKS=yes; \
  252. SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
  253. dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
  254. base=-Wl,--enable-auto-image-base; \
  255. if expr $(PLATFORM) : 'mingw' > /dev/null; then \
  256. case $(LIBNAME) in \
  257. crypto) SHLIB=libeay;; \
  258. ssl) SHLIB=ssleay;; \
  259. esac; \
  260. SHLIB_SOVER=32; \
  261. extras="$(LIBNAME).def"; \
  262. $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
  263. base=; [ $(LIBNAME) = "crypto" -a -n "$(FIPSCANLIB)" ] && base=-Wl,--image-base,0x63000000; \
  264. fi; \
  265. dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
  266. $(PERL) util/mkrc.pl $$dll_name | \
  267. $(RC) -o rc.o; \
  268. extras="$$extras rc.o"; \
  269. ALLSYMSFLAGS='-Wl,--whole-archive'; \
  270. NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
  271. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
  272. [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
  273. [ -f test/$$dll_name ] && rm test/$$dll_name; \
  274. $(LINK_SO_A) || exit 1; \
  275. rm $$extras; \
  276. cp -p $$dll_name apps/; \
  277. cp -p $$dll_name test/
  278. link_app.cygwin:
  279. @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
  280. LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
  281. export LIBDEPS; \
  282. fi; \
  283. $(LINK_APP)
  284. link_o.alpha-osf1:
  285. @ if $(DETECT_GNU_LD); then \
  286. $(DO_GNU_SO); \
  287. else \
  288. SHLIB=lib$(LIBNAME).so; \
  289. SHLIB_SUFFIX=; \
  290. SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
  291. if [ -n "$$SHLIB_HIST" ]; then \
  292. SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
  293. else \
  294. SHLIB_HIST="$(LIBVERSION)"; \
  295. fi; \
  296. SHLIB_SOVER=; \
  297. ALLSYMSFLAGS='-all'; \
  298. NOALLSYMSFLAGS='-none'; \
  299. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  300. if [ -n "$$SHLIB_HIST" ]; then \
  301. SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
  302. fi; \
  303. fi; \
  304. $(LINK_SO_O)
  305. link_a.alpha-osf1:
  306. @ if $(DETECT_GNU_LD); then \
  307. $(DO_GNU_SO); \
  308. else \
  309. SHLIB=lib$(LIBNAME).so; \
  310. SHLIB_SUFFIX=; \
  311. SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
  312. if [ -n "$$SHLIB_HIST" ]; then \
  313. SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
  314. else \
  315. SHLIB_HIST="$(LIBVERSION)"; \
  316. fi; \
  317. SHLIB_SOVER=; \
  318. ALLSYMSFLAGS='-all'; \
  319. NOALLSYMSFLAGS='-none'; \
  320. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
  321. if [ -n "$$SHLIB_HIST" ]; then \
  322. SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
  323. fi; \
  324. fi; \
  325. $(LINK_SO_A)
  326. link_app.alpha-osf1:
  327. @if $(DETECT_GNU_LD); then \
  328. $(DO_GNU_APP); \
  329. else \
  330. LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
  331. fi; \
  332. $(LINK_APP)
  333. link_o.solaris:
  334. @ if $(DETECT_GNU_LD); then \
  335. $(DO_GNU_SO); \
  336. else \
  337. $(CALC_VERSIONS); \
  338. MINUSZ='-z '; \
  339. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
  340. SHLIB=lib$(LIBNAME).so; \
  341. SHLIB_SUFFIX=; \
  342. ALLSYMSFLAGS="$${MINUSZ}allextract"; \
  343. NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
  344. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  345. fi; \
  346. $(LINK_SO_O)
  347. link_a.solaris:
  348. @ if $(DETECT_GNU_LD); then \
  349. $(DO_GNU_SO); \
  350. else \
  351. $(CALC_VERSIONS); \
  352. MINUSZ='-z '; \
  353. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
  354. SHLIB=lib$(LIBNAME).so; \
  355. SHLIB_SUFFIX=;\
  356. ALLSYMSFLAGS="$${MINUSZ}allextract"; \
  357. NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
  358. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
  359. fi; \
  360. $(LINK_SO_A)
  361. link_app.solaris:
  362. @ if $(DETECT_GNU_LD); then \
  363. $(DO_GNU_APP); \
  364. else \
  365. LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
  366. fi; \
  367. $(LINK_APP)
  368. # OpenServer 5 native compilers used
  369. link_o.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_O)
  381. link_a.svr3:
  382. @ if $(DETECT_GNU_LD); then \
  383. $(DO_GNU_SO); \
  384. else \
  385. $(CALC_VERSIONS); \
  386. SHLIB=lib$(LIBNAME).so; \
  387. SHLIB_SUFFIX=; \
  388. ALLSYMSFLAGS=''; \
  389. NOALLSYMSFLAGS=''; \
  390. SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  391. fi; \
  392. $(LINK_SO_A_UNPACKED)
  393. link_app.svr3:
  394. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  395. $(LINK_APP)
  396. # UnixWare 7 and OpenUNIX 8 native compilers used
  397. link_o.svr5:
  398. @ if $(DETECT_GNU_LD); then \
  399. $(DO_GNU_SO); \
  400. else \
  401. $(CALC_VERSIONS); \
  402. SHARE_FLAG='-G'; \
  403. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  404. SHLIB=lib$(LIBNAME).so; \
  405. SHLIB_SUFFIX=; \
  406. ALLSYMSFLAGS=''; \
  407. NOALLSYMSFLAGS=''; \
  408. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  409. fi; \
  410. $(LINK_SO_O)
  411. link_a.svr5:
  412. @ if $(DETECT_GNU_LD); then \
  413. $(DO_GNU_SO); \
  414. else \
  415. $(CALC_VERSIONS); \
  416. SHARE_FLAG='-G'; \
  417. ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
  418. SHLIB=lib$(LIBNAME).so; \
  419. SHLIB_SUFFIX=; \
  420. ALLSYMSFLAGS=''; \
  421. NOALLSYMSFLAGS=''; \
  422. SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
  423. fi; \
  424. $(LINK_SO_A_UNPACKED)
  425. link_app.svr5:
  426. @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
  427. $(LINK_APP)
  428. link_o.irix:
  429. @ if $(DETECT_GNU_LD); then \
  430. $(DO_GNU_SO); \
  431. else \
  432. $(CALC_VERSIONS); \
  433. SHLIB=lib$(LIBNAME).so; \
  434. SHLIB_SUFFIX=; \
  435. MINUSWL=""; \
  436. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
  437. ALLSYMSFLAGS="$${MINUSWL}-all"; \
  438. NOALLSYMSFLAGS="$${MINUSWL}-none"; \
  439. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
  440. fi; \
  441. $(LINK_SO_O)
  442. link_a.irix:
  443. @ if $(DETECT_GNU_LD); then \
  444. $(DO_GNU_SO); \
  445. else \
  446. $(CALC_VERSIONS); \
  447. SHLIB=lib$(LIBNAME).so; \
  448. SHLIB_SUFFIX=; \
  449. MINUSWL=""; \
  450. ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
  451. ALLSYMSFLAGS="$${MINUSWL}-all"; \
  452. NOALLSYMSFLAGS="$${MINUSWL}-none"; \
  453. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
  454. fi; \
  455. $(LINK_SO_A)
  456. link_app.irix:
  457. @LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
  458. $(LINK_APP)
  459. # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
  460. # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
  461. # rules imply that we can only link one level down in catalog structure,
  462. # but that's what takes place for the moment of this writing. +cdp option
  463. # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
  464. # editor context only [it's simply ignored in other cases, which are all
  465. # ELFs by the way].
  466. #
  467. link_o.hpux:
  468. @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
  469. $(CALC_VERSIONS); \
  470. SHLIB=lib$(LIBNAME).sl; \
  471. expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  472. SHLIB_SUFFIX=; \
  473. ALLSYMSFLAGS='-Wl,-Fl'; \
  474. NOALLSYMSFLAGS=''; \
  475. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  476. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  477. fi; \
  478. rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
  479. $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
  480. link_a.hpux:
  481. @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
  482. $(CALC_VERSIONS); \
  483. SHLIB=lib$(LIBNAME).sl; \
  484. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  485. SHLIB_SUFFIX=; \
  486. ALLSYMSFLAGS='-Wl,-Fl'; \
  487. NOALLSYMSFLAGS=''; \
  488. expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
  489. SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
  490. fi; \
  491. rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
  492. $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
  493. link_app.hpux:
  494. @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
  495. LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
  496. fi; \
  497. $(LINK_APP)
  498. link_o.aix:
  499. @ $(CALC_VERSIONS); \
  500. OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
  501. OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
  502. SHLIB=lib$(LIBNAME).so; \
  503. SHLIB_SUFFIX=; \
  504. ALLSYMSFLAGS=''; \
  505. NOALLSYMSFLAGS=''; \
  506. SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
  507. $(LINK_SO_O);
  508. link_a.aix:
  509. @ $(CALC_VERSIONS); \
  510. OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
  511. OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
  512. SHLIB=lib$(LIBNAME).so; \
  513. SHLIB_SUFFIX=; \
  514. ALLSYMSFLAGS='-bnogc'; \
  515. NOALLSYMSFLAGS=''; \
  516. SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
  517. $(LINK_SO_A_VIA_O)
  518. link_app.aix:
  519. LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
  520. $(LINK_APP)
  521. link_o.reliantunix:
  522. @ $(CALC_VERSIONS); \
  523. SHLIB=lib$(LIBNAME).so; \
  524. SHLIB_SUFFIX=; \
  525. ALLSYMSFLAGS=; \
  526. NOALLSYMSFLAGS=''; \
  527. SHAREDFLAGS='$(CFLAGS) -G'; \
  528. $(LINK_SO_O)
  529. link_a.reliantunix:
  530. @ $(CALC_VERSIONS); \
  531. SHLIB=lib$(LIBNAME).so; \
  532. SHLIB_SUFFIX=; \
  533. ALLSYMSFLAGS=; \
  534. NOALLSYMSFLAGS=''; \
  535. SHAREDFLAGS='$(CFLAGS) -G'; \
  536. $(LINK_SO_A_UNPACKED)
  537. link_app.reliantunix:
  538. $(LINK_APP)
  539. # Targets to build symbolic links when needed
  540. symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
  541. symlink.aix symlink.reliantunix:
  542. @ $(CALC_VERSIONS); \
  543. SHLIB=lib$(LIBNAME).so; \
  544. $(SYMLINK_SO)
  545. symlink.darwin:
  546. @ $(CALC_VERSIONS); \
  547. SHLIB=lib$(LIBNAME); \
  548. SHLIB_SUFFIX=.dylib; \
  549. $(SYMLINK_SO)
  550. symlink.hpux:
  551. @ $(CALC_VERSIONS); \
  552. SHLIB=lib$(LIBNAME).sl; \
  553. expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
  554. $(SYMLINK_SO)
  555. # The following lines means those specific architectures do no symlinks
  556. symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath symlink.beos:
  557. # Compatibility targets
  558. link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
  559. link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
  560. link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
  561. symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
  562. link_o.bsd-shared: link_o.bsd
  563. link_a.bsd-shared: link_a.bsd
  564. link_app.bsd-shared: link_app.bsd
  565. link_o.darwin-shared: link_o.darwin
  566. link_a.darwin-shared: link_a.darwin
  567. link_app.darwin-shared: link_app.darwin
  568. symlink.darwin-shared: symlink.darwin
  569. link_o.cygwin-shared: link_o.cygwin
  570. link_a.cygwin-shared: link_a.cygwin
  571. link_app.cygwin-shared: link_app.cygwin
  572. symlink.cygwin-shared: symlink.cygwin
  573. link_o.alpha-osf1-shared: link_o.alpha-osf1
  574. link_a.alpha-osf1-shared: link_a.alpha-osf1
  575. link_app.alpha-osf1-shared: link_app.alpha-osf1
  576. symlink.alpha-osf1-shared: symlink.alpha-osf1
  577. link_o.tru64-shared: link_o.tru64
  578. link_a.tru64-shared: link_a.tru64
  579. link_app.tru64-shared: link_app.tru64
  580. symlink.tru64-shared: symlink.tru64
  581. link_o.tru64-shared-rpath: link_o.tru64-rpath
  582. link_a.tru64-shared-rpath: link_a.tru64-rpath
  583. link_app.tru64-shared-rpath: link_app.tru64-rpath
  584. symlink.tru64-shared-rpath: symlink.tru64-rpath
  585. link_o.solaris-shared: link_o.solaris
  586. link_a.solaris-shared: link_a.solaris
  587. link_app.solaris-shared: link_app.solaris
  588. symlink.solaris-shared: symlink.solaris
  589. link_o.svr3-shared: link_o.svr3
  590. link_a.svr3-shared: link_a.svr3
  591. link_app.svr3-shared: link_app.svr3
  592. symlink.svr3-shared: symlink.svr3
  593. link_o.svr5-shared: link_o.svr5
  594. link_a.svr5-shared: link_a.svr5
  595. link_app.svr5-shared: link_app.svr5
  596. symlink.svr5-shared: symlink.svr5
  597. link_o.irix-shared: link_o.irix
  598. link_a.irix-shared: link_a.irix
  599. link_app.irix-shared: link_app.irix
  600. symlink.irix-shared: symlink.irix
  601. link_o.hpux-shared: link_o.hpux
  602. link_a.hpux-shared: link_a.hpux
  603. link_app.hpux-shared: link_app.hpux
  604. symlink.hpux-shared: symlink.hpux
  605. link_o.aix-shared: link_o.aix
  606. link_a.aix-shared: link_a.aix
  607. link_app.aix-shared: link_app.aix
  608. symlink.aix-shared: symlink.aix
  609. link_o.reliantunix-shared: link_o.reliantunix
  610. link_a.reliantunix-shared: link_a.reliantunix
  611. link_app.reliantunix-shared: link_app.reliantunix
  612. symlink.reliantunix-shared: symlink.reliantunix
  613. link_o.beos-shared: link_o.beos
  614. link_a.beos-shared: link_a.beos
  615. link_app.beos-shared: link_app.gnu
  616. symlink.beos-shared: symlink.beos