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