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