1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 2# $Id: bsd.lib.mk,v 1.58 1997/06/18 03:39:34 asami Exp $ 3# 4 5.if exists(${.CURDIR}/../Makefile.inc) 6.include "${.CURDIR}/../Makefile.inc" 7.endif 8 9.if exists(${.CURDIR}/shlib_version) 10SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major 11SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor 12.endif 13 14.if defined(DESTDIR) 15CFLAGS+= -I${DESTDIR}/usr/include 16CXXINCLUDES+= -I${DESTDIR}/usr/include/g++ 17.endif 18 19.if defined(DEBUG_FLAGS) 20CFLAGS+= ${DEBUG_FLAGS} 21.endif 22 23.if !defined(DEBUG_FLAGS) 24STRIP?= -s 25.endif 26 27.include <bsd.libnames.mk> 28 29.MAIN: all 30 31# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries 32# .so used for PIC object files 33.SUFFIXES: 34.SUFFIXES: .out .o .po .so .s .S .c .cc .cxx .m .C .f .y .l 35 36.c.o: 37 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 38 @${LD} -O ${.TARGET} -x -r ${.TARGET} 39 40.c.po: 41 ${CC} -pg ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 42 @${LD} -O ${.TARGET} -X -r ${.TARGET} 43 44.c.so: 45 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 46 @${LD} -O ${.TARGET} -x -r ${.TARGET} 47 48.cc.o .C.o .cxx.o: 49 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 50 @${LD} -O ${.TARGET} -x -r ${.TARGET} 51 52.cc.po .C.po .cxx.po: 53 ${CXX} -pg ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 54 @${LD} -O ${.TARGET} -X -r ${.TARGET} 55 56.cc.so .C.so .cxx.so: 57 ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 58 @${LD} -O ${.TARGET} -x -r ${.TARGET} 59 60.f.o: 61 ${FC} ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 62 @${LD} -O ${.TARGET} -x -r ${.TARGET} 63 64.f.po: 65 ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 66 @${LD} -O ${.TARGET} -X -r ${.TARGET} 67 68.f.so: 69 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 70 @${LD} -O ${.TARGET} -x -r ${.TARGET} 71 72.s.o: 73 ${CC} -x assembler-with-cpp ${CFLAGS:M-[BID]*} ${AINC} -c \ 74 ${.IMPSRC} -o ${.TARGET} 75 @${LD} -O ${.TARGET} -x -r ${.TARGET} 76 77.s.po: 78 ${CC} -x assembler-with-cpp -DPROF ${CFLAGS:M-[BID]*} ${AINC} -c \ 79 ${.IMPSRC} -o ${.TARGET} 80 @${LD} -O ${.TARGET} -X -r ${.TARGET} 81 82.s.so: 83 ${CC} -x assembler-with-cpp -fpic -DPIC ${CFLAGS:M-[BID]*} ${AINC} -c \ 84 ${.IMPSRC} -o ${.TARGET} 85 @${LD} -O ${.TARGET} -x -r ${.TARGET} 86 87.S.o: 88 ${CC} ${CFLAGS:M-[BID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 89 @${LD} -O ${.TARGET} -x -r ${.TARGET} 90 91.S.po: 92 ${CC} -DPROF ${CFLAGS:M-[BID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 93 @${LD} -O ${.TARGET} -X -r ${.TARGET} 94 95.S.so: 96 ${CC} -fpic -DPIC ${CFLAGS:M-[BID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 97 @${LD} -O ${.TARGET} -x -r ${.TARGET} 98 99.m.o: 100 ${CC} ${CFLAGS} -fgnu-runtime -c ${.IMPSRC} -o ${.TARGET} 101 @${LD} -O ${.TARGET} -x -r ${.TARGET} 102 103.m.po: 104 ${CC} ${CFLAGS} -fgnu-runtime -pg -c ${.IMPSRC} -o ${.TARGET} 105 @${LD} -O ${.TARGET} -X -r ${.TARGET} 106 107.if !defined(INTERNALLIB) || defined(INTERNALSTATICLIB) 108.if !defined(NOPROFILE) && !defined(INTERNALLIB) 109_LIBS=lib${LIB}.a lib${LIB}_p.a 110.else 111_LIBS=lib${LIB}.a 112.endif 113.endif 114 115.if !defined(NOPIC) 116.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 117_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 118.endif 119.if defined(INSTALL_PIC_ARCHIVE) 120_LIBS+=lib${LIB}_pic.a 121.endif 122.endif 123 124.if !defined(PICFLAG) 125PICFLAG=-fpic 126.endif 127 128all: objwarn ${_LIBS} all-man _SUBDIR # llib-l${LIB}.ln 129 130OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 131 132lib${LIB}.a:: ${OBJS} 133 @${ECHO} building standard ${LIB} library 134 @rm -f lib${LIB}.a 135 @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q` ${ARADD} 136 ${RANLIB} lib${LIB}.a 137 138.if !defined(NOPROFILE) 139POBJS+= ${OBJS:.o=.po} 140lib${LIB}_p.a:: ${POBJS} 141 @${ECHO} building profiled ${LIB} library 142 @rm -f lib${LIB}_p.a 143 @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q` ${ARADD} 144 ${RANLIB} lib${LIB}_p.a 145.endif 146 147.if defined(DESTDIR) 148LDDESTDIRENV?= LIBRARY_PATH=${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib 149.endif 150 151.if !defined(NOPIC) 152SOBJS+= ${OBJS:.o=.so} 153lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} 154 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) 155 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 156 @${LDDESTDIRENV} ${CC} -shared -Wl,-x -Wl,-assert -Wl,pure-text \ 157 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 158 `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD} 159 160lib${LIB}_pic.a:: ${SOBJS} 161 @${ECHO} building special pic ${LIB} library 162 @rm -f lib${LIB}_pic.a 163 @${AR} cq lib${LIB}_pic.a ${SOBJS} ${ARADD} 164 ${RANLIB} lib${LIB}_pic.a 165.endif 166 167llib-l${LIB}.ln: ${SRCS} 168 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} 169 170.if !target(clean) 171clean: _SUBDIR 172 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} 173 rm -f lib${LIB}.a llib-l${LIB}.ln 174 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a 175 rm -f ${SOBJS} shared/*.o 176 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a 177.if defined(CLEANDIRS) && !empty(CLEANDIRS) 178 rm -rf ${CLEANDIRS} 179.endif 180.endif 181 182.if defined(SRCS) 183_EXTRADEPEND:: 184 @TMP=_depend$$$$; \ 185 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < ${DEPENDFILE} \ 186 > $$TMP; \ 187 mv $$TMP ${DEPENDFILE} 188.endif 189_EXTRADEPEND:: 190 echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \ 191 `${LDDESTDIRENV} ${CC} -shared -Wl,-f ${LDDESTDIR} ${LDADD}` \ 192 >> ${DEPENDFILE} 193 194.if !target(install) 195.if !target(beforeinstall) 196beforeinstall: 197.endif 198 199.if defined(PRECIOUSLIB) 200SHLINSTALLFLAGS+= -fschg 201.endif 202 203realinstall: beforeinstall 204.if !defined(INTERNALLIB) 205 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 206 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} 207.if !defined(NOPROFILE) 208 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 209 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} 210.endif 211.endif 212.if !defined(NOPIC) 213.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 214 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 215 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ 216 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 217 ${DESTDIR}${SHLIBDIR} 218.endif 219.if defined(INSTALL_PIC_ARCHIVE) 220 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 221 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 222.endif 223.endif 224.if defined(LINKS) && !empty(LINKS) 225 @set ${LINKS}; \ 226 while test $$# -ge 2; do \ 227 l=${DESTDIR}$$1; \ 228 shift; \ 229 t=${DESTDIR}$$1; \ 230 shift; \ 231 ${ECHO} $$t -\> $$l; \ 232 rm -f $$t; \ 233 ln ${LN_FLAGS} $$l $$t; \ 234 done; true 235.endif 236 237install: afterinstall _SUBDIR 238.if !defined(NOMAN) 239afterinstall: realinstall maninstall 240.else 241afterinstall: realinstall 242.endif 243.endif 244 245DISTRIBUTION?= bin 246.if !target(distribute) 247distribute: _SUBDIR 248.for dist in ${DISTRIBUTION} 249 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies 250.endfor 251.endif 252 253.if !target(lint) 254lint: 255.endif 256 257.if defined(NOTAGS) 258tags: 259.endif 260 261.if !target(tags) 262tags: ${SRCS} _SUBDIR 263 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} 264.if defined(HTML) 265 @cd ${.CURDIR} && htags ${HTAGSFLAGS} 266.endif 267.endif 268 269.if !defined(NOMAN) 270.include <bsd.man.mk> 271.elif !target(maninstall) 272maninstall: 273all-man: 274.endif 275 276.include <bsd.dep.mk> 277.include <bsd.obj.mk> 278