If EXTERNAL_TOOLCHAIN is defined, allow the compiler to define the

location of crt{begin,end}{,S}.o and libgcc.a.  Encapsulate all of
this logic into the new bsd.gcc.mk, and use it in bsd.prog.mk and
bsd.lib.mk.
This commit is contained in:
thorpej 2003-05-31 20:33:15 +00:00
parent c2048dc2a3
commit 000836e000
5 changed files with 61 additions and 24 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.36 2003/01/05 23:37:02 sommerfeld Exp $
# $NetBSD: Makefile,v 1.37 2003/05/31 20:33:17 thorpej Exp $
# @(#)Makefile 8.1 (Berkeley) 6/8/93
NOOBJ= # defined
@ -7,10 +7,10 @@ NOOBJ= # defined
.if ${MKSHARE} != "no"
FILES= bsd.README bsd.doc.mk bsd.dep.mk bsd.endian.mk bsd.files.mk \
bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk bsd.init.mk \
bsd.kernobj.mk bsd.kinc.mk bsd.kmod.mk bsd.lib.mk bsd.links.mk \
bsd.man.mk bsd.nls.mk bsd.obj.mk bsd.own.mk bsd.prog.mk bsd.rpc.mk \
bsd.shlib.mk bsd.subdir.mk bsd.sys.mk sys.mk
bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \
bsd.init.mk bsd.kernobj.mk bsd.kinc.mk bsd.kmod.mk bsd.lib.mk \
bsd.links.mk bsd.man.mk bsd.nls.mk bsd.obj.mk bsd.own.mk bsd.prog.mk \
bsd.rpc.mk bsd.shlib.mk bsd.subdir.mk bsd.sys.mk sys.mk
FILESDIR=/usr/share/mk
.endif

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.README,v 1.112 2003/05/30 18:43:24 thorpej Exp $
# $NetBSD: bsd.README,v 1.113 2003/05/31 20:33:16 thorpej Exp $
# @(#)bsd.README 8.2 (Berkeley) 4/2/94
This is the README file for the new make "include" files for the BSD
@ -425,6 +425,32 @@ SHLINKDIR Path to use for shared linker when building a program.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The include file <bsd.gcc.mk> computes various parameters related to GCC
support libraries. It defines no targets. <bsd.own.mk> MUST be included
before bsd.gcc.mk.
The primary users of bsd.gcc.mk are <bsd.prog.mk> and <bsd.lib.mk>, each
of which need to know where to find certain GCC support libraries.
The behavior of bsd.gcc.mk is influenced by the EXTERNAL_TOOLCHAIN variable,
which is generally set by the user. If EXTERNAL_TOOLCHAIN it set, then
the compiler is asked where to find the support libraries, otherwise the
support libraries are found in ${DESTDIR}/usr/lib.
bsd.gcc.mk sets the following variables:
_GCC_CRTBEGIN The full path name to crtbegin.o.
_GCC_CRTBEGINS The full path name to crtbeginS.o.
_GCC_CRTEND The full path name to crtend.o.
_GCC_CRTENDS The full path name to crtendS.o.
_GCC_LIBGCCDIR The directory where libgcc.a is located.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The include file <bsd.prog.mk> handles building programs from one or
more source files, along with their manual pages. It has a limited number
of suffixes, consistent with the current needs of the BSD tree. bsd.prog.mk

20
share/mk/bsd.gcc.mk Normal file
View File

@ -0,0 +1,20 @@
# $NetBSD: bsd.gcc.mk,v 1.1 2003/05/31 20:33:15 thorpej Exp $
.if !defined(_BSD_GCC_MK_)
_BSD_GCC_MK_=1
.if defined(EXTERNAL_TOOLCHAIN)
_GCC_CRTBEGIN!= ${CC} --print-file-name=crtbegin.o
_GCC_CRTBEGINS!= ${CC} --print-file-name=crtbeginS.o
_GCC_CRTEND!= ${CC} --print-file-name=crtend.o
_GCC_CRTENDS!= ${CC} --print-file-name=crtendS.o
_GCC_LIBGCCDIR!= dirname `${CC} --print-libgcc-file-name`
.else
_GCC_CRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o
_GCC_CRTBEGINS= ${DESTDIR}/usr/lib/crtbeginS.o
_GCC_CRTEND= ${DESTDIR}/usr/lib/crtend.o
_GCC_CRTENDS= ${DESTDIR}/usr/lib/crtendS.o
_GCC_LIBGCCDIR= ${DESTDIR}/usr/lib
.endif
.endif # ! defined(_BSD_GCC_MK_)

View File

@ -1,8 +1,9 @@
# $NetBSD: bsd.lib.mk,v 1.218 2003/05/27 19:32:18 wiz Exp $
# $NetBSD: bsd.lib.mk,v 1.219 2003/05/31 20:33:16 thorpej Exp $
# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
.include <bsd.init.mk>
.include <bsd.shlib.mk>
.include <bsd.gcc.mk>
##### Basic targets
.PHONY: checkver cleanlib libinstall
@ -152,14 +153,8 @@ MKSHLIBOBJS= no
.if ${OBJECT_FMT} == "ELF"
SHLIB_SOVERSION= ${SHLIB_MAJOR}
SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
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
SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
.endif
CFLAGS+= ${COPTS}

View File

@ -1,10 +1,11 @@
# $NetBSD: bsd.prog.mk,v 1.166 2003/05/18 07:36:23 lukem Exp $
# $NetBSD: bsd.prog.mk,v 1.167 2003/05/31 20:33:16 thorpej Exp $
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
.ifndef HOSTPROG
.include <bsd.init.mk>
.include <bsd.shlib.mk>
.include <bsd.gcc.mk>
##### Basic targets
.PHONY: cleanextra cleanobjs cleanprog proginstall scriptsinstall
@ -22,16 +23,11 @@ CFLAGS+= -mcmodel=medlow
# ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
.if ${OBJECT_FMT} == "ELF"
.ifndef LIBCRTBEGIN
LIBCRTBEGIN= ${DESTDIR}/usr/lib/crti.o ${DESTDIR}/usr/lib/crtbegin.o
LIBCRTBEGIN= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
.MADE: ${LIBCRTBEGIN}
.endif
.ifndef LIBCRTEND
.if ${MACHINE_ARCH} == "powerpc" && defined(HAVE_GCC3)
LIBCRTEND= ${DESTDIR}/usr/lib/crtsavres.o \
${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crtn.o
.else
LIBCRTEND= ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crtn.o
.endif
LIBCRTEND= ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
.MADE: ${LIBCRTEND}
.endif
_SHLINKER= ${SHLINKDIR}/ld.elf_so
@ -150,7 +146,7 @@ _CCLINK= ${CC}
${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
.if !commands(${PROG})
${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
.endif
.else