xref: /csrg-svn/share/mk/bsd.lib.mk (revision 54671)
1*54671Storek#	@(#)bsd.lib.mk	5.33 (Berkeley) 07/03/92
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:
2341873Sbostic.SUFFIXES: .out .o .po .s .c .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
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
3851824Smarc.if (${MACHINE} == "mips")
3951824SmarcNOPROFILE=1
4053035Sbostic.endif
4153035Sbostic
4240581Sbostic.s.o:
4340581Sbostic	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
4440581Sbostic	    ${AS} -o ${.TARGET}
4540581Sbostic	@${LD} -x -r ${.TARGET}
4641461Sbostic	@mv a.out ${.TARGET}
4740581Sbostic
4840581Sbostic.s.po:
4940581Sbostic	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
5040581Sbostic	    ${AS} -o ${.TARGET}
5140581Sbostic	@${LD} -X -r ${.TARGET}
5241461Sbostic	@mv a.out ${.TARGET}
5340581Sbostic
5440581SbosticMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
5551825Smarcmanpages: ${MANALL}
5640581Sbostic
5748878Sbostic.if !defined(NOPROFILE)
5848878Sbostic_LIBS=lib${LIB}.a lib${LIB}_p.a
5948878Sbostic.else
6048878Sbostic_LIBS=lib${LIB}.a
6148878Sbostic.endif
6240581Sbostic
6351825Smarcall: ${_LIBS} # llib-l${LIB}.ln
6451825Smarc.if !defined(NOMAN)
6551825Smarcall: ${MANALL}
6651825Smarc.endif
6748878Sbostic
6846047SbosticOBJS+=	${SRCS:R:S/$/.o/g}
6946047Sbostic
7040581Sbosticlib${LIB}.a:: ${OBJS}
7140581Sbostic	@echo building standard ${LIB} library
7243509Sbostic	@rm -f lib${LIB}.a
7351824Smarc.if (${MACHINE} == "mips")
7451824Smarc	@${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
7551824Smarc.else
7647601Sbostic	@${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
7751824Smarc.endif
7846871Sbostic	ranlib lib${LIB}.a
7940581Sbostic
8042550SbosticPOBJS+=	${OBJS:.o=.po}
8140581Sbosticlib${LIB}_p.a:: ${POBJS}
8240581Sbostic	@echo building profiled ${LIB} library
8344309Sbostic	@rm -f lib${LIB}_p.a
8447601Sbostic	@${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
8546871Sbostic	ranlib lib${LIB}_p.a
8640581Sbostic
8740581Sbosticllib-l${LIB}.ln: ${SRCS}
8841461Sbostic	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
8940581Sbostic
9041555Sbostic.if !target(clean)
9141555Sbosticclean:
9240581Sbostic	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
9340581Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
9441555Sbostic.endif
9540581Sbostic
9641555Sbostic.if !target(cleandir)
9741555Sbosticcleandir:
9841555Sbostic	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
9941555Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
10042550Sbostic	rm -f ${MANALL} ${.CURDIR}/tags .depend
10141555Sbostic.endif
10240581Sbostic
10341555Sbostic.if !target(depend)
10441555Sbosticdepend: .depend
10541555Sbostic.depend: ${SRCS}
10641461Sbostic	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
10745937Sbostic	@(TMP=/tmp/_depend$$$$; \
108*54671Storek	    sed -e 's/^\([^\.]*\).o *:/\1.o \1.po:/' < .depend > $$TMP; \
10943508Sbostic	    mv $$TMP .depend)
11041555Sbostic.endif
11140581Sbostic
11241555Sbostic.if !target(install)
11341555Sbostic.if !target(beforeinstall)
11441555Sbosticbeforeinstall:
11541555Sbostic.endif
11641555Sbostic
11741555Sbosticrealinstall: beforeinstall
11841600Sbostic	ranlib lib${LIB}.a
11941461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
12041461Sbostic	    ${DESTDIR}${LIBDIR}
12141461Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
12253035Sbostic.if !defined(NOPROFILE)
12341600Sbostic	ranlib lib${LIB}_p.a
12441461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
12541461Sbostic	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
12643867Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
12751902Smarc.endif
12841604Sbostic#	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
12941604Sbostic#	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
13042198Sbostic.if defined(LINKS) && !empty(LINKS)
13142198Sbostic	@set ${LINKS}; \
13242198Sbostic	while test $$# -ge 2; do \
13342198Sbostic		l=${DESTDIR}$$1; \
13442198Sbostic		shift; \
13542198Sbostic		t=${DESTDIR}$$1; \
13642198Sbostic		shift; \
13742198Sbostic		echo $$t -\> $$l; \
13842198Sbostic		rm -f $$t; \
13942198Sbostic		ln $$l $$t; \
14042198Sbostic	done; true
14142198Sbostic.endif
14241461Sbostic
14341555Sbosticinstall: afterinstall
14451825Smarcafterinstall: realinstall
14551825Smarc.if !defined(NOMAN)
14651825Smarcafterinstall: maninstall
14741555Sbostic.endif
14851825Smarc.endif
14941461Sbostic
15041555Sbostic.if !target(lint)
15141555Sbosticlint:
15241555Sbostic.endif
15341555Sbostic
15441555Sbostic.if !target(tags)
15543473Sbostictags: ${SRCS}
15643473Sbostic	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
15742550Sbostic	    sed "s;\${.CURDIR}/;;" > tags
15840581Sbostic.endif
15940581Sbostic
16041600Sbostic.include <bsd.man.mk>
16143473Sbostic.if !target(obj)
16243473Sbostic.if defined(NOOBJ)
16343473Sbosticobj:
16443473Sbostic.else
16543473Sbosticobj:
16643473Sbostic	@cd ${.CURDIR}; rm -rf obj; \
16743473Sbostic	here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
16845780Sbostic	echo "$$here -> $$dest"; ln -s $$dest obj; \
16945780Sbostic	if test -d /usr/obj -a ! -d $$dest; then \
17045780Sbostic		mkdir -p $$dest; \
17145780Sbostic	else \
17245780Sbostic		true; \
17345780Sbostic	fi;
17443473Sbostic.endif
17543473Sbostic.endif
176