Bootstrap toolchain framework, first pass.

This commit is contained in:
tv 2001-08-14 11:01:55 +00:00
parent 58290cfc5d
commit c5d597ce98
20 changed files with 440 additions and 0 deletions

11
tools/Makefile Normal file
View File

@ -0,0 +1,11 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:01:55 tv Exp $
# XXX this should use real dependencies
SUBDIR= binstall .WAIT gencat mkdep rpcgen tsort \
yacc .WAIT \
lex .WAIT config lint lint1 lint2 \
toolchain .WAIT texinfo
TARGETS= build
.include <bsd.subdir.mk>

39
tools/Makefile.host Normal file
View File

@ -0,0 +1,39 @@
# $NetBSD: Makefile.host,v 1.1 2001/08/14 11:01:56 tv Exp $
# Preload <bsd.obj.mk> to set up obj rules (with proper ${.CURDIR}).
.include <bsd.obj.mk>
# Save value of .CURDIR, and reassign it to the "real" source directory.
_CURDIR:= ${.CURDIR}
.CURDIR:= ${_CURDIR}/../../${HOST_SRCDIR}
# Set HOSTPROG as a flag to the real program not to include <bsd.prog.mk>.
HOSTPROG?= ${PROG}
# Pull in the "real" Makefile.
.include "${.CURDIR}/Makefile"
# Set up the environment for <bsd.hostprog.mk>.
HOSTPROGNAME?= ${HOSTPROG}
HOST_BINDIR?= ${TOOLDIR}/bin
HOST_CPPFLAGS:= -include ${_CURDIR}/../compat/compat_netbsd.h -Wall \
${HOST_CPPFLAGS} ${CPPFLAGS}
MKMAN= no
SRCS?= ${PROG}.c
SRCS+= ${HOST_SRCS} nb_progname.c
TIMESTAMP?= ${HOST_BINDIR}/${HOSTPROGNAME}
.undef LINKS
.PATH: ${.CURDIR} ${_CURDIR}/../compat
${TIMESTAMP}: ${.CURDIR}/Makefile
# Include the local definitions, and then <bsd.hostprog.mk>.
.include "${_CURDIR}/../Makefile.inc"
.include <bsd.hostprog.mk>
# Install rule.
realinstall: install.host
install.host:
mkdir -p ${HOST_BINDIR}
${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -m ${BINMODE} \
${HOSTPROG} ${HOST_BINDIR}/${HOSTPROGNAME}

30
tools/Makefile.inc Normal file
View File

@ -0,0 +1,30 @@
# $NetBSD: Makefile.inc,v 1.1 2001/08/14 11:01:56 tv Exp $
.include <bsd.own.mk>
# Ensure that TOOLDIR is set.
.if !defined(TOOLDIR)
.BEGIN:
@echo "===> TOOLDIR must be set in ${MAKECONF} or the environment"
@false
.endif
# Get default tool locations.
_CURDIR?=${.CURDIR}
.include "${_CURDIR}/../Makefile.tools"
# "make build": Only build if the installed program is out-of-date.
# ("make all" and "make install" always build and install.)
.if make(build)
MKTOOLS?=no
build: ${TIMESTAMP}
${TIMESTAMP}: ${_CURDIR}/Makefile
.if ${MKTOOLS} == "yes"
@cd ${_CURDIR} && ${MAKE} all
@cd ${_CURDIR} && ${MAKE} install
.else
@echo "===> $@ must be updated"
@echo "===> (set MKTOOLS=yes in /etc/mk.conf or the environment to continue)"
@false
.endif
.endif

53
tools/Makefile.tools Normal file
View File

@ -0,0 +1,53 @@
# $NetBSD: Makefile.tools,v 1.1 2001/08/14 11:01:57 tv Exp $
#
# Included Makefile fragment used by the top-level Makefile, and by
# the Makefile.inc in the "tools" subdirectory.
AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
#BIB= ${TOOLDIR}/bin/bib
CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
CONFIG= ${TOOLDIR}/bin/config
CPP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
#EQN= ${TOOLDIR}/bin/eqn
FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
GENCAT= ${TOOLDIR}/bin/gencat
#GRIND= ${TOOLDIR}/bin/vgrind -f
#GROFF= ${TOOLDIR}/bin/groff -Tascii
#INDXBIB= ${TOOLDIR}/bin/indxbib
INSTALL= ${TOOLDIR}/bin/binstall
INSTALL_INFO= ${TOOLDIR}/bin/install-info
LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
LEX= ${TOOLDIR}/bin/lex
LINT= ${TOOLDIR}/bin/lint
#LORDER= ${TOOLDIR}/bin/lorder
#MAKE= ${TOOLDIR}/bin/bmake
MAKEINFO= ${TOOLDIR}/bin/makeinfo
MKDEP= ${TOOLDIR}/bin/mkdep
#MKLOCALE= ${TOOLDIR}/bin/mklocale
NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
#NROFF= ${TOOLDIR}/bin/nroff -Tascii
OBJC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
#PIC= ${TOOLDIR}/bin/pic
RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
#REFER= ${TOOLDIR}/bin/refer
#ROFF= ${TOOLDIR}/bin/groff -Tps
RPCGEN= ${TOOLDIR}/bin/rpcgen
SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
#SOELIM= ${TOOLDIR}/bin/soelim
STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
#TBL= ${TOOLDIR}/bin/tbl
TSORT= ${TOOLDIR}/bin/tsort
YACC= ${TOOLDIR}/bin/yacc
# Make sure DESTDIR is set, so that builds with these tools always
# get appropriate -nostdinc, -nostdlib, etc. handling. The value is
# <empty string>, meaning start from /, the root directory.
DESTDIR?=
# Temporary switch for turning on the appropriate toolchain bits
USE_NEW_TOOLCHAIN=1

10
tools/binstall/Makefile Normal file
View File

@ -0,0 +1,10 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:01:57 tv Exp $
HOSTPROG= binstall
HOST_SRCDIR= usr.bin/xinstall
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}
INSTALL:= ./binstall

