diff --git a/Makefile.inc1 b/Makefile.inc1 index d9768d86630c..b4b3f09e2224 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -187,19 +187,20 @@ CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \ GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac # bootstrap-tool stage -BMAKEENV= MAKEOBJDIRPREFIX=${WORLDTMP} \ - DESTDIR= \ - INSTALL="sh ${.CURDIR}/tools/install.sh" -BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ +BMAKEENV= DESTDIR= \ + INSTALL="sh ${.CURDIR}/tools/install.sh" \ + __MAKE_CONF=${.CURDIR}/tools/build/Makefile.boot \ + OLD_MAKE_CONF=${__MAKE_CONF} \ + WORLDTMP=${WORLDTMP} +BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ + ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ BOOTSTRAPPING=${OSRELDATE} \ -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \ -DNO_CPU_CFLAGS -DNO_WARNS # build-tool stage -TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \ - DESTDIR= \ - INSTALL="sh ${.CURDIR}/tools/install.sh" -TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 \ +TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ + ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ BOOTSTRAPPING=${OSRELDATE} -DNO_CPU_CFLAGS -DNO_WARNS # cross-tool stage @@ -610,7 +611,7 @@ _strfile= games/fortune/strfile .endif bootstrap-tools: -.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \ +.for _tool in tools/build ${_strfile} usr.bin/yacc usr.bin/colldef \ usr.bin/makewhatis usr.bin/rpcgen usr.bin/uudecode \ usr.bin/xargs usr.bin/xinstall \ usr.sbin/config usr.sbin/kbdcontrol \ diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile index a2fc8cb92591..036cacb14a17 100644 --- a/gnu/usr.bin/binutils/ld/Makefile +++ b/gnu/usr.bin/binutils/ld/Makefile @@ -10,20 +10,12 @@ SRCS+= ldcref.c ldctor.c ldemul.c ldemul-list.h ldexp.c ldfile.c \ ldgram.y ldlang.c ldlex.l ldmain.c ldmisc.c \ ldver.c ldwrite.c lexsup.c mri.c -.if defined(BOOTSTRAPPING) && !exists(/usr/include/elf-hints.h) -SRCS+= elf-hints.h -CLEANFILES+= elf-hints.h - -elf-hints.h: - ln -sf ${.CURDIR}/../../../../include/${.TARGET} . -.endif - WARNS= 1 CFLAGS+= -DSCRIPTDIR=\"${TOOLS_PREFIX}/usr/libdata\" CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd NOSHARED?= yes -DPADD= ${RELTOP}/libbfd/libbfd.a +DPADD+= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a LDADD= ${DPADD} CLEANDIRS+= ldscripts diff --git a/gnu/usr.bin/binutils/libiberty/Makefile b/gnu/usr.bin/binutils/libiberty/Makefile index c002f6243106..7cce2ca98c32 100644 --- a/gnu/usr.bin/binutils/libiberty/Makefile +++ b/gnu/usr.bin/binutils/libiberty/Makefile @@ -10,11 +10,6 @@ SRCS= argv.c choose-temp.c concat.c cp-demangle.c cplus-dem.c \ hex.c floatformat.c hashtab.c lbasename.c make-temp-file.c \ objalloc.c obstack.c safe-ctype.c xatexit.c xexit.c xmalloc.c \ xstrdup.c xstrerror.c -.if defined(BOOTSTRAPPING) && \ - ( ${BOOTSTRAPPING} < 440000 || \ - ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500022 )) -SRCS+= basename.c -.endif WARNS= 1 CFLAGS+= -DHAVE_CONFIG_H INTERNALLIB= true diff --git a/kerberos5/lib/libasn1/Makefile b/kerberos5/lib/libasn1/Makefile index 3f270e6dcdb3..eafe58d41058 100644 --- a/kerberos5/lib/libasn1/Makefile +++ b/kerberos5/lib/libasn1/Makefile @@ -104,13 +104,7 @@ asn1_compile: \ print_version.o \ get_window_size.c \ strupr.c - ${CC} ${CFLAGS} ${.OODATE} -o ${.TARGET} - -.if defined(BOOTSTRAPPING) && \ - ( ${BOOTSTRAPPING} < 440001 || \ - ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500023 )) -asn1_compile: getprogname.c setprogname.c -.endif + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.OODATE} ${LDADD} parse.o: parse.c roken.h diff --git a/kerberos5/lib/libhdb/Makefile b/kerberos5/lib/libhdb/Makefile index 0970b1360265..d1888a6fe3ae 100644 --- a/kerberos5/lib/libhdb/Makefile +++ b/kerberos5/lib/libhdb/Makefile @@ -59,13 +59,7 @@ asn1_compile: parse.o lex.o main.c hash.c symbol.c emalloc.c gen.c \ gen_encode.c gen_decode.c gen_free.c gen_length.c \ gen_copy.c gen_glue.c getarg.c warnerr.c print_version.o \ get_window_size.c strupr.c - ${CC} ${CFLAGS} ${.OODATE} -o ${.TARGET} - -.if defined(BOOTSTRAPPING) && \ - ( ${BOOTSTRAPPING} < 440001 || \ - ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500023 )) -asn1_compile: getprogname.c setprogname.c -.endif + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.OODATE} ${LDADD} parse.o: parse.c diff --git a/lib/libncurses/Makefile b/lib/libncurses/Makefile index 1b4ec70ae54e..a3ee27b54237 100644 --- a/lib/libncurses/Makefile +++ b/lib/libncurses/Makefile @@ -25,11 +25,7 @@ BROKEN_LINKER= 0 BUILTIN_BOOL= 1 BOOL_TYPE= 0 HAVE_VSSCANF= 1 -.if defined(BOOTSTRAPPING) && !exists(/usr/include/stdbool.h) -HEADER_STDBOOL= 0 -.else HEADER_STDBOOL= 1 -.endif TYPE_OF_BOOL= unsigned char TYPEOF_CHTYPE= long WIDEC_SHIFT= 8 diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile index 1b4ec70ae54e..a3ee27b54237 100644 --- a/lib/ncurses/ncurses/Makefile +++ b/lib/ncurses/ncurses/Makefile @@ -25,11 +25,7 @@ BROKEN_LINKER= 0 BUILTIN_BOOL= 1 BOOL_TYPE= 0 HAVE_VSSCANF= 1 -.if defined(BOOTSTRAPPING) && !exists(/usr/include/stdbool.h) -HEADER_STDBOOL= 0 -.else HEADER_STDBOOL= 1 -.endif TYPE_OF_BOOL= unsigned char TYPEOF_CHTYPE= long WIDEC_SHIFT= 8 diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index f1bc89e2050d..0b164a9f5fcf 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -52,10 +52,3 @@ CFLAGS += -Werror # Allow user-specified additional warning flags CFLAGS += ${CWARNFLAGS} - -# FreeBSD didn't always have the __FBSDID() macro in . -.if defined(BOOTSTRAPPING) && \ - ( ${BOOTSTRAPPING} < 440001 || \ - ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500024 )) -CFLAGS+= -D__FBSDID=__RCSID -.endif diff --git a/tools/build/Makefile b/tools/build/Makefile new file mode 100644 index 000000000000..adde04a56619 --- /dev/null +++ b/tools/build/Makefile @@ -0,0 +1,58 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../include + +LIB= build +SRCS= +INCSGROUPS= INCS +INCS= + +BOOTSTRAPPING?= 0 + +# Some tools need . +.if !exists(/usr/include/sys/endian.h) +INCSGROUPS+= SYSHDRS +SYSHDRS= endian.h +SYSHDRSDIR= ${INCLUDEDIR}/sys +.endif + +# gnu/usr.bin/binutils/ld needs . +.if !exists(/usr/include/elf-hints.h) +INCS+= elf-hints.h +.endif + +# lib/libncurses needs . +.if !exists(/usr/include/stdbool.h) +INCS+= stdbool.h +.endif + +# usr.bin/xargs needs . +.if !exists(/usr/include/langinfo.h) +INCS+= langinfo.h +.endif + +# gnu/usr.bin/binutils/libiberty needs basename(3). +.if ( ${BOOTSTRAPPING} < 440000 || \ + ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500022 )) +.PATH: ${.CURDIR}/../../lib/libc/gen +SRCS+= basename.c +.endif + +# Some tools need {get,set}progname(3). +.if ( ${BOOTSTRAPPING} < 440001 || \ + ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500023 )) +SRCS+= progname.c +.endif + +# install(1) needs strtofflags(3). +.if ( ${BOOTSTRAPPING} < 400021 || \ + ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500007 )) +.PATH: ${.CURDIR}/../../lib/libc/gen +SRCS+= strtofflags.c +.endif + +.if empty(SRCS) +SRCS= dummy.c +.endif + +.include diff --git a/tools/build/Makefile.boot b/tools/build/Makefile.boot new file mode 100644 index 000000000000..e4899811d4a5 --- /dev/null +++ b/tools/build/Makefile.boot @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# FreeBSD didn't always have the __FBSDID() macro in . +.if defined(BOOTSTRAPPING) && \ + ( ${BOOTSTRAPPING} < 440001 || \ + ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500024 )) +CFLAGS+= -D__FBSDID=__RCSID +.endif + +CFLAGS+= -I${WORLDTMP}/usr/include +DPADD= ${WORLDTMP}/usr/lib/libbuild.a +LDADD= -lbuild +LDFLAGS= -L${WORLDTMP}/usr/lib + +OLD_MAKE_CONF?= /etc/make.conf +.if exists(${OLD_MAKE_CONF}) +.include "${OLD_MAKE_CONF}" +.endif diff --git a/tools/build/dummy.c b/tools/build/dummy.c new file mode 100644 index 000000000000..b656a0305a97 --- /dev/null +++ b/tools/build/dummy.c @@ -0,0 +1,5 @@ +/* + * $FreeBSD$ + * + * Empty file to keep linker happy. + */ diff --git a/tools/build/endian.h b/tools/build/endian.h new file mode 100644 index 000000000000..dbec54500ebc --- /dev/null +++ b/tools/build/endian.h @@ -0,0 +1,57 @@ +/* + * $FreeBSD$ + */ + +#include + +#if __FreeBSD_version >= 500034 +#include_next +#else +#include + +#define bswap16(x) (uint16_t) \ + ((x >> 8) | (x << 8)) + +#define bswap32(x) (uint32_t) \ + ((x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24)) + +#define bswap64(x) (uint64_t) \ + ((x >> 56) | ((x >> 40) & 0xff00) | ((x >> 24) & 0xff0000) | \ + ((x >> 8) & 0xff000000) | ((x << 8) & ((uint64_t)0xff << 32)) | \ + ((x << 24) & ((uint64_t)0xff << 40)) | \ + ((x << 40) & ((uint64_t)0xff << 48)) | ((x << 56))) + +/* + * Host to big endian, host to little endian, big endian to host, and little + * endian to host byte order functions as detailed in byteorder(9). + */ +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define htobe16(x) bswap16((uint16_t)(x)) +#define htobe32(x) bswap32((uint32_t)(x)) +#define htobe64(x) bswap64((uint64_t)(x)) +#define htole16(x) ((uint16_t)(x)) +#define htole32(x) ((uint32_t)(x)) +#define htole64(x) ((uint64_t)(x)) + +#define be16toh(x) bswap16((uint16_t)(x)) +#define be32toh(x) bswap32((uint32_t)(x)) +#define be64toh(x) bswap64((uint64_t)(x)) +#define le16toh(x) ((uint16_t)(x)) +#define le32toh(x) ((uint32_t)(x)) +#define le64toh(x) ((uint64_t)(x)) +#else /* _BYTE_ORDER != _LITTLE_ENDIAN */ +#define htobe16(x) ((uint16_t)(x)) +#define htobe32(x) ((uint32_t)(x)) +#define htobe64(x) ((uint64_t)(x)) +#define htole16(x) bswap16((uint16_t)(x)) +#define htole32(x) bswap32((uint32_t)(x)) +#define htole64(x) bswap64((uint64_t)(x)) + +#define be16toh(x) ((uint16_t)(x)) +#define be32toh(x) ((uint32_t)(x)) +#define be64toh(x) ((uint64_t)(x)) +#define le16toh(x) bswap16((uint16_t)(x)) +#define le32toh(x) bswap32((uint32_t)(x)) +#define le64toh(x) bswap64((uint64_t)(x)) +#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ +#endif diff --git a/tools/build/langinfo.h b/tools/build/langinfo.h new file mode 100644 index 000000000000..419c7214ed7e --- /dev/null +++ b/tools/build/langinfo.h @@ -0,0 +1,17 @@ +/* $FreeBSD$ */ + +#ifndef LANGINFO_H +#define LANGINFO_H + +#include + +#define YESEXPR 1 + +/* xargs only needs yesexpr, so that's all we implement, for english */ +static inline const char * +nl_langinfo(int type __unused) +{ + return ("^[yY]"); +} + +#endif /* LANGINFO_H */ diff --git a/tools/build/progname.c b/tools/build/progname.c new file mode 100644 index 000000000000..dc1611e9ac28 --- /dev/null +++ b/tools/build/progname.c @@ -0,0 +1,25 @@ +/* $FreeBSD$ */ + +/* + * Compat shims for those programs that use this newer interface. These + * are more minimal than their libc bretheren as far as namespaces and + * such go because their use is so limited. Also, the libc versions + * have too many depends on libc build environment; it is more of a pain + * to set that up than to recreate them here shorn of all the other goo. + */ + +extern const char *__progname; + +void +setprogname(const char *p) +{ + + __progname = p; +} + +const char * +getprogname(void) +{ + + return (__progname); +} diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 8b75dbb97864..a31f2a62a0e3 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -52,19 +52,12 @@ static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93"; __FBSDID("$FreeBSD$"); #include -#if (__FreeBSD_version >= 450002 && __FreeBSD_version < 500000) || \ - __FreeBSD_version >= 500017 -#define HAS_LANGINFO -#endif - #include #include #include #include -#ifdef HAS_LANGINFO #include -#endif #include #include #include @@ -590,13 +583,7 @@ prompt(void) (void)fprintf(stderr, "?..."); (void)fflush(stderr); if ((response = fgetln(ttyfp, &rsize)) == NULL || - regcomp(&cre, -#ifdef HAS_LANGINFO - nl_langinfo(YESEXPR), -#else - "^[yY]", -#endif - REG_BASIC) != 0) { + regcomp(&cre, nl_langinfo(YESEXPR), REG_BASIC) != 0) { (void)fclose(ttyfp); return (0); } diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile index 2ed1eea375c0..3116d07f9771 100644 --- a/usr.bin/xinstall/Makefile +++ b/usr.bin/xinstall/Makefile @@ -6,11 +6,4 @@ PROGNAME= install SRCS= xinstall.c MAN= install.1 -.if defined(BOOTSTRAPPING) && \ - ( ${BOOTSTRAPPING} < 400021 || \ - ( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500007 )) -.PATH: ${.CURDIR}/../../lib/libc/gen -SRCS+= strtofflags.c -.endif - .include