bsd.lib.mk revision 25104
1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 2# $Id: bsd.lib.mk,v 1.53 1997/04/13 06:44:23 jkh 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/${CXX} 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-[ID]*} ${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-[ID]*} ${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-[ID]*} ${AINC} -c \ 84 ${.IMPSRC} -o ${.TARGET} 85 @${LD} -O ${.TARGET} -x -r ${.TARGET} 86 87.S.o: 88 ${CC} ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 89 @${LD} -O ${.TARGET} -x -r ${.TARGET} 90 91.S.po: 92 ${CC} -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 93 @${LD} -O ${.TARGET} -X -r ${.TARGET} 94 95.S.so: 96 ${CC} -fpic -DPIC ${CFLAGS:M-[ID]*} ${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) 148LDDESTDIR?= -L${DESTDIR}${SHLIBDIR} -L${DESTDIR}/usr/lib 149# LDDESTDIR+= -nostdlib 150.endif 151 152.if !defined(NOPIC) 153.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir) 154SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o 155.endif 156 157SOBJS+= ${OBJS:.o=.so} 158lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} 159 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) 160 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 161 @${LD} -Bshareable -x \ 162 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 163 `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD} 164 165lib${LIB}_pic.a:: ${SOBJS} 166 @${ECHO} building special pic ${LIB} library 167 @rm -f lib${LIB}_pic.a 168 @${AR} cq lib${LIB}_pic.a ${SOBJS} ${ARADD} 169 ${RANLIB} lib${LIB}_pic.a 170.endif 171 172llib-l${LIB}.ln: ${SRCS} 173 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} 174 175.if !target(clean) 176clean: _SUBDIR 177 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} 178 rm -f lib${LIB}.a llib-l${LIB}.ln 179 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a 180 rm -f ${SOBJS} shared/*.o 181 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a 182.if defined(CLEANDIRS) && !empty(CLEANDIRS) 183 rm -rf ${CLEANDIRS} 184.endif 185.endif 186 187.if defined(SRCS) 188_EXTRADEPEND:: 189 @TMP=_depend$$$$; \ 190 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < ${DEPENDFILE} \ 191 > $$TMP; \ 192 mv $$TMP ${DEPENDFILE} 193.endif 194.if defined(LDADD) 195_EXTRADEPEND:: 196 echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \ 197 `ld -Bshareable -x -f ${LDDESTDIR} ${LDADD}` >> ${DEPENDFILE} 198.endif 199 200.if !target(install) 201.if !target(beforeinstall) 202beforeinstall: 203.endif 204 205.if defined(PRECIOUSLIB) 206SHLINSTALLFLAGS+= -fschg 207.endif 208 209realinstall: beforeinstall 210.if !defined(INTERNALLIB) 211 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 212 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} 213.if !defined(NOPROFILE) 214 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 215 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} 216.endif 217.endif 218.if !defined(NOPIC) 219.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 220 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 221 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ 222 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 223 ${DESTDIR}${SHLIBDIR} 224.endif 225.if defined(INSTALL_PIC_ARCHIVE) 226 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 227 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 228.endif 229.endif 230.if defined(LINKS) && !empty(LINKS) 231 @set ${LINKS}; \ 232 while test $$# -ge 2; do \ 233 l=${DESTDIR}$$1; \ 234 shift; \ 235 t=${DESTDIR}$$1; \ 236 shift; \ 237 ${ECHO} $$t -\> $$l; \ 238 rm -f $$t; \ 239 ln ${LN_FLAGS} $$l $$t; \ 240 done; true 241.endif 242 243install: afterinstall _SUBDIR 244.if !defined(NOMAN) 245afterinstall: realinstall maninstall 246.else 247afterinstall: realinstall 248.endif 249.endif 250 251DISTRIBUTION?= bin 252.if !target(distribute) 253distribute: _SUBDIR 254 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 255.endif 256 257.if !target(lint) 258lint: 259.endif 260 261.if defined(NOTAGS) 262tags: 263.endif 264 265.if !target(tags) 266tags: ${SRCS} _SUBDIR 267 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} 268.if defined(HTML) 269 @cd ${.CURDIR} && htags ${HTAGSFLAGS} 270.endif 271.endif 272 273.if !defined(NOMAN) 274.include <bsd.man.mk> 275.elif !target(maninstall) 276maninstall: 277all-man: 278.endif 279 280.include <bsd.dep.mk> 281.include <bsd.obj.mk> 282