View File

@ -0,0 +1,45 @@
/* $NetBSD: compat_netbsd.h,v 1.1 2001/08/14 11:01:58 tv Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Todd Vierling.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __COMPAT_NETBSD_H__
#define __COMPAT_NETBSD_H__
extern void setprogname(const char *);
extern const char *getprogname(void);
#endif

View File

@ -0,0 +1,58 @@
/* $NetBSD: nb_progname.c,v 1.1 2001/08/14 11:01:58 tv Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Todd Vierling.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Stub to emulate [gs]etprogname() where needed. */
#ifdef __NetBSD__
#include <sys/param.h>
#if !defined(__NetBSD_Version__) || (__NetBSD_Version__ < 106000000)
#undef __NetBSD__
#endif
#endif
#ifndef __NetBSD__
const char *ln_progname;
void setprogname(const char *progname) {
ln_progname = progname;
}
const char *getprogname(void) {
return ln_progname;
}
#endif

7
tools/config/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:01:59 tv Exp $
HOST_SRCDIR= usr.sbin/config
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

7
tools/gencat/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:01:59 tv Exp $
HOST_SRCDIR= usr.bin/gencat
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

10
tools/lex/Makefile Normal file
View File

@ -0,0 +1,10 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:00 tv Exp $
HOST_SRCDIR= usr.bin/lex
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS:Nscan.c:Nskel.c} initscan.c
scan.c:
echo '#include <initscan.c>' >$@

9
tools/lint/Makefile Normal file
View File

@ -0,0 +1,9 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:00 tv Exp $
HOSTPROGNAME= lint
HOST_SRCDIR= usr.bin/xlint/xlint
HOST_CPPFLAGS= -DPATH_LIBEXEC=\"${TOOLDIR}/libexec\"
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

8
tools/lint1/Makefile Normal file
View File

@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:01 tv Exp $
HOST_SRCDIR= usr.bin/xlint/lint1
HOST_BINDIR= ${TOOLDIR}/libexec
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

8
tools/lint2/Makefile Normal file
View File

@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:01 tv Exp $
HOST_SRCDIR= usr.bin/xlint/lint2
HOST_BINDIR= ${TOOLDIR}/libexec
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

7
tools/mkdep/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:02 tv Exp $
HOST_SRCDIR= usr.bin/mkdep
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

7
tools/rpcgen/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:02 tv Exp $
HOST_SRCDIR= usr.bin/rpcgen
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

46
tools/texinfo/Makefile Normal file
View File

