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