Home | History | Annotate | Line # | Download | only in mk
bsd.lib.mk revision 1.22
      1 #	@(#)bsd.lib.mk	5.26 (Berkeley) 5/2/91
      2 
      3 .if exists(${.CURDIR}/../Makefile.inc)
      4 .include "${.CURDIR}/../Makefile.inc"
      5 .endif
      6 
      7 LIBDIR?=	/usr/lib
      8 LINTLIBDIR?=	/usr/libdata/lint
      9 LIBGRP?=	bin
     10 LIBOWN?=	bin
     11 LIBMODE?=	444
     12 
     13 STRIP?=	-s
     14 
     15 BINGRP?=	bin
     16 BINOWN?=	bin
     17 BINMODE?=	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 .cc .C .f .y .l .8 .7 .6 .5 .4 .3 .2 .1 .0
     24 
     25 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
     26 	nroff -mandoc ${.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 .cc.o .C.o:
     39 	${CXX} ${CXXFLAGS} -c ${.IMPSRC} 
     40 	@${LD} -x -r ${.TARGET}
     41 	@mv a.out ${.TARGET}
     42 
     43 .cc.po .C.po:
     44 	${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
     45 	@${LD} -X -r ${.TARGET}
     46 	@mv a.out ${.TARGET}
     47 
     48 .s.o:
     49 	${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
     50 	    ${AS} -o ${.TARGET}
     51 	@${LD} -x -r ${.TARGET}
     52 	@mv a.out ${.TARGET}
     53 
     54 .s.po:
     55 	${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \
     56 	    ${AS} -o ${.TARGET}
     57 	@${LD} -X -r ${.TARGET}
     58 	@mv a.out ${.TARGET}
     59 
     60 .if !defined(NOMAN)
     61 MANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
     62 .endif
     63 
     64 .if !defined(NOPROFILE)
     65 _LIBS=lib${LIB}.a lib${LIB}_p.a
     66 .else
     67 _LIBS=lib${LIB}.a
     68 .endif
     69 
     70 all: ${_LIBS} ${MANALL}# llib-l${LIB}.ln
     71 
     72 OBJS+=	${SRCS:N*.h:R:S/$/.o/g}
     73 
     74 lib${LIB}.a:: ${OBJS}
     75 	@echo building standard ${LIB} library
     76 	@rm -f lib${LIB}.a
     77 	@${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${LDADD}
     78 	${RANLIB} lib${LIB}.a
     79 
     80 POBJS+=	${OBJS:.o=.po}
     81 lib${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 
     87 llib-l${LIB}.ln: ${SRCS}
     88 	${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c}
     89 
     90 .if !target(clean)
     91 clean:
     92 	rm -f a.out Errs errs mklog core ${CLEANFILES}
     93 	rm -f ${OBJS}
     94 	rm -f ${POBJS} profiled/*.o
     95 	rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
     96 .endif
     97 
     98 .if !target(cleandir)
     99 cleandir:
    100 	rm -f a.out Errs errs mklog core ${CLEANFILES}
    101 	rm -f ${OBJS}
    102 	rm -f ${POBJS} profiled/*.o
    103 	rm -f lib${LIB}.a lib${LIB}_p.a llib-l${LIB}.ln
    104 	rm -f ${MANALL} ${.CURDIR}/tags .depend
    105 .endif
    106 
    107 .if !target(depend)
    108 depend: .depend
    109 .depend: ${SRCS}
    110 	rm -f .depend
    111 	files="${.ALLSRC:M*.c}"; \
    112 	if [ "$$files" != "" ]; then \
    113 	  mkdep -a ${MKDEP} ${CFLAGS:M-[ID]*} $$files; \
    114 	fi
    115 	files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
    116 	if [ "$$files" != "  " ]; then \
    117 	  mkdep -a ${MKDEP} -+ ${CXXFLAGS:M-[ID]*} $$files; \
    118 	fi
    119 	@(TMP=/tmp/_depend$$$$; \
    120 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po:/' < .depend > $$TMP; \
    121 	    mv $$TMP .depend)
    122 .endif
    123 
    124 .if !target(install)
    125 .if !target(beforeinstall)
    126 beforeinstall:
    127 	@install -d -o root -g wheel -m 755 ${DESTDIR}${LIBDIR}
    128 .endif
    129 
    130 realinstall:
    131 #	ranlib lib${LIB}.a
    132 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} lib${LIB}.a \
    133 	    ${DESTDIR}${LIBDIR}
    134 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
    135 .if !defined(NOPROFILE)
    136 #	ranlib lib${LIB}_p.a
    137 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    138 	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
    139 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    140 .endif
    141 #	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    142 #	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
    143 .if defined(LINKS) && !empty(LINKS)
    144 	@set ${LINKS}; \
    145 	while test $$# -ge 2; do \
    146 		l=${DESTDIR}$$1; \
    147 		shift; \
    148 		t=${DESTDIR}$$1; \
    149 		shift; \
    150 		echo $$t -\> $$l; \
    151 		rm -f $$t; \
    152 		ln $$l $$t; \
    153 	done; true
    154 .endif
    155 
    156 install: maninstall
    157 maninstall: afterinstall
    158 afterinstall: realinstall
    159 realinstall: beforeinstall
    160 .endif
    161 
    162 .if !target(lint)
    163 lint:
    164 .endif
    165 
    166 .if !target(tags)
    167 tags: ${SRCS}
    168 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \
    169 	    sed "s;\${.CURDIR}/;;" > tags
    170 .endif
    171 
    172 .if !defined(NOMAN)
    173 .include <bsd.man.mk>
    174 .endif
    175 
    176 .include <bsd.obj.mk>
    177