@ -0,0 +1,46 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:03 tv Exp $
.include <bsd.own.mk> # for TOOLDIR
DIST= ${.CURDIR}/../../gnu/dist/texinfo
TIMESTAMP= ${TOOLDIR}/bin/makeinfo
# Dependencies that trigger a rebuild.
${TIMESTAMP}: \
${.CURDIR}/Makefile \
${DIST}/ChangeLog
realall: texinfo.all
realinstall: texinfo.install
clean: texinfo.clean
texinfo.configure:
rm -rf texinfo
mkdir texinfo
cd texinfo && \
CC="${HOST_CC}" \
CFLAGS="${HOST_CFLAGS}" \
CPPFLAGS="${HOST_CPPFLAGS}" \
LDFLAGS="${HOST_LDFLAGS}" \
PATH="${TOOLDIR}/bin:$$PATH" \
${DIST}/configure \
--disable-shared --with-included-gettext \
--prefix=${TOOLDIR}
@touch $@
texinfo.all: texinfo.configure
cd texinfo && \
PATH="${TOOLDIR}/bin:$$PATH" \
${MAKE} all LEX=true BISON=true
texinfo.install:
.for d in makeinfo util
cd texinfo/${d} && \
PATH="${TOOLDIR}/bin:$$PATH" \
${MAKE} install LEX=true BISON=true
.endfor
texinfo.clean:
rm -rf texinfo*
.include <bsd.hostprog.mk>

66
tools/toolchain/Makefile Normal file
View File

@ -0,0 +1,66 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:03 tv Exp $
.include <bsd.own.mk> # for TOOLDIR
DIST= ${.CURDIR}/../../gnu/dist/toolchain
TIMESTAMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
# Dependencies that trigger a rebuild.
${TIMESTAMP}: \
${.CURDIR}/Makefile \
${DIST}/ChangeLog \
${DIST}/bfd/ChangeLog \
${DIST}/binutils/ChangeLog \
${DIST}/gas/ChangeLog \
${DIST}/gcc/ChangeLog \
${DIST}/gcc/cp/ChangeLog \
${DIST}/gcc/f/ChangeLog \
${DIST}/ld/ChangeLog \
${DIST}/opcodes/ChangeLog
realall: toolchain.all
realinstall: toolchain.install
clean: toolchain.clean
.for f in aclocal autoconf autoheader automake
toolchain.configure: ${TOOLDIR}/bin/${f}
${TOOLDIR}/bin/${f}: stub.sh
${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -m ${BINMODE} $> $@
.endfor
toolchain.configure:
rm -rf toolchain
mkdir toolchain
cd toolchain && \
CC="${HOST_CC}" \
CFLAGS="${HOST_CFLAGS}" \
CPPFLAGS="${HOST_CPPFLAGS}" \
LDFLAGS="${HOST_LDFLAGS}" \
PATH="${TOOLDIR}/bin:$$PATH" \
LANGUAGES="c c++ objc" \
${DIST}/configure \
--target=${MACHINE_GNU_PLATFORM} \
--disable-shared --disable-nls \
--prefix=${TOOLDIR}
cd toolchain/gcc && \
mv -f Makefile Makefile.orig && \
egrep -v '^(LIBGCC|LIBGCC1_TEST|LIBGCC2|INSTALL_LIBGCC) =' \
Makefile.orig >Makefile
@touch $@
toolchain.all: toolchain.configure
cd toolchain && \
PATH="${TOOLDIR}/bin:$$PATH" \
${MAKE} all-binutils all-gas all-ld all-gcc \
LEX=true BISON=true
toolchain.install:
cd toolchain && \
PATH="${TOOLDIR}/bin:$$PATH" \
${MAKE} install-binutils install-gas install-ld install-gcc \
LEX=true BISON=true
toolchain.clean:
rm -rf toolchain*
.include <bsd.hostprog.mk>

5
tools/toolchain/stub.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# $NetBSD: stub.sh,v 1.1 2001/08/14 11:02:03 tv Exp $
#
# Do-nothing stub to override autoconf, automake, etc.
#

7
tools/tsort/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:04 tv Exp $
HOST_SRCDIR= usr.bin/tsort
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}

7
tools/yacc/Makefile Normal file
View File

@ -0,0 +1,7 @@
# $NetBSD: Makefile,v 1.1 2001/08/14 11:02:04 tv Exp $
HOST_SRCDIR= usr.bin/yacc
.include "${.CURDIR}/../Makefile.host"
${TIMESTAMP}: ${SRCS}