xref: /csrg-svn/share/mk/bsd.lib.mk (revision 41461)
1*41461Sbostic.include <bsd.global.mk>
240581Sbostic
3*41461Sbostic.if exists(${.CURDIR}/../Makefile.inc)
4*41461Sbostic.include "${.CURDIR}/../Makefile.inc"
5*41461Sbostic.endif
6*41461Sbostic
740581Sbostic.MAIN: all
840581Sbostic
940581Sbostic# minor mods to prefer .s to a .c, and add .po
1040581Sbostic.SUFFIXES:
1140581Sbostic.SUFFIXES: .out .a .ln .o .po .s .c .F .f .e .r .y .l .cl .p .h \
1240581Sbostic                .8 .7 .6 .5 .4 .3 .2 .1 .0
1340581Sbostic.c.o:
1440581Sbostic	${CC} ${CFLAGS} -c ${.IMPSRC}
1540581Sbostic	@${LD} -x -r ${.TARGET}
16*41461Sbostic	@mv a.out ${.TARGET}
1740581Sbostic
1840581Sbostic.c.po:
1940581Sbostic	${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
2040581Sbostic	@${LD} -X -r ${.TARGET}
21*41461Sbostic	@mv a.out ${.TARGET}
2240581Sbostic
2340581Sbostic.s.o:
2440581Sbostic	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
2540581Sbostic	    ${AS} -o ${.TARGET}
2640581Sbostic	@${LD} -x -r ${.TARGET}
27*41461Sbostic	@mv a.out ${.TARGET}
2840581Sbostic
2940581Sbostic.s.po:
3040581Sbostic	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
3140581Sbostic	    ${AS} -o ${.TARGET}
3240581Sbostic	@${LD} -X -r ${.TARGET}
33*41461Sbostic	@mv a.out ${.TARGET}
3440581Sbostic
3540581SbosticMANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
3640581Sbostic
3740581Sbosticall: ranlib llib-l${LIB}.ln ${MANALL}
3840581Sbostic
39*41461Sbosticranlib: lib${LIB}.a lib${LIB}_p.a
4040581Sbostic	ranlib lib${LIB}.a
4140581Sbostic	ranlib lib${LIB}_p.a
4240581Sbostic
43*41461Sbostic.if target(reorder)
44*41461Sbosticranlib: reorder
45*41461Sbostic.endif
4640581Sbostic
4740581SbosticOBJS=	${SRCS:S/.c$/.o/g:S/.f$/.o/g:S/.s$/.o/g}
4840581Sbosticlib${LIB}.a:: ${OBJS}
4940581Sbostic	@echo building standard ${LIB} library
50*41461Sbostic	@${AR} cr lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
5140581Sbostic
5240581SbosticPOBJS=	${OBJS:.o=.po}
5340581Sbosticlib${LIB}_p.a:: ${POBJS}
5440581Sbostic	@echo building profiled ${LIB} library
55*41461Sbostic	@${AR} cr lib${LIB}_p.a `lorder ${POBJS} | tsort` ${LDADD}
5640581Sbostic
5740581Sbosticllib-l${LIB}.ln: ${SRCS}
58*41461Sbostic	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
5940581Sbostic
60*41461SbosticSTDCLEAN:
6140581Sbostic	rm -f a.out Errs errs mklog core ${CLEANFILES} ${OBJS} ${POBJS} \
6240581Sbostic	    profiled/*.o lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
6340581Sbostic
64*41461SbosticSTDCLEANDIR:
65*41461Sbostic	rm -f ${MANALL} tags .depend
6640581Sbostic
6740581SbosticSTDDEPEND: ${SRCS} .USE
68*41461Sbostic	mkdep ${CFLAGS:M-[ID]*} ${AINC} ${.ALLSRC}
6940581Sbostic
70*41461SbosticSTDINSTALL:
71*41461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
72*41461Sbostic	    ${DESTDIR}${LIBDIR}
73*41461Sbostic	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
74*41461Sbostic	install -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
75*41461Sbostic	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
76*41461Sbostic	${RANLIB} -t ${DESTDIR}/usr/lib/lib${LIB}_p.a
77*41461Sbostic	install -c -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
78*41461Sbostic	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
79*41461Sbostic
80*41461SbosticSTDLINT:
81*41461Sbostic
8240581SbosticSTDTAGS: .USE
83*41461Sbostic	tags ${.ALLSRC:M*.c}
84*41461Sbostic	sed -e 's;../gen/;/usr/src/lib/libc/gen/;' \
8540581Sbostic	    -e 's;../compat-43/;/usr/src/lib/libc/gen/;' \
8640581Sbostic	    < tags > tags.tmp
8740581Sbostic.if !empty(SRCS:M*.s)
8840581Sbostic	egrep -o "^ENTRY(.*)|^SYSCALL(.*)" ${.ALLSRC:M*.s} | sed \
8940581Sbostic	"s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \`pwd\`/\1 /^\2(\3\4$$/;" \
9040581Sbostic	>> tags.tmp
91*41461Sbostic	sort tags.tmp -o tags.tmp
9240581Sbostic.endif
93*41461Sbostic	mv tags.tmp tags
9440581Sbostic
9540581Sbostic.include <bsd.own.mk>
96*41461Sbostic.include <bsd.stdtarg.mk>
97