Annotation of src/share/mk/bsd.lib.mk, Revision 1.145
1.145 ! erh 1: # $NetBSD: bsd.lib.mk,v 1.144 1998/11/12 05:39:45 erh Exp $
1.92 mikel 2: # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
1.1 cgd 3:
1.117 mycroft 4: .if !target(__initialized__)
5: __initialized__:
1.1 cgd 6: .if exists(${.CURDIR}/../Makefile.inc)
7: .include "${.CURDIR}/../Makefile.inc"
8: .endif
1.97 mycroft 9: .include <bsd.own.mk>
1.117 mycroft 10: .include <bsd.obj.mk>
11: .MAIN: all
12: .endif
1.97 mycroft 13:
1.143 erh 14: .PHONY: checkver cleanlib libinstall
15: realinstall: checkver libinstall
1.137 lukem 16: clean cleandir distclean: cleanlib
1.1 cgd 17:
1.35 pk 18: .if exists(${.CURDIR}/shlib_version)
1.37 cgd 19: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
20: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
1.143 erh 21:
22: # Check for higher installed library versions.
1.145 ! erh 23: .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
! 24: exists(${BSDSRCDIR}/lib/checkver)
1.143 erh 25: checkver:
1.144 erh 26: @(cd ${.CURDIR} && \
27: ${BSDSRCDIR}/lib/checkver -d ${DESTDIR}${LIBDIR} ${LIB})
1.143 erh 28: .else
29: checkver:
30: .endif
31: .else
32: checkver:
1.35 pk 33: .endif
1.1 cgd 34:
1.101 mycroft 35: # add additional suffixes not exported.
36: # .po is used for profiling object files.
37: # .so is used for PIC object files.
1.118 lukem 38: .SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
39: .SUFFIXES: .sh .m4 .m
1.82 mikel 40:
1.86 jonathan 41:
42: # Set PICFLAGS to cc flags for producing position-independent code,
43: # if not already set. Includes -DPIC, if required.
44:
45: # Data-driven table using make variables to control how shared libraries
46: # are built for different platforms and object formats.
1.125 jonathan 47: # OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
1.86 jonathan 48: # SHLIB_SOVERSION: version number to be compiled into a shared library
49: # via -soname. Usualy ${SHLIB_MAJOR} on ELF.
50: # NetBSD/pmax used to use ${SHLIB_MAJOR}.{SHLIB-MINOR}.
1.123 jonathan 51: # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
52: # with ELF, also set shared-lib version for ld.so.
53: # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
54: # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
1.107 jonathan 55: # CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
56: # CPICFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
57: # CAPICFLAGS flags for {$CC} to compiling .[Ss] files
58: # (usually just ${CPPPICFLAGS} ${CPICFLAGS})
59: # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
1.86 jonathan 60:
61: .if (${MACHINE_ARCH} == "alpha")
1.123 jonathan 62: # Alpha-specific shared library flags
1.86 jonathan 63: CPICFLAGS ?= -fpic -DPIC
1.107 jonathan 64: CPPPICFLAGS?= -DPIC
65: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
66: APICFLAGS ?=
1.86 jonathan 67: .elif (${MACHINE_ARCH} == "mips")
1.123 jonathan 68: # mips-specific shared library flags
1.86 jonathan 69:
70: # On mips, all libs need to be compiled with ABIcalls, not just sharedlibs.
71: CPICFLAGS?=
72: APICFLAGS?=
73: #CPICFLAGS?= -fpic -DPIC
74: #APICFLAGS?= -DPIC
75:
76: # so turn shlib PIC flags on for ${CPP}, ${CC}, and ${AS} as follows:
77: AINC+=-DPIC -DABICALLS
78: COPTS+= -fPIC ${AINC}
79: AFLAGS+= -fPIC
80: AS+= -KPIC
81:
82: .else
83:
1.125 jonathan 84: # Platform-independent flags for NetBSD a.out shared libraries (and PowerPC)
1.88 cgd 85: SHLIB_LDSTARTFILE=
86: SHLIB_LDENDFILE=
1.125 jonathan 87: SHLIB_SHFLAGS=
1.86 jonathan 88: SHLIB_SOVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}
1.116 pk 89: CPICFLAGS?= -fpic -DPIC
1.107 jonathan 90: CPPPICFLAGS?= -DPIC
91: CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
92: APICFLAGS?= -k
1.86 jonathan 93:
94: .endif
95:
1.123 jonathan 96: # Platform-independent linker flags for ELF shared libraries
1.125 jonathan 97: .if (${OBJECT_FMT} == "ELF")
1.123 jonathan 98: SHLIB_SOVERSION=${SHLIB_MAJOR}
1.125 jonathan 99: SHLIB_SHFLAGS=-soname lib${LIB}.so.${SHLIB_SOVERSION}
1.142 jonathan 100: SHLIB_LDSTARTFILE= ${DESTDIR}/usr/lib/crtbeginS.o
101: SHLIB_LDENDFILE= ${DESTDIR}/usr/lib/crtendS.o
1.123 jonathan 102: .endif
1.86 jonathan 103:
1.82 mikel 104: CFLAGS+= ${COPTS}
1.1 cgd 105:
106: .c.o:
1.80 christos 107: @echo ${COMPILE.c:Q} ${.IMPSRC}
1.122 cgd 108: @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 109: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
110: @rm -f ${.TARGET}.o
1.1 cgd 111:
112: .c.po:
1.80 christos 113: @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 114: @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 115: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
116: @rm -f ${.TARGET}.o
1.17 mycroft 117:
1.27 pk 118: .c.so:
1.86 jonathan 119: @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
120: @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 121: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
122: @rm -f ${.TARGET}.o
1.27 pk 123:
1.58 cgd 124: .c.ln:
1.121 thorpej 125: ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
1.58 cgd 126:
1.18 mycroft 127: .cc.o .C.o:
1.80 christos 128: @echo ${COMPILE.cc:Q} ${.IMPSRC}
1.62 christos 129: @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
1.63 jtc 130: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
1.62 christos 131: @rm -f ${.TARGET}.o
1.17 mycroft 132:
1.18 mycroft 133: .cc.po .C.po:
1.80 christos 134: @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 135: @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 136: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
137: @rm -f ${.TARGET}.o
1.28 cgd 138:
139: .cc.so .C.so:
1.86 jonathan 140: @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
141: @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 142: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
143: @rm -f ${.TARGET}.o
1.118 lukem 144:
145: .m.o:
146: @echo ${COMPILE.m:Q} ${.IMPSRC}
1.122 cgd 147: @${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o
1.118 lukem 148: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
149: @rm -f ${.TARGET}.o
150:
151: .m.po:
152: @echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
153: @${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
154: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
155: @rm -f ${.TARGET}.o
156:
157: .m.so:
158: @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
159: @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
160: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
161: @rm -f ${.TARGET}.o
1.1 cgd 162:
1.40 cgd 163: .S.o .s.o:
1.80 christos 164: @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.69 jtc 165: @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 166: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
167: @rm -f ${.TARGET}.o
1.1 cgd 168:
1.40 cgd 169: .S.po .s.po:
1.80 christos 170: @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.75 jtc 171: @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 172: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
173: @rm -f ${.TARGET}.o
1.1 cgd 174:
1.40 cgd 175: .S.so .s.so:
1.107 jonathan 176: @echo ${COMPILE.S:Q} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
177: @${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 178: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
179: @rm -f ${.TARGET}.o
1.27 pk 180:
1.139 tv 181: .if defined(NOPIC) || (defined(LDSTATIC) && ${LDSTATIC} != "") \
182: || !defined(NOLINKLIB)
1.130 tv 183: _LIBS=lib${LIB}.a
184: .else
185: _LIBS=
186: .endif
1.58 cgd 187:
1.139 tv 188: .if !defined(NOPROFILE) && !defined(NOLINKLIB)
1.130 tv 189: _LIBS+=lib${LIB}_p.a
1.1 cgd 190: .endif
191:
1.27 pk 192: .if !defined(NOPIC)
193: _LIBS+=lib${LIB}_pic.a
1.37 cgd 194: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
195: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27 pk 196: .endif
1.35 pk 197: .endif
1.27 pk 198:
1.139 tv 199: .if !defined(NOLINT) && !defined(NOLINKLIB)
1.58 cgd 200: _LIBS+=llib-l${LIB}.ln
1.27 pk 201: .endif
202:
1.102 mycroft 203: all: ${SRCS} ${_LIBS}
1.1 cgd 204:
1.90 christos 205: __archivebuild: .USE
1.89 christos 206: @rm -f ${.TARGET}
1.138 tv 207: @${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
1.89 christos 208: ${RANLIB} ${.TARGET}
209:
210: __archiveinstall: .USE
1.140 christos 211: ${INSTALL} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
212: ${.ALLSRC} ${.TARGET}
1.89 christos 213: ${RANLIB} -t ${.TARGET}
214: chmod ${LIBMODE} ${.TARGET}
215:
1.104 mycroft 216: DPSRCS+= ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
1.128 tv 217: CLEANFILES+= ${DPSRCS}
1.129 tv 218: .if defined(YHEADER)
219: CLEANFILES+= ${SRCS:M*.y:.y=.h}
220: .endif
1.103 mycroft 221:
222: OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
1.89 christos 223: lib${LIB}.a:: ${OBJS} __archivebuild
1.1 cgd 224: @echo building standard ${LIB} library
225:
1.103 mycroft 226: POBJS+= ${OBJS:.o=.po}
1.89 christos 227: lib${LIB}_p.a:: ${POBJS} __archivebuild
1.1 cgd 228: @echo building profiled ${LIB} library
229:
1.103 mycroft 230: SOBJS+= ${OBJS:.o=.so}
1.89 christos 231: lib${LIB}_pic.a:: ${SOBJS} __archivebuild
1.27 pk 232: @echo building shared object ${LIB} library
233:
1.88 cgd 234: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
235: ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
1.38 cgd 236: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
1.37 cgd 237: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.126 jonathan 238: $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
1.123 jonathan 239: ${SHLIB_LDSTARTFILE} \
1.126 jonathan 240: --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
1.115 cjs 241: ${SHLIB_LDENDFILE}
1.133 tv 242: .if (${OBJECT_FMT} == "ELF")
1.135 tv 243: rm -f lib${LIB}.so.${SHLIB_MAJOR}
1.133 tv 244: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.135 tv 245: lib${LIB}.so.${SHLIB_MAJOR}
246: rm -f lib${LIB}.so
1.133 tv 247: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.135 tv 248: lib${LIB}.so
1.133 tv 249: .endif
1.35 pk 250:
1.103 mycroft 251: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
252: LLIBS?= -lc
1.58 cgd 253: llib-l${LIB}.ln: ${LOBJS}
254: @echo building llib-l${LIB}.ln
255: @rm -f llib-l${LIB}.ln
1.141 wrstuden 256: @${LINT} -C${LIB} ${.ALLSRC} ${LLIBS}
1.1 cgd 257:
1.81 cgd 258: cleanlib:
1.48 mycroft 259: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59 cgd 260: rm -f lib${LIB}.a ${OBJS}
261: rm -f lib${LIB}_p.a ${POBJS}
1.133 tv 262: rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS}
1.59 cgd 263: rm -f llib-l${LIB}.ln ${LOBJS}
1.1 cgd 264:
1.26 mycroft 265: .if defined(SRCS)
1.64 christos 266: afterdepend: .depend
1.1 cgd 267: @(TMP=/tmp/_depend$$$$; \
1.79 cgd 268: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58 cgd 269: < .depend > $$TMP; \
1.1 cgd 270: mv $$TMP .depend)
1.26 mycroft 271: .endif
1.1 cgd 272:
1.97 mycroft 273: .if !target(libinstall)
1.139 tv 274: # Make sure it gets defined, in case NOPIC && NOLINKLIB are defined
275: libinstall::
276:
277: .if !defined(NOLINKLIB)
1.89 christos 278: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a
279: .if !defined(UPDATE)
280: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a
281: .endif
282: .if !defined(BUILD)
283: ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE
284: .endif
285:
1.95 mycroft 286: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.89 christos 287: ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall
1.130 tv 288: .endif
1.89 christos 289:
1.139 tv 290: .if !defined(NOPROFILE) && !defined(NOLINKLIB)
1.89 christos 291: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
292: .if !defined(UPDATE)
293: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.32 pk 294: .endif
1.89 christos 295: .if !defined(BUILD)
296: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE
297: .endif
298:
1.95 mycroft 299: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.89 christos 300: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall
301: .endif
302:
1.139 tv 303: .if !defined(NOPIC) && !defined(NOPICINSTALL) && !defined(NOLINKLIB)
1.89 christos 304: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
305: .if !defined(UPDATE)
306: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
307: .endif
308: .if !defined(BUILD)
309: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE
1.33 pk 310: .endif
1.89 christos 311:
1.95 mycroft 312: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.89 christos 313: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall
314: .endif
315:
1.37 cgd 316: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.89 christos 317: libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
318: .if !defined(UPDATE)
319: .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
320: .endif
321: .if !defined(BUILD)
322: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: .MADE
323: .endif
1.92 mikel 324:
1.95 mycroft 325: .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.89 christos 326: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.140 christos 327: ${INSTALL} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
328: ${.ALLSRC} ${.TARGET}
1.125 jonathan 329: .if (${OBJECT_FMT} == "ELF")
1.83 cgd 330: rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
331: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
332: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
333: rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
1.139 tv 334: .if !defined(NOLINKLIB)
1.83 cgd 335: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
336: ${DESTDIR}${LIBDIR}/lib${LIB}.so
337: .endif
1.12 cgd 338: .endif
1.139 tv 339: .endif
1.89 christos 340:
1.139 tv 341: .if !defined(NOLINT) && !defined(NOLINKLIB)
1.89 christos 342: libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
343: .if !defined(UPDATE)
344: .PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
345: .endif
346: .if !defined(BUILD)
347: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE
348: .endif
349:
1.95 mycroft 350: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln
351: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln
1.140 christos 352: ${INSTALL} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.136 christos 353: ${.ALLSRC} ${DESTDIR}${LINTLIBDIR}
1.58 cgd 354: .endif
1.1 cgd 355: .endif
356:
357: .include <bsd.man.mk>
1.57 jtc 358: .include <bsd.nls.mk>
1.91 christos 359: .include <bsd.files.mk>
1.89 christos 360: .include <bsd.inc.mk>
1.109 cjs 361: .include <bsd.links.mk>
1.24 mycroft 362: .include <bsd.dep.mk>
1.66 christos 363: .include <bsd.sys.mk>
1.117 mycroft 364:
365: # Make sure all of the standard targets are defined, even if they do nothing.
366: lint regress:
CVSweb <webmaster@jp.NetBSD.org>