Annotation of src/share/mk/bsd.lib.mk, Revision 1.9
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:
50: MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
51:
52: .if !defined(NOPROFILE)
53: _LIBS=lib${LIB}.a lib${LIB}_p.a
54: .else
55: _LIBS=lib${LIB}.a
56: .endif
57:
58: all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
59:
60: OBJS+= ${SRCS:R:S/$/.o/g}
61:
62: lib${LIB}.a:: ${OBJS}
63: @echo building standard ${LIB} library
64: @rm -f lib${LIB}.a
65: @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
66: ranlib lib${LIB}.a
67:
68: POBJS+= ${OBJS:.o=.po}
69: lib${LIB}_p.a:: ${POBJS}
70: @echo building profiled ${LIB} library
71: @rm -f lib${LIB}_p.a
72: @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
73: ranlib lib${LIB}_p.a
74:
75: llib-l${LIB}.ln: ${SRCS}
76: ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
77:
78: .if !target(clean)
79: clean:
1.9 ! cgd 80: rm -f a.out Errs errs mklog core ${CLEANFILES}
! 81: rm -f ${OBJS}
! 82: rm -f ${POBJS} profiled/*.o
! 83: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 84: .endif
85:
86: .if !target(cleandir)
87: cleandir:
1.9 ! cgd 88: rm -f a.out Errs errs mklog core ${CLEANFILES}
! 89: rm -f ${OBJS}
! 90: rm -f ${POBJS} profiled/*.o
! 91: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 92: rm -f ${MANALL} ${.CURDIR}/tags .depend
93: .endif
94:
95: .if !target(depend)
96: depend: .depend
97: .depend: ${SRCS}
1.8 cgd 98: mkdep ${CFLAGS:M-[ID+]*} ${AINC} ${.ALLSRC}
1.1 cgd 99: @(TMP=/tmp/_depend$$$$; \
100: sed -e 's/^\([^\.]*\).o:/\1.o \1.po:/' < .depend > $$TMP; \
101: mv $$TMP .depend)
102: .endif
103:
104: .if !target(install)
105: .if !target(beforeinstall)
106: beforeinstall:
1.7 cgd 107: @if [ ! -d "${DESTDIR}${LIBDIR}" ]; then \
1.6 cgd 108: /bin/rm -f ${DESTDIR}${LIBDIR} ; \
1.5 cgd 109: mkdir -p ${DESTDIR}${LIBDIR} ; \
110: chown root.wheel ${DESTDIR}${LIBDIR} ; \
111: chmod 755 ${DESTDIR}${LIBDIR} ; \
112: else \
113: true ; \
114: fi
1.1 cgd 115: .endif
116:
117: realinstall: beforeinstall
118: ranlib lib${LIB}.a
1.8 cgd 119: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
1.1 cgd 120: ${DESTDIR}${LIBDIR}
121: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
122: ranlib lib${LIB}_p.a
1.8 cgd 123: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 124: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
125: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.8 cgd 126: # install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 127: # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
128: .if defined(LINKS) && !empty(LINKS)
129: @set ${LINKS}; \
130: while test $$# -ge 2; do \
131: l=${DESTDIR}$$1; \
132: shift; \
133: t=${DESTDIR}$$1; \
134: shift; \
135: echo $$t -\> $$l; \
136: rm -f $$t; \
137: ln $$l $$t; \
138: done; true
139: .endif
140:
141: install: afterinstall
142: afterinstall: realinstall maninstall
143: .endif
144:
145: .if !target(lint)
146: lint:
147: .endif
148:
149: .if !target(tags)
150: tags: ${SRCS}
151: -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
152: sed "s;\${.CURDIR}/;;" > tags
153: .endif
154:
155: .include <bsd.man.mk>
156: .if !target(obj)
157: .if defined(NOOBJ)
158: obj:
159: .else
160: obj:
1.3 cgd 161: @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
1.2 cgd 162: here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
163: if test $$here != $$subdir ; then \
164: dest=/usr/obj/$$subdir ; \
165: echo "$$here -> $$dest"; ln -s $$dest obj; \
166: if test -d /usr/obj -a ! -d $$dest; then \
167: mkdir -p $$dest; \
168: else \
169: true; \
170: fi; \
1.1 cgd 171: else \
1.2 cgd 172: true ; \
173: dest=$$here/obj ; \
174: echo "making $$here/obj" ; \
175: if test ! -d obj ; then \
176: mkdir $$here/obj; \
177: fi; \
1.1 cgd 178: fi;
179: .endif
180: .endif
CVSweb <webmaster@jp.NetBSD.org>