]>
Commit | Line | Data |
---|---|---|
30afcc07 RL |
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 | ||
8 | # CC contains the current compiler. This one MUST be defined | |
9 | CC=cc | |
f210eb7b | 10 | CFLAGS=$(CFLAG) |
2d3de726 RL |
11 | # LDFLAGS contains flags to be used when temporary object files (when building |
12 | # shared libraries) are created, or when an application is linked. | |
13 | # SHARED_LDFLAGS contains flags to be used when the shared library is created. | |
c86ddbe6 RL |
14 | LDFLAGS=$(LDFLAG) |
15 | SHARED_LDFLAGS=$(SHARED_LDFLAG) | |
30afcc07 | 16 | |
64c443e3 RL |
17 | # SHARED_RCFLAGS are flags used with windres, i.e. when build for Cygwin |
18 | # or Mingw. | |
19 | SHARED_RCFLAGS=$(SHARED_RCFLAG) | |
20 | ||
cbfb39d1 AP |
21 | NM=nm |
22 | ||
2d3de726 | 23 | # LIBNAME contains just the name of the library, without prefix ("lib" |
30afcc07 | 24 | # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so, |
2d3de726 RL |
25 | # .dll, ...). This one MUST have a value when using this makefile to |
26 | # build shared libraries. | |
30afcc07 RL |
27 | # For example, to build libfoo.so, you need to do the following: |
28 | #LIBNAME=foo | |
29 | LIBNAME= | |
30 | ||
2d3de726 RL |
31 | # APPNAME contains just the name of the application, without suffix ("" |
32 | # on Unix, ".exe" on Windows, ...). This one MUST have a value when using | |
33 | # this makefile to build applications. | |
34 | # For example, to build foo, you need to do the following: | |
35 | #APPNAME=foo | |
36 | APPNAME= | |
37 | ||
d7465918 RL |
38 | # DSTDIR is the directory where the built file should end up in. |
39 | DSTDIR=. | |
40 | ||
41 | # SRCDIR is the top directory of the source tree. | |
42 | SRCDIR=. | |
43 | ||
2d3de726 RL |
44 | # OBJECTS contains all the object files to link together into the application. |
45 | # This must contain at least one object file. | |
46 | #OBJECTS=foo.o | |
47 | OBJECTS= | |
48 | ||
30afcc07 | 49 | # LIBEXTRAS contains extra modules to link together with the library. |
8d6fc30b | 50 | # For example, if a second library, say libbar.a needs to be linked into |
30afcc07 RL |
51 | # libfoo.so, you need to do the following: |
52 | #LIBEXTRAS=libbar.a | |
e048fd51 RL |
53 | # Note that this MUST be used when using the link_dso targets, to hold the |
54 | # names of all object files that go into the target shared object. | |
30afcc07 RL |
55 | LIBEXTRAS= |
56 | ||
57 | # LIBVERSION contains the current version of the library. | |
58 | # For example, to build libfoo.so.1.2, you need to do the following: | |
59 | #LIBVERSION=1.2 | |
60 | LIBVERSION= | |
61 | ||
62 | # LIBCOMPATVERSIONS contains the compatibility versions (a list) of | |
63 | # the library. They MUST be in decreasing order. | |
64 | # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2 | |
65 | # and libfoo.so.1, you need to do the following: | |
66 | #LIBCOMPATVERSIONS=1.2 1 | |
67 | # Note that on systems that use sonames, the last number will appear as | |
68 | # part of it. | |
69 | # It's also possible, for systems that support it (Tru64, for example), | |
70 | # to add extra compatibility info with more precision, by adding a second | |
71 | # list of versions, separated from the first with a semicolon, like this: | |
72 | #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0 | |
73 | LIBCOMPATVERSIONS= | |
74 | ||
75 | # LIBDEPS contains all the flags necessary to cover all necessary | |
76 | # dependencies to other libraries. | |
77 | LIBDEPS= | |
78 | ||
79 | #------------------------------------------------------------------------------ | |
80 | # The rest is private to this makefile. | |
81 | ||
c4cd925c | 82 | SET_X=: |
1dc02bba | 83 | #SET_X=set -x |
30afcc07 RL |
84 | |
85 | top: | |
86 | echo "Trying to use this makefile interactively? Don't." | |
87 | ||
88 | CALC_VERSIONS= \ | |
89 | SHLIB_COMPAT=; SHLIB_SOVER=; \ | |
cf3b8b52 | 90 | if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \ |
30afcc07 RL |
91 | prev=""; \ |
92 | for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \ | |
f968059c | 93 | SHLIB_SOVER_NODOT=$$v; \ |
30afcc07 RL |
94 | SHLIB_SOVER=.$$v; \ |
95 | if [ -n "$$prev" ]; then \ | |
a0bf8f20 | 96 | SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \ |
30afcc07 RL |
97 | fi; \ |
98 | prev=$$v; \ | |
99 | done; \ | |
100 | fi | |
101 | ||
2d3de726 | 102 | LINK_APP= \ |
fe28866d | 103 | ( $(SET_X); \ |
7858cc03 | 104 | LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \ |
c86ddbe6 | 105 | LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS) $(LDFLAGS)}"; \ |
ab4d6898 | 106 | LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \ |
d6fd88ff | 107 | LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \ |
f3ac5003 RL |
108 | echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ |
109 | $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS}; \ | |
e96133e4 | 110 | LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ |
7858cc03 | 111 | $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} ) |
2d3de726 | 112 | |
30afcc07 | 113 | LINK_SO= \ |
fe28866d | 114 | ( $(SET_X); \ |
7858cc03 AP |
115 | LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \ |
116 | SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \ | |
117 | SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \ | |
ab4d6898 | 118 | LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \ |
d6fd88ff | 119 | LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \ |
f3ac5003 RL |
120 | echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ |
121 | $${SHAREDCMD} $${SHAREDFLAGS} \ | |
d7465918 | 122 | -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \ |
f3ac5003 | 123 | $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS; \ |
e96133e4 | 124 | LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \ |
7858cc03 | 125 | $${SHAREDCMD} $${SHAREDFLAGS} \ |
d7465918 | 126 | -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \ |
f210eb7b | 127 | $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \ |
d6c76457 | 128 | ) && $(SYMLINK_SO) |
f210eb7b | 129 | |
30afcc07 | 130 | SYMLINK_SO= \ |
bfa96bc2 RL |
131 | if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \ |
132 | prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \ | |
133 | if [ -n "$$SHLIB_COMPAT" ]; then \ | |
134 | for x in $$SHLIB_COMPAT; do \ | |
d7465918 RL |
135 | ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX; \ |
136 | ln -s $$prev $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX ); \ | |
bfa96bc2 RL |
137 | prev=$$SHLIB$$x$$SHLIB_SUFFIX; \ |
138 | done; \ | |
139 | fi; \ | |
140 | if [ -n "$$SHLIB_SOVER" ]; then \ | |
d7465918 RL |
141 | ( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX; \ |
142 | ln -s $$prev $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX ); \ | |
bfa96bc2 | 143 | fi; \ |
30afcc07 | 144 | fi |
cf3b8b52 | 145 | |
e048fd51 RL |
146 | LINK_SO_SHLIB= SHOBJECTS="$(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO) |
147 | LINK_SO_DSO= INHIBIT_SYMLINKS=yes; SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO) | |
f210eb7b | 148 | |
e048fd51 | 149 | LINK_SO_SHLIB_VIA_O= \ |
d7465918 | 150 | SHOBJECTS=$(DSTDIR)/lib$(LIBNAME).o; \ |
f968059c | 151 | ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \ |
d7465918 RL |
152 | ( echo ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \ |
153 | ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \ | |
154 | $(LINK_SO) && ( echo rm -f $$SHOBJECTS; rm -f $$SHOBJECTS ) | |
f210eb7b | 155 | |
e048fd51 | 156 | LINK_SO_SHLIB_UNPACKED= \ |
30afcc07 | 157 | UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \ |
d7465918 | 158 | (cd $$UNPACKDIR; ar x ../$(DSTDIR)/lib$(LIBNAME).a) && \ |
e96133e4 | 159 | ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \ |
30afcc07 RL |
160 | SHOBJECTS=$$UNPACKDIR/*.o; \ |
161 | $(LINK_SO) && rm -rf $$UNPACKDIR | |
162 | ||
a370537b | 163 | DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null |
4d77d5b3 | 164 | |
2b9608b0 | 165 | DO_GNU_SO_COMMON=\ |
35b3a614 RL |
166 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" |
167 | DO_GNU_DSO=\ | |
168 | SHLIB=$(LIBNAME).so; \ | |
169 | SHLIB_SOVER=; \ | |
f968059c | 170 | SHLIB_SUFFIX=; \ |
35b3a614 RL |
171 | $(DO_GNU_SO_COMMON) |
172 | DO_GNU_SO=\ | |
173 | $(CALC_VERSIONS); \ | |
1cb7757e | 174 | SHLIB=lib$(LIBNAME).so; \ |
f968059c RL |
175 | ALLSYMSFLAGS='-Wl,--whole-archive'; \ |
176 | NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ | |
35b3a614 | 177 | $(DO_GNU_SO_COMMON) |
c86ddbe6 | 178 | DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)" |
12fd8be2 | 179 | |
132eaa59 RL |
180 | #This is rather special. It's a special target with which one can link |
181 | #applications without bothering with any features that have anything to | |
182 | #do with shared libraries, for example when linking against static | |
183 | #libraries. It's mostly here to avoid a lot of conditionals everywhere | |
184 | #else... | |
185 | link_app.: | |
132eaa59 RL |
186 | $(LINK_APP) |
187 | ||
e048fd51 | 188 | link_dso.gnu: |
35b3a614 | 189 | @ $(DO_GNU_DSO); $(LINK_SO_DSO) |
e048fd51 RL |
190 | link_shlib.gnu: |
191 | @ $(DO_GNU_SO); $(LINK_SO_SHLIB) | |
2d3de726 RL |
192 | link_app.gnu: |
193 | @ $(DO_GNU_APP); $(LINK_APP) | |
30afcc07 | 194 | |
e048fd51 | 195 | link_shlib.linux-shared: |
24e75727 RL |
196 | @$(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \ |
197 | $(DO_GNU_SO); \ | |
e863d920 | 198 | ALLSYMSFLAGS='-Wl,--whole-archive,--version-script=$(LIBNAME).map'; \ |
24e75727 | 199 | $(LINK_SO_SHLIB) |
e863d920 | 200 | |
e048fd51 | 201 | link_dso.bsd: |
35b3a614 | 202 | @if $(DETECT_GNU_LD); then $(DO_GNU_DSO); else \ |
9ee0ed3d | 203 | SHLIB=$(LIBNAME).so; \ |
16760a30 | 204 | SHLIB_SUFFIX=; \ |
f210eb7b | 205 | LIBDEPS=" "; \ |
35b3a614 | 206 | ALLSYMSFLAGS=; \ |
16760a30 | 207 | NOALLSYMSFLAGS=; \ |
f210eb7b | 208 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \ |
e048fd51 RL |
209 | fi; $(LINK_SO_DSO) |
210 | link_shlib.bsd: | |
a370537b | 211 | @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \ |
16760a30 AP |
212 | $(CALC_VERSIONS); \ |
213 | SHLIB=lib$(LIBNAME).so; \ | |
214 | SHLIB_SUFFIX=; \ | |
f210eb7b | 215 | LIBDEPS=" "; \ |
16760a30 AP |
216 | ALLSYMSFLAGS="-Wl,-Bforcearchive"; \ |
217 | NOALLSYMSFLAGS=; \ | |
f210eb7b | 218 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \ |
e048fd51 | 219 | fi; $(LINK_SO_SHLIB) |
16760a30 | 220 | link_app.bsd: |
a370537b | 221 | @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \ |
c86ddbe6 | 222 | LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBPATH)"; \ |
16760a30 AP |
223 | fi; $(LINK_APP) |
224 | ||
30afcc07 | 225 | # For Darwin AKA Mac OS/X (dyld) |
e048fd51 | 226 | # Originally link_dso.darwin produced .so, because it was hard-coded |
cad6650f AP |
227 | # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib |
228 | # extension in order to allow for run-time linking with vendor- | |
e048fd51 | 229 | # supplied shared libraries such as libz, so that link_dso.darwin had |
cad6650f AP |
230 | # to be harmonized with it. This caused minor controversy, because |
231 | # it was believed that dlopen can't be used to dynamically load | |
232 | # .dylib-s, only so called bundle modules (ones linked with -bundle | |
233 | # flag). The belief seems to be originating from pre-10.4 release, | |
234 | # where dlfcn functionality was emulated by dlcompat add-on. In | |
235 | # 10.4 dlopen was rewritten as native part of dyld and is documented | |
236 | # to be capable of loading both dynamic libraries and bundles. In | |
237 | # order to provide compatibility with pre-10.4 dlopen, modules are | |
238 | # linked with -bundle flag, which makes .dylib extension misleading. | |
239 | # It works, because dlopen is [and always was] extension-agnostic. | |
75db4b2f AP |
240 | # Alternative to this heuristic approach is to develop specific |
241 | # MacOS X dso module relying on whichever "native" dyld interface. | |
e048fd51 | 242 | link_dso.darwin: |
9ee0ed3d | 243 | @ SHLIB=$(LIBNAME); \ |
cad6650f | 244 | SHLIB_SUFFIX=.dylib; \ |
35b3a614 | 245 | ALLSYMSFLAGS=''; \ |
f968059c | 246 | NOALLSYMSFLAGS=''; \ |
72f42193 | 247 | SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \ |
e048fd51 RL |
248 | $(LINK_SO_DSO) |
249 | link_shlib.darwin: | |
30afcc07 | 250 | @ $(CALC_VERSIONS); \ |
f968059c RL |
251 | SHLIB=lib$(LIBNAME); \ |
252 | SHLIB_SUFFIX=.dylib; \ | |
f968059c RL |
253 | ALLSYMSFLAGS='-all_load'; \ |
254 | NOALLSYMSFLAGS=''; \ | |
ab6cf1b8 | 255 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \ |
36757b44 | 256 | if [ -n "$(LIBVERSION)" ]; then \ |
62966f38 | 257 | SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \ |
36757b44 RL |
258 | fi; \ |
259 | if [ -n "$$SHLIB_SOVER_NODOT" ]; then \ | |
62966f38 | 260 | SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \ |
36757b44 | 261 | fi; \ |
6727565a | 262 | SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \ |
e048fd51 | 263 | $(LINK_SO_SHLIB) |
f210eb7b | 264 | link_app.darwin: # is there run-path on darwin? |
2d3de726 | 265 | $(LINK_APP) |
30afcc07 | 266 | |
e048fd51 | 267 | link_dso.cygwin: |
9ee0ed3d | 268 | @SHLIB=$(LIBNAME); \ |
f968059c | 269 | SHLIB_SUFFIX=.dll; \ |
35b3a614 RL |
270 | ALLSYMSFLAGS=''; \ |
271 | NOALLSYMSFLAGS=''; \ | |
9ee0ed3d RL |
272 | base=-Wl,--enable-auto-image-base; \ |
273 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic"; \ | |
e048fd51 | 274 | $(LINK_SO_DSO) |
e048fd51 | 275 | link_shlib.cygwin: |
bfa96bc2 RL |
276 | @ $(CALC_VERSIONS); \ |
277 | INHIBIT_SYMLINKS=yes; \ | |
5b50f99e | 278 | SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \ |
5b50f99e | 279 | dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \ |
7b866627 RL |
280 | echo "$(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name |" \ |
281 | "$(CROSS_COMPILE)windres $(SHARED_RCFLAGS) -o rc.o"; \ | |
1407f856 | 282 | $(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name | \ |
64c443e3 | 283 | $(CROSS_COMPILE)windres $(SHARED_RCFLAGS) -o rc.o; \ |
f968059c RL |
284 | ALLSYMSFLAGS='-Wl,--whole-archive'; \ |
285 | NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ | |
520f434b | 286 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,--enable-auto-image-base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a rc.o"; \ |
e048fd51 | 287 | $(LINK_SO_SHLIB) || exit 1; \ |
520f434b | 288 | rm rc.o |
2d3de726 | 289 | link_app.cygwin: |
2d3de726 | 290 | $(LINK_APP) |
30afcc07 | 291 | |
520f434b RL |
292 | # link_dso.mingw-shared and link_app.mingw-shared are mapped to the |
293 | # corresponding cygwin targets, as they do the exact same thing. | |
294 | link_shlib.mingw: | |
295 | @ $(CALC_VERSIONS); \ | |
296 | INHIBIT_SYMLINKS=yes; \ | |
297 | arch=; \ | |
298 | if expr $(PLATFORM) : mingw64 > /dev/null; then arch=-x64; fi; \ | |
299 | sover=`echo $(LIBVERSION) | sed -e 's/\./_/g'` ; \ | |
300 | SHLIB=lib$(LIBNAME); \ | |
301 | SHLIB_SOVER=-$$sover$$arch; \ | |
302 | SHLIB_SUFFIX=.dll; \ | |
303 | dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \ | |
464dadb2 | 304 | base=; [ $(LIBNAME) = "crypto" -a -n "$(FIPSCANLIB)" ] && base=-Wl,--image-base,0x63000000; \ |
520f434b RL |
305 | $(PERL) $(SRCDIR)/util/mkdef.pl 32 $(LIBNAME) \ |
306 | | sed -e 's|^\(LIBRARY *\)$(LIBNAME)32|\1'"$$dll_name"'|' \ | |
307 | > $(LIBNAME).def; \ | |
308 | echo "$(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name |" \ | |
309 | "$(CROSS_COMPILE)windres $(SHARED_RCFLAGS) -o rc.o"; \ | |
310 | $(PERL) $(SRCDIR)/util/mkrc.pl $$dll_name | \ | |
311 | $(CROSS_COMPILE)windres $(SHARED_RCFLAGS) -o rc.o; \ | |
312 | ALLSYMSFLAGS='-Wl,--whole-archive'; \ | |
313 | NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \ | |
314 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $(LIBNAME).def rc.o"; \ | |
315 | $(LINK_SO_SHLIB) || exit 1; \ | |
316 | rm $(LIBNAME).def rc.o | |
317 | ||
e048fd51 | 318 | link_dso.alpha-osf1: |
a370537b | 319 | @ if $(DETECT_GNU_LD); then \ |
35b3a614 | 320 | $(DO_GNU_DSO); \ |
30afcc07 | 321 | else \ |
9ee0ed3d | 322 | SHLIB=$(LIBNAME).so; \ |
f968059c | 323 | SHLIB_SUFFIX=; \ |
35b3a614 RL |
324 | ALLSYMSFLAGS=''; \ |
325 | NOALLSYMSFLAGS=''; \ | |
ae4eb3c9 | 326 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \ |
12fd8be2 | 327 | fi; \ |
e048fd51 RL |
328 | $(LINK_SO_DSO) |
329 | link_shlib.alpha-osf1: | |
a370537b | 330 | @ if $(DETECT_GNU_LD); then \ |
2d3de726 | 331 | $(DO_GNU_SO); \ |
30afcc07 | 332 | else \ |
f968059c RL |
333 | SHLIB=lib$(LIBNAME).so; \ |
334 | SHLIB_SUFFIX=; \ | |
30afcc07 RL |
335 | SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \ |
336 | if [ -n "$$SHLIB_HIST" ]; then \ | |
337 | SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \ | |
338 | else \ | |
339 | SHLIB_HIST="$(LIBVERSION)"; \ | |
62966f38 | 340 | fi; \ |
f968059c RL |
341 | SHLIB_SOVER=; \ |
342 | ALLSYMSFLAGS='-all'; \ | |
343 | NOALLSYMSFLAGS='-none'; \ | |
ae4eb3c9 | 344 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \ |
36757b44 | 345 | if [ -n "$$SHLIB_HIST" ]; then \ |
9ab51701 | 346 | SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \ |
36757b44 | 347 | fi; \ |
12fd8be2 | 348 | fi; \ |
e048fd51 | 349 | $(LINK_SO_SHLIB) |
2d3de726 | 350 | link_app.alpha-osf1: |
a370537b | 351 | @if $(DETECT_GNU_LD); then \ |
2d3de726 RL |
352 | $(DO_GNU_APP); \ |
353 | else \ | |
c86ddbe6 | 354 | LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \ |
2d3de726 RL |
355 | fi; \ |
356 | $(LINK_APP) | |
30afcc07 | 357 | |
e048fd51 | 358 | link_dso.solaris: |
a370537b | 359 | @ if $(DETECT_GNU_LD); then \ |
35b3a614 | 360 | $(DO_GNU_DSO); \ |
30afcc07 RL |
361 | else \ |
362 | $(CALC_VERSIONS); \ | |
37529928 | 363 | SHLIB=$(LIBNAME).so; \ |
f968059c | 364 | SHLIB_SUFFIX=; \ |
35b3a614 RL |
365 | ALLSYMSFLAGS=""; \ |
366 | NOALLSYMSFLAGS=""; \ | |
f210eb7b | 367 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \ |
12fd8be2 | 368 | fi; \ |
e048fd51 RL |
369 | $(LINK_SO_DSO) |
370 | link_shlib.solaris: | |
a370537b | 371 | @ if $(DETECT_GNU_LD); then \ |
2d3de726 | 372 | $(DO_GNU_SO); \ |
30afcc07 RL |
373 | else \ |
374 | $(CALC_VERSIONS); \ | |
f968059c RL |
375 | SHLIB=lib$(LIBNAME).so; \ |
376 | SHLIB_SUFFIX=;\ | |
24e75727 RL |
377 | $(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \ |
378 | ALLSYMSFLAGS="-Wl,-z,allextract,-M,$(LIBNAME).map"; \ | |
4ad38641 | 379 | NOALLSYMSFLAGS="-Wl,-z,defaultextract"; \ |
f210eb7b | 380 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \ |
12fd8be2 | 381 | fi; \ |
e048fd51 | 382 | $(LINK_SO_SHLIB) |
2d3de726 | 383 | link_app.solaris: |
a370537b | 384 | @ if $(DETECT_GNU_LD); then \ |
2d3de726 RL |
385 | $(DO_GNU_APP); \ |
386 | else \ | |
c86ddbe6 | 387 | LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \ |
2d3de726 RL |
388 | fi; \ |
389 | $(LINK_APP) | |
30afcc07 RL |
390 | |
391 | # OpenServer 5 native compilers used | |
e048fd51 | 392 | link_dso.svr3: |
a370537b | 393 | @ if $(DETECT_GNU_LD); then \ |
35b3a614 | 394 | $(DO_GNU_DSO); \ |
a1092201 RL |
395 | else \ |
396 | $(CALC_VERSIONS); \ | |
9ee0ed3d | 397 | SHLIB=$(LIBNAME).so; \ |
a1092201 | 398 | SHLIB_SUFFIX=; \ |
a1092201 RL |
399 | ALLSYMSFLAGS=''; \ |
400 | NOALLSYMSFLAGS=''; \ | |
e048fd51 | 401 | SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SUFFIX"; \ |
a1092201 | 402 | fi; \ |
e048fd51 RL |
403 | $(LINK_SO_DSO) |
404 | link_shlib.svr3: | |
a370537b | 405 | @ if $(DETECT_GNU_LD); then \ |
a1092201 RL |
406 | $(DO_GNU_SO); \ |
407 | else \ | |
408 | $(CALC_VERSIONS); \ | |
409 | SHLIB=lib$(LIBNAME).so; \ | |
410 | SHLIB_SUFFIX=; \ | |
a1092201 RL |
411 | ALLSYMSFLAGS=''; \ |
412 | NOALLSYMSFLAGS=''; \ | |
4aca9297 | 413 | SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \ |
a1092201 | 414 | fi; \ |
e048fd51 | 415 | $(LINK_SO_SHLIB_UNPACKED) |
a1092201 | 416 | link_app.svr3: |
a370537b | 417 | @$(DETECT_GNU_LD) && $(DO_GNU_APP); \ |
a1092201 RL |
418 | $(LINK_APP) |
419 | ||
420 | # UnixWare 7 and OpenUNIX 8 native compilers used | |
e048fd51 | 421 | link_dso.svr5: |
a370537b | 422 | @ if $(DETECT_GNU_LD); then \ |
35b3a614 | 423 | $(DO_GNU_DSO); \ |
30afcc07 | 424 | else \ |
24692fc5 | 425 | SHARE_FLAG='-G'; \ |
f210eb7b | 426 | ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \ |
9ee0ed3d | 427 | SHLIB=$(LIBNAME).so; \ |
f968059c | 428 | SHLIB_SUFFIX=; \ |
e96133e4 | 429 | ALLSYMSFLAGS=''; \ |
f968059c | 430 | NOALLSYMSFLAGS=''; \ |
e048fd51 | 431 | SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SUFFIX"; \ |
12fd8be2 | 432 | fi; \ |
e048fd51 RL |
433 | $(LINK_SO_DSO) |
434 | link_shlib.svr5: | |
a370537b | 435 | @ if $(DETECT_GNU_LD); then \ |
2d3de726 | 436 | $(DO_GNU_SO); \ |
30afcc07 RL |
437 | else \ |
438 | $(CALC_VERSIONS); \ | |
24692fc5 | 439 | SHARE_FLAG='-G'; \ |
a370537b | 440 | ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \ |
f968059c RL |
441 | SHLIB=lib$(LIBNAME).so; \ |
442 | SHLIB_SUFFIX=; \ | |
e96133e4 | 443 | ALLSYMSFLAGS=''; \ |
f968059c | 444 | NOALLSYMSFLAGS=''; \ |
4aca9297 | 445 | SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \ |
12fd8be2 | 446 | fi; \ |
e048fd51 | 447 | $(LINK_SO_SHLIB_UNPACKED) |
a1092201 | 448 | link_app.svr5: |
a370537b | 449 | @$(DETECT_GNU_LD) && $(DO_GNU_APP); \ |
2d3de726 | 450 | $(LINK_APP) |
30afcc07 | 451 | |
e048fd51 | 452 | link_dso.irix: |
a370537b | 453 | @ if $(DETECT_GNU_LD); then \ |
35b3a614 | 454 | $(DO_GNU_DSO); \ |
30afcc07 | 455 | else \ |
9ee0ed3d | 456 | SHLIB=$(LIBNAME).so; \ |
f968059c | 457 | SHLIB_SUFFIX=; \ |
35b3a614 RL |
458 | ALLSYMSFLAGS=""; \ |
459 | NOALLSYMSFLAGS=""; \ | |
e048fd51 | 460 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SUFFIX,-B,symbolic"; \ |
12fd8be2 | 461 | fi; \ |
e048fd51 RL |
462 | $(LINK_SO_DSO) |
463 | link_shlib.irix: | |
a370537b | 464 | @ if $(DETECT_GNU_LD); then \ |
2d3de726 | 465 | $(DO_GNU_SO); \ |
30afcc07 RL |
466 | else \ |
467 | $(CALC_VERSIONS); \ | |
f968059c RL |
468 | SHLIB=lib$(LIBNAME).so; \ |
469 | SHLIB_SUFFIX=; \ | |
30fbcaa2 AP |
470 | MINUSWL=""; \ |
471 | ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \ | |
472 | ALLSYMSFLAGS="$${MINUSWL}-all"; \ | |
bd16cd6b | 473 | NOALLSYMSFLAGS="$${MINUSWL}-none"; \ |
ae4eb3c9 | 474 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \ |
12fd8be2 | 475 | fi; \ |
e048fd51 | 476 | $(LINK_SO_SHLIB) |
2d3de726 | 477 | link_app.irix: |
c86ddbe6 | 478 | @LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"; \ |
2d3de726 | 479 | $(LINK_APP) |
30afcc07 | 480 | |
393b704d AP |
481 | # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so |
482 | # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite | |
483 | # rules imply that we can only link one level down in catalog structure, | |
484 | # but that's what takes place for the moment of this writing. +cdp option | |
485 | # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link | |
486 | # editor context only [it's simply ignored in other cases, which are all | |
487 | # ELFs by the way]. | |
30afcc07 | 488 | # |
e048fd51 | 489 | link_dso.hpux: |
35b3a614 | 490 | @if $(DETECT_GNU_LD); then $(DO_GNU_DSO); else \ |
9ee0ed3d | 491 | SHLIB=$(LIBNAME).sl; \ |
d784bcff | 492 | expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=$(LIBNAME).so; \ |
f968059c | 493 | SHLIB_SUFFIX=; \ |
35b3a614 | 494 | ALLSYMSFLAGS=''; \ |
f968059c | 495 | NOALLSYMSFLAGS=''; \ |
1a83c372 | 496 | expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \ |
e048fd51 | 497 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \ |
15fd2de3 | 498 | fi; \ |
e048fd51 RL |
499 | rm -f $$SHLIB$$SHLIB_SUFFIX || :; \ |
500 | $(LINK_SO_DSO) && chmod a=rx $$SHLIB$$SHLIB_SUFFIX | |
501 | link_shlib.hpux: | |
a370537b | 502 | @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \ |
15fd2de3 | 503 | $(CALC_VERSIONS); \ |
f968059c | 504 | SHLIB=lib$(LIBNAME).sl; \ |
86119343 | 505 | expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \ |
f968059c | 506 | SHLIB_SUFFIX=; \ |
2bbc970e | 507 | ALLSYMSFLAGS='-Wl,-Fl'; \ |
f968059c | 508 | NOALLSYMSFLAGS=''; \ |
1a83c372 | 509 | expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \ |
7df4c86b | 510 | SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \ |
15fd2de3 | 511 | fi; \ |
a41b0aad | 512 | rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \ |
e048fd51 | 513 | $(LINK_SO_SHLIB) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX |
1a83c372 | 514 | link_app.hpux: |
a370537b | 515 | @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \ |
c86ddbe6 | 516 | LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \ |
15fd2de3 | 517 | fi; \ |
2d3de726 | 518 | $(LINK_APP) |
30afcc07 | 519 | |
e048fd51 RL |
520 | link_dso.aix: |
521 | @OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \ | |
fe28866d | 522 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ |
9ee0ed3d | 523 | SHLIB=$(LIBNAME).so; \ |
f968059c | 524 | SHLIB_SUFFIX=; \ |
0d1aa74d | 525 | ALLSYMSFLAGS=''; \ |
f968059c | 526 | NOALLSYMSFLAGS=''; \ |
492279f6 | 527 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \ |
e048fd51 RL |
528 | $(LINK_SO_DSO); |
529 | link_shlib.aix: | |
30afcc07 | 530 | @ $(CALC_VERSIONS); \ |
492279f6 | 531 | OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \ |
fe28866d | 532 | OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \ |
f968059c RL |
533 | SHLIB=lib$(LIBNAME).so; \ |
534 | SHLIB_SUFFIX=; \ | |
f968059c RL |
535 | ALLSYMSFLAGS='-bnogc'; \ |
536 | NOALLSYMSFLAGS=''; \ | |
492279f6 | 537 | SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \ |
e048fd51 | 538 | $(LINK_SO_SHLIB_VIA_O) |
2d3de726 | 539 | link_app.aix: |
c86ddbe6 | 540 | LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \ |
2d3de726 | 541 | $(LINK_APP) |
30afcc07 | 542 | |
30afcc07 RL |
543 | |
544 | # Targets to build symbolic links when needed | |
a1092201 | 545 | symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \ |
6c23ca0c | 546 | symlink.aix: |
30afcc07 | 547 | @ $(CALC_VERSIONS); \ |
bfa96bc2 | 548 | SHLIB=lib$(LIBNAME).so; \ |
30afcc07 | 549 | $(SYMLINK_SO) |
83699c47 RL |
550 | symlink.darwin: |
551 | @ $(CALC_VERSIONS); \ | |
f968059c | 552 | SHLIB=lib$(LIBNAME); \ |
bfa96bc2 | 553 | SHLIB_SUFFIX=.dylib; \ |
83699c47 | 554 | $(SYMLINK_SO) |
1a83c372 | 555 | symlink.hpux: |
30afcc07 | 556 | @ $(CALC_VERSIONS); \ |
bfa96bc2 | 557 | SHLIB=lib$(LIBNAME).sl; \ |
86119343 | 558 | expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \ |
30afcc07 | 559 | $(SYMLINK_SO) |
bfa96bc2 | 560 | # The following lines means those specific architectures do no symlinks |
fcf64ba0 | 561 | symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath: |
30afcc07 RL |
562 | |
563 | # Compatibility targets | |
6e08e9e7 | 564 | link_dso.bsd-gcc-shared link_dso.linux-shared link_dso.gnu-shared link_dso.haiku-shared: link_dso.gnu |
150a4790 | 565 | link_shlib.bsd-gcc-shared: link_shlib.linux-shared |
6e08e9e7 JD |
566 | link_shlib.gnu-shared link_shlib.haiku-shared: link_shlib.gnu |
567 | link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared link_app.haiku-shared: link_app.gnu | |
568 | symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared symlink.haiku-shared: symlink.gnu | |
e048fd51 RL |
569 | link_dso.bsd-shared: link_dso.bsd |
570 | link_shlib.bsd-shared: link_shlib.bsd | |
16760a30 | 571 | link_app.bsd-shared: link_app.bsd |
e048fd51 RL |
572 | link_dso.darwin-shared: link_dso.darwin |
573 | link_shlib.darwin-shared: link_shlib.darwin | |
2d3de726 | 574 | link_app.darwin-shared: link_app.darwin |
30afcc07 | 575 | symlink.darwin-shared: symlink.darwin |
e048fd51 RL |
576 | link_dso.cygwin-shared: link_dso.cygwin |
577 | link_shlib.cygwin-shared: link_shlib.cygwin | |
2d3de726 | 578 | link_app.cygwin-shared: link_app.cygwin |
30afcc07 | 579 | symlink.cygwin-shared: symlink.cygwin |
520f434b RL |
580 | link_dso.mingw-shared: link_dso.cygwin |
581 | link_shlib.mingw-shared: link_shlib.mingw | |
582 | link_app.mingw-shared: link_app.cygwin | |
583 | symlink.mingw-shared: symlink.cygwin | |
e048fd51 RL |
584 | link_dso.alpha-osf1-shared: link_dso.alpha-osf1 |
585 | link_shlib.alpha-osf1-shared: link_shlib.alpha-osf1 | |
2d3de726 | 586 | link_app.alpha-osf1-shared: link_app.alpha-osf1 |
30afcc07 | 587 | symlink.alpha-osf1-shared: symlink.alpha-osf1 |
e048fd51 RL |
588 | link_dso.tru64-shared: link_dso.tru64 |
589 | link_shlib.tru64-shared: link_shlib.tru64 | |
2d3de726 | 590 | link_app.tru64-shared: link_app.tru64 |
30afcc07 | 591 | symlink.tru64-shared: symlink.tru64 |
e048fd51 RL |
592 | link_dso.tru64-shared-rpath: link_dso.tru64-rpath |
593 | link_shlib.tru64-shared-rpath: link_shlib.tru64-rpath | |
2d3de726 | 594 | link_app.tru64-shared-rpath: link_app.tru64-rpath |
30afcc07 | 595 | symlink.tru64-shared-rpath: symlink.tru64-rpath |
e048fd51 RL |
596 | link_dso.solaris-shared: link_dso.solaris |
597 | link_shlib.solaris-shared: link_shlib.solaris | |
2d3de726 | 598 | link_app.solaris-shared: link_app.solaris |
30afcc07 | 599 | symlink.solaris-shared: symlink.solaris |
e048fd51 RL |
600 | link_dso.svr3-shared: link_dso.svr3 |
601 | link_shlib.svr3-shared: link_shlib.svr3 | |
2d3de726 | 602 | link_app.svr3-shared: link_app.svr3 |
30afcc07 | 603 | symlink.svr3-shared: symlink.svr3 |
e048fd51 RL |
604 | link_dso.svr5-shared: link_dso.svr5 |
605 | link_shlib.svr5-shared: link_shlib.svr5 | |
a1092201 RL |
606 | link_app.svr5-shared: link_app.svr5 |
607 | symlink.svr5-shared: symlink.svr5 | |
e048fd51 RL |
608 | link_dso.irix-shared: link_dso.irix |
609 | link_shlib.irix-shared: link_shlib.irix | |
2d3de726 | 610 | link_app.irix-shared: link_app.irix |
30afcc07 | 611 | symlink.irix-shared: symlink.irix |
e048fd51 RL |
612 | link_dso.hpux-shared: link_dso.hpux |
613 | link_shlib.hpux-shared: link_shlib.hpux | |
1a83c372 AP |
614 | link_app.hpux-shared: link_app.hpux |
615 | symlink.hpux-shared: symlink.hpux | |
e048fd51 RL |
616 | link_dso.aix-shared: link_dso.aix |
617 | link_shlib.aix-shared: link_shlib.aix | |
2d3de726 | 618 | link_app.aix-shared: link_app.aix |
30afcc07 | 619 | symlink.aix-shared: symlink.aix |