From 920e0a4d6654509464c832543bf607c3ed8fca0c Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 2 Jan 2014 10:40:57 +0000
Subject: [PATCH] testing/kbuild: upgrade to 0.1.9998_pre20131130 and fix build
 on musl

---
 .../kbuild/0001-define-ALLPERMS-is-missing.patch   | 43 ++++++++++++++++++++
 testing/kbuild/APKBUILD                            | 46 ++++++++++++++++++----
 testing/kbuild/allperms.patch                      | 30 ++++++++++++++
 testing/kbuild/glob.patch                          | 19 +++++++++
 testing/kbuild/kbuild-0.1.5_p2-qa.patch            | 26 ------------
 testing/kbuild/kobjcache.patch                     | 10 +++++
 testing/kbuild/obstack.patch                       | 42 ++++++++++++++++++++
 testing/kbuild/strlcpy.patch                       | 15 +------
 testing/kbuild/sys-types.patch                     | 14 +++++++
 9 files changed, 198 insertions(+), 47 deletions(-)
 create mode 100644 testing/kbuild/0001-define-ALLPERMS-is-missing.patch
 create mode 100644 testing/kbuild/allperms.patch
 create mode 100644 testing/kbuild/glob.patch
 delete mode 100644 testing/kbuild/kbuild-0.1.5_p2-qa.patch
 create mode 100644 testing/kbuild/kobjcache.patch
 create mode 100644 testing/kbuild/obstack.patch
 create mode 100644 testing/kbuild/sys-types.patch

diff --git a/testing/kbuild/0001-define-ALLPERMS-is-missing.patch b/testing/kbuild/0001-define-ALLPERMS-is-missing.patch
new file mode 100644
index 0000000..ffe1b75
--- /dev/null
+++ b/testing/kbuild/0001-define-ALLPERMS-is-missing.patch
@@ -0,0 +1,43 @@
+From ad40844b8d4ccd3fec48fd1db3d165926d247398 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 2 Jan 2014 08:55:33 +0000
+Subject: [PATCH] define ALLPERMS is missing
+
+---
+ src/kmk/kmkbuiltin/chmod.c   | 4 ++++
+ src/kmk/kmkbuiltin/install.c | 4 ++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/src/kmk/kmkbuiltin/chmod.c b/src/kmk/kmkbuiltin/chmod.c
+index 792a286..8edce38 100644
+--- a/src/kmk/kmkbuiltin/chmod.c
++++ b/src/kmk/kmkbuiltin/chmod.c
+@@ -66,6 +66,10 @@ static char sccsid[] = "@(#)chmod.c	8.8 (Berkeley) 4/1/94";
+ #include "getopt.h"
+ #include "kmkbuiltin.h"
+ 
++#ifndef ALLPERMS
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
++#endif
++
+ extern void * bsd_setmode(const char *p);
+ extern mode_t bsd_getmode(const void *bbox, mode_t omode);
+ extern void bsd_strmode(mode_t mode, char *p);
+diff --git a/src/kmk/kmkbuiltin/install.c b/src/kmk/kmkbuiltin/install.c
+index 13bec72..08d8ffe 100644
+--- a/src/kmk/kmkbuiltin/install.c
++++ b/src/kmk/kmkbuiltin/install.c
+@@ -127,6 +127,10 @@ extern mode_t bsd_getmode(const void *bbox, mode_t omode);
+ # define IS_SLASH(ch)   ((ch) == '/')
+ #endif
+ 
++#ifndef ALLPERMS
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
++#endif
++
+ static gid_t gid;
+ static uid_t uid;
+ static int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose, mode_given;
+-- 
+1.8.5.2
+
diff --git a/testing/kbuild/APKBUILD b/testing/kbuild/APKBUILD
index ac1fc45..ed6e80f 100644
--- a/testing/kbuild/APKBUILD
+++ b/testing/kbuild/APKBUILD
@@ -1,7 +1,7 @@
 # Contributor: Natanael Copa <ncopa@alpinelinux.org>
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=kbuild
-pkgver=0.1.9998_pre20120806
+pkgver=0.1.9998_pre20131130
 _ver=${pkgver/_/-}
 pkgrel=1
 pkgdesc="A makefile framework for writing simple makefiles for complex tasks"
