Hi, I would like to work on a better BSD support as a host system for OpenWrt. Here is my first patch which fixes a lot of compile errors on OpenBSD.
What you think about this patch? best regards Waldemar
Index: tools/e2fsprogs/patches/003-openbsd-compat.patch =================================================================== --- tools/e2fsprogs/patches/003-openbsd-compat.patch (revision 0) +++ tools/e2fsprogs/patches/003-openbsd-compat.patch (working copy) @@ -0,0 +1,22 @@ +diff -Nur e2fsprogs-1.42.7.orig/lib/blkid/getsize.c e2fsprogs-1.42.7/lib/blkid/getsize.c +--- e2fsprogs-1.42.7.orig/lib/blkid/getsize.c Fri Nov 30 03:40:18 2012 ++++ e2fsprogs-1.42.7/lib/blkid/getsize.c Tue Mar 5 14:55:43 2013 +@@ -26,6 +26,7 @@ + #include <fcntl.h> + #ifdef HAVE_SYS_IOCTL_H + #include <sys/ioctl.h> ++#include <sys/dkio.h> + #endif + #ifdef HAVE_LINUX_FD_H + #include <linux/fd.h> +diff -Nur e2fsprogs-1.42.7.orig/lib/quota/mkquota.c e2fsprogs-1.42.7/lib/quota/mkquota.c +--- e2fsprogs-1.42.7.orig/lib/quota/mkquota.c Wed Jan 2 01:47:20 2013 ++++ e2fsprogs-1.42.7/lib/quota/mkquota.c Tue Mar 5 14:56:06 2013 +@@ -8,6 +8,7 @@ + #include <sys/stat.h> + #include <unistd.h> + #include <errno.h> ++#include <stdint.h> + #include <string.h> + #include <fcntl.h> + Index: tools/include/getline.h =================================================================== --- tools/include/getline.h (revision 35879) +++ tools/include/getline.h (working copy) @@ -32,7 +32,7 @@ #include <stdlib.h> #include <string.h> -#if !defined(__linux__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) +#if !defined(__linux__) && !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 35879) +++ tools/include/endian.h (working copy) @@ -15,6 +15,11 @@ #define bswap_16(x) bswap16(x) #define bswap_32(x) bswap32(x) #define bswap_64(x) bswap64(x) +#elif defined(__OpenBSD__) +#include <sys/types.h> +#define bswap_16(x) __swap16(x) +#define bswap_32(x) __swap32(x) +#define bswap_64(x) __swap64(x) #else #include <machine/endian.h> #define bswap_16(x) swap16(x) Index: tools/squashfs4/patches/180-openbsd_compat.patch =================================================================== --- tools/squashfs4/patches/180-openbsd_compat.patch (revision 0) +++ tools/squashfs4/patches/180-openbsd_compat.patch (working copy) @@ -0,0 +1,26 @@ +diff -Nur squashfs4.2.orig/squashfs-tools/mksquashfs.c squashfs4.2/squashfs-tools/mksquashfs.c +--- squashfs4.2.orig/squashfs-tools/mksquashfs.c Tue Mar 5 16:20:49 2013 ++++ squashfs4.2/squashfs-tools/mksquashfs.c Tue Mar 5 16:25:10 2013 +@@ -32,6 +32,9 @@ + #include <stdio.h> + #include <stddef.h> + #include <sys/time.h> ++#if defined(__OpenBSD__) ++#include <sys/param.h> ++#endif + #include <sys/types.h> + #include <sys/stat.h> + #include <fcntl.h> +diff -Nur squashfs4.2.orig/squashfs-tools/unsquashfs.h squashfs4.2/squashfs-tools/unsquashfs.h +--- squashfs4.2.orig/squashfs-tools/unsquashfs.h Tue Mar 5 16:20:49 2013 ++++ squashfs4.2/squashfs-tools/unsquashfs.h Tue Mar 5 16:25:57 2013 +@@ -25,6 +25,9 @@ + #define TRUE 1 + #define FALSE 0 + #include <stdio.h> ++#if defined(__OpenBSD__) ++#include <sys/param.h> ++#endif + #include <sys/types.h> + #include <unistd.h> + #include <stdlib.h> Index: tools/yaffs2/patches/110-openbsd-compat.patch =================================================================== --- tools/yaffs2/patches/110-openbsd-compat.patch (revision 0) +++ tools/yaffs2/patches/110-openbsd-compat.patch (working copy) @@ -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 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/quilt/Makefile =================================================================== --- tools/quilt/Makefile (revision 35879) +++ tools/quilt/Makefile (working copy) @@ -15,11 +15,10 @@ include $(INCLUDE_DIR)/host-build.mk -GETOPT:=$(shell which getopt) - HOST_CONFIGURE_ARGS += \ - --with-patch=$(PATCH) \ + --with-patch=$(STAGING_DIR_HOST)/bin/patch \ --with-find=$(FIND) \ + --with-diff=$(DIFF) \ --with-getopt=$(GETOPT) define Host/Configure Index: tools/patch/Makefile =================================================================== --- tools/patch/Makefile (revision 0) +++ tools/patch/Makefile (working copy) @@ -0,0 +1,38 @@ +# +# Copyright (C) 2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_NAME:=patch +PKG_VERSION:=2.7.1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=ftp://ftp.gnu.org/gnu/patch +PKG_MD5SUM:=e9ae5393426d3ad783a300a338c09b72 + +include $(INCLUDE_DIR)/host-build.mk + +#HOST_CONFIGURE_ARGS += \ + +#define Host/Configure +# cd $(HOST_BUILD_DIR) && autoconf +# $(call Host/Configure/Default) +# [ -f $(HOST_BUILD_DIR)/Makefile ] +#endef + +#define Host/Compile +# $(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" all lib/backup-files +#endef + +#define Host/Install +# $(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" install +#endef + +#define Host/Clean +# rm -f $(STAGING_DIR_HOST)/bin/quilt +#endef + +$(eval $(call HostBuild)) Index: tools/Makefile =================================================================== --- tools/Makefile (revision 35879) +++ tools/Makefile (working copy) @@ -15,7 +15,7 @@ endif tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs tools-y += sstrip ipkg-utils genext2fs e2fsprogs mtd-utils mkimage -tools-y += firmware-utils patch-image quilt yaffs2 flock padjffs2 +tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2 tools-y += mm-macros xorg-macros xfce-macros missing-macros xz cmake scons tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2 tools-$(CONFIG_powerpc) += upx @@ -128,8 +128,10 @@ $(eval $(call PrepareCommand,md5sum,gmd5sum md5sum $(SCRIPT_DIR)/md5sum)) $(eval $(call PrepareCommand,cp,gcp cp)) $(eval $(call PrepareCommand,seq,gseq seq)) -$(eval $(call PrepareCommand,python,python2 python)) +$(eval $(call PrepareCommand,python,python2 python2.7 python)) $(eval $(call PrepareCommand,awk,gawk awk)) +$(eval $(call PrepareCommand,getopt,gnugetopt getopt)) +$(eval $(call PrepareCommand,grep,ggrep grep)) $(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat seq python awk) $(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps) Index: include/host-build.mk =================================================================== --- include/host-build.mk (revision 35879) +++ include/host-build.mk (working copy) @@ -71,7 +71,7 @@ HOST_MAKE_FLAGS = -HOST_CONFIGURE_CMD = ./configure +HOST_CONFIGURE_CMD = $(BASH) ./configure ifneq ($(HOST_OS),Darwin) ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) Index: include/prereq-build.mk =================================================================== --- include/prereq-build.mk (revision 35879) +++ include/prereq-build.mk (working copy) @@ -39,6 +39,7 @@ )) define Require/getopt + gnugetopt --help 2>&1 | grep long >/dev/null || \ getopt --help 2>&1 | grep long >/dev/null endef $(eval $(call Require,getopt, \ @@ -134,15 +135,19 @@ Please install bzip2. \ )) -$(eval $(call RequireCommand,patch, \ - Please install patch. \ -)) +#$(eval $(call RequireCommand,patch, \ +# Please install patch. \ +#)) $(eval $(call RequireCommand,perl, \ Please install perl. \ )) -$(eval $(call RequireCommand,python, \ +define Require/python + $(PYTHON) --version 2>&1 > /dev/null +endef + +$(eval $(call Require,python, \ Please install python. \ )) Index: include/host.mk =================================================================== --- include/host.mk (revision 35879) +++ include/host.mk (working copy) @@ -62,6 +62,15 @@ PATCH=`which gpatch 2>/dev/null`; \ [ -n "$$PATCH" -a -x "$$PATCH" ] || PATCH=`which patch 2>/dev/null`; \ echo "PATCH:=$$PATCH" >> $@; \ + DIFF=`which gdiff 2>/dev/null`; \ + [ -n "$$DIFF" -a -x "$$DIFF" ] || DIFF=`which diff 2>/dev/null`; \ + echo "DIFF:=$$DIFF" >> $@; \ + GETOPT=`which gnugetopt 2>/dev/null`; \ + [ -n "$$GETOPT" -a -x "$$GETOPT" ] || GETOPT=`which getopt 2>/dev/null`; \ + echo "GETOPT:=$$GETOPT" >> $@; \ + PYTHON=`which python2.7 2>/dev/null`; \ + [ -n "$$PYTHON" -a -x "$$PYTHON" ] || PYTHON=`which python 2>/dev/null`; \ + echo "PYTHON:=$$PYTHON" >> $@; \ ) endif Index: scripts/openbsd.sh =================================================================== --- scripts/openbsd.sh (revision 0) +++ scripts/openbsd.sh (working copy) @@ -0,0 +1,24 @@ +#!/bin/sh +ver=$(uname -r) +arch=$(uname -m) +echo "Preparing OpenBSD $arch $ver for OpenWrt" +PKG_PATH="http://ftp.openbsd.org/pub/OpenBSD/${ver}/packages/${arch}/" +export PKG_PATH +pkg_add -v gmake +pkg_add -v findutils +pkg_add -v coreutils +pkg_add -v gdiff +pkg_add -v rsync-- +pkg_add -v git +pkg_add -v bash +pkg_add -v unzip +pkg_add -v wget +pkg_add -v gtar-- +pkg_add -v ggrep +pkg_add -v gawk +pkg_add -v gsed +pkg_add -v xz +pkg_add -v apr-util-- +pkg_add -v cyrus-sasl-- +pkg_add -v subversion +pkg_add -v gnugetopt Property changes on: scripts/openbsd.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel