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