xref: /csrg-svn/share/mk/bsd.lib.mk (revision 42550)
1*42550Sbostic#	@(#)bsd.lib.mk	5.11 (Berkeley) 06/01/90
240581Sbostic
341461Sbostic.if exists(${.CURDIR}/../Makefile.inc)
441461Sbostic.include "${.CURDIR}/../Makefile.inc"
541461Sbostic.endif
641461Sbostic
741600SbosticLIBDIR?=	/usr/lib
841600SbosticLINTLIBDIR?=	/usr/libdata/lint
941600SbosticLIBGRP?=	bin
1041600SbosticLIBOWN?=	bin
1141600SbosticLIBMODE?=	444
1241600Sbostic
1340581Sbostic.MAIN: all
1440581Sbostic
1541600Sbostic# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
1640581Sbostic.SUFFIXES:
1741873Sbostic.SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
1841558Sbostic
1941867Sbostic.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
2041867Sbostic	nroff -man -h ${.IMPSRC} > ${.TARGET}
2141867Sbostic
2240581Sbostic.c.o:
2340581Sbostic	${CC} ${CFLAGS} -c ${.IMPSRC}
2440581Sbostic	@${LD} -x -r ${.TARGET}
2541461Sbostic	@mv a.out ${.TARGET}
2640581Sbostic
2740581Sbostic.c.po:
2840581Sbostic	${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
2940581Sbostic	@${LD} -X -r ${.TARGET}
3041461Sbostic	@mv a.out ${.TARGET}
3140581Sbostic
3240581Sbostic.s.o:
3340581Sbostic	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
3440581Sbostic	    ${AS} -o ${.TARGET}
3540581Sbostic	@${LD} -x -r ${.TARGET}
3641461Sbostic	@mv a.out ${.TARGET}
3740581Sbostic
3840581Sbostic.s.po:
3940581Sbostic	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
4040581Sbostic	    ${AS} -o ${.TARGET}
4140581Sbostic	@${LD} -X -r ${.TARGET}
4241461Sbostic	@mv a.out ${.TARGET}
4340581Sbostic
4440581SbosticMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
4540581Sbostic
4641600Sbosticall: lib${LIB}.a lib${LIB}_p.a ${MANALL}# llib-l${LIB}.ln
4740581Sbostic
48*42550SbosticOBJS+=	${SRCS:S/.c$/.o/g:S/.f$/.o/g:S/.s$/.o/g}
4940581Sbosticlib${LIB}.a:: ${OBJS}
5040581Sbostic	@echo building standard ${LIB} library
5141461Sbostic	@${AR} cr lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
5240581Sbostic
53*42550SbosticPOBJS+=	${OBJS:.o=.po}
5440581Sbosticlib${LIB}_p.a:: ${POBJS}
5540581Sbostic	@echo building profiled ${LIB} library
5641461Sbostic	@${AR} cr lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
5740581Sbostic
5840581Sbosticllib-l${LIB}.ln: ${SRCS}
5941461Sbostic	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
6040581Sbostic
6141555Sbostic.if !target(clean)
6241555Sbosticclean:
6340581Sbostic	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
6440581Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
6541555Sbostic.endif
6640581Sbostic
6741555Sbostic.if !target(cleandir)
6841555Sbosticcleandir:
6941555Sbostic	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
7041555Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
71*42550Sbostic	rm -f ${MANALL} ${.CURDIR}/tags .depend
7241555Sbostic.endif
7340581Sbostic
7441555Sbostic.if !target(depend)
7541555Sbosticdepend: .depend
7641555Sbostic.depend: ${SRCS}
7741461Sbostic	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
7841555Sbostic.endif
7940581Sbostic
8041555Sbostic.if !target(install)
8141555Sbostic.if !target(beforeinstall)
8241555Sbosticbeforeinstall:
8341555Sbostic.endif
8441555Sbostic
8541555Sbosticrealinstall: beforeinstall
8641600Sbostic	ranlib lib${LIB}.a
8741461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
8841461Sbostic	    ${DESTDIR}${LIBDIR}
8941461Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
9041600Sbostic	ranlib lib${LIB}_p.a
9141461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
9241461Sbostic	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
9341461Sbostic	${RANLIB} -t ${DESTDIR}/usr/lib/lib${LIB}_p.a
9441604Sbostic#	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
9541604Sbostic#	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
9642198Sbostic.if defined(LINKS) && !empty(LINKS)
9742198Sbostic	@set ${LINKS}; \
9842198Sbostic	while test $$# -ge 2; do \
9942198Sbostic		l=${DESTDIR}$$1; \
10042198Sbostic		shift; \
10142198Sbostic		t=${DESTDIR}$$1; \
10242198Sbostic		shift; \
10342198Sbostic		echo $$t -\> $$l; \
10442198Sbostic		rm -f $$t; \
10542198Sbostic		ln $$l $$t; \
10642198Sbostic	done; true
10742198Sbostic.endif
10841461Sbostic
10941555Sbosticinstall: afterinstall
11041600Sbosticafterinstall: realinstall maninstall
11141555Sbostic.endif
11241461Sbostic
11341555Sbostic.if !target(lint)
11441555Sbosticlint:
11541555Sbostic.endif
11641555Sbostic
11741555Sbostic.if !target(tags)
11841555Sbostictags:
119*42550Sbostic	cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
120*42550Sbostic	    sed "s;\${.CURDIR}/;;" > tags
12140581Sbostic.if !empty(SRCS:M*.s)
122*42550Sbostic	cd ${.CURDIR}; egrep -o "^ENTRY(.*)|^SYSCALL(.*)" ${.ALLSRC:M*.s} | \
123*42550Sbostic	    sed \
124*42550Sbostic	    "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \`pwd\`/\1 /^\2(\3\4$$/;" \
125*42550Sbostic	    >> tags; sort -o tags tags
12640581Sbostic.endif
12741555Sbostic.endif
12840581Sbostic
12941600Sbostic.include <bsd.man.mk>
130