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.171 retrieving revision 1.194 diff -u -p -r1.171 -r1.194 --- src/share/mk/bsd.lib.mk 2000/07/03 21:08:55 1.171 +++ src/share/mk/bsd.lib.mk 2001/11/28 04:38:29 1.194 @@ -1,61 +1,67 @@ -# $NetBSD: bsd.lib.mk,v 1.171 2000/07/03 21:08:55 christos Exp $ +# $NetBSD: bsd.lib.mk,v 1.194 2001/11/28 04:38:29 tv Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 -.if !target(__initialized__) -__initialized__: -.if exists(${.CURDIR}/../Makefile.inc) -.include "${.CURDIR}/../Makefile.inc" -.endif -.include -.include -.include -.MAIN: all -.endif +.include +##### Basic targets .PHONY: checkver cleanlib libinstall realinstall: checkver libinstall -clean cleandir distclean: cleanlib +clean: cleanlib + +##### Build and install rules +CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} +CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++} -.if exists(${SHLIB_VERSION_FILE}) +.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny -.if !empty(SHLIB_TEENY) -SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} -.else -SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} -.endif - # Check for higher installed library versions. .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \ exists(${BSDSRCDIR}/lib/checkver) checkver: @(cd ${.CURDIR} && \ - ${BSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ + sh ${BSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ -d ${DESTDIR}${LIBDIR} ${LIB}) -.else +.endif +.endif + +.if !target(checkver) checkver: .endif + print-shlib-major: +.if defined(SHLIB_MAJOR) && ${MKPIC} != "no" @echo ${SHLIB_MAJOR} +.else + @false +.endif print-shlib-minor: +.if defined(SHLIB_MINOR) && ${MKPIC} != "no" @echo ${SHLIB_MINOR} +.else + @false +.endif print-shlib-teeny: +.if defined(SHLIB_TEENY) && ${MKPIC} != "no" @echo ${SHLIB_TEENY} .else -checkver: - -print-shlib-major: - @false - -print-shlib-minor: @false +.endif -print-shlib-teeny: - @false +.if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) +.if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR) +.if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY) +SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} +.else +SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} +.endif +.else +SHLIB_FULLVERSION=${SHLIB_MAJOR} +.endif .endif # add additional suffixes not exported. @@ -73,12 +79,13 @@ print-shlib-teeny: # OBJECT_FMT: currently either "ELF" or "a.out", from # SHLIB_SOVERSION: version number to be compiled into a shared library # via -soname. Usualy ${SHLIB_MAJOR} on ELF. -# NetBSD/pmax used to use ${SHLIB_MAJOR}.${SHLIB_MINOR} -# [.${SHLIB_TEENY}] +# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR} +# [.${SHLIB_TEENY}]] # SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library. # with ELF, also set shared-lib version for ld.so. # SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors # 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 @@ -87,6 +94,7 @@ print-shlib-teeny: .if ${MACHINE_ARCH} == "alpha" # Alpha-specific shared library flags +FPICFLAGS ?= -fPIC CPICFLAGS ?= -fPIC -DPIC CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} @@ -102,8 +110,14 @@ AINC+=-DABICALLS AFLAGS+= -fPIC AS+= -KPIC -.elif ${MACHINE_ARCH} == "sparc" && ${OBJECT_FMT} == "ELF" +.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" +FPICFLAGS ?= -fPIC CPICFLAGS ?= -fPIC -DPIC CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} @@ -111,11 +125,10 @@ APICFLAGS ?= -KPIC .else -# Platform-independent flags for NetBSD a.out shared libraries (and PowerPC) -SHLIB_LDSTARTFILE= -SHLIB_LDENDFILE= +# Platform-independent flags for NetBSD a.out shared libraries SHLIB_SOVERSION=${SHLIB_FULLVERSION} SHLIB_SHFLAGS= +FPICFLAGS ?= -fPIC CPICFLAGS?= -fPIC -DPIC CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} @@ -127,13 +140,14 @@ MKPICLIB?= yes # 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_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 .endif CFLAGS+= ${COPTS} +FFLAGS+= ${FOPTS} .c.o: .if defined(COPTS) && !empty(COPTS:M*-g*) @@ -198,6 +212,39 @@ CFLAGS+= ${COPTS} @rm -f ${.TARGET}.o .endif +.f.o: +.if defined(FOPTS) && !empty(FOPTS:M*-g*) + ${COMPILE.f} ${.IMPSRC} +.else + @echo ${COMPILE.f:Q} ${.IMPSRC} + @${COMPILE.f} ${.IMPSRC} -o ${.TARGET}.o + @${LD} -x -r ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o +.endif + +.f.po: +.if defined(FOPTS) && !empty(FOPTS:M*-g*) + ${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET} +.else + @echo ${COMPILE.f:Q} -pg ${.IMPSRC} -o ${.TARGET} + @${COMPILE.f} -pg ${.IMPSRC} -o ${.TARGET}.o + @${LD} -X -r ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o +.endif + +.f.so: +.if defined(FOPTS) && !empty(FOPTS:M*-g*) + ${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET} +.else + @echo ${COMPILE.f:Q} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET} + @${COMPILE.f} ${FPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o + @${LD} -x -r ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o +.endif + +.f.ln: + ${ECHO} Skipping lint for Fortran libraries. + .m.o: .if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*) ${COMPILE.m} ${.IMPSRC} @@ -273,18 +320,22 @@ _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION} .endif .endif -.if ${MKLINT} != "no" && ${MKLINKLIB} != "no" -_LIBS+=llib-l${LIB}.ln LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} +.if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS) +_LIBS+=llib-l${LIB}.ln .endif .if ${MKPIC} == "no" || (defined(LDSTATIC) && ${LDSTATIC} != "") \ || ${MKLINKLIB} != "no" -ALLOBJS=${OBJS} ${POBJS} ${SOBJS} ${LOBJS} +ALLOBJS=${OBJS} ${POBJS} ${SOBJS} .else -ALLOBJS=${POBJS} ${SOBJS} ${LOBJS} +ALLOBJS=${POBJS} ${SOBJS} +.endif +.if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS) +ALLOBJS+=${LOBJS} .endif -.NOPATH: ${ALLOBJS} ${_LIBS} + +.NOPATH: ${ALLOBJS} ${_LIBS} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} @@ -294,16 +345,12 @@ __archivebuild: .USE ${RANLIB} ${.TARGET} __archiveinstall: .USE - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -o ${LIBOWN} \ - -g ${LIBGRP} -m 600 ${.ALLSRC} ${.TARGET} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m 600 ${.ALLSRC} ${.TARGET} ${RANLIB} -t ${.TARGET} chmod ${LIBMODE} ${.TARGET} -DPSRCS+= ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c} -CLEANFILES+= ${DPSRCS} -.if defined(YHEADER) -CLEANFILES+= ${SRCS:M*.y:.y=.h} -.endif +DPSRCS+= ${SRCS:M*.[ly]:C/\..$/.c/} +CLEANFILES+= ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}} lib${LIB}.a:: ${OBJS} __archivebuild @echo building standard ${LIB} library @@ -332,17 +379,22 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL ${SHLIB_LDENDFILE} .endif .if ${OBJECT_FMT} == "ELF" - rm -f lib${LIB}.so.${SHLIB_MAJOR} - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR} - rm -f lib${LIB}.so - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so + # 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 + mv -f lib${LIB}.so.tmp lib${LIB}.so .endif +.if !empty(LOBJS) LLIBS?= -lc llib-l${LIB}.ln: ${LOBJS} @echo building llib-l${LIB}.ln @rm -f llib-l${LIB}.ln @${LINT} -C${LIB} ${.ALLSRC} ${LLIBS} +.endif cleanlib: rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} @@ -401,8 +453,7 @@ ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MA .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 + ${INSTALL_SYMLINK} lib${LIB}.a ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a .else ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall .endif @@ -419,24 +470,22 @@ libinstall:: ${DESTDIR}${LIBDIR}/lib${LI ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE .endif ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION} - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -o ${LIBOWN} \ - -g ${LIBGRP} -m ${LIBMODE} ${.ALLSRC} ${.TARGET} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${.ALLSRC} ${.TARGET} .if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR) /sbin/ldconfig -m ${LIBDIR} .endif .if ${OBJECT_FMT} == "ELF" - rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR} - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${INSTALL_SYMLINK} lib${LIB}.so.${SHLIB_FULLVERSION}\ ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR} - rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so .if ${MKLINKLIB} != "no" - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} \ + ${INSTALL_SYMLINK} lib${LIB}.so.${SHLIB_FULLVERSION}\ ${DESTDIR}${LIBDIR}/lib${LIB}.so .endif .endif .endif -.if ${MKLINT} != "no" && ${MKLINKLIB} != "no" +.if ${MKLINT} != "no" && ${MKLINKLIB} != "no" && !empty(LOBJS) libinstall:: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln .if !defined(UPDATE) @@ -447,11 +496,12 @@ libinstall:: ${DESTDIR}${LINTLIBDIR}/lli ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .MADE .endif ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -o ${LIBOWN} \ - -g ${LIBGRP} -m ${LIBMODE} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} .endif .endif +##### Pull in related .mk logic .include .include .include @@ -460,5 +510,4 @@ ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .include .include -# Make sure all of the standard targets are defined, even if they do nothing. -lint regress: +${TARGETS}: # ensure existence