Annotation of src/share/mk/bsd.lib.mk, Revision 1.20
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:
1.17 mycroft 23: .SUFFIXES: .out .o .po .s .c .cc .C .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
1.1 cgd 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}
1.17 mycroft 35: @${LD} -X -r ${.TARGET}
36: @mv a.out ${.TARGET}
37:
1.18 mycroft 38: .cc.o .C.o:
1.17 mycroft 39: ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
40: @${LD} -x -r ${.TARGET}
41: @mv a.out ${.TARGET}
42:
1.18 mycroft 43: .cc.po .C.po:
1.17 mycroft 44: ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
1.1 cgd 45: @${LD} -X -r ${.TARGET}
46: @mv a.out ${.TARGET}
47:
48: .s.o:
49: ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
50: ${AS} -o ${.TARGET}
51: @${LD} -x -r ${.TARGET}
52: @mv a.out ${.TARGET}
53:
54: .s.po:
55: ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
56: ${AS} -o ${.TARGET}
57: @${LD} -X -r ${.TARGET}
58: @mv a.out ${.TARGET}
59:
1.10 mycroft 60: .if !defined(NOMAN)
1.1 cgd 61: MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
1.10 mycroft 62: .endif
1.1 cgd 63:
64: .if !defined(NOPROFILE)
65: _LIBS=lib${LIB}.a lib${LIB}_p.a
66: .else
67: _LIBS=lib${LIB}.a
68: .endif
69:
70: all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
71:
72: OBJS+= ${SRCS:R:S/$/.o/g}
73:
74: lib${LIB}.a:: ${OBJS}
75: @echo building standard ${LIB} library
76: @rm -f lib${LIB}.a
1.16 mycroft 77: @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
1.13 cgd 78: ${RANLIB} lib${LIB}.a
1.1 cgd 79:
80: POBJS+= ${OBJS:.o=.po}
81: lib${LIB}_p.a:: ${POBJS}
82: @echo building profiled ${LIB} library
83: @rm -f lib${LIB}_p.a
1.16 mycroft 84: @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
1.13 cgd 85: ${RANLIB} lib${LIB}_p.a
1.1 cgd 86:
87: llib-l${LIB}.ln: ${SRCS}
88: ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
89:
90: .if !target(clean)
91: clean:
1.9 cgd 92: rm -f a.out Errs errs mklog core ${CLEANFILES}
93: rm -f ${OBJS}
94: rm -f ${POBJS} profiled/*.o
95: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 96: .endif
97:
98: .if !target(cleandir)
99: cleandir:
1.9 cgd 100: rm -f a.out Errs errs mklog core ${CLEANFILES}
101: rm -f ${OBJS}
102: rm -f ${POBJS} profiled/*.o
103: rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
1.1 cgd 104: rm -f ${MANALL} ${.CURDIR}/tags .depend
105: .endif
106:
107: .if !target(depend)
108: depend: .depend
109: .depend: ${SRCS}
1.19 mycroft 110: rm -f .depend
111: files="${.ALLSRC:M*.c}"; \
112: if [ "$$files" != "" ]; then \
113: mkdep -a ${MKDEP} ${CFLAGS:M-[ID]*} $$files; \
114: fi
115: files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
116: if [ "$$files" != " " ]; then \
117: mkdep -a ${MKDEP} -+ ${CXXFLAGS:M-[ID]*} $$files; \
118: fi
1.1 cgd 119: @(TMP=/tmp/_depend$$$$; \
1.14 cgd 120: sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po:/' < .depend > $$TMP; \
1.1 cgd 121: mv $$TMP .depend)
122: .endif
123:
124: .if !target(install)
125: .if !target(beforeinstall)
126: beforeinstall:
1.7 cgd 127: @if [ ! -d "${DESTDIR}${LIBDIR}" ]; then \
1.6 cgd 128: /bin/rm -f ${DESTDIR}${LIBDIR} ; \
1.5 cgd 129: mkdir -p ${DESTDIR}${LIBDIR} ; \
130: chown root.wheel ${DESTDIR}${LIBDIR} ; \
131: chmod 755 ${DESTDIR}${LIBDIR} ; \
132: else \
133: true ; \
134: fi
1.1 cgd 135: .endif
136:
1.11 mycroft 137: realinstall:
1.13 cgd 138: # ranlib lib${LIB}.a
1.8 cgd 139: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
1.1 cgd 140: ${DESTDIR}${LIBDIR}
141: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
1.12 cgd 142: .if !defined(NOPROFILE)
1.13 cgd 143: # ranlib lib${LIB}_p.a
1.8 cgd 144: install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 145: lib${LIB}_p.a ${DESTDIR}${LIBDIR}
146: ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
1.12 cgd 147: .endif
1.8 cgd 148: # install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
1.1 cgd 149: # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
150: .if defined(LINKS) && !empty(LINKS)
151: @set ${LINKS}; \
152: while test $$# -ge 2; do \
153: l=${DESTDIR}$$1; \
154: shift; \
155: t=${DESTDIR}$$1; \
156: shift; \
157: echo $$t -\> $$l; \
158: rm -f $$t; \
159: ln $$l $$t; \
160: done; true
161: .endif
162:
1.11 mycroft 163: install: maninstall
164: maninstall: afterinstall
165: afterinstall: realinstall
166: realinstall: beforeinstall
1.1 cgd 167: .endif
168:
169: .if !target(lint)
170: lint:
171: .endif
172:
173: .if !target(tags)
174: tags: ${SRCS}
175: -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
176: sed "s;\${.CURDIR}/;;" > tags
177: .endif
178:
1.10 mycroft 179: .if !defined(NOMAN)
1.1 cgd 180: .include <bsd.man.mk>
1.10 mycroft 181: .endif
182:
1.1 cgd 183: .if !target(obj)
184: .if defined(NOOBJ)
185: obj:
186: .else
187: obj:
1.3 cgd 188: @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
1.2 cgd 189: here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
190: if test $$here != $$subdir ; then \
191: dest=/usr/obj/$$subdir ; \
192: echo "$$here -> $$dest"; ln -s $$dest obj; \
193: if test -d /usr/obj -a ! -d $$dest; then \
194: mkdir -p $$dest; \
195: else \
196: true; \
197: fi; \
1.1 cgd 198: else \
1.2 cgd 199: true ; \
200: dest=$$here/obj ; \
201: if test ! -d obj ; then \
1.20 ! mycroft 202: echo "making $$dest" ; \
! 203: mkdir $$dest; \
1.2 cgd 204: fi; \
1.1 cgd 205: fi;
206: .endif
207: .endif
CVSweb <webmaster@jp.NetBSD.org>