Hi, this patch enables NetBSD (6.0.1 amd64) as buildsystem for OpenWrt. This makes the BSD family support nearly completely usable for the base system. As reference I am building Realviw Qemu Arm images.
Please commit. Signed-off-by: Waldemar Brodkorb <m...@waldemar-brodkorb.de> Index: include/prereq-build.mk =================================================================== --- include/prereq-build.mk (revision 35902) +++ include/prereq-build.mk (working copy) @@ -41,6 +41,7 @@ define Require/getopt gnugetopt --help 2>&1 | grep long >/dev/null || \ /usr/local/bin/getopt --help 2>&1 | grep long >/dev/null || \ + /usr/pkg/bin/getopt --help 2>&1 | grep long >/dev/null || \ getopt --help 2>&1 | grep long >/dev/null endef $(eval $(call Require,getopt, \ @@ -96,7 +97,8 @@ define Require/ncurses echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \ - gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses + gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses \ + -I/usr/pkg/include/ncurses -I/usr/pkg/include -L/usr/pkg/lib endef $(eval $(call Require,ncurses, \ Index: scripts/netbsd.sh =================================================================== --- scripts/netbsd.sh (revision 0) +++ scripts/netbsd.sh (revision 0) @@ -0,0 +1,19 @@ +#!/bin/sh +arch=$(uname -m) + +export PKG_PATH="http://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/${arch}/6.0/All" +pkg_add -vu xz +pkg_add -vu scmgit +pkg_add -vu subversion +pkg_add -vu gmake +pkg_add -vu bash +pkg_add -vu wget +pkg_add -vu unzip +pkg_add -vu gtar +pkg_add -vu gawk +pkg_add -vu findutils +pkg_add -vu python +pkg_add -vu coreutils +pkg_add -vu diffutils +pkg_add -vu getopt + Index: scripts/config/lex.zconf.c_shipped =================================================================== --- scripts/config/lex.zconf.c_shipped (revision 35902) +++ scripts/config/lex.zconf.c_shipped (working copy) @@ -2271,7 +2271,12 @@ if (retval == GLOB_NOMATCH) return; +#if defined(__NetBSD__) + if (retval == GLOB_NOSPACE) { +#else if (retval == GLOB_NOSPACE || retval == GLOB_ABORTED) { +#endif + printf("%s:%d: glob failed: %s \"%s\"\n", zconf_curname(), zconf_lineno(), retval == GLOB_NOSPACE ? "failed to allocate memory" : retval == GLOB_ABORTED ? "read error" : "no match", Index: package/opkg/patches/080-netbsd-fixes.patch =================================================================== --- package/opkg/patches/080-netbsd-fixes.patch (revision 0) +++ package/opkg/patches/080-netbsd-fixes.patch (revision 0) @@ -0,0 +1,17 @@ +diff -Nur opkg-618.orig/src/opkg-cl.c opkg-618/src/opkg-cl.c +--- opkg-618.orig/src/opkg-cl.c 2013-03-13 13:49:37.000000000 +0100 ++++ opkg-618/src/opkg-cl.c 2013-03-13 13:50:28.000000000 +0100 +@@ -109,8 +109,13 @@ + char *tuple, *targ; + + while (1) { ++#if defined(__NetBSD__) ++ c = getopt_long(argc, argv, "Ad:f:ino:p:t:vV::", ++ long_options, &option_index); ++#else + c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::", + long_options, &option_index); ++#endif + if (c == -1) + break; + Index: tools/m4/patches/110-netbsd-fixes.patch =================================================================== --- tools/m4/patches/110-netbsd-fixes.patch (revision 0) +++ tools/m4/patches/110-netbsd-fixes.patch (revision 0) @@ -0,0 +1,24 @@ +diff -Nur m4-1.4.16.orig/lib/fflush.c m4-1.4.16/lib/fflush.c +--- m4-1.4.16.orig/lib/fflush.c 2011-03-01 17:39:27.000000000 +0100 ++++ m4-1.4.16/lib/fflush.c 2013-03-12 13:40:25.000000000 +0100 +@@ -91,7 +91,7 @@ + update_fpos_cache (FILE *fp, off_t pos) + { + #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +-# if defined __CYGWIN__ ++# if defined (__CYGWIN__) || defined(__NetBSD__) + /* fp_->_offset is typed as an integer. */ + fp_->_offset = pos; + # else +diff -Nur m4-1.4.16.orig/lib/fseeko.c m4-1.4.16/lib/fseeko.c +--- m4-1.4.16.orig/lib/fseeko.c 2011-03-01 17:39:28.000000000 +0100 ++++ m4-1.4.16/lib/fseeko.c 2013-03-12 13:39:36.000000000 +0100 +@@ -109,7 +109,7 @@ + #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ + fp->_flags &= ~_IO_EOF_SEEN; + #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +-# if defined __CYGWIN__ ++# if defined (__CYGWIN__) || defined(__NetBSD__) + /* fp_->_offset is typed as an integer. */ + fp_->_offset = pos; + # else Index: tools/yaffs2/patches/110-bsd-compat.patch =================================================================== --- tools/yaffs2/patches/110-bsd-compat.patch (revision 0) +++ tools/yaffs2/patches/110-bsd-compat.patch (revision 0) @@ -0,0 +1,14 @@ +diff -Nur yaffs2_android.orig/yaffs2/yaffs_guts.h yaffs2_android/yaffs2/yaffs_guts.h +--- yaffs2_android.orig/yaffs2/yaffs_guts.h 2009-02-15 16:23:50.000000000 +0100 ++++ yaffs2_android/yaffs2/yaffs_guts.h 2013-03-12 16:49:59.000000000 +0100 +@@ -823,6 +823,10 @@ + int yaffs_SetAttributes(yaffs_Object * obj, struct iattr *attr); + int yaffs_GetAttributes(yaffs_Object * obj, struct iattr *attr); + ++#if defined(__OpenBSD__) || defined(__NetBSD__) ++#define loff_t off_t ++#endif ++ + /* File operations */ + int yaffs_ReadDataFromFile(yaffs_Object * obj, __u8 * buffer, loff_t offset, + int nBytes); Index: tools/yaffs2/patches/110-openbsd-compat.patch =================================================================== --- tools/yaffs2/patches/110-openbsd-compat.patch (revision 35902) +++ tools/yaffs2/patches/110-openbsd-compat.patch (working copy) @@ -1,14 +0,0 @@ -diff -Nur yaffs2_android.orig/yaffs2/yaffs_guts.h yaffs2_android/yaffs2/yaffs_guts.h ---- yaffs2_android.orig/yaffs2/yaffs_guts.h Sun Feb 15 16:23:50 2009 -+++ yaffs2_android/yaffs2/yaffs_guts.h Tue Mar 5 15:45:21 2013 -@@ -823,6 +823,10 @@ - int yaffs_SetAttributes(yaffs_Object * obj, struct iattr *attr); - int yaffs_GetAttributes(yaffs_Object * obj, struct iattr *attr); - -+#if defined(__OpenBSD__) -+#define loff_t off_t -+#endif -+ - /* File operations */ - int yaffs_ReadDataFromFile(yaffs_Object * obj, __u8 * buffer, loff_t offset, - int nBytes); Index: tools/e2fsprogs/patches/005-netbsd-compat.patch =================================================================== --- tools/e2fsprogs/patches/005-netbsd-compat.patch (revision 0) +++ tools/e2fsprogs/patches/005-netbsd-compat.patch (revision 0) @@ -0,0 +1,36 @@ +diff -Nur e2fsprogs-1.42.7.orig/lib/ext2fs/bitops.c e2fsprogs-1.42.7/lib/ext2fs/bitops.c +--- e2fsprogs-1.42.7.orig/lib/ext2fs/bitops.c 2012-11-30 03:40:18.000000000 +0100 ++++ e2fsprogs-1.42.7/lib/ext2fs/bitops.c 2013-03-12 15:34:36.000000000 +0100 +@@ -123,7 +123,7 @@ + return (res + (res >> 4)) & 0x0F; + } + +-static unsigned int popcount32(unsigned int w) ++static unsigned int _popcount32(unsigned int w) + { + unsigned int res = w - ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); +@@ -145,7 +145,7 @@ + p = (__u32 *) cp; + + while (nbytes > 4) { +- res += popcount32(*p++); ++ res += _popcount32(*p++); + nbytes -= 4; + } + cp = (const unsigned char *) p; +diff -Nur e2fsprogs-1.42.7.orig/lib/ext2fs/ismounted.c e2fsprogs-1.42.7/lib/ext2fs/ismounted.c +--- e2fsprogs-1.42.7.orig/lib/ext2fs/ismounted.c 2013-01-02 01:47:20.000000000 +0100 ++++ e2fsprogs-1.42.7/lib/ext2fs/ismounted.c 2013-03-12 15:33:43.000000000 +0100 +@@ -199,7 +199,11 @@ + static errcode_t check_getmntinfo(const char *file, int *mount_flags, + char *mtpt, int mtlen) + { ++#if defined(__NetBSD__) ++ struct statvfs *mp; ++#else + struct statfs *mp; ++#endif + int len, n; + const char *s1; + char *s2; Index: tools/Makefile =================================================================== --- tools/Makefile (revision 35902) +++ tools/Makefile (working copy) @@ -132,7 +132,7 @@ $(eval $(call PrepareCommand,seq,gseq seq)) $(eval $(call PrepareCommand,python,python2 python2.7 python)) $(eval $(call PrepareCommand,awk,gawk awk)) -$(eval $(call PrepareCommand,getopt,gnugetopt /usr/local/bin/getopt getopt)) +$(eval $(call PrepareCommand,getopt,gnugetopt /usr/pkg/bin/getopt /usr/local/bin/getopt getopt)) $(eval $(call PrepareCommand,grep,ggrep grep)) $(eval $(call PrepareCommand,tar,gtar tar)) $(eval $(call PrepareCommand,diff,gdiff diff)) Index: tools/include/getline.h =================================================================== --- tools/include/getline.h (revision 35902) +++ tools/include/getline.h (working copy) @@ -32,7 +32,7 @@ #include <stdlib.h> #include <string.h> -#if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) +#if !defined(__linux__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) /* * Emulate glibc getline() via BSD fgetln(). * Note that outsize is not changed unless memory is allocated. Index: tools/include/endian.h =================================================================== --- tools/include/endian.h (revision 35902) +++ tools/include/endian.h (working copy) @@ -10,6 +10,11 @@ #define bswap_16(x) NXSwapShort(x) #define bswap_32(x) NXSwapInt(x) #define bswap_64(x) NXSwapLongLong(x) +#elif defined(__NetBSD__) +#include <sys/endian.h> +#define bswap_16(x) bswap16(x) +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) #elif defined(__FreeBSD__) #include <sys/endian.h> #define bswap_16(x) bswap16(x) _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel