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