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