@@ -14,13 +14,17 @@ makedepends="autoconf automake flex bison"
 install=""
 subpackages="$pkgname-doc"
 source="http://dev.gentoo.org/~polynomial-c/kBuild-${_ver}-src.tar.xz
-	kbuild-0.1.5_p2-qa.patch
 	lchmod.patch
 	strlcpy.patch
 	underlinking.patch
 	sys_siglist.patch
 	kbuild-0.1.9998_pre20110817-gcc-4.7.patch
-	uclibc.patch"
+	0001-define-ALLPERMS-is-missing.patch
+	sys-types.patch
+	uclibc.patch
+	kobjcache.patch
+	obstack.patch
+	glob.patch"
 
 _builddir="$srcdir"/kBuild-$_ver
 prepare() {
@@ -60,11 +64,39 @@ package() {
 		|| return 1
 }
 
-md5sums="520d65bd2356c26d1b9bbb25fd7d70ce  kBuild-0.1.9998-pre20120806-src.tar.xz
-79d4d445b28f0c50f2a7a8ca12bbed4b  kbuild-0.1.5_p2-qa.patch
+md5sums="a9fad7d9c26dba44c2c1ad3d93d49372  kBuild-0.1.9998-pre20131130-src.tar.xz
 b3dd26cc185c96658d9b554eef2f811c  lchmod.patch
-90cae3b53b4ec6fc5f1c336922083df0  strlcpy.patch
+9b101e058900afb9986689076a214d54  strlcpy.patch
 ca09174d7c885fdea1e3c2dc580d80b3  underlinking.patch
 52c3450a3e2645f57871b0141c465776  sys_siglist.patch
 2fdb2fb96c48371b2a15785926c9144b  kbuild-0.1.9998_pre20110817-gcc-4.7.patch
-b3c2d0e6902f1285c09d81f74e573c4f  uclibc.patch"
+4fda881d60b2c80502ad4321d18161a4  0001-define-ALLPERMS-is-missing.patch
+a4ad5a3bf960394856b9fafecfe921d4  sys-types.patch
+b3c2d0e6902f1285c09d81f74e573c4f  uclibc.patch
+e92680df9641e25dd4a58e6a2733dbea  kobjcache.patch
+4d8f14019970a974b6fde15fd4b991d9  obstack.patch
+b0c55468f3d4c0800687d16c37bf111f  glob.patch"
+sha256sums="def0a44cc0a91b6aa8a80f73ace0cfc315f298ba3e0d3d81fe52834091b68586  kBuild-0.1.9998-pre20131130-src.tar.xz
+79909f11e631757140c5095af1347c9f48c065f25cdd875c555477529ca6a693  lchmod.patch
+132305af7aa1cc94f4920ffe97775efcb6f0495f165035051298984d9f5ca4c0  strlcpy.patch
+1c99c0579af3d9cf4148b7b61d98b92ff86eaec441b6630754007ae3c3b5a2cc  underlinking.patch
+8adb0ffa45a0b49737bbde54b54405a7708a2281d608d8f713437fce77e11d07  sys_siglist.patch
+420caeee42dca3fa9a474faa3ae6e34a884d26792ab3b6567a3b9ecf678a90e7  kbuild-0.1.9998_pre20110817-gcc-4.7.patch
+c308a64bddc997826ee83dc8f165ad5072368cb2c837a97308e69238a0390d7e  0001-define-ALLPERMS-is-missing.patch
+21ec6669485f97e0af37f3120bea2f688ed96df9c59a89cf1043645464db7a46  sys-types.patch
+1f581e0cf8fefae174c8aeb1b279e956fc7712146bf4a58451f0b318795309e9  uclibc.patch
+1f9788d65c597346f64cd2513875ed65d4ac199ce879dc313ce2970f40013f77  kobjcache.patch
+7093e35ca03c4b82961157225c5509c42b9996128b31b5ec32154a72c154848e  obstack.patch
+e13e0f02132824e07b3895666ab1952672a85a246e68e854d714dd8acdc0d445  glob.patch"
+sha512sums="66f418c0e052389d2b5cfc4d46bc8598ceaeded369151047e455e921bef494ec42099cdc368d24b572eacd809bb7c124d07e0fab54788af01664b72f571fb047  kBuild-0.1.9998-pre20131130-src.tar.xz
+3ab991b13a122e82125392d01e27ad8c06f2b5f5e0c5bb2fa024fdcf16a65f5f460c14222d84d50b31a2ad4040c89871ee2a47f885eca329c15bb9abb3f8f5df  lchmod.patch
+fbab0dc51f4e2d14b020a6b63820a26eeee884ac9cfd5b59a6afc6243ffb7679c775ed8529f6161917bf3cc5e2a651c959706cdc404a4a79c1b29cc9f3a614a5  strlcpy.patch
+839c12659ae81e99c0c2f35f045ef8651c2d30ddb391ae76995ded6df19f4ca5ae728da96c16b7aab08cdf447030de645455751122a390755e0ff46c03cb23d6  underlinking.patch
+2e0cb32b6e296d92c4c092f798e83eee1fe49753826426fd957f9977149b64487547f71bde64b654a3f3a0511dfa9ac1c533ad0cd469c7bdd7e0acdfa3c2e3ac  sys_siglist.patch
+7a0618e9dbd18ba10f1afd9c2a47f6efb136143a86008d2562eb2ff704f289b7150bbc10f2e3c57341b485252366ff46d49bd70c24cadba45f09496333ceaa76  kbuild-0.1.9998_pre20110817-gcc-4.7.patch
+4bdcae4362ff0ac6b401c65120f54e395a41b98d4bdea796a1e85405c3444853b94626c2be6d9d703ffd904fb89ea0a14d1e847a67eb56d81faf48246220e166  0001-define-ALLPERMS-is-missing.patch
+58ae3ec4a1535fddd4af67803c081c9ca4cd66244ea2a7ddfbf59eb5b849421377116376d893d5e643a15413b902463affa51153afeb2d2217bac135122b66a5  sys-types.patch
+41d568b05af4d9f650e736cafc4fd4285cc592726de1ee3f599b26cf2277a9436477ff512b99c2dbe1abc3d21cb9d4f24a0568aa71418e2114e294171cc008f0  uclibc.patch
+7afcc78589ee66c60dd7a73819b4776531a4fc0f73c8a8824f4b53967f7c903095206455d2b113288ad4cf337e67c0dc82cd679b994096c5d9270f83d55689ad  kobjcache.patch
+dae18964bb4c7f46e277b147bae53cabb03d5bbd6199ec5a8deeaf6a6d12804b281ea6debf7eda44fee3bff12d6097d7b46385617a446e2a2a7570d83d03eb8e  obstack.patch
+f843176d1ed988965947f0243b31b02431c3467249576fbac64cb561d7d64da71bdcadbd4eb4d36ed5f4483c1ac146c57f7f1f60bdbabaea2c0cd2dc80ed0446  glob.patch"
diff --git a/testing/kbuild/allperms.patch b/testing/kbuild/allperms.patch
new file mode 100644
index 0000000..2e8bfbf
--- /dev/null
+++ b/testing/kbuild/allperms.patch
@@ -0,0 +1,30 @@
+diff --git a/src/kmk/kmkbuiltin/chmod.c b/src/kmk/kmkbuiltin/chmod.c
+index 792a286..8edce38 100644
+--- a/src/kmk/kmkbuiltin/chmod.c
++++ b/src/kmk/kmkbuiltin/chmod.c
+@@ -66,6 +66,10 @@ static char sccsid[] = "@(#)chmod.c	8.8 (Berkeley) 4/1/94";
+ #include "getopt.h"
+ #include "kmkbuiltin.h"
+ 
++#ifndef ALLPERMS
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
++#endif
++
+ extern void * bsd_setmode(const char *p);
+ extern mode_t bsd_getmode(const void *bbox, mode_t omode);
+ extern void bsd_strmode(mode_t mode, char *p);
+diff --git a/src/kmk/kmkbuiltin/install.c b/src/kmk/kmkbuiltin/install.c
+index 13bec72..08d8ffe 100644
+--- a/src/kmk/kmkbuiltin/install.c
++++ b/src/kmk/kmkbuiltin/install.c
+@@ -127,6 +127,10 @@ extern mode_t bsd_getmode(const void *bbox, mode_t omode);
+ # define IS_SLASH(ch)   ((ch) == '/')
+ #endif
+ 
++#ifndef ALLPERMS
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
++#endif
++
+ static gid_t gid;
+ static uid_t uid;
+ static int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose, mode_given;
diff --git a/testing/kbuild/glob.patch b/testing/kbuild/glob.patch
new file mode 100644
index 0000000..b17f012
--- /dev/null
+++ b/testing/kbuild/glob.patch
@@ -0,0 +1,19 @@
+--- ./src/kmk/Makefile.kmk.orig
++++ ./src/kmk/Makefile.kmk
+@@ -60,6 +60,7 @@
+ TEMPLATE_BIN-KMK_INCS.haiku = glob
+ TEMPLATE_BIN-KMK_INCS.openbsd = glob
+ TEMPLATE_BIN-KMK_INCS.solaris = glob
++TEMPLATE_BIN-KMK_INCS.linux = glob
+ TEMPLATE_BIN-KMK_LIBS = $(TEMPLATE_BIN-THREADED_LIBS) $(kmkmissing_1_TARGET) $(LIB_KUTIL)
+ ifdef ELECTRIC_HEAP # for electric heap (see electric.c) - windows only.
+ ifeq ($(KBUILD_TARGET),win)
+@@ -108,7 +109,7 @@
+ 	glob/fnmatch.c
+ 
+ kmkmissing_SOURCES.linux += \
+-	kmkbuiltin/strlcpy.c
++	glob/glob.c
+ 
+ kmkmissing_SOURCES.openbsd = \
+ 	kmkbuiltin/openbsd.c \
diff --git a/testing/kbuild/kbuild-0.1.5_p2-qa.patch b/testing/kbuild/kbuild-0.1.5_p2-qa.patch
deleted file mode 100644
index 706c3a7..0000000
--- a/testing/kbuild/kbuild-0.1.5_p2-qa.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-* warning: implicit declaration of function ‘unlink’
-* warning: too few arguments for format
---- a/src/sed/lib/utils.c
-+++ b/src/sed/lib/utils.c
-@@ -35,6 +35,10 @@
- # include <stdlib.h>
- #endif /* HAVE_STDLIB_H */
- 
-+#ifdef HAVE_UNISTD_H
-+# include <unistd.h>
-+#endif /* HAVE_UNISTD_H */
-+
- #include "utils.h"
- 
- const char *myname;
---- a/src/kmk/kmkbuiltin/printf.c
-+++ b/src/kmk/kmkbuiltin/printf.c
-@@ -206,7 +206,7 @@
- 
- 	(void)funcname;
- 	if (rc != 0)
--		fatal (NILF, _("$(%s): failure rc=%d\n"), rc);
-+		fatal (NILF, _("$(%s): failure rc=%d\n"), funcname, rc);
- 	return o;
- }
- #endif
diff --git a/testing/kbuild/kobjcache.patch b/testing/kbuild/kobjcache.patch
new file mode 100644
index 0000000..4fb4e02
--- /dev/null
+++ b/testing/kbuild/kobjcache.patch
@@ -0,0 +1,10 @@
+--- ./src/kObjCache/kObjCache.c.orig
++++ ./src/kObjCache/kObjCache.c
+@@ -38,6 +38,7 @@
+ #include <errno.h>
+ #include <assert.h>
+ #include <sys/stat.h>
++#include <sys/file.h>
+ #include <fcntl.h>
+ #include <limits.h>
+ #include <ctype.h>
diff --git a/testing/kbuild/obstack.patch b/testing/kbuild/obstack.patch
new file mode 100644
index 0000000..8301a42
--- /dev/null
+++ b/testing/kbuild/obstack.patch
@@ -0,0 +1,42 @@
+--- ./src/sed/Makefile.kmk.orig
++++ ./src/sed/Makefile.kmk
+@@ -56,36 +56,30 @@
+ 	sed/mbcs.c \
+ 	lib/getopt1.c \
+ 	lib/getopt.c \
++	lib/obstack.c \
+ 	lib/utils.c
+ kmk_sed_SOURCES.darwin = \
+ 	lib/strverscmp.c \
+-	lib/obstack.c \
+ 	lib/getline.c
+ kmk_sed_SOURCES.dragonfly = \
+ 	lib/strverscmp.c \
+-	lib/obstack.c \
+ 	lib/getline.c
+ kmk_sed_SOURCES.freebsd = \
+ 	lib/strverscmp.c \
+-	lib/obstack.c \
+ 	lib/getline.c
+ kmk_sed_SOURCES.haiku = \
+-	lib/strverscmp.c \
+-	lib/obstack.c
++	lib/strverscmp.c
+ kmk_sed_SOURCES.openbsd = \
+ 	lib/strverscmp.c \
+-	lib/obstack.c \
+ 	lib/getline.c
+ kmk_sed_SOURCES.solaris = \
+-	lib/strverscmp.c \
+-	lib/obstack.c
++	lib/strverscmp.c
+ ifdef KBUILD_SOLARIS_10
+ kmk_sed_SOURCES.solaris += \
+ 	lib/getline.c
+ endif
+ kmk_sed_SOURCES.win = \
+ 	lib/strverscmp.c \
+-	lib/obstack.c \
+ 	lib/mkstemp.c \
+ 	lib/getline.c \
+ 	../lib/startuphacks-win.c
diff --git a/testing/kbuild/strlcpy.patch b/testing/kbuild/strlcpy.patch
index 42b25bd..d0b3a04 100644
--- a/testing/kbuild/strlcpy.patch
+++ b/testing/kbuild/strlcpy.patch
@@ -7,20 +7,7 @@ index 44b76ab..85fec01 100644
  #include "kbuild_protection.h"
  
 -#if defined(_MSC_VER) || defined(__gnu_linux__) || defined(__linux__)
