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