bsd.lib.mk revision 1.23 1 # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91
2 # $Id: bsd.lib.mk,v 1.23 1993/08/15 19:37:06 mycroft Exp $
3
4 .if exists(${.CURDIR}/../Makefile.inc)
5 .include "${.CURDIR}/../Makefile.inc"
6 .endif
7
8 LIBDIR?= /usr/lib
9 LINTLIBDIR?= /usr/libdata/lint
10 LIBGRP?= bin
11 LIBOWN?= bin
12 LIBMODE?= 444
13
14 STRIP?= -s
15
16 BINGRP?= bin
17 BINOWN?= bin
18 BINMODE?= 555
19
20 .MAIN: all
21
22 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
23 .SUFFIXES:
24 .SUFFIXES: .out .o .po .s .c .cc .C .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
25
26 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
27 nroff -mandoc ${.IMPSRC} > ${.TARGET}
28
29 .c.o:
30 ${CC} ${CFLAGS} -c ${.IMPSRC}
31 @${LD} -x -r ${.TARGET}
32 @mv a.out ${.TARGET}
33
34 .c.po:
35 ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
36 @${LD} -X -r ${.TARGET}
37 @mv a.out ${.TARGET}
38
39 .cc.o .C.o:
40 ${CXX} ${CXXFLAGS} -c ${.IMPSRC}
41 @${LD} -x -r ${.TARGET}
42 @mv a.out ${.TARGET}
43
44 .cc.po .C.po:
45 ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
46 @${LD} -X -r ${.TARGET}
47 @mv a.out ${.TARGET}
48
49 .s.o:
50 ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
51 ${AS} -o ${.TARGET}
52 @${LD} -x -r ${.TARGET}
53 @mv a.out ${.TARGET}
54
55 .s.po:
56 ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
57 ${AS} -o ${.TARGET}
58 @${LD} -X -r ${.TARGET}
59 @mv a.out ${.TARGET}
60
61 .if !defined(NOMAN)
62 MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
63 .endif
64
65 .if !defined(NOPROFILE)
66 _LIBS=lib${LIB}.a lib${LIB}_p.a
67 .else
68 _LIBS=lib${LIB}.a
69 .endif
70
71 all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
72
73 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
74
75 lib${LIB}.a:: ${OBJS}
76 @echo building standard ${LIB} library
77 @rm -f lib${LIB}.a
78 @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
79 ${RANLIB} lib${LIB}.a
80
81 POBJS+= ${OBJS:.o=.po}
82 lib${LIB}_p.a:: ${POBJS}
83 @echo building profiled ${LIB} library
84 @rm -f lib${LIB}_p.a
85 @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
86 ${RANLIB} lib${LIB}_p.a
87
88 llib-l${LIB}.ln: ${SRCS}
89 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
90
91 .if !target(clean)
92 clean:
93 rm -f a.out Errs errs mklog core ${CLEANFILES}
94 rm -f ${OBJS}
95 rm -f ${POBJS} profiled/*.o
96 rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
97 .endif
98
99 .if !target(cleandir)
100 cleandir: clean
101 rm -f ${MANALL} ${.CURDIR}/tags .depend
102 .endif
103
104 .include <bsd.dep.mk>
105 afterdepend:
106 @(TMP=/tmp/_depend$$$$; \
107 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po:/' < .depend > $$TMP; \
108 mv $$TMP .depend)
109
110 .if !target(install)
111 .if !target(beforeinstall)
112 beforeinstall:
113 @install -d -o root -g wheel -m 755 ${DESTDIR}${LIBDIR}
114 .endif
115
116 realinstall:
117 # ranlib lib${LIB}.a
118 install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
119 ${DESTDIR}${LIBDIR}
120 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
121 .if !defined(NOPROFILE)
122 # ranlib lib${LIB}_p.a
123 install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
124 lib${LIB}_p.a ${DESTDIR}${LIBDIR}
125 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
126 .endif
127 # install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
128 # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
129 .if defined(LINKS) && !empty(LINKS)
130 @set ${LINKS}; \
131 while test $$# -ge 2; do \
132 l=${DESTDIR}$$1; \
133 shift; \
134 t=${DESTDIR}$$1; \
135 shift; \
136 echo $$t -\> $$l; \
137 rm -f $$t; \
138 ln $$l $$t; \
139 done; true
140 .endif
141
142 install: maninstall
143 maninstall: afterinstall
144 afterinstall: realinstall
145 realinstall: beforeinstall
146 .endif
147
148 .if !target(lint)
149 lint:
150 .endif
151
152 .if !target(tags)
153 tags: ${SRCS}
154 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
155 sed "s;\${.CURDIR}/;;" > tags
156 .endif
157
158 .if !defined(NOMAN)
159 .include <bsd.man.mk>
160 .endif
161
162 .include <bsd.obj.mk>
163