diff options
author | Warner Losh <imp@FreeBSD.org> | 2003-04-05 20:30:30 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2003-04-05 20:30:30 +0000 |
commit | 30aaff1192acd09c20cd6e8c70c9e8d023d4c818 (patch) | |
tree | b6fc0351de0d24cf42e51ee60290331a14961c9c /tools | |
parent | ca6a2c5aef9d2fdfb6f19fc7d050288f91c7afa2 (diff) | |
download | src-30aaff1192acd09c20cd6e8c70c9e8d023d4c818.tar.gz src-30aaff1192acd09c20cd6e8c70c9e8d023d4c818.zip |
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.
Notes
Notes:
svn path=/head/; revision=113136
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build/Makefile | 58 | ||||
-rw-r--r-- | tools/build/Makefile.boot | 18 | ||||
-rw-r--r-- | tools/build/dummy.c | 5 | ||||
-rw-r--r-- | tools/build/endian.h | 57 | ||||
-rw-r--r-- | tools/build/langinfo.h | 17 | ||||
-rw-r--r-- | tools/build/progname.c | 25 |
6 files changed, 180 insertions, 0 deletions
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 <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 000000000000..e4899811d4a5 --- /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 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 <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 000000000000..419c7214ed7e --- /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 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); +} |