This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / share / mk / bsd.lib.mk
CommitLineData
15637ed4
RG
1# @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2#
3# PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
4# -------------------- ----- ----------------------
5# CURRENT PATCH LEVEL: 1 00157
6# -------------------- ----- ----------------------
7#
8# 27 Apr 93 Rodney W. Grimes Break up cleandir so that we do not
9# overflow shell args
a33daf07
RG
10# $History$
11# $Log$
15637ed4
RG
12
13.if exists(${.CURDIR}/../Makefile.inc)
14.include "${.CURDIR}/../Makefile.inc"
15.endif
16
17LIBDIR?= /usr/lib
18LINTLIBDIR?= /usr/libdata/lint
19LIBGRP?= bin
20LIBOWN?= bin
21LIBMODE?= 444
22
23STRIP?= -s
24
25BINGRP?= bin
26BINOWN?= bin
27BINMODE?= 555
28
29.MAIN: all
30
31# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
32.SUFFIXES:
33.SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
34
35.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
36 nroff -mandoc ${.IMPSRC} > ${.TARGET}
37
38.c.o:
39 ${CC} ${CFLAGS} -c ${.IMPSRC}
40 @${LD} -x -r ${.TARGET}
41 @mv a.out ${.TARGET}
42
43.c.po:
44 ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
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
60MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
61
62.if !defined(NOPROFILE)
63_LIBS=lib${LIB}.a lib${LIB}_p.a
64.else
65_LIBS=lib${LIB}.a
66.endif
67
68all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
69
70OBJS+= ${SRCS:R:S/$/.o/g}
71
72lib${LIB}.a:: ${OBJS}
73 @echo building standard ${LIB} library
74 @rm -f lib${LIB}.a
75 @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
76 ranlib lib${LIB}.a
77
78POBJS+= ${OBJS:.o=.po}
79lib${LIB}_p.a:: ${POBJS}
80 @echo building profiled ${LIB} library
81 @rm -f lib${LIB}_p.a
82 @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
83 ranlib lib${LIB}_p.a
84
85llib-l${LIB}.ln: ${SRCS}
86 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
87
88.if !target(clean)
89clean:
a33daf07
RG
90 rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} \
91 lib${LIB}.a llib-l${LIB}.ln ${MANALL}
92 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a
15637ed4
RG
93.endif
94
95.if !target(cleandir)
96cleandir:
97 rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} \
98 lib${LIB}.a llib-l${LIB}.ln \
99 ${MANALL} ${.CURDIR}/tags .depend
100 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a
101 cd ${.CURDIR}; rm -rf obj;
102.endif
103
104.if !target(depend)
105depend: .depend
106.depend: ${SRCS}
107 mkdep ${CFLAGS:M-[ID+]*} ${AINC} ${.ALLSRC}
108 @(TMP=/tmp/_depend$$$$; \
109 sed -e 's/^\([^\.]*\).o:/\1.o \1.po:/' < .depend > $$TMP; \
110 mv $$TMP .depend)
111.endif
112
113.if !target(install)
114.if !target(beforeinstall)
115beforeinstall:
116.endif
117
118realinstall: beforeinstall
119 ranlib lib${LIB}.a
120 install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
121 ${DESTDIR}${LIBDIR}
122 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
123.if !defined(NOPROFILE)
124 ranlib lib${LIB}_p.a
125 install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
126 lib${LIB}_p.a ${DESTDIR}${LIBDIR}
127 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
128.endif
129# install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
130# llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
131.if defined(LINKS) && !empty(LINKS)
132 @set ${LINKS}; \
133 while test $$# -ge 2; do \
134 l=${DESTDIR}$$1; \
135 shift; \
136 t=${DESTDIR}$$1; \
137 shift; \
138 echo $$t -\> $$l; \
139 rm -f $$t; \
140 ln $$l $$t; \
141 done; true
142.endif
143
144install: afterinstall
145afterinstall: realinstall maninstall
146.endif
147
148.if !target(lint)
149lint:
150.endif
151
152.if !target(tags)
153tags: ${SRCS}
154 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
155 sed "s;\${.CURDIR}/;;" > tags
156.endif
157
158.include <bsd.man.mk>
159.if !target(obj)
160.if defined(NOOBJ)
161obj:
162.else
163obj:
164 @cd ${.CURDIR}; rm -rf obj; \
165 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
166 echo "$$here -> $$dest"; ln -s $$dest obj; \
167 if test -d /usr/obj -a ! -d $$dest; then \
168 mkdir -p $$dest; \
169 else \
170 true; \
171 fi;
172.endif
173.endif