Annotation of src/share/mk/bsd.lib.mk, Revision 1.16
1.1 cgd 1: # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2:
3: .if exists(${.CURDIR}/../Makefile.inc)
4: .include "${.CURDIR}/../Makefile.inc"
5: .endif
6:
7: LIBDIR?= /usr/lib
8: LINTLIBDIR?= /usr/libdata/lint
9: LIBGRP?= bin
10: LIBOWN?= bin
11: LIBMODE?= 444
12:
13: STRIP?= -s
14:
15: BINGRP?= bin
16: BINOWN?= bin
17: BINMODE?= 555
18:
19: .MAIN: all
20:
21: # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
22: .SUFFIXES:
23: .SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
24:
25: .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
26: nroff -mandoc ${.IMPSRC} > ${.TARGET}
27:
28: .c.o:
29: ${CC} ${CFLAGS} -c ${.IMPSRC}
30: @${LD} -x -r ${.TARGET}
31: @mv a.out ${.TARGET}
32:
33: .c.po:
34: ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
35: @${LD} -X -r ${.TARGET}
36: @mv a.out ${.TARGET}
37:
38: .s.o:
39: ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
40: ${AS} -o ${.TARGET}
41: @${LD} -x -r ${.TARGET}
42: @mv a.out ${.TARGET}
43:
44: .s.po:
45: ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
46: ${AS} -o ${.TARGET}
47: @${LD} -X -r ${.TARGET}
48: @mv a.out ${.TARGET}
49:
1.10 mycroft 50: .if !defined(NOMAN)
1.1 cgd 51: MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
1.10 mycroft 52: .endif
1.1 cgd 53:
54: .if !defined(NOPROFILE)
55: _LIBS=lib${LIB}.a lib${LIB}_p.a
56: .else
57: _LIBS=lib${LIB}.a
58: .endif
59:
60: all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
61:
62: OBJS+= ${SRCS:R:S/$/.o/g}
63:
64: lib${LIB}.a:: ${OBJS}
65: @echo building standard ${LIB} library
66: @rm -f lib${LIB}.a
1.16 ! mycroft 67: @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
1.13 cgd 68: ${RANLIB} lib${LIB}.a
1.1 cgd 69:
70: POBJS+= ${OBJS:.o=.po}
71: lib${LIB}_p.a:: ${POBJS}
72: @echo building profiled ${LIB} library
73: @rm -f lib${LIB}_p.a
1.16 ! mycroft 74: @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
1.13 cgd 75: ${RANLIB} lib${LIB}_p.a
1.1 cgd 76:
77: llib-l${LIB}.ln: ${SRCS}
78: ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
79:
80: .if !target(clean)
81: clean:
1.9 cgd 82: rm -f a.out Errs errs mklog core ${CLEANFILES}
83: rm -f ${OBJS}
84: rm -f ${POBJS} profiled/*.o
85: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 86: .endif
87:
88: .if !target(cleandir)
89: cleandir:
1.9 cgd 90: rm -f a.out Errs errs mklog core ${CLEANFILES}
91: rm -f ${OBJS}
92: rm -f ${POBJS} profiled/*.o
93: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 94: rm -f ${MANALL} ${.CURDIR}/tags .depend
95: .endif
96:
97: .if !target(depend)
98: depend: .depend
99: .depend: ${SRCS}
1.8 cgd 100: mkdep ${CFLAGS:M-[ID+]*} ${AINC} ${.ALLSRC}
1.1 cgd 101: @(TMP=/tmp/_depend$$$$; \
1.14 cgd 102: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po:/' < .depend > $$TMP; \
1.1 cgd 103: mv $$TMP .depend)
104: .endif
105:
106: .if !target(install)
107: .if !target(beforeinstall)
108: beforeinstall:
1.7 cgd 109: @if [ ! -d "${DESTDIR}${LIBDIR}" ]; then \
1.6 cgd 110: /bin/rm -f ${DESTDIR}${LIBDIR} ; \
1.5 cgd 111: mkdir -p ${DESTDIR}${LIBDIR} ; \
112: chown root.wheel ${DESTDIR}${LIBDIR} ; \
113: chmod 755 ${DESTDIR}${LIBDIR} ; \
114: else \
115: true ; \
116: fi
1.1 cgd 117: .endif
118:
1.11 mycroft 119: realinstall:
1.13 cgd 120: # ranlib lib${LIB}.a
1.8 cgd 121: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
1.1 cgd 122: ${DESTDIR}${LIBDIR}
123: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.12 cgd 124: .if !defined(NOPROFILE)
1.13 cgd 125: # ranlib lib${LIB}_p.a
1.8 cgd 126: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 127: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
128: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.12 cgd 129: .endif
1.8 cgd 130: # install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 131: # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
132: .if defined(LINKS) && !empty(LINKS)
133: @set ${LINKS}; \
134: while test $$# -ge 2; do \
135: l=${DESTDIR}$$1; \
136: shift; \
137: t=${DESTDIR}$$1; \
138: shift; \
139: echo $$t -\> $$l; \
140: rm -f $$t; \
141: ln $$l $$t; \
142: done; true
143: .endif
144:
1.11 mycroft 145: install: maninstall
146: maninstall: afterinstall
147: afterinstall: realinstall
148: realinstall: beforeinstall
1.1 cgd 149: .endif
150:
151: .if !target(lint)
152: lint:
153: .endif
154:
155: .if !target(tags)
156: tags: ${SRCS}
157: -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
158: sed "s;\${.CURDIR}/;;" > tags
159: .endif
160:
1.10 mycroft 161: .if !defined(NOMAN)
1.1 cgd 162: .include <bsd.man.mk>
1.10 mycroft 163: .endif
164:
1.1 cgd 165: .if !target(obj)
166: .if defined(NOOBJ)
167: obj:
168: .else
169: obj:
1.3 cgd 170: @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
1.2 cgd 171: here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
172: if test $$here != $$subdir ; then \
173: dest=/usr/obj/$$subdir ; \
174: echo "$$here -> $$dest"; ln -s $$dest obj; \
175: if test -d /usr/obj -a ! -d $$dest; then \
176: mkdir -p $$dest; \
177: else \
178: true; \
179: fi; \
1.1 cgd 180: else \
1.2 cgd 181: true ; \
182: dest=$$here/obj ; \
183: echo "making $$here/obj" ; \
184: if test ! -d obj ; then \
185: mkdir $$here/obj; \
186: fi; \
1.1 cgd 187: fi;
188: .endif
189: .endif
CVSweb <webmaster@jp.NetBSD.org>