Migrate to a new way of dealing with building from old revisions of
FreeBSD. This method attempts to centralize all the necessary hacks or work arounds in one of two places in the tree (src/Makefile.inc1 and src/tools/build). We build a small compatibility library (libbuild.a) as well as selectively installing necessary include files. We then include this directory when building host binaries. This removes all the past release compatibilty hacks from various places in the tree. We still build on tip of stable and current. I will work with those that want to support more, although I anticipate it will just work. Many thanks to ru@, obrien@ and jhb@ for providing valuable input at various stage of implementation, as well as for working together to positively effect a change for the better.
This commit is contained in:
parent
ca6a2c5aef
commit
30aaff1192
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -52,10 +52,3 @@ CFLAGS += -Werror
|
||||
|
||||
# Allow user-specified additional warning flags
|
||||
CFLAGS += ${CWARNFLAGS}
|
||||
|
||||
# FreeBSD didn't always have the __FBSDID() macro in <sys/cdefs.h>.
|
||||
.if defined(BOOTSTRAPPING) && \
|
||||
( ${BOOTSTRAPPING} < 440001 || \
|
||||
( ${BOOTSTRAPPING} >= 500000 && ${BOOTSTRAPPING} < 500024 ))
|
||||
CFLAGS+= -D__FBSDID=__RCSID
|
||||
.endif
|
||||
|
58
tools/build/Makefile
Normal file
58
tools/build/Makefile
Normal file
@ -0,0 +1,58 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../include
|
||||
|
||||
LIB= build
|
||||
SRCS=
|
||||
INCSGROUPS= INCS
|
||||
INCS=
|
||||
|
||||
BOOTSTRAPPING?= 0
|
||||
|
||||
# Some tools need <sys/endian.h>.
|
||||
.if !exists(/usr/include/sys/endian.h)
|
||||
INCSGROUPS+= SYSHDRS
|
||||
SYSHDRS= endian.h
|
||||
SYSHDRSDIR= ${INCLUDEDIR}/sys
|
||||
.endif
|
||||
|
||||
# gnu/usr.bin/binutils/ld needs <elf-hints.h>.
|
||||
.if !exists(/usr/include/elf-hints.h)
|
||||
INCS+= elf-hints.h
|
||||
.endif
|
||||
|
||||
# lib/libncurses needs <stdbool.h>.
|
||||
.if !exists(/usr/include/stdbool.h)
|
||||
INCS+= stdbool.h
|
||||
.endif
|
||||
|
||||
# usr.bin/xargs needs <nl_langinfo.h>.
|
||||
.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 <bsd.lib.mk>
|
18
tools/build/Makefile.boot
Normal file
18
tools/build/Makefile.boot
Normal file
@ -0,0 +1,18 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# FreeBSD didn't always have the __FBSDID() macro in <sys/cdefs.h>.
|
||||
.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
|
5
tools/build/dummy.c
Normal file
5
tools/build/dummy.c
Normal file
@ -0,0 +1,5 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*
|
||||
* Empty file to keep linker happy.
|
||||
*/
|
57
tools/build/endian.h
Normal file
57
tools/build/endian.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#if __FreeBSD_version >= 500034
|
||||
#include_next <sys/endian.h>
|
||||
#else
|
||||
#include <machine/endian.h>
|
||||
|
||||
#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
|
17
tools/build/langinfo.h
Normal file
17
tools/build/langinfo.h
Normal file
@ -0,0 +1,17 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef LANGINFO_H
|
||||
#define LANGINFO_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#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 */
|
25
tools/build/progname.c
Normal file
25
tools/build/progname.c
Normal file
@ -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);
|
||||
}
|
@ -52,19 +52,12 @@ static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93";
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#if (__FreeBSD_version >= 450002 && __FreeBSD_version < 500000) || \
|
||||
__FreeBSD_version >= 500017
|
||||
#define HAS_LANGINFO
|
||||
#endif
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAS_LANGINFO
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#include <locale.h>
|
||||
#include <paths.h>
|
||||
#include <regex.h>
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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 <bsd.prog.mk>
|
||||
|
Loading…
Reference in New Issue
Block a user