| 1 | # @(#)bsd.lib.mk 5.18 (Berkeley) %G% |
| 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 -man -h ${.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 | all: lib${LIB}.a lib${LIB}_p.a ${MANALL}# llib-l${LIB}.ln |
| 53 | |
| 54 | OBJS+= ${SRCS:S/.c$/.o/g:S/.f$/.o/g:S/.s$/.o/g} |
| 55 | lib${LIB}.a:: ${OBJS} |
| 56 | @echo building standard ${LIB} library |
| 57 | @rm -f lib${LIB}.a |
| 58 | @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD} |
| 59 | |
| 60 | POBJS+= ${OBJS:.o=.po} |
| 61 | lib${LIB}_p.a:: ${POBJS} |
| 62 | @echo building profiled ${LIB} library |
| 63 | @rm -f lib${LIB}_p.a |
| 64 | @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD} |
| 65 | |
| 66 | llib-l${LIB}.ln: ${SRCS} |
| 67 | ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} |
| 68 | |
| 69 | .if !target(clean) |
| 70 | clean: |
| 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 |
| 73 | .endif |
| 74 | |
| 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 |
| 79 | rm -f ${MANALL} ${.CURDIR}/tags .depend |
| 80 | .endif |
| 81 | |
| 82 | .if !target(depend) |
| 83 | depend: .depend |
| 84 | .depend: ${SRCS} |
| 85 | mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC} |
| 86 | @(TMP=/tmp/_depend$$$$; \ |
| 87 | sed -e 's/^\([^\.]*\).o:/\1.o \1.po:/' < .depend > $$TMP; \ |
| 88 | mv $$TMP .depend) |
| 89 | .endif |
| 90 | |
| 91 | .if !target(install) |
| 92 | .if !target(beforeinstall) |
| 93 | beforeinstall: |
| 94 | .endif |
| 95 | |
| 96 | realinstall: beforeinstall |
| 97 | ranlib lib${LIB}.a |
| 98 | install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \ |
| 99 | ${DESTDIR}${LIBDIR} |
| 100 | ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a |
| 101 | ranlib lib${LIB}_p.a |
| 102 | install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ |
| 103 | lib${LIB}_p.a ${DESTDIR}${LIBDIR} |
| 104 | ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a |
| 105 | # install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ |
| 106 | # llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} |
| 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 |
| 119 | |
| 120 | install: afterinstall |
| 121 | afterinstall: realinstall maninstall |
| 122 | .endif |
| 123 | |
| 124 | .if !target(lint) |
| 125 | lint: |
| 126 | .endif |
| 127 | |
| 128 | .if !target(tags) |
| 129 | tags: ${SRCS} |
| 130 | -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \ |
| 131 | sed "s;\${.CURDIR}/;;" > tags |
| 132 | .if !empty(SRCS:M*.s) |
| 133 | -cd ${.CURDIR}; egrep -o "^ENTRY(.*)|^SYSCALL(.*)" ${.ALLSRC:M*.s} | \ |
| 134 | sed \ |
| 135 | "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \`pwd\`/\1 /^\2(\3\4$$/;" \ |
| 136 | >> tags; sort -o tags tags |
| 137 | .endif |
| 138 | .endif |
| 139 | |
| 140 | .include <bsd.man.mk> |
| 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/,,'`; \ |
| 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; |
| 154 | .endif |
| 155 | .endif |