summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-04-05 20:30:30 +0000
committerimp <imp@FreeBSD.org>2003-04-05 20:30:30 +0000
commitb0693a4cbc1561df17854d11e8a1b4b331f8b742 (patch)
treeb6fc0351de0d24cf42e51ee60290331a14961c9c
parentcb5cc10e3188fdee3c927d3d39c4793ebfc3f045 (diff)
downloadFreeBSD-src-b0693a4cbc1561df17854d11e8a1b4b331f8b742.zip
FreeBSD-src-b0693a4cbc1561df17854d11e8a1b4b331f8b742.tar.gz
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.
-rw-r--r--Makefile.inc119
-rw-r--r--gnu/usr.bin/binutils/ld/Makefile10
-rw-r--r--gnu/usr.bin/binutils/libiberty/Makefile5
-rw-r--r--kerberos5/lib/libasn1/Makefile8
-rw-r--r--kerberos5/lib/libhdb/Makefile8
-rw-r--r--lib/libncurses/Makefile4
-rw-r--r--lib/ncurses/ncurses/Makefile4
-rw-r--r--share/mk/bsd.sys.mk7
-rw-r--r--tools/build/Makefile58
-rw-r--r--tools/build/Makefile.boot18
-rw-r--r--tools/build/dummy.c5
-rw-r--r--tools/build/endian.h57
-rw-r--r--tools/build/langinfo.h17
-rw-r--r--tools/build/progname.c25
-rw-r--r--usr.bin/xargs/xargs.c15
-rw-r--r--usr.bin/xinstall/Makefile7
16 files changed, 194 insertions, 73 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index d9768d8..b4b3f09 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 a2fc8cb..036cacb 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 c002f62..7cce2ca 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 3f270e6..eafe58d 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 0970b13..d1888a6 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 1b4ec70..a3ee27b5 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 1b4ec70..a3ee27b5 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 f1bc89e..0b164a9 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 <sys/cdefs.h>.
-.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 0000000..adde04a
--- /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 <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>
diff --git a/tools/build/Makefile.boot b/tools/build/Makefile.boot
new file mode 100644
index 0000000..e489981
--- /dev/null
+++ b/tools/build/Makefile.boot
@@ -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
diff --git a/tools/build/dummy.c b/tools/build/dummy.c
new file mode 100644
index 0000000..b656a03
--- /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 0000000..dbec545
--- /dev/null
+++ b/tools/build/endian.h
@@ -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
diff --git a/tools/build/langinfo.h b/tools/build/langinfo.h
new file mode 100644
index 0000000..419c721
--- /dev/null
+++ b/tools/build/langinfo.h
@@ -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 */
diff --git a/tools/build/progname.c b/tools/build/progname.c
new file mode 100644
index 0000000..dc1611e
--- /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 8b75dbb..a31f2a6 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 <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);
}
diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile
index 2ed1eea..3116d07 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 <bsd.prog.mk>
OpenPOWER on IntegriCloud