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