xref: /csrg-svn/share/mk/bsd.lib.mk (revision 67051)
1*67051Sbostic#	@(#)bsd.lib.mk	8.3 (Berkeley) 04/22/94
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
1343473SbosticSTRIP?=	-s
1443473Sbostic
1543473SbosticBINGRP?=	bin
1643473SbosticBINOWN?=	bin
1743473SbosticBINMODE?=	555
1843473Sbostic
1940581Sbostic.MAIN: all
2040581Sbostic
2141600Sbostic# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
2240581Sbostic.SUFFIXES:
2354728Storek.SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0 .m4
2441558Sbostic
2541867Sbostic.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
2651825Smarc	nroff -man ${.IMPSRC} > ${.TARGET}
2741867Sbostic
2840581Sbostic.c.o:
2940581Sbostic	${CC} ${CFLAGS} -c ${.IMPSRC}
3040581Sbostic	@${LD} -x -r ${.TARGET}
3141461Sbostic	@mv a.out ${.TARGET}
3240581Sbostic
3340581Sbostic.c.po:
3440581Sbostic	${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
3540581Sbostic	@${LD} -X -r ${.TARGET}
3641461Sbostic	@mv a.out ${.TARGET}
3740581Sbostic
3840581Sbostic.s.o:
3940581Sbostic	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
4040581Sbostic	    ${AS} -o ${.TARGET}
4140581Sbostic	@${LD} -x -r ${.TARGET}
4241461Sbostic	@mv a.out ${.TARGET}
4340581Sbostic
4440581Sbostic.s.po:
4540581Sbostic	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
4640581Sbostic	    ${AS} -o ${.TARGET}
4740581Sbostic	@${LD} -X -r ${.TARGET}
4841461Sbostic	@mv a.out ${.TARGET}
4940581Sbostic
5040581SbosticMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
5151825Smarcmanpages: ${MANALL}
5240581Sbostic
5348878Sbostic.if !defined(NOPROFILE)
5448878Sbostic_LIBS=lib${LIB}.a lib${LIB}_p.a
5548878Sbostic.else
5648878Sbostic_LIBS=lib${LIB}.a
5748878Sbostic.endif
5840581Sbostic
5951825Smarcall: ${_LIBS} # llib-l${LIB}.ln
6051825Smarc.if !defined(NOMAN)
6151825Smarcall: ${MANALL}
6251825Smarc.endif
6348878Sbostic
6446047SbosticOBJS+=	${SRCS:R:S/$/.o/g}
6546047Sbostic
6640581Sbosticlib${LIB}.a:: ${OBJS}
6740581Sbostic	@echo building standard ${LIB} library
6843509Sbostic	@rm -f lib${LIB}.a
6947601Sbostic	@${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
7046871Sbostic	ranlib lib${LIB}.a
7140581Sbostic
7242550SbosticPOBJS+=	${OBJS:.o=.po}
7340581Sbosticlib${LIB}_p.a:: ${POBJS}
7440581Sbostic	@echo building profiled ${LIB} library
7544309Sbostic	@rm -f lib${LIB}_p.a
7647601Sbostic	@${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
7746871Sbostic	ranlib lib${LIB}_p.a
7840581Sbostic
7940581Sbosticllib-l${LIB}.ln: ${SRCS}
8041461Sbostic	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
8140581Sbostic
8241555Sbostic.if !target(clean)
8341555Sbosticclean:
8457916Sbostic	rm -f ${OBJS}
8557916Sbostic	rm -f ${POBJS}
8666686Sbostic	rm -f a.out [Ee]rrs mklog ${CLEANFILES} \
8740581Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
8841555Sbostic.endif
8940581Sbostic
9041555Sbostic.if !target(cleandir)
9141555Sbosticcleandir:
9257916Sbostic	rm -f ${OBJS}
9357916Sbostic	rm -f ${POBJS}
9466686Sbostic	rm -f a.out [Ee]rrs mklog ${CLEANFILES} \
9541555Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
96*67051Sbostic	rm -f ${MANALL} .depend
9741555Sbostic.endif
9840581Sbostic
9941555Sbostic.if !target(depend)
10041555Sbosticdepend: .depend
10141555Sbostic.depend: ${SRCS}
10241461Sbostic	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
10345937Sbostic	@(TMP=/tmp/_depend$$$$; \
10454671Storek	    sed -e 's/^\([^\.]*\).o *:/\1.o \1.po:/' < .depend > $$TMP; \
10543508Sbostic	    mv $$TMP .depend)
10641555Sbostic.endif
10740581Sbostic
10841555Sbostic.if !target(install)
10941555Sbostic.if !target(beforeinstall)
11041555Sbosticbeforeinstall:
11141555Sbostic.endif
11241555Sbostic
11341555Sbosticrealinstall: beforeinstall
11441600Sbostic	ranlib lib${LIB}.a
11541461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
11641461Sbostic	    ${DESTDIR}${LIBDIR}
11741461Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
11853035Sbostic.if !defined(NOPROFILE)
11941600Sbostic	ranlib lib${LIB}_p.a
12041461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
12141461Sbostic	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
12243867Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
12351902Smarc.endif
12441604Sbostic#	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
12541604Sbostic#	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
12642198Sbostic.if defined(LINKS) && !empty(LINKS)
12742198Sbostic	@set ${LINKS}; \
12842198Sbostic	while test $$# -ge 2; do \
12942198Sbostic		l=${DESTDIR}$$1; \
13042198Sbostic		shift; \
13142198Sbostic		t=${DESTDIR}$$1; \
13242198Sbostic		shift; \
13342198Sbostic		echo $$t -\> $$l; \
13442198Sbostic		rm -f $$t; \
13542198Sbostic		ln $$l $$t; \
13642198Sbostic	done; true
13742198Sbostic.endif
13841461Sbostic
13941555Sbosticinstall: afterinstall
14051825Smarcafterinstall: realinstall
14151825Smarc.if !defined(NOMAN)
14251825Smarcafterinstall: maninstall
14341555Sbostic.endif
14451825Smarc.endif
14541461Sbostic
14641555Sbostic.if !target(lint)
14741555Sbosticlint:
14841555Sbostic.endif
14941555Sbostic
15041555Sbostic.if !target(tags)
15143473Sbostictags: ${SRCS}
15256928Sbostic	-ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
15356928Sbostic	    sed "s;\${.CURDIR}/;;" > ${.CURDIR}/tags
15440581Sbostic.endif
15540581Sbostic
15641600Sbostic.include <bsd.man.mk>
15743473Sbostic.if !target(obj)
15843473Sbostic.if defined(NOOBJ)
15943473Sbosticobj:
16043473Sbostic.else
16143473Sbosticobj:
16243473Sbostic	@cd ${.CURDIR}; rm -rf obj; \
16343473Sbostic	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
16445780Sbostic	echo "$$here -> $$dest"; ln -s $$dest obj; \
16545780Sbostic	if test -d /usr/obj -a ! -d $$dest; then \
16645780Sbostic		mkdir -p $$dest; \
16745780Sbostic	else \
16845780Sbostic		true; \
16945780Sbostic	fi;
17043473Sbostic.endif
17143473Sbostic.endif
172