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.152.2.3 retrieving revision 1.164 diff -u -p -r1.152.2.3 -r1.164 --- src/share/mk/bsd.lib.mk 2000/07/06 16:54:37 1.152.2.3 +++ src/share/mk/bsd.lib.mk 2000/04/24 14:22:05 1.164 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.152.2.3 2000/07/06 16:54:37 he Exp $ +# $NetBSD: bsd.lib.mk,v 1.164 2000/04/24 14:22:05 simonb Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .if !target(__initialized__) @@ -8,6 +8,7 @@ __initialized__: .endif .include .include +.include .MAIN: all .endif @@ -15,22 +16,17 @@ __initialized__: realinstall: checkver libinstall clean cleandir distclean: cleanlib -.if exists(${.CURDIR}/shlib_version) -SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major -SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor -SHLIB_TEENY != . ${.CURDIR}/shlib_version ; echo $$teeny -.if !empty(SHLIB_TEENY) -SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} -.else -SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} -.endif +.if exists(${SHLIB_VERSION_FILE}) +SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major +SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor # Check for higher installed library versions. .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \ exists(${BSDSRCDIR}/lib/checkver) checkver: @(cd ${.CURDIR} && \ - ${BSDSRCDIR}/lib/checkver -d ${DESTDIR}${LIBDIR} ${LIB}) + ${BSDSRCDIR}/lib/checkver -v ${SHLIB_VERSION_FILE} \ + -d ${DESTDIR}${LIBDIR} ${LIB}) .else checkver: .endif @@ -48,21 +44,21 @@ checkver: # Set PICFLAGS to cc flags for producing position-independent code, # if not already set. Includes -DPIC, if required. -# Data-driven table using make variables to control how shared libraries +# Data-driven table using make variables to control how shared libraries # are built for different platforms and object formats. # 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_SHFLAGS: Flags to tell ${LD} to emit shared library. +# 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_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 -# 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 +# 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 # (usually just ${CPPPICFLAGS} ${CPICFLAGS}) -# APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects. +# APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects. .if ${MACHINE_ARCH} == "alpha" # Alpha-specific shared library flags @@ -73,15 +69,11 @@ APICFLAGS ?= .elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" # mips-specific shared library flags -# On mips, all libs need to be compiled with ABIcalls, not just sharedlibs. -CPICFLAGS?= -APICFLAGS?= -#CPICFLAGS?= -fpic -DPIC -#APICFLAGS?= -DPIC - -# so turn shlib PIC flags on for ${CPP}, ${CC}, and ${AS} as follows: -AINC+=-DPIC -DABICALLS -COPTS+= -fPIC ${AINC} +# 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 @@ -98,7 +90,7 @@ APICFLAGS ?= -KPIC SHLIB_LDSTARTFILE= SHLIB_LDENDFILE= SHLIB_SHFLAGS= -SHLIB_SOVERSION=${SHLIB_FULLVERSION} +SHLIB_SOVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR} CPICFLAGS?= -fpic -DPIC CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} @@ -106,6 +98,8 @@ APICFLAGS?= -k .endif +MKPICLIB?= yes + # Platform-independent linker flags for ELF shared libraries .if ${OBJECT_FMT} == "ELF" SHLIB_SOVERSION=${SHLIB_MAJOR} @@ -117,61 +111,97 @@ SHLIB_LDENDFILE= ${DESTDIR}/usr/lib/crte CFLAGS+= ${COPTS} .c.o: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.c} ${.IMPSRC} +.else @echo ${COMPILE.c:Q} ${.IMPSRC} @${COMPILE.c} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .c.po: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET} @${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o @${LD} -X -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .c.so: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.c:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} @${COMPILE.c} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .c.ln: ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} .cc.o .C.o: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.cc} ${.IMPSRC} +.else @echo ${COMPILE.cc:Q} ${.IMPSRC} @${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .cc.po .C.po: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET} @${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o @${LD} -X -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .cc.so .C.so: +.if defined(COPTS) && !empty(COPTS:M*-g*) + ${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.cc:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} @${COMPILE.cc} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .m.o: +.if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*) + ${COMPILE.m} ${.IMPSRC} +.else @echo ${COMPILE.m:Q} ${.IMPSRC} @${COMPILE.m} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .m.po: +.if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*) + ${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET} @${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o @${LD} -X -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .m.so: +.if defined(OBJCFLAGS) && !empty(OBJCFLAGS:M*-g*) + ${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} +.else @echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET} @${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o @${LD} -x -r ${.TARGET}.o -o ${.TARGET} @rm -f ${.TARGET}.o +.endif .S.o .s.o: @echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} @@ -198,22 +228,35 @@ _LIBS=lib${LIB}.a _LIBS= .endif +OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g} + .if ${MKPROFILE} != "no" _LIBS+=lib${LIB}_p.a +POBJS+=${OBJS:.o=.po} .endif .if ${MKPIC} != "no" -_LIBS+=lib${LIB}_pic.a +.if ${MKPICLIB} == "no" +SOLIB=lib${LIB}.a +.else +SOLIB=lib${LIB}_pic.a +_LIBS+=${SOLIB} +SOBJS+=${OBJS:.o=.so} +.endif .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) -_LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION} +_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif .endif .if ${MKLINT} != "no" && ${MKLINKLIB} != "no" _LIBS+=llib-l${LIB}.ln +LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} .endif -all: ${SRCS} ${_LIBS} +ALLOBJS=${OBJS} ${POBJS} ${SOBJS} ${LOBJS} +.NOPATH: ${ALLOBJS} ${_LIBS} + +realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} __archivebuild: .USE @rm -f ${.TARGET} @@ -221,8 +264,8 @@ __archivebuild: .USE ${RANLIB} ${.TARGET} __archiveinstall: .USE - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \ - -m 600 ${.ALLSRC} ${.TARGET} + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -o ${LIBOWN} \ + -g ${LIBGRP} -m 600 ${.ALLSRC} ${.TARGET} ${RANLIB} -t ${.TARGET} chmod ${LIBMODE} ${.TARGET} @@ -232,45 +275,41 @@ CLEANFILES+= ${DPSRCS} CLEANFILES+= ${SRCS:M*.y:.y=.h} .endif -OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g} lib${LIB}.a:: ${OBJS} __archivebuild @echo building standard ${LIB} library -POBJS+= ${OBJS:.o=.po} lib${LIB}_p.a:: ${POBJS} __archivebuild @echo building profiled ${LIB} library -SOBJS+= ${OBJS:.o=.so} lib${LIB}_pic.a:: ${SOBJS} __archivebuild @echo building shared object ${LIB} library -lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}_pic.a ${DPADD} \ +lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOLIB} ${DPADD} \ ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} - @echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\) - @rm -f lib${LIB}.so.${SHLIB_FULLVERSION} + @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) + @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} .if defined(DESTDIR) - $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ + $(LD) -nostdlib -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ ${SHLIB_LDSTARTFILE} \ - --whole-archive lib${LIB}_pic.a \ - -nostdlib -L${DESTDIR}${LIBDIR} -R${LIBDIR} \ + --whole-archive ${SOLIB} \ + -L${DESTDIR}${LIBDIR} -R${LIBDIR} \ --no-whole-archive ${LDADD} \ ${SHLIB_LDENDFILE} .else $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ ${SHLIB_LDSTARTFILE} \ - --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \ + --whole-archive ${SOLIB} --no-whole-archive ${LDADD} \ ${SHLIB_LDENDFILE} .endif .if ${OBJECT_FMT} == "ELF" rm -f lib${LIB}.so.${SHLIB_MAJOR} - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} \ + ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ lib${LIB}.so.${SHLIB_MAJOR} rm -f lib${LIB}.so - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} \ + ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ lib${LIB}.so .endif -LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} LLIBS?= -lc llib-l${LIB}.ln: ${LOBJS} @echo building llib-l${LIB}.ln @@ -323,6 +362,7 @@ ${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${ .endif .if ${MKPIC} != "no" && ${MKPICINSTALL} != "no" +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a .if !defined(UPDATE) .PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a @@ -330,34 +370,38 @@ libinstall:: ${DESTDIR}${LIBDIR}/lib${LI .if !defined(BUILD) && !make(all) && !make(lib${LIB}_pic.a) ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: .MADE .endif - -.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +.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 +.else ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall .endif +.endif .if ${MKPIC} != "no" && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) -libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} .if !defined(UPDATE) -.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} +.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif -.if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_FULLVERSION}) -${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: .MADE +.if !defined(BUILD) && !make(all) && !make(lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}) +${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: .MADE .endif -.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION} -${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_FULLVERSION}: lib${LIB}.so.${SHLIB_FULLVERSION} - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \ - -m ${LIBMODE} ${.ALLSRC} ${.TARGET} +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} +${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -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} \ + ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR} rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so .if ${MKLINKLIB} != "no" - ln -s lib${LIB}.so.${SHLIB_FULLVERSION} \ + ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ ${DESTDIR}${LIBDIR}/lib${LIB}.so .endif .endif @@ -374,8 +418,8 @@ ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: .PRECIOUS: ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}/llib-l${LIB}.ln: llib-l${LIB}.ln - ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN} -g ${LIBGRP} \ - -m ${LIBMODE} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} -o ${LIBOWN} \ + -g ${LIBGRP} -m ${LIBMODE} ${.ALLSRC} ${DESTDIR}${LINTLIBDIR} .endif .endif