-+#if defined(_MSC_VER) || defined(__gnu_linux__) || defined(__linux__) && !defined(__UCLIBC__)
++#if defined(_MSC_VER) || defined(__gnu_linux__) && !defined(__UCLIBC__)
  extern char *strlcpy(char *, const char *, size_t);
  #endif
  
-diff --git a/src/kmk/Makefile.kmk b/src/kmk/Makefile.kmk
-index 12b9697..db1deb2 100644
---- a/src/kmk/Makefile.kmk
-+++ b/src/kmk/Makefile.kmk
-@@ -101,7 +101,7 @@ kmkmissing_SOURCES.freebsd = \
- 	glob/fnmatch.c
- 
- kmkmissing_SOURCES.linux += \
--	kmkbuiltin/strlcpy.c
-+	getloadavg.c
- 
- kmkmissing_SOURCES.solaris = \
- 	kmkbuiltin/strlcpy.c \
diff --git a/testing/kbuild/sys-types.patch b/testing/kbuild/sys-types.patch
new file mode 100644
index 0000000..dccb48a
--- /dev/null
+++ b/testing/kbuild/sys-types.patch
@@ -0,0 +1,14 @@
+diff --git a/src/kmk/kmkbuiltin/ftsfake.h b/src/kmk/kmkbuiltin/ftsfake.h
+index 2518d30..5410256 100644
+--- a/src/kmk/kmkbuiltin/ftsfake.h
++++ b/src/kmk/kmkbuiltin/ftsfake.h
+@@ -38,6 +38,9 @@
+ # include "kmkbuiltin/mscfakes.h"
+ #endif
+ 
++/* for u_int */
++#include <sys/types.h>
++
+ typedef struct {
+ 	struct _ftsent *fts_cur;	/* current node */
+ 	struct _ftsent *fts_child;	/* linked list of children */
-- 
1.8.5.2

