Home | History | Annotate | Line # | Download | only in mk
bsd.lib.mk revision 1.71
      1 #	$NetBSD: bsd.lib.mk,v 1.71 1996/09/23 20:23:05 abrown Exp $
      2 #	@(#)bsd.lib.mk	5.26 (Berkeley) 5/2/91
      3 
      4 .if exists(${.CURDIR}/../Makefile.inc)
      5 .include "${.CURDIR}/../Makefile.inc"
      6 .endif
      7 
      8 .include <bsd.own.mk>				# for 'NOPIC' definition
      9 
     10 .if exists(${.CURDIR}/shlib_version)
     11 SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
     12 SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
     13 .endif
     14 
     15 .MAIN: all
     16 
     17 # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
     18 # .so used for PIC object files.  .ln used for lint output files.
     19 .SUFFIXES:
     20 .SUFFIXES: .out .o .po .so .S .s .c .cc .C .f .y .l .ln .m4
     21 
     22 .c.o:
     23 	@echo "${COMPILE.c} ${.IMPSRC}"
     24 	@${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
     25 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     26 	@rm -f ${.TARGET}.o
     27 
     28 .c.po:
     29 	@echo "${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}"
     30 	@${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
     31 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     32 	@rm -f ${.TARGET}.o
     33 
     34 .c.so:
     35 	@echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
     36 	@${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
     37 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     38 	@rm -f ${.TARGET}.o
     39 
     40 .c.ln:
     41 	${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
     42 
     43 .cc.o .C.o:
     44 	@echo "${COMPILE.cc} ${.IMPSRC}"
     45 	@${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
     46 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     47 	@rm -f ${.TARGET}.o
     48 
     49 .cc.po .C.po:
     50 	@echo "${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}"
     51 	@${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
     52 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     53 	@rm -f ${.TARGET}.o
     54 
     55 .cc.so .C.so:
     56 	@echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
     57 	@${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
     58 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     59 	@rm -f ${.TARGET}.o
     60 
     61 .S.o .s.o:
     62 	@echo "${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}"
     63 	@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     64 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     65 	@rm -f ${.TARGET}.o
     66 
     67 .S.po .s.po:
     68 	@echo "${COMPILE.S} -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o"
     69 	@${COMPILE.S} -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     70 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     71 	@rm -f ${.TARGET}.o
     72 
     73 .S.so .s.so:
     74 	@echo "${COMPILE.S} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o"
     75 	@${COMPILE.S} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     76 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     77 	@rm -f ${.TARGET}.o
     78 
     79 .if !defined(PICFLAG)
     80 PICFLAG=-fpic
     81 .endif
     82 
     83 .if !defined(NOPROFILE)
     84 _LIBS=lib${LIB}.a lib${LIB}_p.a
     85 .else
     86 _LIBS=lib${LIB}.a
     87 .endif
     88 
     89 .if !defined(NOPIC)
     90 _LIBS+=lib${LIB}_pic.a
     91 .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
     92 _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
     93 .endif
     94 .endif
     95 
     96 .if !defined(NOLINT)
     97 _LIBS+=llib-l${LIB}.ln
     98 .endif
     99 
    100 all: ${_LIBS} _SUBDIRUSE
    101 
    102 OBJS+=	${SRCS:N*.h:R:S/$/.o/g}
    103 
    104 lib${LIB}.a:: ${OBJS}
    105 	@echo building standard ${LIB} library
    106 	@rm -f lib${LIB}.a
    107 	@${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
    108 	${RANLIB} lib${LIB}.a
    109 
    110 POBJS+=	${OBJS:.o=.po}
    111 lib${LIB}_p.a:: ${POBJS}
    112 	@echo building profiled ${LIB} library
    113 	@rm -f lib${LIB}_p.a
    114 	@${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
    115 	${RANLIB} lib${LIB}_p.a
    116 
    117 SOBJS+=	${OBJS:.o=.so}
    118 lib${LIB}_pic.a:: ${SOBJS}
    119 	@echo building shared object ${LIB} library
    120 	@rm -f lib${LIB}_pic.a
    121 	@${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
    122 	${RANLIB} lib${LIB}_pic.a
    123 
    124 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
    125 	@echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
    126 	@rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
    127 	$(LD) -x -Bshareable -Bforcearchive \
    128 	    -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
    129 
    130 LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
    131 # the following looks XXX to me... -- cgd
    132 LLIBS?=	-lc
    133 llib-l${LIB}.ln: ${LOBJS}
    134 	@echo building llib-l${LIB}.ln
    135 	@rm -f llib-l${LIB}.ln
    136 	@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
    137 
    138 .if !target(clean)
    139 clean: _SUBDIRUSE
    140 	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
    141 	rm -f lib${LIB}.a ${OBJS}
    142 	rm -f lib${LIB}_p.a ${POBJS}
    143 	rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
    144 	rm -f llib-l${LIB}.ln ${LOBJS}
    145 .endif
    146 
    147 cleandir: _SUBDIRUSE clean
    148 
    149 .if defined(SRCS)
    150 afterdepend: .depend
    151 	@(TMP=/tmp/_depend$$$$; \
    152 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' \
    153 	      < .depend > $$TMP; \
    154 	    mv $$TMP .depend)
    155 .endif
    156 
    157 .if !target(install)
    158 .if !target(beforeinstall)
    159 beforeinstall:
    160 .endif
    161 
    162 realinstall:
    163 #	ranlib lib${LIB}.a
    164 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
    165 	    ${DESTDIR}${LIBDIR}
    166 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
    167 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
    168 .if !defined(NOPROFILE)
    169 #	ranlib lib${LIB}_p.a
    170 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
    171 	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
    172 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    173 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    174 .endif
    175 .if !defined(NOPIC)
    176 #	ranlib lib${LIB}_pic.a
    177 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
    178 	    lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
    179 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    180 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    181 .endif
    182 .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
    183 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    184 	    lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
    185 .endif
    186 .if !defined(NOLINT)
    187 	install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    188 	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
    189 .endif
    190 .if defined(LINKS) && !empty(LINKS)
    191 	@set ${LINKS}; \
    192 	while test $$# -ge 2; do \
    193 		l=${DESTDIR}$$1; \
    194 		shift; \
    195 		t=${DESTDIR}$$1; \
    196 		shift; \
    197 		echo $$t -\> $$l; \
    198 		rm -f $$t; \
    199 		ln $$l $$t; \
    200 	done; true
    201 .endif
    202 
    203 install: maninstall _SUBDIRUSE
    204 maninstall: afterinstall
    205 afterinstall: realinstall
    206 realinstall: beforeinstall
    207 .endif
    208 
    209 .if !defined(NOMAN)
    210 .include <bsd.man.mk>
    211 .endif
    212 
    213 .if !defined(NONLS)
    214 .include <bsd.nls.mk>
    215 .endif
    216 
    217 .include <bsd.obj.mk>
    218 .include <bsd.dep.mk>
    219 .include <bsd.subdir.mk>
    220 .include <bsd.sys.mk>
    221