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