Annotation of src/share/mk/bsd.lib.mk, Revision 1.85
1.85 ! cgd 1: # $NetBSD: bsd.lib.mk,v 1.84 1997/03/13 02:46:00 perry Exp $
1.50 cgd 2: # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
1.1 cgd 3:
4: .if exists(${.CURDIR}/../Makefile.inc)
5: .include "${.CURDIR}/../Makefile.inc"
6: .endif
1.54 cgd 7:
8: .include <bsd.own.mk> # for 'NOPIC' definition
1.1 cgd 9:
1.35 pk 10: .if exists(${.CURDIR}/shlib_version)
1.37 cgd 11: SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
12: SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
1.35 pk 13: .endif
14:
1.1 cgd 15: .MAIN: all
16:
1.58 cgd 17: # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
18: # .so used for PIC object files. .ln used for lint output files.
1.1 cgd 19: .SUFFIXES:
1.58 cgd 20: .SUFFIXES: .out .o .po .so .S .s .c .cc .C .f .y .l .ln .m4
1.82 mikel 21:
22: CFLAGS+= ${COPTS}
1.1 cgd 23:
24: .c.o:
1.80 christos 25: @echo ${COMPILE.c:Q} ${.IMPSRC}
1.62 christos 26: @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o
27: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
28: @rm -f ${.TARGET}.o
1.1 cgd 29:
30: .c.po:
1.80 christos 31: @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 32: @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 33: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
34: @rm -f ${.TARGET}.o
1.17 mycroft 35:
1.27 pk 36: .c.so:
1.80 christos 37: @echo ${COMPILE.c:Q} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}
1.62 christos 38: @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
39: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
40: @rm -f ${.TARGET}.o
1.27 pk 41:
1.58 cgd 42: .c.ln:
43: ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
44:
1.18 mycroft 45: .cc.o .C.o:
1.80 christos 46: @echo ${COMPILE.cc:Q} ${.IMPSRC}
1.62 christos 47: @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
1.63 jtc 48: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
1.62 christos 49: @rm -f ${.TARGET}.o
1.17 mycroft 50:
1.18 mycroft 51: .cc.po .C.po:
1.80 christos 52: @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
1.68 cgd 53: @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 54: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
55: @rm -f ${.TARGET}.o
1.28 cgd 56:
57: .cc.so .C.so:
1.80 christos 58: @echo ${COMPILE.cc:Q} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}
1.62 christos 59: @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
60: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
61: @rm -f ${.TARGET}.o
1.1 cgd 62:
1.40 cgd 63: .S.o .s.o:
1.80 christos 64: @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
1.69 jtc 65: @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 66: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
67: @rm -f ${.TARGET}.o
1.1 cgd 68:
1.40 cgd 69: .S.po .s.po:
1.80 christos 70: @echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.75 jtc 71: @${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 72: @${LD} -X -r ${.TARGET}.o -o ${.TARGET}
73: @rm -f ${.TARGET}.o
1.1 cgd 74:
1.40 cgd 75: .S.so .s.so:
1.80 christos 76: @echo ${COMPILE.S:Q} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
1.70 jtc 77: @${COMPILE.S} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
1.62 christos 78: @${LD} -x -r ${.TARGET}.o -o ${.TARGET}
79: @rm -f ${.TARGET}.o
1.27 pk 80:
1.58 cgd 81: .if !defined(PICFLAG)
82: PICFLAG=-fpic
83: .endif
84:
1.1 cgd 85: .if !defined(NOPROFILE)
86: _LIBS=lib${LIB}.a lib${LIB}_p.a
87: .else
88: _LIBS=lib${LIB}.a
89: .endif
90:
1.27 pk 91: .if !defined(NOPIC)
92: _LIBS+=lib${LIB}_pic.a
1.37 cgd 93: .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
94: _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.27 pk 95: .endif
1.35 pk 96: .endif
1.27 pk 97:
1.58 cgd 98: .if !defined(NOLINT)
99: _LIBS+=llib-l${LIB}.ln
1.27 pk 100: .endif
101:
1.58 cgd 102: all: ${_LIBS} _SUBDIRUSE
1.1 cgd 103:
1.21 mycroft 104: OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
1.1 cgd 105:
106: lib${LIB}.a:: ${OBJS}
107: @echo building standard ${LIB} library
108: @rm -f lib${LIB}.a
1.67 mycroft 109: @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
1.13 cgd 110: ${RANLIB} lib${LIB}.a
1.1 cgd 111:
112: POBJS+= ${OBJS:.o=.po}
113: lib${LIB}_p.a:: ${POBJS}
114: @echo building profiled ${LIB} library
115: @rm -f lib${LIB}_p.a
1.67 mycroft 116: @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
1.13 cgd 117: ${RANLIB} lib${LIB}_p.a
1.1 cgd 118:
1.27 pk 119: SOBJS+= ${OBJS:.o=.so}
120: lib${LIB}_pic.a:: ${SOBJS}
121: @echo building shared object ${LIB} library
122: @rm -f lib${LIB}_pic.a
1.67 mycroft 123: @${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
1.27 pk 124: ${RANLIB} lib${LIB}_pic.a
125:
1.42 mycroft 126: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
1.38 cgd 127: @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
1.37 cgd 128: @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
1.72 cgd 129: .if (${MACHINE_ARCH} != "alpha")
1.53 pk 130: $(LD) -x -Bshareable -Bforcearchive \
1.42 mycroft 131: -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
1.72 cgd 132: .else
1.77 cgd 133: $(LD) -shared -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
1.85 ! cgd 134: -soname lib${LIB}.so.${SHLIB_MAJOR} \
! 135: ${DESTDIR}/usr/lib/crtbeginS.o \
1.77 cgd 136: --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
1.85 ! cgd 137: ${DESTDIR}/usr/lib/crtendS.o
1.72 cgd 138: .endif
1.35 pk 139:
1.58 cgd 140: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
141: LLIBS?= -lc
142: llib-l${LIB}.ln: ${LOBJS}
143: @echo building llib-l${LIB}.ln
144: @rm -f llib-l${LIB}.ln
145: @${LINT} -C${LIB} ${LOBJS} ${LLIBS}
1.1 cgd 146:
147: .if !target(clean)
1.81 cgd 148: cleanlib:
1.48 mycroft 149: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
1.59 cgd 150: rm -f lib${LIB}.a ${OBJS}
151: rm -f lib${LIB}_p.a ${POBJS}
1.61 cgd 152: rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
1.59 cgd 153: rm -f llib-l${LIB}.ln ${LOBJS}
1.1 cgd 154:
1.81 cgd 155: clean: _SUBDIRUSE cleanlib
156: cleandir: _SUBDIRUSE cleanlib
157: .else
1.49 cgd 158: cleandir: _SUBDIRUSE clean
1.81 cgd 159: .endif
1.25 mycroft 160:
1.26 mycroft 161: .if defined(SRCS)
1.64 christos 162: afterdepend: .depend
1.1 cgd 163: @(TMP=/tmp/_depend$$$$; \
1.79 cgd 164: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
1.58 cgd 165: < .depend > $$TMP; \
1.1 cgd 166: mv $$TMP .depend)
1.26 mycroft 167: .endif
1.1 cgd 168:
169: .if !target(install)
170: .if !target(beforeinstall)
171: beforeinstall:
172: .endif
173:
1.11 mycroft 174: realinstall:
1.13 cgd 175: # ranlib lib${LIB}.a
1.73 thorpej 176: ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
1.1 cgd 177: ${DESTDIR}${LIBDIR}
178: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.56 cgd 179: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.12 cgd 180: .if !defined(NOPROFILE)
1.13 cgd 181: # ranlib lib${LIB}_p.a
1.73 thorpej 182: ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.1 cgd 183: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
184: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.56 cgd 185: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.32 pk 186: .endif
1.39 pk 187: .if !defined(NOPIC)
1.32 pk 188: # ranlib lib${LIB}_pic.a
1.73 thorpej 189: ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
1.32 pk 190: lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
191: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.56 cgd 192: chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
1.33 pk 193: .endif
1.37 cgd 194: .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
1.73 thorpej 195: ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.37 cgd 196: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
1.83 cgd 197: .if (${MACHINE_ARCH} == "alpha")
198: rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
199: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
200: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
201: rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
202: ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
203: ${DESTDIR}${LIBDIR}/lib${LIB}.so
204: .endif
1.12 cgd 205: .endif
1.58 cgd 206: .if !defined(NOLINT)
1.73 thorpej 207: ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.58 cgd 208: llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
209: .endif
1.1 cgd 210: .if defined(LINKS) && !empty(LINKS)
211: @set ${LINKS}; \
212: while test $$# -ge 2; do \
213: l=${DESTDIR}$$1; \
214: shift; \
215: t=${DESTDIR}$$1; \
216: shift; \
217: echo $$t -\> $$l; \
218: rm -f $$t; \
219: ln $$l $$t; \
1.84 perry 220: done; true
221: .endif
222: .if defined(SYMLINKS) && !empty(SYMLINKS)
223: @set ${SYMLINKS}; \
224: while test $$# -ge 2; do \
225: l=${DESTDIR}$$1; \
226: shift; \
227: t=${DESTDIR}$$1; \
228: shift; \
229: echo $$t -\> $$l; \
230: rm -f $$t; \
231: ln -s $$l $$t; \
1.1 cgd 232: done; true
233: .endif
234:
1.49 cgd 235: install: maninstall _SUBDIRUSE
1.11 mycroft 236: maninstall: afterinstall
237: afterinstall: realinstall
238: realinstall: beforeinstall
1.1 cgd 239: .endif
240:
1.10 mycroft 241: .if !defined(NOMAN)
1.1 cgd 242: .include <bsd.man.mk>
1.57 jtc 243: .endif
244:
245: .if !defined(NONLS)
246: .include <bsd.nls.mk>
1.10 mycroft 247: .endif
248:
1.22 mycroft 249: .include <bsd.obj.mk>
1.24 mycroft 250: .include <bsd.dep.mk>
1.49 cgd 251: .include <bsd.subdir.mk>
1.66 christos 252: .include <bsd.sys.mk>
CVSweb <webmaster@jp.NetBSD.org>