xref: /original-bsd/share/mk/bsd.lib.mk (revision 37492ebb)
1#	@(#)bsd.lib.mk	5.28 (Berkeley) 09/09/91
2
3.if exists(${.CURDIR}/../Makefile.inc)
4.include "${.CURDIR}/../Makefile.inc"
5.endif
6
7LIBDIR?=	/usr/lib
8LINTLIBDIR?=	/usr/libdata/lint
9LIBGRP?=	bin
10LIBOWN?=	bin
11LIBMODE?=	444
12
13STRIP?=	-s
14
15BINGRP?=	bin
16BINOWN?=	bin
17BINMODE?=	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 -man ${.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
50MANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
51manpages: ${MANALL}
52
53.if !defined(NOPROFILE)
54_LIBS=lib${LIB}.a lib${LIB}_p.a
55.else
56_LIBS=lib${LIB}.a
57.endif
58
59all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
60
61OBJS+=	${SRCS:R:S/$/.o/g}
62
63lib${LIB}.a:: ${OBJS}
64	@echo building standard ${LIB} library
65	@rm -f lib${LIB}.a
66	@${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
67	ranlib lib${LIB}.a
68
69POBJS+=	${OBJS:.o=.po}
70lib${LIB}_p.a:: ${POBJS}
71	@echo building profiled ${LIB} library
72	@rm -f lib${LIB}_p.a
73	@${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
74	ranlib lib${LIB}_p.a
75
76llib-l${LIB}.ln: ${SRCS}
77	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
78
79.if !target(clean)
80clean:
81	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
82	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
83.endif
84
85.if !target(cleandir)
86cleandir:
87	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
88	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
89	rm -f ${MANALL} ${.CURDIR}/tags .depend
90.endif
91
92.if !target(depend)
93depend: .depend
94.depend: ${SRCS}
95	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
96	@(TMP=/tmp/_depend$$$$; \
97	    sed -e 's/^\([^\.]*\).o:/\1.o \1.po:/' < .depend > $$TMP; \
98	    mv $$TMP .depend)
99.endif
100
101.if !target(install)
102.if !target(beforeinstall)
103beforeinstall:
104.endif
105
106realinstall: beforeinstall
107	ranlib lib${LIB}.a
108	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
109	    ${DESTDIR}${LIBDIR}
110	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
111	ranlib lib${LIB}_p.a
112	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
113	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
114	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
115#	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
116#	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
117.if defined(LINKS) && !empty(LINKS)
118	@set ${LINKS}; \
119	while test $$# -ge 2; do \
120		l=${DESTDIR}$$1; \
121		shift; \
122		t=${DESTDIR}$$1; \
123		shift; \
124		echo $$t -\> $$l; \
125		rm -f $$t; \
126		ln $$l $$t; \
127	done; true
128.endif
129
130install: afterinstall
131afterinstall: realinstall maninstall
132.endif
133
134.if !target(lint)
135lint:
136.endif
137
138.if !target(tags)
139tags: ${SRCS}
140	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
141	    sed "s;\${.CURDIR}/;;" > tags
142.endif
143
144.include <bsd.man.mk>
145.if !target(obj)
146.if defined(NOOBJ)
147obj:
148.else
149obj:
150	@cd ${.CURDIR}; rm -rf obj; \
151	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
152	echo "$$here -> $$dest"; ln -s $$dest obj; \
153	if test -d /usr/obj -a ! -d $$dest; then \
154		mkdir -p $$dest; \
155	else \
156		true; \
157	fi;
158.endif
159.endif
160