bsd.lib.mk revision 1.4 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 MANALL= ${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
58 all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
59
60 OBJS+= ${SRCS:R:S/$/.o/g}
61
62 lib${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
68 POBJS+= ${OBJS:.o=.po}
69 lib${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
75 llib-l${LIB}.ln: ${SRCS}
76 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
77
78 .if !target(clean)
79 clean:
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)
85 cleandir:
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)
92 depend: .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)
102 beforeinstall:
103 .endif
104
105 realinstall: beforeinstall
106 ranlib lib${LIB}.a
107 install -c -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 -c -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
129 install: afterinstall
130 afterinstall: realinstall maninstall
131 .endif
132
133 .if !target(lint)
134 lint:
135 .endif
136
137 .if !target(tags)
138 tags: ${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)
146 obj:
147 .else
148 obj:
149 @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \
150 here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \
151 if test $$here != $$subdir ; then \
152 dest=/usr/obj/$$subdir ; \
153 echo "$$here -> $$dest"; ln -s $$dest obj; \
154 if test -d /usr/obj -a ! -d $$dest; then \
155 mkdir -p $$dest; \
156 else \
157 true; \
158 fi; \
159 else \
160 true ; \
161 dest=$$here/obj ; \
162 echo "making $$here/obj" ; \
163 if test ! -d obj ; then \
164 mkdir $$here/obj; \
165 fi; \
166 fi;
167 .endif
168 .endif
169