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