Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v rcsdiff: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.190 retrieving revision 1.216 diff -u -p -r1.190 -r1.216 --- src/share/mk/bsd.lib.mk 2001/11/14 21:49:53 1.190 +++ src/share/mk/bsd.lib.mk 2003/04/22 12:55:26 1.216 @@ -1,7 +1,8 @@ -# $NetBSD: bsd.lib.mk,v 1.190 2001/11/14 21:49:53 tv Exp $ +# $NetBSD: bsd.lib.mk,v 1.216 2003/04/22 12:55:26 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include +.include ##### Basic targets .PHONY: checkver cleanlib libinstall @@ -9,7 +10,8 @@ realinstall: checkver libinstall clean: cleanlib ##### Build and install rules -CPPFLAGS+= ${DESTDIR:D-nostdinc -isystem ${DESTDIR}/usr/include} +CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} +CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++} .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major @@ -18,11 +20,11 @@ SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; # Check for higher installed library versions. .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \ - exists(${BSDSRCDIR}/lib/checkver) + exists(${NETBSDSRCDIR}/lib/checkver) checkver: @(cd ${.CURDIR} && \ - sh ${BSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ - -d ${DESTDIR}${LIBDIR} ${LIB}) + sh ${NETBSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ + -d ${DESTDIR}${_LIBSODIR} ${LIB}) .endif .endif @@ -86,42 +88,43 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR} # SHLIB_LDENDFILE: support .o file, call C++ file-level destructors # FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects. # CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} -# CPICFLAGS: flags for ${CC} to compile .[cC] files to .so objects. -# CAPICFLAGS flags for {$CC} to compiling .[Ss] files +# CPICFLAGS: flags for ${CC} to compile .[cC] files to pic objects. +# CSHLIBFLAGS: flags for ${CC} to compile .[cC] files to .so objects. +# (usually includes ${CPICFLAGS}) +# CAPICFLAGS: flags for ${CC} to compiling .[Ss] files # (usually just ${CPPPICFLAGS} ${CPICFLAGS}) # APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects. .if ${MACHINE_ARCH} == "alpha" - # Alpha-specific shared library flags + FPICFLAGS ?= -fPIC CPICFLAGS ?= -fPIC -DPIC CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} APICFLAGS ?= -.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" - # mips-specific shared library flags - -# On mips, all libs are compiled with ABIcalls, not just sharedlibs. -MKPICLIB= no - -# so turn shlib PIC flags on for ${AS}. -AINC+=-DABICALLS -AFLAGS+= -fPIC -AS+= -KPIC - -.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF" -# On the VAX, all object are PIC by default, not just sharedlibs. -MKPICLIB= no .elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \ ${OBJECT_FMT} == "ELF" +# If you use -fPIC you need to define BIGPIC to turn on 32-bit +# relocations in asm code FPICFLAGS ?= -fPIC CPICFLAGS ?= -fPIC -DPIC -CPPPICFLAGS?= -DPIC +CPPPICFLAGS?= -DPIC -DBIGPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} APICFLAGS ?= -KPIC +.elif ${MACHINE_ARCH} == "hppa" + +FPICFLAGS ?= -fPIC +CPICFLAGS?= -fPIC -DPIC +CPPPICFLAGS?= -DPIC +CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} +APICFLAGS?= -k +# XXX libraries often need the millicode functions in libgcc.a, +# so we have to work around the -nostdlib: +LDADD+= `$(CC) -print-libgcc-file-name` + .else # Platform-independent flags for NetBSD a.out shared libraries @@ -135,14 +138,28 @@ APICFLAGS?= -k .endif -MKPICLIB?= yes +.if ${MKPICLIB} != "no" +CSHLIBFLAGS+= ${CPICFLAGS} +.endif + +.if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS) +MKSHLIBOBJS= yes +.else +MKSHLIBOBJS= no +.endif # Platform-independent linker flags for ELF shared libraries .if ${OBJECT_FMT} == "ELF" SHLIB_SOVERSION= ${SHLIB_MAJOR} SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION} -SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crtbeginS.o -SHLIB_LDENDFILE?= ${DESTDIR}/usr/lib/crtendS.o +SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${DESTDIR}/usr/lib/crtbeginS.o +# Some platforms require additional endfile support. +.if ${MACHINE_ARCH} == "powerpc" && defined(HAVE_GCC3) +SHLIB_LDENDFILE?= ${DESTDIR}/usr/lib/crtsavres.o \ + ${DESTDIR}/usr/lib/crtendS.o ${DESTDIR}/usr/lib/crtn.o +.else +SHLIB_LDENDFILE?= ${DESTDIR}/usr/lib/crtendS.o ${DESTDIR}/usr/lib/crtn.o +.endif .endif CFLAGS+= ${COPTS} @@ -170,10 +187,10 @@ FFLAGS+= ${FOPTS} .c.so: .if defined(COPTS) && !empty(COPTS:M*-g*) - ${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} .else - @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} - @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o + @echo ${COMPILE.c:Q} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} + @${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o .endif @@ -203,10 +220,10 @@ FFLAGS+= ${FOPTS} .cc.so .C.so: .if defined(COPTS) && !empty(COPTS:M*-g*) - ${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} .else @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} - @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o + @${COMPILE.cc} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o .endif @@ -266,10 +283,10 @@ FFLAGS+= ${FOPTS} .m.so: .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*) - ${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} + ${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET} .else @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} - @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o + @${COMPILE.m} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o .endif @@ -292,6 +309,7 @@ FFLAGS+= ${FOPTS} @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.if defined(LIB) .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \ || ${MKLINKLIB} != "no" _LIBS=lib${LIB}.a @@ -308,7 +326,15 @@ POBJS+=${OBJS:.o=.po} .if ${MKPIC} != "no" .if ${MKPICLIB} == "no" +.if ${MKSHLIBOBJS} != "no" +# make _pic.a, which isn't really pic, +# since it's needed for making shared lib. +# but don't install it. +SOLIB=lib${LIB}_pic.a +SOBJS+=${OBJS:.o=.so} +.else SOLIB=lib${LIB}.a +.endif .else SOLIB=lib${LIB}_pic.a _LIBS+=${SOLIB} @@ -333,8 +359,12 @@ ALLOBJS=${POBJS} ${SOBJS} .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS) ALLOBJS+=${LOBJS} .endif +.else +LOBJS= +SOBJS= +.endif -.NOPATH: ${ALLOBJS} ${_LIBS} ${SRCS:M*.[ly]:C/..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} +.NOPATH: ${ALLOBJS} ${_LIBS} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} @@ -344,11 +374,13 @@ __archivebuild: .USE ${RANLIB} ${.TARGET} __archiveinstall: .USE - ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m 600 ${.ALLSRC} ${.TARGET} - ${RANLIB} -t ${.TARGET} - chmod ${LIBMODE} ${.TARGET} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${UPDATE:D:U-a "${RANLIB} -t"} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET} + +__archivesymlinkpic: .USE + ${INSTALL_SYMLINK} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET} -DPSRCS+= ${SRCS:M*.[ly]:C/..$/.c/} +DPSRCS+= ${SRCS:M*.[ly]:C/\..$/.c/} CLEANFILES+= ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}} lib${LIB}.a:: ${OBJS} __archivebuild @@ -369,7 +401,8 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL ${SHLIB_LDSTARTFILE} \ --whole-archive ${SOLIB} \ --no-whole-archive ${LDADD} \ - -L${DESTDIR}${LIBDIR} -R${LIBDIR} \ + -L${DESTDIR}${_LIBSODIR} -L${DESTDIR}${LIBDIR} \ + -R${_LIBSODIR} -R${LIBDIR} \ ${SHLIB_LDENDFILE} .else $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ @@ -378,6 +411,9 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL ${SHLIB_LDENDFILE} .endif .if ${OBJECT_FMT} == "ELF" +# We don't use INSTALL_SYMLINK here because this is just +# happening inside the build directory/objdir. XXX Why does +# this spend so much effort on libraries that aren't live??? XXX ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR} ln -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp @@ -389,8 +425,12 @@ LLIBS?= -lc llib-l${LIB}.ln: ${LOBJS} @echo building llib-l${LIB}.ln @rm -f llib-l${LIB}.ln +.if defined(DESTDIR) + @${LINT} -C${LIB} ${.ALLSRC} -L${DESTDIR}/usr/libdata ${LLIBS} +.else @${LINT} -C${LIB} ${.ALLSRC} ${LLIBS} .endif +.endif cleanlib: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} @@ -414,74 +454,105 @@ libinstall:: .if ${MKLINKLIB} != "no" libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a + .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a +.if !defined(BUILD) && !make(all) && !make(lib${LIB}.a) +${DESTDIR}${LIBDIR}/lib${LIB}.a! .MADE .endif - +${DESTDIR}${LIBDIR}/lib${LIB}.a! lib${LIB}.a __archiveinstall +.else .if !defined(BUILD) && !make(all) && !make(lib${LIB}.a) ${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE .endif ${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall .endif +.endif .if ${MKPROFILE} != "no" libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a + .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a +.if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a) +${DESTDIR}${LIBDIR}/lib${LIB}_p.a! .MADE .endif - +${DESTDIR}${LIBDIR}/lib${LIB}_p.a! lib${LIB}_p.a __archiveinstall +.else .if !defined(BUILD) && !make(all) && !make(lib${LIB}_p.a) ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: .MADE .endif ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall .endif +.endif .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no" libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a .PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a + .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +.if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a) +${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! .MADE .endif - +.if ${MKPICLIB} == "no" +${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}.a __archivesymlinkpic +.else +${DESTDIR}${LIBDIR}/lib${LIB}_pic.a! lib${LIB}_pic.a __archiveinstall +.endif +.else .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a) ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE .endif .if ${MKPICLIB} == "no" -${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: - rm -f ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a - ln -s lib${LIB}.a ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}.a __archivesymlinkpic .else ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall .endif .endif +.endif .if ${MKPIC} != "no" && defined(SHLIB_FULLVERSION) -libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} -.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +libinstall:: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +.PRECIOUS: ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} + .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +.if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION}) +${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! .MADE .endif - +${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}! lib${LIB}.so.${SHLIB_FULLVERSION} +.else .if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION}) -${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE +${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE +.endif +${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION} .endif -${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION} ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${.ALLSRC} ${.TARGET} + ${SYSPKGTAG} ${.ALLSRC} ${.TARGET} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} ${SYSPKGTAG} \ + ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +.endif .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR) - /sbin/ldconfig -m ${LIBDIR} + /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR} .endif .if ${OBJECT_FMT} == "ELF" - ln -sf lib${LIB}.so.${SHLIB_FULLVERSION}\ - ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.tmp - mv -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.tmp\ - ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR} + ${INSTALL_SYMLINK} ${SYSPKGTAG} \ + lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${DESTDIR}${_LIBSODIR}/lib${LIB}.so.${SHLIB_MAJOR} +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} ${SYSPKGTAG} \ + ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR} +.endif .if ${MKLINKLIB} != "no" - ln -sf lib${LIB}.so.${SHLIB_FULLVERSION}\ - ${DESTDIR}${LIBDIR}/lib${LIB}.so.tmp - mv -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.tmp\ - ${DESTDIR}${LIBDIR}/lib${LIB}.so + ${INSTALL_SYMLINK} ${SYSPKGTAG} \ + lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${DESTDIR}${_LIBSODIR}/lib${LIB}.so +.if ${_LIBSODIR} != ${LIBDIR} + ${INSTALL_SYMLINK} ${SYSPKGTAG} \ + ${_LIBSODIR}/lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${DESTDIR}${LIBDIR}/lib${LIB}.so +.endif .endif .endif .endif @@ -489,16 +560,20 @@ ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS) libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln + .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln +.if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln) +${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! .MADE .endif - +${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln! llib-l${LIB}.ln +.else .if !defined(BUILD) && !make(all) && !make(llib-l${LIB}.ln) ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE .endif ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln +.endif ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} + ${SYSPKGTAG} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} .endif .endif