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