1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 2# $FreeBSD$ 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} -p ${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} -p ${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} -p ${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 90.S.po: 91 ${CC} -DPROF ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 92 93.S.so: 94 ${CC} -fpic -DPIC ${CFLAGS:M-[ID]*} ${AINC} -c ${.IMPSRC} -o ${.TARGET} 95 @${LD} -O ${.TARGET} -x -r ${.TARGET} 96 97.m.po: 98 ${CC} ${CFLAGS} -fgnu-runtime -p -c ${.IMPSRC} -o ${.TARGET} 99 @${LD} -O ${.TARGET} -X -r ${.TARGET} 100 101.m.o: 102 ${CC} ${CFLAGS} -fgnu-runtime -c ${.IMPSRC} -o ${.TARGET} 103 @${LD} -O ${.TARGET} -X -r ${.TARGET} 104 105.if !defined(INTERNALLIB) || defined(INTERNALSTATICLIB) 106.if !defined(NOPROFILE) && !defined(INTERNALLIB) 107_LIBS=lib${LIB}.a lib${LIB}_p.a 108.else 109_LIBS=lib${LIB}.a 110.endif 111.endif 112 113.if !defined(NOPIC) 114.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 115_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 116.endif 117.if defined(INSTALL_PIC_ARCHIVE) 118_LIBS+=lib${LIB}_pic.a 119.endif 120.endif 121 122.if !defined(PICFLAG) 123PICFLAG=-fpic 124.endif 125 126all: objwarn ${_LIBS} all-man _SUBDIR # llib-l${LIB}.ln 127 128OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 129 130lib${LIB}.a:: ${OBJS} 131 @${ECHO} building standard ${LIB} library 132 @rm -f lib${LIB}.a 133 @${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q` ${ARADD} 134 ${RANLIB} lib${LIB}.a 135 136.if !defined(NOPROFILE) 137POBJS+= ${OBJS:.o=.po} 138lib${LIB}_p.a:: ${POBJS} 139 @${ECHO} building profiled ${LIB} library 140 @rm -f lib${LIB}_p.a 141 @${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q` ${ARADD} 142 ${RANLIB} lib${LIB}_p.a 143.endif 144 145.if defined(DESTDIR) 146LDDESTDIR?= -L${DESTDIR}/usr/lib 147.endif 148 149.if !defined(NOPIC) 150.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir) 151SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o 152.endif 153 154SOBJS+= ${OBJS:.o=.so} 155lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} 156 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) 157 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 158 @${LD} -Bshareable -x \ 159 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 160 `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD} 161 162lib${LIB}_pic.a:: ${SOBJS} 163 @${ECHO} building special pic ${LIB} library 164 @rm -f lib${LIB}_pic.a 165 @${AR} cq lib${LIB}_pic.a ${SOBJS} ${ARADD} 166 ${RANLIB} lib${LIB}_pic.a 167.endif 168 169llib-l${LIB}.ln: ${SRCS} 170 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} 171 172.if !target(clean) 173clean: _SUBDIR 174 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} 175 rm -f lib${LIB}.a llib-l${LIB}.ln 176 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a 177 rm -f ${SOBJS} shared/*.o 178 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a 179.if defined(CLEANDIRS) && !empty(CLEANDIRS) 180 rm -rf ${CLEANDIRS} 181.endif 182.endif 183 184.if defined(SRCS) 185afterdepend: 186 @(TMP=_depend$$$$; \ 187 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < .depend > $$TMP; \ 188 mv $$TMP .depend) 189.endif 190 191.if !target(install) 192.if !target(beforeinstall) 193beforeinstall: 194.endif 195 196.if defined(PRECIOUSLIB) 197SHLINSTALLFLAGS+= -fschg 198.endif 199 200realinstall: beforeinstall 201.if !defined(INTERNALLIB) 202 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 203 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} 204.if !defined(NOPROFILE) 205 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 206 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} 207.endif 208.endif 209.if !defined(NOPIC) 210.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 211 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 212 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ 213 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 214 ${DESTDIR}${SHLIBDIR} 215.endif 216.if defined(INSTALL_PIC_ARCHIVE) 217 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 218 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 219.endif 220.endif 221.if defined(LINKS) && !empty(LINKS) 222 @set ${LINKS}; \ 223 while test $$# -ge 2; do \ 224 l=${DESTDIR}$$1; \ 225 shift; \ 226 t=${DESTDIR}$$1; \ 227 shift; \ 228 ${ECHO} $$t -\> $$l; \ 229 rm -f $$t; \ 230 ln ${LN_FLAGS} $$l $$t; \ 231 done; true 232.endif 233 234install: afterinstall _SUBDIR 235.if !defined(NOMAN) 236afterinstall: realinstall maninstall 237.else 238afterinstall: realinstall 239.endif 240.endif 241 242DISTRIBUTION?= bin 243.if !target(distribute) 244distribute: _SUBDIR 245 cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies 246.endif 247 248.if !target(lint) 249lint: 250.endif 251 252.if !target(tags) 253tags: ${SRCS} _SUBDIR 254 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \ 255 sed "s;\${.CURDIR}/;;" > tags 256.endif 257 258.if !defined(NOMAN) 259.include <bsd.man.mk> 260.elif !target(maninstall) 261maninstall: 262all-man: 263.endif 264 265.include <bsd.dep.mk> 266.include <bsd.obj.mk> 267