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