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