Annotation of src/share/mk/bsd.lib.mk, Revision 1.206
1.206 ! thorpej 1: # $NetBSD: bsd.lib.mk,v 1.205 2002/07/20 08:50:10 yamt Exp $
1.92 mikel 2: # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
1.1 cgd 3:
1.188 tv 4: .include <bsd.init.mk>
1.97 mycroft 5:
1.188 tv 6: ##### Basic targets
1.143 erh 7: .PHONY: checkver cleanlib libinstall
8: realinstall: checkver libinstall
1.183 tv 9: clean: cleanlib
1.1 cgd 10:
1.188 tv 11: ##### Build and install rules
1.192 thorpej 12: CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.194 tv 13: CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++}
1.190 tv 14:
1.184 tv 15: .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})
1.154 simonb 16: SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
17: SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
1.171 christos 18: SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
1.143 erh 19:
20: # Check for higher installed library versions.
1.145 erh 21: .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
1.201 lukem 22: exists(${NETBSDSRCDIR}/lib/checkver)
1.143 erh 23: checkver:
1.144 erh 24: @(cd ${.CURDIR} && \
1.201 lukem 25: sh ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \
1.195 lukem 26: -d ${DESTDIR}${_LIBSODIR} ${LIB})
1.173 christos 27: .endif
28: .endif
29:
30: .if !target(checkver)
1.143 erh 31: checkver:
32: .endif
1.173 christos 33:
1.169 thorpej 34: print-shlib-major:
1.185 tv 35: .if defined(SHLIB_MAJOR) && ${MKPIC} != "no"
1.169 thorpej 36: @echo ${SHLIB_MAJOR}
1.173 christos 37: .else
38: @false
39: .endif
1.169 thorpej 40:
41: print-shlib-minor:
1.185 tv 42: .if defined(SHLIB_MINOR) && ${MKPIC} != "no"
1.169 thorpej 43: @echo ${SHLIB_MINOR}
1.173 christos 44: .else
45: @false
46: .endif
1.171 christos 47:
48: print-shlib-teeny:
1.185 tv 49: .if defined(SHLIB_TEENY) && ${MKPIC} != "no"
1.171 christos 50: @echo ${SHLIB_TEENY}
1.143 erh 51: .else
1.169 thorpej 52: @false
1.173 christos 53: .endif
1.169 thorpej 54:
1.173 christos 55: .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)
56: .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
57: .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
58: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY}
59: .else
60: SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
61: .endif
62: .else
63: SHLIB_FULLVERSION=${SHLIB_MAJOR}
64: .endif
1.35 pk 65: .endif
1.1 cgd 66:
1.101 mycroft 67: # add additional suffixes not exported.
68: # .po is used for profiling object files.
69: # .so is used for PIC object files.
1.118 lukem 70: .SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
71: .SUFFIXES: .sh .m4 .m
1.82 mikel 72:
1.86 jonathan 73:
74: # Set PICFLAGS to cc flags for producing position-independent code,
75: # if not already set. Includes -DPIC, if required.
76:
1.164 simonb 77: # Data-driven table using make variables to control how shared libraries
1.86 jonathan 78: # are built for different platforms and object formats.
1.125 jonathan 79: # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
1.164 simonb 80: # SHLIB_SOVERSION: version number to be compiled into a shared library
81: # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
1.173 christos 82: # NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
83: # [.${SHLIB_TEENY}]]
1.164 simonb 84: # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
1.123 jonathan 85: # with ELF, also set shared-lib version for ld.so.
86: # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
87: # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
1.179 dmcmahil 88: # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
1.164 simonb 89: # CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
1.205 yamt 90: # CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects.
91: # CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
92: # (usually includes ${CPICFLAGS})
93: # CAPICFLAGS: flags for ${CC} to compiling .[Ss] files
1.107 jonathan 94: # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
1.164 simonb 95: # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
1.86 jonathan 96:
1.148 lukem 97: .if ${MACHINE_ARCH} == "alpha"
1.123 jonathan 98: # Alpha-specific shared library flags
1.179 dmcmahil 99: FPICFLAGS ?= -fPIC
1.165 dmcmahil 100: CPICFLAGS ?= -fPIC -DPIC
1.107 jonathan 101: CPPPICFLAGS?= -DPIC
102: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
103: APICFLAGS ?=
1.151 drochner 104: .elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
1.123 jonathan 105: # mips-specific shared library flags
1.86 jonathan 106:
1.160 simonb 107: # On mips, all libs are compiled with ABIcalls, not just sharedlibs.
108: MKPICLIB= no
109:
110: # so turn shlib PIC flags on for ${AS}.
111: AINC+=-DABICALLS
1.86 jonathan 112: AFLAGS+= -fPIC
113: AS+= -KPIC
1.172 matt 114:
115: .elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
116: # On the VAX, all object are PIC by default, not just sharedlibs.
117: MKPICLIB= no
1.150 christos 118:
1.175 mrg 119: .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
120: ${OBJECT_FMT} == "ELF"
1.202 eeh 121: # If you use -fPIC you need to define BIGPIC to turn on 32-bit
122: # relocations in asm code
1.179 dmcmahil 123: FPICFLAGS ?= -fPIC
1.165 dmcmahil 124: CPICFLAGS ?= -fPIC -DPIC
1.202 eeh 125: CPPPICFLAGS?= -DPIC -DBIGPIC
1.150 christos 126: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
1.203 eeh 127: APICFLAGS ?= -KPIC
1.204 fredette 128:
129: .elif ${MACHINE_ARCH} == "hppa"
130:
131: FPICFLAGS ?= -fPIC
132: CPICFLAGS?= -fPIC -DPIC
133: CPPPICFLAGS?= -DPIC
134: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
135: APICFLAGS?= -k
136: # XXX libraries often need the millicode functions in libgcc.a,
137: # so we have to work around the -nostdlib:
138: LDADD+= `$(CC) -print-libgcc-file-name`
1.86 jonathan 139:
140: .else
141:
1.187 nathanw 142: # Platform-independent flags for NetBSD a.out shared libraries
1.171 christos 143: SHLIB_SOVERSION=${SHLIB_FULLVERSION}
1.125 jonathan 144: SHLIB_SHFLAGS=
1.179 dmcmahil 145: FPICFLAGS ?= -fPIC
1.165 dmcmahil 146: CPICFLAGS?= -fPIC -DPIC
1.107 jonathan 147: CPPPICFLAGS?= -DPIC
148: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
149: APICFLAGS?= -k
1.86 jonathan 150:
151: .endif
152:
1.160 simonb 153: MKPICLIB?= yes
154:
1.205 yamt 155: .if ${MKPICLIB} != "no"
156: CSHLIBFLAGS+= ${CPICFLAGS}
157: .endif
158:
159: .if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
160: MKSHLIBOBJS= yes
161: .else
162: MKSHLIBOBJS= no
163: .endif
164:
1.123 jonathan 165: # Platform-independent linker flags for ELF shared libraries
1.148 lukem 166: .if ${OBJECT_FMT} == "ELF"
1.182 mrg 167: SHLIB_SOVERSION= ${SHLIB_MAJOR}
168: SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
169: SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crtbeginS.o
170: SHLIB_LDENDFILE?= ${DESTDIR}/usr/lib/crtendS.o
1.123 jonathan 171: .endif
1.86 jonathan 172:
1.82 mikel 173: CFLAGS+= ${COPTS}
1.179 dmcmahil 174: FFLAGS+= ${FOPTS}
1.1 cgd 175:
176: .c.o:
1.153 christos 177: .if defined(COPTS) && !empty(COPTS:M*-g*)
178: ${COMPILE.c} ${.IMPSRC}
179: .else
1.80 christos 180: @echo ${COMPILE.c:Q} ${.IMPSRC}
1.122 cgd 181: @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 182: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
183: @rm -f ${.TARGET}.o
1.153 christos 184: .endif
1.1 cgd 185:
186: .c.po:
1.153 christos 187: .if defined(COPTS) && !empty(COPTS:M*-g*)
188: ${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}
189: .else
1.80 christos 190: @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 191: @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 192: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
193: @rm -f ${.TARGET}.o
1.153 christos 194: .endif
1.17 mycroft 195:
1.27 pk 196: .c.so:
1.153 christos 197: .if defined(COPTS) && !empty(COPTS:M*-g*)
1.205 yamt 198: ${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.153 christos 199: .else
1.205 yamt 200: @echo ${COMPILE.c:Q} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
201: @${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 202: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
203: @rm -f ${.TARGET}.o
1.153 christos 204: .endif
1.27 pk 205:
1.58 cgd 206: .c.ln:
1.121 thorpej 207: ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.58 cgd 208:
1.18 mycroft 209: .cc.o .C.o:
1.153 christos 210: .if defined(COPTS) && !empty(COPTS:M*-g*)
211: ${COMPILE.cc} ${.IMPSRC}
212: .else
1.80 christos 213: @echo ${COMPILE.cc:Q} ${.IMPSRC}
1.62 christos 214: @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
1.63 jtc 215: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
1.62 christos 216: @rm -f ${.TARGET}.o
1.153 christos 217: .endif
1.17 mycroft 218:
1.18 mycroft 219: .cc.po .C.po:
1.153 christos 220: .if defined(COPTS) && !empty(COPTS:M*-g*)
221: ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
222: .else
1.80 christos 223: @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 224: @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 225: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
226: @rm -f ${.TARGET}.o
1.153 christos 227: .endif
1.28 cgd 228:
229: .cc.so .C.so:
1.153 christos 230: .if defined(COPTS) && !empty(COPTS:M*-g*)
1.205 yamt 231: ${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.153 christos 232: .else
1.86 jonathan 233: @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
1.205 yamt 234: @${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 235: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
236: @rm -f ${.TARGET}.o
1.153 christos 237: .endif
1.118 lukem 238:
1.179 dmcmahil 239: .f.o:
240: .if defined(FOPTS) && !empty(FOPTS:M*-g*)
241: ${COMPILE.f} ${.IMPSRC}
242: .else
243: @echo ${COMPILE.f:Q} ${.IMPSRC}
244: @${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.o
245: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
246: @rm -f ${.TARGET}.o
247: .endif
248:
249: .f.po:
250: .if defined(FOPTS) && !empty(FOPTS:M*-g*)
251: ${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}
252: .else
253: @echo ${COMPILE.f:Q} -pg ${.IMPSRC} -o ${.TARGET}
254: @${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}.o
255: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
256: @rm -f ${.TARGET}.o
257: .endif
258:
259: .f.so:
260: .if defined(FOPTS) && !empty(FOPTS:M*-g*)
261: ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
262: .else
263: @echo ${COMPILE.f:Q} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}
264: @${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
265: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
266: @rm -f ${.TARGET}.o
267: .endif
268:
269: .f.ln:
270: ${ECHO} Skipping lint for Fortran libraries.
271:
1.118 lukem 272: .m.o:
1.153 christos 273: .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
274: ${COMPILE.m} ${.IMPSRC}
275: .else
1.118 lukem 276: @echo ${COMPILE.m:Q} ${.IMPSRC}
1.122 cgd 277: @${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o
1.118 lukem 278: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
279: @rm -f ${.TARGET}.o
1.153 christos 280: .endif
1.118 lukem 281:
282: .m.po:
1.153 christos 283: .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
284: ${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}
285: .else
1.118 lukem 286: @echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
287: @${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
288: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
289: @rm -f ${.TARGET}.o
1.153 christos 290: .endif
1.118 lukem 291:
292: .m.so:
1.153 christos 293: .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*)
1.205 yamt 294: ${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}
1.153 christos 295: .else
1.118 lukem 296: @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
1.205 yamt 297: @${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.118 lukem 298: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
299: @rm -f ${.TARGET}.o
1.153 christos 300: .endif
1.1 cgd 301:
1.40 cgd 302: .S.o .s.o:
1.80 christos 303: @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.69 jtc 304: @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 305: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
306: @rm -f ${.TARGET}.o
1.1 cgd 307:
1.40 cgd 308: .S.po .s.po:
1.80 christos 309: @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.75 jtc 310: @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 311: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
312: @rm -f ${.TARGET}.o
1.1 cgd 313:
1.40 cgd 314: .S.so .s.so:
1.107 jonathan 315: @echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
316: @${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 317: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
318: @rm -f ${.TARGET}.o
1.27 pk 319:
1.148 lukem 320: .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
321: || ${MKLINKLIB} != "no"
1.130 tv 322: _LIBS=lib${LIB}.a
323: .else
324: _LIBS=
325: .endif
1.58 cgd 326:
1.167 matt 327: OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.158 christos 328:
1.149 lukem 329: .if ${MKPROFILE} != "no"
1.130 tv 330: _LIBS+=lib${LIB}_p.a
1.167 matt 331: POBJS+=${OBJS:.o=.po}
1.1 cgd 332: .endif
333:
1.148 lukem 334: .if ${MKPIC} != "no"
1.160 simonb 335: .if ${MKPICLIB} == "no"
1.205 yamt 336: .if ${MKSHLIBOBJS} != "no"
337: # make _pic.a, which isn't really pic,
338: # since it's needed for making shared lib.
339: # but don't install it.
340: SOLIB=lib${LIB}_pic.a
341: SOBJS+=${OBJS:.o=.so}
342: .else
1.160 simonb 343: SOLIB=lib${LIB}.a
1.205 yamt 344: .endif
1.160 simonb 345: .else
346: SOLIB=lib${LIB}_pic.a
347: _LIBS+=${SOLIB}
1.167 matt 348: SOBJS+=${OBJS:.o=.so}
1.160 simonb 349: .endif
1.171 christos 350: .if defined(SHLIB_FULLVERSION)
351: _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION}
1.27 pk 352: .endif
1.35 pk 353: .endif
1.27 pk 354:
1.179 dmcmahil 355: LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
356: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
1.58 cgd 357: _LIBS+=llib-l${LIB}.ln
1.27 pk 358: .endif
359:
1.167 matt 360: .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \
361: || ${MKLINKLIB} != "no"
1.179 dmcmahil 362: ALLOBJS=${OBJS} ${POBJS} ${SOBJS}
1.167 matt 363: .else
1.179 dmcmahil 364: ALLOBJS=${POBJS} ${SOBJS}
365: .endif
366: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
367: ALLOBJS+=${LOBJS}
1.167 matt 368: .endif
1.186 tv 369:
1.191 tv 370: .NOPATH: ${ALLOBJS} ${_LIBS} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.158 christos 371:
1.162 mycroft 372: realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
1.1 cgd 373:
1.90 christos 374: __archivebuild: .USE
1.89 christos 375: @rm -f ${.TARGET}
1.138 tv 376: @${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1.89 christos 377: ${RANLIB} ${.TARGET}
378:
379: __archiveinstall: .USE
1.198 lukem 380: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.199 lukem 381: ${UPDATE:D:U-a "${RANLIB} -t"} ${.ALLSRC} ${.TARGET}
1.89 christos 382:
1.197 mycroft 383: __archivesymlinkpic: .USE
384: ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET}
385:
1.191 tv 386: DPSRCS+= ${SRCS:M*.[ly]:C/\..$/.c/}
1.186 tv 387: CLEANFILES+= ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
1.103 mycroft 388:
1.89 christos 389: lib${LIB}.a:: ${OBJS} __archivebuild
1.1 cgd 390: @echo building standard ${LIB} library
391:
1.89 christos 392: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1 cgd 393: @echo building profiled ${LIB} library
394:
1.89 christos 395: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27 pk 396: @echo building shared object ${LIB} library
397:
1.171 christos 398: lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} \
1.88 cgd 399: ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.171 christos 400: @echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
401: @rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
1.152 fair 402: .if defined(DESTDIR)
1.155 wrstuden 403: $(LD) -nostdlib -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
1.152 fair 404: ${SHLIB_LDSTARTFILE} \
1.160 simonb 405: --whole-archive ${SOLIB} \
1.170 erh 406: --no-whole-archive ${LDADD} \
1.195 lukem 407: -L${DESTDIR}${_LIBSODIR} -L${DESTDIR}${LIBDIR} \
408: -R${_LIBSODIR} -R${LIBDIR} \
1.152 fair 409: ${SHLIB_LDENDFILE}
410: .else
1.126 jonathan 411: $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
1.123 jonathan 412: ${SHLIB_LDSTARTFILE} \
1.160 simonb 413: --whole-archive ${SOLIB} --no-whole-archive ${LDADD} \
1.115 cjs 414: ${SHLIB_LDENDFILE}
1.152 fair 415: .endif
1.148 lukem 416: .if ${OBJECT_FMT} == "ELF"
1.196 lukem 417: # We don't use INSTALL_SYMLINK here because this is just
418: # happening inside the build directory/objdir. XXX Why does
419: # this spend so much effort on libraries that aren't live??? XXX
1.177 mycroft 420: ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
421: mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
422: ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
423: mv -f lib${LIB}.so.tmp lib${LIB}.so
1.133 tv 424: .endif
1.35 pk 425:
1.179 dmcmahil 426: .if !empty(LOBJS)
1.103 mycroft 427: LLIBS?= -lc
1.58 cgd 428: llib-l${LIB}.ln: ${LOBJS}
429: @echo building llib-l${LIB}.ln
430: @rm -f llib-l${LIB}.ln
1.206 ! thorpej 431: .if defined(DESTDIR)
! 432: @${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS}
! 433: .else
1.141 wrstuden 434: @${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.206 ! thorpej 435: .endif
1.179 dmcmahil 436: .endif
1.1 cgd 437:
1.81 cgd 438: cleanlib:
1.48 mycroft 439: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59 cgd 440: rm -f lib${LIB}.a ${OBJS}
441: rm -f lib${LIB}_p.a ${POBJS}
1.133 tv 442: rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.59 cgd 443: rm -f llib-l${LIB}.ln ${LOBJS}
1.1 cgd 444:
1.26 mycroft 445: .if defined(SRCS)
1.64 christos 446: afterdepend: .depend
1.1 cgd 447: @(TMP=/tmp/_depend$$$$; \
1.79 cgd 448: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58 cgd 449: < .depend > $$TMP; \
1.1 cgd 450: mv $$TMP .depend)
1.26 mycroft 451: .endif
1.1 cgd 452:
1.97 mycroft 453: .if !target(libinstall)
1.148 lukem 454: # Make sure it gets defined, in case MKPIC==no && MKLINKLIB==no
1.139 tv 455: libinstall::
456:
1.148 lukem 457: .if ${MKLINKLIB} != "no"
1.89 christos 458: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.168 mycroft 459: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.197 mycroft 460:
1.89 christos 461: .if !defined(UPDATE)
1.197 mycroft 462: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
463: ${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE
1.89 christos 464: .endif
1.197 mycroft 465: ${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall
466: .else
1.157 fredb 467: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a)
1.89 christos 468: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
469: .endif
470: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130 tv 471: .endif
1.197 mycroft 472: .endif
1.89 christos 473:
1.149 lukem 474: .if ${MKPROFILE} != "no"
1.89 christos 475: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.168 mycroft 476: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.197 mycroft 477:
1.89 christos 478: .if !defined(UPDATE)
1.197 mycroft 479: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
480: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE
1.32 pk 481: .endif
1.197 mycroft 482: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall
483: .else
1.157 fredb 484: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a)
1.89 christos 485: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
486: .endif
487: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
488: .endif
1.197 mycroft 489: .endif
1.89 christos 490:
1.149 lukem 491: .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no"
1.168 mycroft 492: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.160 simonb 493: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.197 mycroft 494:
1.89 christos 495: .if !defined(UPDATE)
1.197 mycroft 496: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
497: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE
1.89 christos 498: .endif
1.197 mycroft 499: .if ${MKPICLIB} == "no"
500: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic
501: .else
502: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall
503: .endif
504: .else
1.157 fredb 505: .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a)
1.89 christos 506: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33 pk 507: .endif
1.160 simonb 508: .if ${MKPICLIB} == "no"
1.197 mycroft 509: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic
1.160 simonb 510: .else
1.89 christos 511: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
1.160 simonb 512: .endif
1.89 christos 513: .endif
1.197 mycroft 514: .endif
1.89 christos 515:
1.171 christos 516: .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION)
1.195 lukem 517: libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
518: .PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 519:
1.89 christos 520: .if !defined(UPDATE)
1.197 mycroft 521: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
522: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE
1.89 christos 523: .endif
1.197 mycroft 524: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION}
525: .else
1.171 christos 526: .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION})
1.195 lukem 527: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE
1.89 christos 528: .endif
1.195 lukem 529: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION}
1.197 mycroft 530: .endif
1.188 tv 531: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
532: ${.ALLSRC} ${.TARGET}
1.195 lukem 533: .if ${_LIBSODIR} != ${LIBDIR}
534: ${INSTALL_SYMLINK} ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
535: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}
536: .endif
1.148 lukem 537: .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR)
1.195 lukem 538: /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR}
1.146 thorpej 539: .endif
1.148 lukem 540: .if ${OBJECT_FMT} == "ELF"
1.195 lukem 541: ${INSTALL_SYMLINK} lib${LIB}.so.${SHLIB_FULLVERSION} \
542: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR}
543: .if ${_LIBSODIR} != ${LIBDIR}
544: ${INSTALL_SYMLINK} ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.83 cgd 545: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
1.195 lukem 546: .endif
1.148 lukem 547: .if ${MKLINKLIB} != "no"
1.195 lukem 548: ${INSTALL_SYMLINK} lib${LIB}.so.${SHLIB_FULLVERSION} \
549: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so
550: .if ${_LIBSODIR} != ${LIBDIR}
551: ${INSTALL_SYMLINK} ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \
1.83 cgd 552: ${DESTDIR}${LIBDIR}/lib${LIB}.so
1.195 lukem 553: .endif
1.83 cgd 554: .endif
1.12 cgd 555: .endif
1.139 tv 556: .endif
1.89 christos 557:
1.179 dmcmahil 558: .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS)
1.89 christos 559: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.168 mycroft 560: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
1.197 mycroft 561:
1.89 christos 562: .if !defined(UPDATE)
1.197 mycroft 563: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
564: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE
1.89 christos 565: .endif
1.197 mycroft 566: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln
567: .else
1.157 fredb 568: .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln)
1.89 christos 569: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
570: .endif
1.95 mycroft 571: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.197 mycroft 572: .endif
1.188 tv 573: ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
574: ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
1.58 cgd 575: .endif
1.1 cgd 576: .endif
577:
1.188 tv 578: ##### Pull in related .mk logic
1.1 cgd 579: .include <bsd.man.mk>
1.57 jtc 580: .include <bsd.nls.mk>
1.91 christos 581: .include <bsd.files.mk>
1.89 christos 582: .include <bsd.inc.mk>
1.109 cjs 583: .include <bsd.links.mk>
1.24 mycroft 584: .include <bsd.dep.mk>
1.66 christos 585: .include <bsd.sys.mk>
1.117 mycroft 586:
1.188 tv 587: ${TARGETS}: # ensure existence
CVSweb <webmaster@jp.NetBSD.org>