bsd.lib.mk revision 2353
1# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 2# $Id: bsd.lib.mk,v 1.5 1994/08/26 18:58:10 wollman 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 19INSTALL?= install 20LIBDIR?= /usr/lib 21LINTLIBDIR?= /usr/libdata/lint 22LIBGRP?= bin 23LIBOWN?= bin 24LIBMODE?= 444 25 26STRIP?= -s 27 28BINGRP?= bin 29BINOWN?= bin 30BINMODE?= 555 31 32.MAIN: all 33 34# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries 35# .so used for PIC object files 36.SUFFIXES: 37.SUFFIXES: .out .o .po .so .s .S .c .cc .cxx .m .C .f .y .l 38 39.c.o: 40 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 41 @${LD} -x -r ${.TARGET} 42 @mv a.out ${.TARGET} 43 44.c.po: 45 ${CC} -p ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 46 @${LD} -X -r ${.TARGET} 47 @mv a.out ${.TARGET} 48 49.c.so: 50 ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 51 52.cc.o .cxx.o .C.o: 53 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 54 @${LD} -x -r ${.TARGET} 55 @mv a.out ${.TARGET} 56 57.cc.po .C.po .cxx.o: 58 ${CXX} -p ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 59 @${LD} -X -r ${.TARGET} 60 @mv a.out ${.TARGET} 61 62.cc.so .C.so: 63 ${CXX} ${PICFLAG} -DPIC ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 64 65.f.o: 66 ${FC} ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 67 @${LD} -x -r ${.TARGET} 68 @mv a.out ${.TARGET} 69 70.f.po: 71 ${FC} -p ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 72 @${LD} -X -r ${.TARGET} 73 @mv a.out ${.TARGET} 74 75.f.so: 76 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 77 78.s.o: 79 ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 80 ${AS} -o ${.TARGET} 81 @${LD} -x -r ${.TARGET} 82 @mv a.out ${.TARGET} 83 84.s.po: 85 ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 86 ${AS} -o ${.TARGET} 87 @${LD} -X -r ${.TARGET} 88 @mv a.out ${.TARGET} 89 90.s.so: 91 ${CPP} -E -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 92 ${AS} -k -o ${.TARGET} 93 94.S.o: 95 ${CPP} -E ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 96 ${AS} -o ${.TARGET} 97 98.S.po: 99 ${CPP} -E -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 100 ${AS} -o ${.TARGET} 101 102.S.so: 103 ${CPP} -E -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} | \ 104 ${AS} -k -o ${.TARGET} 105 106.m.po: 107 ${CC} ${CFLAGS} -p -c ${.IMPSRC} -o ${.TARGET} 108 @${LD} -X -r ${.TARGET} 109 @mv a.out ${.TARGET} 110 111.m.o: 112 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 113 @${LD} -X -r ${.TARGET} 114 @mv a.out ${.TARGET} 115 116.if !defined(INTERNALLIB) 117.if !defined(NOPROFILE) 118_LIBS=lib${LIB}.a lib${LIB}_p.a 119.else 120_LIBS=lib${LIB}.a 121.endif 122.endif 123 124.if !defined(NOPIC) 125.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 126_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 127.endif 128.if defined(INSTALL_PIC_ARCHIVE) 129_LIBS+=lib${LIB}_pic.a 130.endif 131.endif 132 133.if !defined(PICFLAG) 134PICFLAG=-fpic 135.endif 136 137all: ${_LIBS} # llib-l${LIB}.ln 138 139OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 140 141lib${LIB}.a:: ${OBJS} 142 @${ECHO} building standard ${LIB} library 143 @rm -f lib${LIB}.a 144 @${AR} cTq lib${LIB}.a `lorder ${OBJS} | tsort` ${ARADD} 145 ${RANLIB} lib${LIB}.a 146 147POBJS+= ${OBJS:.o=.po} 148lib${LIB}_p.a:: ${POBJS} 149 @${ECHO} building profiled ${LIB} library 150 @rm -f lib${LIB}_p.a 151 @${AR} cTq lib${LIB}_p.a `lorder ${POBJS} | tsort` ${ARADD} 152 ${RANLIB} lib${LIB}_p.a 153 154.if defined(DESTDIR) 155LDDESTDIR?= -L${DESTDIR}/usr/lib 156.endif 157 158.if defined(CPLUSPLUSLIB) && !make(clean) && !make(cleandir) 159SOBJS+= ${DESTDIR}/usr/lib/c++rt0.o 160.endif 161 162SOBJS+= ${OBJS:.o=.so} 163lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} 164 @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) 165 @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} 166 @${LD} -Bshareable \ 167 -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 168 ${SOBJS} ${LDDESTDIR} ${LDADD} 169 170lib${LIB}_pic.a:: ${SOBJS} 171 @${ECHO} building special pic ${LIB} library 172 @rm -f lib${LIB}_pic.a 173 @${AR} cTq lib${LIB}_pic.a ${SOBJS} ${ARADD} 174 ${RANLIB} lib${LIB}_pic.a 175 176llib-l${LIB}.ln: ${SRCS} 177 ${LINT} -C${LIB} ${CFLAGS} ${.ALLSRC:M*.c} 178 179.if !target(clean) 180clean: 181 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} 182 rm -f lib${LIB}.a llib-l${LIB}.ln 183 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a 184 rm -f ${SOBJS} shared/*.o 185 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a 186.endif 187 188.if !target(cleandir) 189cleandir: 190 rm -f a.out Errs errs mklog ${CLEANFILES} ${OBJS} 191 rm -f lib${LIB}.a llib-l${LIB}.ln 192 rm -f ${.CURDIR}/tags .depend 193 rm -f ${POBJS} profiled/*.o lib${LIB}_p.a 194 rm -f ${SOBJS} shared/*.o 195 rm -f lib${LIB}.so.*.* lib${LIB}_pic.a 196 cd ${.CURDIR}; rm -rf obj; 197.endif 198 199.if defined(SRCS) 200afterdepend: 201 @(TMP=/tmp/_depend$$$$; \ 202 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so:/' < .depend > $$TMP; \ 203 mv $$TMP .depend) 204.endif 205 206.if !target(install) 207.if !target(beforeinstall) 208beforeinstall: 209.endif 210 211.if defined(PRECIOUSLIB) 212SHLINSTALLFLAGS+= -fschg 213.endif 214 215realinstall: beforeinstall 216.if !defined(INTERNALLIB) 217 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 218 ${INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} 219 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a 220.if !defined(NOPROFILE) 221 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 222 ${INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} 223 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 224.endif 225.endif 226.if !defined(NOPIC) 227.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) 228 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 229 ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ 230 lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ 231 ${DESTDIR}${LIBDIR} 232.endif 233.if defined(INSTALL_PIC_ARCHIVE) 234 ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 235 ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 236 ${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a 237.endif 238.endif 239.if defined(LINKS) && !empty(LINKS) 240 @set ${LINKS}; \ 241 while test $$# -ge 2; do \ 242 l=${DESTDIR}$$1; \ 243 shift; \ 244 t=${DESTDIR}$$1; \ 245 shift; \ 246 ${ECHO} $$t -\> $$l; \ 247 rm -f $$t; \ 248 ln $$l $$t; \ 249 done; true 250.endif 251 252install: afterinstall 253.if !defined(NOMAN) 254afterinstall: realinstall maninstall 255.else 256afterinstall: realinstall 257.endif 258.endif 259 260.if !target(lint) 261lint: 262.endif 263 264.if !target(tags) 265tags: ${SRCS} 266 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:M*.c} | \ 267 sed "s;\${.CURDIR}/;;" > tags 268.endif 269 270.if !defined(NOMAN) 271.include <bsd.man.mk> 272.elif !target(maninstall) 273maninstall: 274.endif 275 276.if !target(obj) 277.if defined(NOOBJ) 278obj: 279.else 280obj: 281 @cd ${.CURDIR}; rm -rf obj; \ 282 here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \ 283 ${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \ 284 if test -d /usr/obj -a ! -d $$dest; then \ 285 mkdir -p $$dest; \ 286 else \ 287 true; \ 288 fi; 289.endif 290.endif 291 292.include <bsd.dep.mk> 293