1# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 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 .m4 24 25.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0: 26 nroff -man ${.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} 51manpages: ${MANALL} 52 53.if !defined(NOPROFILE) 54_LIBS=lib${LIB}.a lib${LIB}_p.a 55.else 56_LIBS=lib${LIB}.a 57.endif 58 59all: ${_LIBS} # llib-l${LIB}.ln 60.if !defined(NOMAN) 61all: ${MANALL} 62.endif 63 64OBJS+= ${SRCS:R:S/$/.o/g} 65 66lib${LIB}.a:: ${OBJS} 67 @echo building standard ${LIB} library 68 @rm -f lib${LIB}.a 69 @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD} 70 ranlib lib${LIB}.a 71 72POBJS+= ${OBJS:.o=.po} 73lib${LIB}_p.a:: ${POBJS} 74 @echo building profiled ${LIB} library 75 @rm -f lib${LIB}_p.a 76 @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD} 77 ranlib lib${LIB}_p.a 78 79llib-l${LIB}.ln: ${SRCS} 80 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} 81 82.if !target(clean) 83clean: 84 rm -f ${OBJS} 85 rm -f ${POBJS} 86 rm -f a.out [Ee]rrs mklog ${CLEANFILES} \ 87 profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln 88.endif 89 90.if !target(cleandir) 91cleandir: 92 rm -f ${OBJS} 93 rm -f ${POBJS} 94 rm -f a.out [Ee]rrs mklog ${CLEANFILES} \ 95 profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln 96 rm -f ${MANALL} .depend 97.endif 98 99.if !target(depend) 100depend: .depend 101.depend: ${SRCS} 102 mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC} 103 @(TMP=/tmp/_depend$$$$; \ 104 sed -e 's/^\([^\.]*\).o *:/\1.o \1.po:/' < .depend > $$TMP; \ 105 mv $$TMP .depend) 106.endif 107 108.if !target(install) 109.if !target(beforeinstall) 110beforeinstall: 111.endif 112 113realinstall: beforeinstall 114 ranlib lib${LIB}.a 115 install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \ 116 ${DESTDIR}${LIBDIR} 117 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a 118.if !defined(NOPROFILE) 119 ranlib lib${LIB}_p.a 120 install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 121 lib${LIB}_p.a ${DESTDIR}${LIBDIR} 122 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 123.endif 124# install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 125# llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} 126.if defined(LINKS) && !empty(LINKS) 127 @set ${LINKS}; \ 128 while test $$# -ge 2; do \ 129 l=${DESTDIR}$$1; \ 130 shift; \ 131 t=${DESTDIR}$$1; \ 132 shift; \ 133 echo $$t -\> $$l; \ 134 rm -f $$t; \ 135 ln $$l $$t; \ 136 done; true 137.endif 138 139install: afterinstall 140afterinstall: realinstall 141.if !defined(NOMAN) 142afterinstall: maninstall 143.endif 144.endif 145 146.if !target(lint) 147lint: 148.endif 149 150.if !target(tags) 151tags: ${SRCS} 152 -ctags -f /dev/stdout ${.ALLSRC:M*.c} | \ 153 sed "s;\${.CURDIR}/;;" > ${.CURDIR}/tags 154.endif 155 156.include <bsd.man.mk> 157.if !target(obj) 158.if defined(NOOBJ) 159obj: 160.else 161obj: 162 @cd ${.CURDIR}; rm -rf obj; \ 163 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ 164 echo "$$here -> $$dest"; ln -s $$dest obj; \ 165 if test -d /usr/obj -a ! -d $$dest; then \ 166 mkdir -p $$dest; \ 167 else \ 168 true; \ 169 fi; 170.endif 171.endif 172