bsd.lib.mk revision 1638
1148422Sphk#	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
2150366Sphk
3148422Sphk.if exists(${.CURDIR}/../Makefile.inc)
4150366Sphk.include "${.CURDIR}/../Makefile.inc"
5148422Sphk.endif
6150366Sphk
7150366SphkLIBDIR?=	/usr/lib
8150366SphkLINTLIBDIR?=	/usr/libdata/lint
9150366SphkLIBGRP?=	bin
10150366SphkLIBOWN?=	bin
11150366SphkLIBMODE?=	444
12150366Sphk
13150366SphkSTRIP?=	-s
14148422Sphk
15150366SphkBINGRP?=	bin
16150366SphkBINOWN?=	bin
17150366SphkBINMODE?=	555
18150366Sphk
19150366Sphk.MAIN: all
20150366Sphk
21150366Sphk# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
22150366Sphk.SUFFIXES:
23150366Sphk.SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0 .m4
24150366Sphk
25150366Sphk.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
26150366Sphk	nroff -man ${.IMPSRC} > ${.TARGET}
27148422Sphk
28148422Sphk.c.o:
29148422Sphk	${CC} ${CFLAGS} -c ${.IMPSRC} 
30148422Sphk	@${LD} -x -r ${.TARGET}
31148422Sphk	@mv a.out ${.TARGET}
32150366Sphk
33150366Sphk.c.po:
34150366Sphk	${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
35150366Sphk	@${LD} -X -r ${.TARGET}
36150366Sphk	@mv a.out ${.TARGET}
37150366Sphk
38150366Sphk.s.o:
39148422Sphk	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
40148422Sphk	    ${AS} -o ${.TARGET}
41148422Sphk	@${LD} -x -r ${.TARGET}
42148422Sphk	@mv a.out ${.TARGET}
43148422Sphk
44148422Sphk.s.po:
45150366Sphk	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
46150366Sphk	    ${AS} -o ${.TARGET}
47150366Sphk	@${LD} -X -r ${.TARGET}
48170607Sphk	@mv a.out ${.TARGET}
49170607Sphk
50186181SphkMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
51170607Sphkmanpages: ${MANALL}
52148422Sphk
53148422Sphk.if !defined(NOPROFILE)
54148648Sphk_LIBS=lib${LIB}.a lib${LIB}_p.a
55148422Sphk.else
56175258Ssimon_LIBS=lib${LIB}.a
57175258Ssimon.endif
58175258Ssimon
59175258Ssimonall: ${_LIBS} # llib-l${LIB}.ln
60148422Sphk.if !defined(NOMAN)
61148422Sphkall: ${MANALL}
62148422Sphk.endif
63183284Sbms
64183284SbmsOBJS+=	${SRCS:R:S/$/.o/g}
65183284Sbms
66148422Sphklib${LIB}.a:: ${OBJS}
67148422Sphk	@echo building standard ${LIB} library
68148422Sphk	@rm -f lib${LIB}.a
69148422Sphk	@${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
70148422Sphk	ranlib lib${LIB}.a
71148422Sphk
72148422SphkPOBJS+=	${OBJS:.o=.po}
73148422Sphklib${LIB}_p.a:: ${POBJS}
74148422Sphk	@echo building profiled ${LIB} library
75148422Sphk	@rm -f lib${LIB}_p.a
76148422Sphk	@${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
77148422Sphk	ranlib lib${LIB}_p.a
78149073Sphk
79149073Sphkllib-l${LIB}.ln: ${SRCS}
80149073Sphk	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
81181461Sphk
82181461Sphk.if !target(clean)
83181461Sphkclean:
84148648Sphk	rm -f ${OBJS}
85148648Sphk	rm -f ${POBJS}
86148648Sphk	rm -f a.out [Ee]rrs mklog ${CLEANFILES} \
87149082Sphk	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
88149082Sphk.endif
89149082Sphk
90148648Sphk.if !target(cleandir)
91183284Sbmscleandir:
92148648Sphk	rm -f ${OBJS}
93148648Sphk	rm -f ${POBJS}
94148422Sphk	rm -f a.out [Ee]rrs mklog ${CLEANFILES} \
95148648Sphk	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
96171986Sphk	rm -f ${MANALL} .depend
97171986Sphk.endif
98171986Sphk
99171986Sphk.if !target(depend)
100149535Ssimondepend: .depend
101149120Sphk.depend: ${SRCS}
102149120Sphk	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
103149120Sphk	@(TMP=/tmp/_depend$$$$; \
104149120Sphk	    sed -e 's/^\([^\.]*\).o *:/\1.o \1.po:/' < .depend > $$TMP; \
105149120Sphk	    mv $$TMP .depend)
106148422Sphk.endif
107148648Sphk
108148648Sphk.if !target(install)
109149120Sphk.if !target(beforeinstall)
110149120Sphkbeforeinstall:
111149120Sphk.endif
112148422Sphk
113154466Sphkrealinstall: beforeinstall
114154466Sphk	ranlib lib${LIB}.a
115154466Sphk	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
116154466Sphk	    ${DESTDIR}${LIBDIR}
117154466Sphk	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
118154466Sphk.if !defined(NOPROFILE)
119148422Sphk	ranlib lib${LIB}_p.a
120170607Sphk	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
121148422Sphk	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
122148422Sphk	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
123168894Sadrian.endif
124168894Sadrian#	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
125168894Sadrian#	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
126168894Sadrian.if defined(LINKS) && !empty(LINKS)
127209225Simp	@set ${LINKS}; \
128209225Simp	while test $$# -ge 2; do \
129209225Simp		l=${DESTDIR}$$1; \
130209225Simp		shift; \
131175258Ssimon		t=${DESTDIR}$$1; \
132175258Ssimon		shift; \
133175258Ssimon		echo $$t -\> $$l; \
134175258Ssimon		rm -f $$t; \
135183314Ssimon		ln $$l $$t; \
136183314Ssimon	done; true
137183314Ssimon.endif
138148422Sphk
139206276Simpinstall: afterinstall
140206276Simpafterinstall: realinstall
141206276Simp.if !defined(NOMAN)
142206276Simpafterinstall: maninstall
143148648Sphk.endif
144205980Simp.endif
145148648Sphk
146148648Sphk.if !target(lint)
147150366Sphklint:
148150366Sphk.endif
149150366Sphk
150150366Sphk.if !target(tags)
151150366Sphktags: ${SRCS}
152148422Sphk	-ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
153149120Sphk	    sed "s;\${.CURDIR}/;;" > ${.CURDIR}/tags
154183314Ssimon.endif
155148422Sphk
156194431Sn_hibma.include <bsd.man.mk>
157148422Sphk.if !target(obj)
158194431Sn_hibma.if defined(NOOBJ)
159148422Sphkobj:
160148422Sphk.else
161150343Sphkobj:
162148422Sphk	@cd ${.CURDIR}; rm -rf obj; \
163148422Sphk	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
164148422Sphk	echo "$$here -> $$dest"; ln -s $$dest obj; \
165194431Sn_hibma	if test -d /usr/obj -a ! -d $$dest; then \
166148422Sphk		mkdir -p $$dest; \
167194431Sn_hibma	else \
168194431Sn_hibma		true; \
169148422Sphk	fi;
170148422Sphk.endif
171148422Sphk.endif
172183314Ssimon