From 8c05a446bf0dd9c8666f7d4398a0e7dd652c8378 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sat, 30 Aug 1997 23:23:18 +0000 Subject: [PATCH] A first cut at some rules for building elf shared libs. Of particular note, using "-Wl,-f" to generate a library objects list doesn't work anymore since the hack to ld hasn't been incorporated into binutils-2.8. (and the -f switch is used for something else already) This is disabled by default, don't panic! :-) --- share/mk/bsd.lib.mk | 39 ++++++++++++++++++++++++++++++++++++++- share/mk/bsd.prog.mk | 12 +++++++++++- share/mk/sys.mk | 5 ++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 648de6aff56f..0d3cbbc45ccd 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 -# $Id: bsd.lib.mk,v 1.59 1997/06/21 15:40:32 jkh Exp $ +# $Id: bsd.lib.mk,v 1.60 1997/08/05 03:49:48 asami Exp $ # .if exists(${.CURDIR}/../Makefile.inc) @@ -8,8 +8,10 @@ .if exists(${.CURDIR}/shlib_version) SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major +.if ${BINFORMAT} == aout SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor .endif +.endif .if defined(DESTDIR) CFLAGS+= -I${DESTDIR}/usr/include @@ -113,9 +115,15 @@ _LIBS=lib${LIB}.a .endif .if !defined(NOPIC) +.if ${BINFORMAT} == aout .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif +.else +.if defined(SHLIB_MAJOR) +_LIBS+=lib${LIB}.so.${SHLIB_MAJOR} +.endif +.endif .if defined(INSTALL_PIC_ARCHIVE) _LIBS+=lib${LIB}_pic.a .endif @@ -150,12 +158,23 @@ LDDESTDIRENV?= LIBRARY_PATH=${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib .if !defined(NOPIC) SOBJS+= ${OBJS:.o=.so} + +.if ${BINFORMAT} == aout lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOBJS} @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} @${LDDESTDIRENV} ${CC} -shared -Wl,-x -Wl,-assert -Wl,pure-text \ -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD} +.else +lib${LIB}.so.${SHLIB_MAJOR}: ${SOBJS} + @${ECHO} building shared ${LIB} library \(version ${SHLIB_MAJOR}\) + @rm -f lib${LIB}.so.${SHLIB_MAJOR} + @${LDDESTDIRENV} ${CC} -shared -Wl,-x \ + -o lib${LIB}.so.${SHLIB_MAJOR} \ + -Wl,-soname,lib${LIB}.so.${SHLIB_MAJOR} \ + `lorder ${SOBJS} | tsort -q` ${LDDESTDIR} ${LDADD} +.endif lib${LIB}_pic.a:: ${SOBJS} @${ECHO} building special pic ${LIB} library @@ -188,9 +207,16 @@ _EXTRADEPEND:: .endif .if !defined(NOEXTRADEPEND) _EXTRADEPEND:: +.if ${BINFORMAT} == aout echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \ `${LDDESTDIRENV} ${CC} -shared -Wl,-f ${LDDESTDIR} ${LDADD}` \ >> ${DEPENDFILE} +.else +.if defined(DPADD) && ${DPADD} != "" + echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \ + ${DPADD} >> ${DEPENDFILE} +.endif +.endif .endif .if !target(install) @@ -212,12 +238,23 @@ realinstall: beforeinstall .endif .endif .if !defined(NOPIC) +.if ${BINFORMAT} == aout .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR) ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \ ${DESTDIR}${SHLIBDIR} .endif +.else +.if defined(SHLIB_MAJOR) + ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${INSTALLFLAGS} ${SHLINSTALLFLAGS} \ + lib${LIB}.so.${SHLIB_MAJOR} \ + ${DESTDIR}${SHLIBDIR} + ln ${LN_FLAGS} -sf lib${LIB}.so.${SHLIB_MAJOR} \ + ${DESTDIR}${SHLIBDIR}/lib${LIB}.so +.endif +.endif .if defined(INSTALL_PIC_ARCHIVE) ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index febc39300a38..805ab5443edc 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 -# $Id: bsd.prog.mk,v 1.53 1997/07/31 06:12:04 asami Exp $ +# $Id: bsd.prog.mk,v 1.54 1997/08/05 03:49:49 asami Exp $ .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" @@ -65,8 +65,14 @@ clean: _SUBDIR .if defined(PROG) && !defined(NOEXTRADEPEND) _EXTRADEPEND: +.if ${BINFORMAT} == aout echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} +.else +.if defined(DPADD) && ${DPADD} != "" + echo ${PROG}: ${DPADD} >> ${DEPENDFILE} +.endif +.endif .endif .if !target(install) @@ -140,5 +146,9 @@ maninstall: all-man: .endif +.if ${BINFORMAT} != aout +.include +.endif + .include .include diff --git a/share/mk/sys.mk b/share/mk/sys.mk index f67177f4be28..bd145c1c0958 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -1,5 +1,5 @@ # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 -# $Id: sys.mk,v 1.22 1997/02/22 13:56:15 peter Exp $ +# $Id: sys.mk,v 1.23 1997/04/13 06:44:25 jkh Exp $ unix ?= We run FreeBSD, not UNIX. @@ -98,6 +98,9 @@ YFLAGS ?= -d GTAGSFLAGS= -se HTAGSFLAGS= +# Binary file format +BINFORMAT?= aout + .if defined(%POSIX) # Posix 1003.2 mandated rules #