Revert "KBuild: Build fix, recipe cleanup, WIP" (#1072)

This commit is contained in:
waddlesplash
2017-01-14 12:55:02 -05:00
committed by GitHub
parent dc9e690e6f
commit 84c3ecef64
2 changed files with 275 additions and 424 deletions

View File

@@ -12,62 +12,29 @@ simplification.
Tools and SDKs for helping out the templates with flexibility.
Non-recursive makefile method by using sub-makefiles."
HOMEPAGE="https://trac.netlabs.org/kbuild/"
SOURCE_URI="ftp://ftp.netlabs.org/pub/kbuild/kBuild-0.1.5-p2-src.tar.gz"
SOURCE_DIR="kBuild-0.1.5-p2"
COPYRIGHT="kBuild developers"
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="ftp://ftp.netlabs.org/pub/kbuild/kBuild-$portVersion-p2-src.tar.gz"
CHECKSUM_SHA256="8205db5e74d27ef6394bd48118a310e4f5caab455575f0ea975f62dcb8d642a6"
SOURCE_DIR="kBuild-$portVersion-p2"
PATCHES="kbuild-0.1.5-p2.patchset"
ARCHITECTURES="?x86_gcc2 ?x86 x86_64"
SECONDARY_ARCHITECTURES="?x86"
ARCHITECTURES="!x86_gcc2 !x86 !x86_64"
SECONDARY_ARCHITECTURES="!x86_gcc2 !x86"
# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
commandSuffix=
commandBinDir=$prefix/bin
fi
PATCHES="kbuild-0.1.5-p2.patch"
PROVIDES="
kbuild$secondaryArchSuffix = $portVersion
kDepIDB$commandSuffix = $portVersion
kDepPre$commandSuffix = $portVersion
kmk$commandSuffix = $portVersion
kmk_append$commandSuffix = $portVersion
kmk_ash$commandSuffix = $portVersion
kmk_cat$commandSuffix = $portVersion
kmk_chmod$commandSuffix = $portVersion
kmk_cmp$commandSuffix = $portVersion
kmk_cp$commandSuffix = $portVersion
kmk_echo$commandSuffix = $portVersion
kmk_expr$commandSuffix = $portVersion
kmk_gmake$commandSuffix = $portVersion
kmk_install$commandSuffix = $portVersion
kmk_ln$commandSuffix = $portVersion
kmk_md5sum$commandSuffix = $portVersion
kmk_mkdir$commandSuffix = $portVersion
kmk_mv$commandSuffix = $portVersion
kmk_printf$commandSuffix = $portVersion
kmk_redirect$commandSuffix = $portVersion
kmk_rm$commandSuffix = $portVersion
kmk_rmdir$commandSuffix = $portVersion
kmk_sed$commandSuffix = $portVersion
kmk_sleep$commandSuffix = $portVersion
kmk_test$commandSuffix = $portVersion
kmk_time$commandSuffix = $portVersion
kObjCache$commandSuffix = $portVersion
kmk = $portVersion
"
REQUIRES="
haiku$secondaryArchSuffix
REQUIRES=""
BUILD_REQUIRES="haiku >= $haikuVersion
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
"
BUILD_PREREQUIRES="
haiku${secondaryArchSuffix}_devel >= $haikuVersion
cmd:aclocal
cmd:autopoint
cmd:autoreconf
@@ -81,29 +48,15 @@ BUILD_PREREQUIRES="
cmd:yacc
"
# Global variables
export NIX_INSTALL_DIR=$commandBinDir
export MY_INST_DATA=$dataDir
export MY_INST_DOC=$docDir
archpath=x86
if [ "$targetArchitecture" = x86_64 ]; then
archpath=amd64
fi
PATCH()
{
sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' src/sed/configure.ac
}
BUILD()
{
rm -rf out || true
kBuild/env.sh --full make -f bootstrap.gmk
sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' src/sed/configure.ac
# TODO: fix install paths
kBuild/env.sh --full make -f bootstrap.gmk NIX_INSTALL_DIR=$prefix
}
INSTALL()
{
kBuild/env.sh --full-with-bin kmk
cp -R out/haiku.${archpath}/release/packages/${portVersionedName} $prefix
kBuild/env.sh --full-with-bin kmk NIX_INSTALL_DIR=$prefix
PATH_INS="${D}" install
}

View File

@@ -1,57 +1,5 @@
From 8826b318de76f5ce17d344e44e4e6481c8d787ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Wed, 11 Jan 2017 12:21:14 +0100
Subject: [PATCH] Haiku supporting patch from Diver
---
Config.kmk | 24 ++++++++++++++++++-
SvnInfo.kmk | 0
kBuild/env.sh | 6 ++++-
kBuild/header.kmk | 2 +-
src/ash/Makefile.kmk | 6 ++++-
src/ash/error.h | 2 +-
src/ash/eval.c | 5 +++-
src/ash/jobs.c | 18 +++++++++-----
src/ash/show.c | 4 +++-
src/ash/trap.c | 8 +++----
src/ash/var.c | 8 +++++++
src/kObjCache/kObjCache.c | 3 +++
src/kash/Makefile.kmk | 4 +++-
src/kash/error.h | 8 +++++--
src/kash/jobs.c | 2 ++
src/kash/shfile.h | 6 +++--
src/kash/shtypes.h | 6 +++--
src/kmk/Makefile.kmk | 6 +++++
src/kmk/arscan.c | 2 +-
src/kmk/glob/fnmatch.c | 2 +-
src/kmk/incdep.c | 2 +-
src/kmk/job.c | 2 +-
src/kmk/kmkbuiltin/chmod.c | 4 ++++
src/kmk/kmkbuiltin/cp_utils.c | 5 ++++
src/kmk/kmkbuiltin/fts.c | 2 +-
src/kmk/kmkbuiltin/haikufakes.c | 52 +++++++++++++++++++++++++++++++++++++++++
src/kmk/kmkbuiltin/haikufakes.h | 39 +++++++++++++++++++++++++++++++
src/kmk/kmkbuiltin/install.c | 11 +++++++--
src/kmk/kmkbuiltin/mkdir.c | 7 +++++-
src/kmk/kmkbuiltin/mv.c | 11 +++++++--
src/kmk/kmkbuiltin/rm.c | 9 +++++--
src/kmk/main.c | 21 +++++++++++++++++
src/kmk/maintMakefile | 2 +-
src/kmk/make.h | 2 +-
src/lib/k/kDefs.h | 4 +++-
src/misc/kmk_time.c | 2 ++
src/sed/Makefile.kmk | 3 +++
src/sed/config/help2man | 2 +-
src/sed/lib/regexec.c | 1 +
src/sed/lib/utils.c | 2 +-
src/sed/sed/sed.h | 1 +
41 files changed, 265 insertions(+), 41 deletions(-)
mode change 100755 => 100644 SvnInfo.kmk
create mode 100644 src/kmk/kmkbuiltin/haikufakes.c
create mode 100644 src/kmk/kmkbuiltin/haikufakes.h
diff --git a/Config.kmk b/Config.kmk
index 774bda5..4e0a47e 100644
index 774bda5..6e42081 100644
--- a/Config.kmk
+++ b/Config.kmk
@@ -107,6 +107,8 @@ DEFS.openbsd += KBUILD_OS_OPENBSD
@@ -63,33 +11,24 @@ index 774bda5..4e0a47e 100644
DEFS.x86 += KBUILD_ARCH_X86
DEFS.amd64 += KBUILD_ARCH_AMD64
@@ -291,7 +313,7 @@ ifndef TEMPLATE_BIN_TOOL
TEMPLATE_BIN_CXXFLAGS.sparc32+= -m32
TEMPLATE_BIN_CXXFLAGS.amd64 += -m64
TEMPLATE_BIN_CXXFLAGS.sparc64+= -m64
- TEMPLATE_BIN_LDFLAGS.x86 += -m32
+ TEMPLATE_BIN_LDFLAGS.x86 += -m32 -lbsd -lroot
TEMPLATE_BIN_LDFLAGS.sparc32 += -m32
TEMPLATE_BIN_LDFLAGS.amd64 += -m64
TEMPLATE_BIN_LDFLAGS.sparc64 += -m64
diff --git a/SvnInfo.kmk b/SvnInfo.kmk
old mode 100755
new mode 100644
diff --git a/kBuild/env.sh b/kBuild/env.sh
index 19f8eb2..6ddfa01 100755
index 19f8eb2..59901bf 100755
--- a/kBuild/env.sh
+++ b/kBuild/env.sh
@@ -280,6 +280,10 @@ if test -z "$KBUILD_HOST"; then
@@ -279,6 +279,10 @@ if test -z "$KBUILD_HOST"; then
os2|OS/2|OS2)
KBUILD_HOST=os2
;;
+
+ Haiku*)
+ KBUILD_HOST=haiku
+ ;;
+
SunOS)
KBUILD_HOST=solaris
;;
@@ -322,7 +326,7 @@ if test -z "$KBUILD_HOST_ARCH"; then
x86_64|AMD64|amd64|k8|k8l|k9|k10)
KBUILD_HOST_ARCH='amd64'
@@ -112,187 +51,6 @@ index d575934..4ec5b84 100644
KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha
diff --git a/src/ash/Makefile.kmk b/src/ash/Makefile.kmk
index ad1ca85..1a3dabf 100644
--- a/src/ash/Makefile.kmk
+++ b/src/ash/Makefile.kmk
@@ -36,6 +36,7 @@ kmk_ash_DEFS.debug = DEBUG=2
endif
kmk_ash_DEFS.linux = BSD
kmk_ash_DEFS.solaris = BSD
+kmk_ash_DEFS.haiku = haiku
kmk_ash_DEFS.win = \
BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
kmk_ash_DEFS.os2 = \
@@ -94,7 +95,10 @@ kmk_ash_SOURCES.solaris = \
sys_signame.c \
strlcpy.c \
setmode.c
-
+kmk_ash_SOURCES.haiku = \
+ sys_signame.c \
+ strlcpy.c \
+ setmode.c
kmk_ash_INTERMEDIATES = \
$(PATH_kmk_ash)/builtins.h \
$(PATH_kmk_ash)/nodes.h \
diff --git a/src/ash/error.h b/src/ash/error.h
index b4637f1..9bb0ebe 100644
--- a/src/ash/error.h
+++ b/src/ash/error.h
@@ -111,7 +111,7 @@ void sh_exit(int) __attribute__((__noreturn__));
* so we use _setjmp instead.
*/
-#if defined(BSD) && !defined(__SVR4) && !defined(__GLIBC__) && !defined(__KLIBC__) && !defined(_MSC_VER)
+#if defined(BSD) && !defined(__SVR4) && !defined(__GLIBC__) && !defined(__KLIBC__) && !defined(_MSC_VER) && !defined(__HAIKU__)
#define setjmp(jmploc) _setjmp(jmploc)
#define longjmp(jmploc, val) _longjmp(jmploc, val)
#endif
diff --git a/src/ash/eval.c b/src/ash/eval.c
index 7e8a51c..1a71c09 100644
--- a/src/ash/eval.c
+++ b/src/ash/eval.c
@@ -47,7 +47,9 @@ __RCSID("$NetBSD: eval.c,v 1.84 2005/06/23 23:05:29 christos Exp $");
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
-#include <sys/fcntl.h>
+#ifndef __HAIKU__
+# include <sys/fcntl.h>
+#endif
#include <sys/times.h>
#include <sys/param.h>
#include <sys/types.h>
@@ -137,6 +139,7 @@ static int
sh_pipe(int fds[2])
{
int nfd;
+ int F_DUPFD;
if (pipe(fds))
return -1;
diff --git a/src/ash/jobs.c b/src/ash/jobs.c
index 146326a..a19c11e 100644
--- a/src/ash/jobs.c
+++ b/src/ash/jobs.c
@@ -58,7 +58,7 @@ __RCSID("$NetBSD: jobs.c,v 1.63 2005/06/01 15:41:19 lukem Exp $");
#endif
#include <sys/types.h>
#include <sys/param.h>
-#if defined(BSD) || defined(__sun__)
+#if defined(BSD) || defined(__sun__) || defined(__HAIKU__)
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -467,10 +467,12 @@ showjob(struct output *out, struct job *jp, int mode)
scopyn(sys_siglist[st], s + col, 32);
else
fmtstr(s + col, 16, "Signal %d", st);
- if (WCOREDUMP(ps->status)) {
- col += strlen(s + col);
- scopyn(" (core dumped)", s + col, 64 - col);
- }
+ #ifndef __HAIKU__
+ if (WCOREDUMP(ps->status)) {
+ col += strlen(s + col);
+ scopyn(" (core dumped)", s + col, 64 - col);
+ }
+ #endif
}
col += strlen(s + col);
outstr(s, out);
@@ -1158,7 +1160,11 @@ waitproc(int block, struct job *jp, int *status)
#endif
if (block == 0)
flags |= WNOHANG;
- return wait3(status, flags, (struct rusage *)NULL);
+ #ifndef __HAIKU__
+ return wait3(status, flags, (struct rusage *)NULL);
+ #else
+ return waitpid(status, flags, (struct rusage *)NULL);
+ #endif
#else
#ifdef SYSV
int (*save)();
diff --git a/src/ash/show.c b/src/ash/show.c
index 2769c69..4d2353c 100644
--- a/src/ash/show.c
+++ b/src/ash/show.c
@@ -46,7 +46,9 @@ __RCSID("$NetBSD: show.c,v 1.26 2003/11/14 10:46:13 dsl Exp $");
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <sys/fcntl.h>
+#ifndef __HAIKU__
+# include <sys/fcntl.h>
+#endif
#include <unistd.h>
#include "shell.h"
diff --git a/src/ash/trap.c b/src/ash/trap.c
index 6a246e6..378856e 100644
--- a/src/ash/trap.c
+++ b/src/ash/trap.c
@@ -88,7 +88,7 @@ int pendingsigs; /* indicates some signal received */
#ifdef __sun__
typedef void (*sig_t) (int);
#endif
-static int getsigaction(int, sig_t *);
+static int getsigaction(int, __sighandler_t *);
/*
* return the signal number described by `p' (as a number or a name)
@@ -251,7 +251,7 @@ long
setsignal(int signo, int vforked)
{
int action;
- sig_t sigact = SIG_DFL;
+ __sighandler_t sigact = SIG_DFL;
char *t, tsig;
if ((t = trap[signo]) == NULL)
@@ -327,13 +327,13 @@ setsignal(int signo, int vforked)
* Return the current setting for sig w/o changing it.
*/
static int
-getsigaction(int signo, sig_t *sigact)
+getsigaction(int signo, __sighandler_t *sigact)
{
struct sigaction sa;
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
return 0;
- *sigact = (sig_t) sa.sa_handler;
+ *sigact = (__sighandler_t) sa.sa_handler;
return 1;
}
diff --git a/src/ash/var.c b/src/ash/var.c
index 4f2e2a3..0cb74a8 100644
--- a/src/ash/var.c
+++ b/src/ash/var.c
@@ -46,12 +46,20 @@ __RCSID("$NetBSD: var.c,v 1.36 2004/10/06 10:23:43 enami Exp $");
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
+
+#ifdef __HAIKU__
+#define _BSD_SOURCE
+#include <bsd/paths.h>
+#endif
+
+#ifndef _PATH_DEFPATH
#ifndef __sun__
#include <paths.h>
#else
#define _PATH_DEFPATH "/usr/bin:/usr/sbin"
#include <iso/limits_iso.h>
#endif
+#endif
#ifdef PC_OS2_LIBPATHS
#define INCL_BASE
diff --git a/src/kObjCache/kObjCache.c b/src/kObjCache/kObjCache.c
index b403d58..fb757e0 100644
--- a/src/kObjCache/kObjCache.c
@@ -479,7 +237,7 @@ index 6d14300..137f2d6 100644
#else
static double last_sec;
diff --git a/src/kmk/kmkbuiltin/chmod.c b/src/kmk/kmkbuiltin/chmod.c
index 3e1eaec..4a7aeff 100644
index 3e1eaec..6bcc1e6 100644
--- a/src/kmk/kmkbuiltin/chmod.c
+++ b/src/kmk/kmkbuiltin/chmod.c
@@ -60,6 +60,9 @@ static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
@@ -534,109 +292,6 @@ index f913f17..9860f67 100644
# define HAVE_STRUCT_DIRENT_D_NAMLEN 1
# endif
#endif
diff --git a/src/kmk/kmkbuiltin/haikufakes.c b/src/kmk/kmkbuiltin/haikufakes.c
new file mode 100644
index 0000000..d904624
--- /dev/null
+++ b/src/kmk/kmkbuiltin/haikufakes.c
@@ -0,0 +1,52 @@
+/* $Id: haikufakes.c 2413 2010-09-11 17:43:04Z bird $ */
+/** @file
+ * Fake Unix stuff for Haiku.
+ */
+
+/*
+ * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/*******************************************************************************
+* Header Files *
+*******************************************************************************/
+#include "config.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "haikufakes.h"
+
+
+int haiku_lchmod(const char *pszPath, mode_t mode)
+{
+ /*
+ * Weed out symbolic links.
+ */
+ struct stat s;
+ if ( !lstat(pszPath, &s)
+ && S_ISLNK(s.st_mode))
+ {
+ errno = -ENOSYS;
+ return -1;
+ }
+
+ return chmod(pszPath, mode);
+}
diff --git a/src/kmk/kmkbuiltin/haikufakes.h b/src/kmk/kmkbuiltin/haikufakes.h
new file mode 100644
index 0000000..27d5c3d
--- /dev/null
+++ b/src/kmk/kmkbuiltin/haikufakes.h
@@ -0,0 +1,39 @@
+/* $Id: mscfakes.h 2413 2010-09-11 17:43:04Z bird $ */
+/** @file
+ * Unix fakes for MSC.
+ */
+
+/*
+ * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef ___haikufakes_h
+#define ___haikufakes_h
+
+#define EX_OK 0
+#define EX_OSERR 1
+#define EX_NOUSER 1
+#define EX_USAGE 1
+#define EX_TEMPFAIL 1
+#define EX_SOFTWARE 1
+
+#define lutimes(path, tvs) utimes(path, tvs)
+#define lchmod chmod
+
+#endif
diff --git a/src/kmk/kmkbuiltin/install.c b/src/kmk/kmkbuiltin/install.c
index 9ab4b00..e13bf89 100644
--- a/src/kmk/kmkbuiltin/install.c
@@ -731,7 +386,7 @@ index 2233c56..8f9e271 100644
# include "mscfakes.h"
#endif
diff --git a/src/kmk/kmkbuiltin/rm.c b/src/kmk/kmkbuiltin/rm.c
index 1b6522c..d9a606d 100644
index 1b6522c..c6b2fb8 100644
--- a/src/kmk/kmkbuiltin/rm.c
+++ b/src/kmk/kmkbuiltin/rm.c
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
@@ -743,15 +398,15 @@ index 1b6522c..d9a606d 100644
# include <sys/param.h>
# include <sys/mount.h>
#endif
@@ -57,10 +57,15 @@ static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
@@ -57,10 +57,14 @@ static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
+#ifndef __HAIKU__
+# include <sysexits.h>
+#endif
#include <unistd.h>
+#endif#include <unistd.h>
#include <ctype.h>
#include "getopt.h"
+#ifdef __HAIKU__
@@ -761,7 +416,7 @@ index 1b6522c..d9a606d 100644
# include "mscfakes.h"
#endif
diff --git a/src/kmk/main.c b/src/kmk/main.c
index e901e98..0e930c4 100644
index e901e98..3a95bf7 100644
--- a/src/kmk/main.c
+++ b/src/kmk/main.c
@@ -55,6 +55,9 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -849,7 +504,7 @@ index ead7fd0..fef30bf 100644
# define K_OS K_OS_LINUX
# elif defined(__NetBSD__) /*??*/
diff --git a/src/misc/kmk_time.c b/src/misc/kmk_time.c
index 9b2e73b..ff19e5e 100644
index 9b2e73b..fb3e58e 100644
--- a/src/misc/kmk_time.c
+++ b/src/misc/kmk_time.c
@@ -360,8 +360,10 @@ int main(int argc, char **argv)
@@ -887,6 +542,110 @@ index af57f41..89638a0 100755
# Generate a short man page from --help and --version output.
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software
Index: a/src/kmk/kmkbuiltin/haikufakes.c
===================================================================
--- a/src/kmk/kmkbuiltin/haikufakes.c (revision 0)
+++ b/src/kmk/kmkbuiltin/haikufakes.c (revision 0)
@@ -0,0 +1,52 @@
+/* $Id: haikufakes.c 2413 2010-09-11 17:43:04Z bird $ */
+/** @file
+ * Fake Unix stuff for Haiku.
+ */
+
+/*
+ * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/*******************************************************************************
+* Header Files *
+*******************************************************************************/
+#include "config.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "haikufakes.h"
+
+
+int haiku_lchmod(const char *pszPath, mode_t mode)
+{
+ /*
+ * Weed out symbolic links.
+ */
+ struct stat s;
+ if ( !lstat(pszPath, &s)
+ && S_ISLNK(s.st_mode))
+ {
+ errno = -ENOSYS;
+ return -1;
+ }
+
+ return chmod(pszPath, mode);
+}
Index: a/src/kmk/kmkbuiltin/haikufakes.h
===================================================================
--- a/src/kmk/kmkbuiltin/haikufakes.h (revision 0)
+++ b/src/kmk/kmkbuiltin/haikufakes.h (revision 0)
@@ -0,0 +1,39 @@
+/* $Id: mscfakes.h 2413 2010-09-11 17:43:04Z bird $ */
+/** @file
+ * Unix fakes for MSC.
+ */
+
+/*
+ * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
+ *
+ * This file is part of kBuild.
+ *
+ * kBuild is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * kBuild is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with kBuild. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef ___haikufakes_h
+#define ___haikufakes_h
+
+#define EX_OK 0
+#define EX_OSERR 1
+#define EX_NOUSER 1
+#define EX_USAGE 1
+#define EX_TEMPFAIL 1
+#define EX_SOFTWARE 1
+
+#define lutimes(path, tvs) utimes(path, tvs)
+#define lchmod chmod
+
+#endif
diff --git a/src/sed/lib/regexec.c b/src/sed/lib/regexec.c
index 8c5e296..aa4f65c 100644
--- a/src/sed/lib/regexec.c
@@ -899,6 +658,7 @@ index 8c5e296..aa4f65c 100644
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
int n) internal_function;
diff --git a/src/sed/lib/utils.c b/src/sed/lib/utils.c
index 647fd6d..21eb4d0 100644
--- a/src/sed/lib/utils.c
@@ -912,6 +672,7 @@ index 647fd6d..21eb4d0 100644
#include <errno.h>
#ifndef errno
extern int errno;
diff --git a/src/sed/sed/sed.h b/src/sed/sed/sed.h
index 78bd937..646cfc3 100644
--- a/src/sed/sed/sed.h
@@ -923,7 +684,144 @@ index 78bd937..646cfc3 100644
+#include "stdbool.h"
#include "basicdefs.h"
#include "regex.h"
--
2.11.0
diff --git a/src/ash/eval.c b/src/ash/eval.c
index 7e8a51c..1a71c09 100644
--- a/src/ash/eval.c
+++ b/src/ash/eval.c
@@ -47,7 +47,9 @@ __RCSID("$NetBSD: eval.c,v 1.84 2005/06/23 23:05:29 christos Exp $");
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
-#include <sys/fcntl.h>
+#ifndef __HAIKU__
+# include <sys/fcntl.h>
+#endif
#include <sys/times.h>
#include <sys/param.h>
#include <sys/types.h>
@@ -137,6 +139,7 @@ static int
sh_pipe(int fds[2])
{
int nfd;
+ int F_DUPFD;
if (pipe(fds))
return -1;
diff --git a/src/ash/jobs.c b/src/ash/jobs.c
index 146326a..9b6165e 100644
--- a/src/ash/jobs.c
+++ b/src/ash/jobs.c
@@ -58,7 +58,7 @@ __RCSID("$NetBSD: jobs.c,v 1.63 2005/06/01 15:41:19 lukem Exp $");
#endif
#include <sys/types.h>
#include <sys/param.h>
-#if defined(BSD) || defined(__sun__)
+#if defined(BSD) || defined(__sun__) || defined(__HAIKU__)
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/src/ash/show.c b/src/ash/show.c
index 2769c69..4d2353c 100644
--- a/src/ash/show.c
+++ b/src/ash/show.c
@@ -46,7 +46,9 @@ __RCSID("$NetBSD: show.c,v 1.26 2003/11/14 10:46:13 dsl Exp $");
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
-#include <sys/fcntl.h>
+#ifndef __HAIKU__
+# include <sys/fcntl.h>
+#endif
#include <unistd.h>
#include "shell.h"
diff --git a/src/ash/trap.c b/src/ash/trap.c
index 6a246e6..378856e 100644
--- a/src/ash/trap.c
+++ b/src/ash/trap.c
@@ -88,7 +88,7 @@ int pendingsigs; /* indicates some signal received */
#ifdef __sun__
typedef void (*sig_t) (int);
#endif
-static int getsigaction(int, sig_t *);
+static int getsigaction(int, __sighandler_t *);
/*
* return the signal number described by `p' (as a number or a name)
@@ -251,7 +251,7 @@ long
setsignal(int signo, int vforked)
{
int action;
- sig_t sigact = SIG_DFL;
+ __sighandler_t sigact = SIG_DFL;
char *t, tsig;
if ((t = trap[signo]) == NULL)
@@ -327,13 +327,13 @@ setsignal(int signo, int vforked)
* Return the current setting for sig w/o changing it.
*/
static int
-getsigaction(int signo, sig_t *sigact)
+getsigaction(int signo, __sighandler_t *sigact)
{
struct sigaction sa;
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
return 0;
- *sigact = (sig_t) sa.sa_handler;
+ *sigact = (__sighandler_t) sa.sa_handler;
return 1;
}
diff --git a/Config.kmk b/Config.kmk
index 6e42081..1856f31 100644
--- a/Config.kmk
+++ b/Config.kmk
@@ -293,7 +293,7 @@ ifndef TEMPLATE_BIN_TOOL
TEMPLATE_BIN_CXXFLAGS.sparc32+= -m32
TEMPLATE_BIN_CXXFLAGS.amd64 += -m64
TEMPLATE_BIN_CXXFLAGS.sparc64+= -m64
- TEMPLATE_BIN_LDFLAGS.x86 += -m32
+ TEMPLATE_BIN_LDFLAGS.x86 += -m32 -lbsd -lroot
TEMPLATE_BIN_LDFLAGS.sparc32 += -m32
TEMPLATE_BIN_LDFLAGS.amd64 += -m64
TEMPLATE_BIN_LDFLAGS.sparc64 += -m64
diff --git a/src/ash/error.h b/src/ash/error.h
index b4637f1..9bb0ebe 100644
--- a/src/ash/error.h
+++ b/src/ash/error.h
@@ -111,7 +111,7 @@ void sh_exit(int) __attribute__((__noreturn__));
* so we use _setjmp instead.
*/
-#if defined(BSD) && !defined(__SVR4) && !defined(__GLIBC__) && !defined(__KLIBC__) && !defined(_MSC_VER)
+#if defined(BSD) && !defined(__SVR4) && !defined(__GLIBC__) && !defined(__KLIBC__) && !defined(_MSC_VER) && !defined(__HAIKU__)
#define setjmp(jmploc) _setjmp(jmploc)
#define longjmp(jmploc, val) _longjmp(jmploc, val)
#endif
diff --git a/src/ash/Makefile.kmk b/src/ash/Makefile.kmk
index ad1ca85..1a3dabf 100644
--- a/src/ash/Makefile.kmk
+++ b/src/ash/Makefile.kmk
@@ -36,6 +36,7 @@ kmk_ash_DEFS.debug = DEBUG=2
endif
kmk_ash_DEFS.linux = BSD
kmk_ash_DEFS.solaris = BSD
+kmk_ash_DEFS.haiku = haiku
kmk_ash_DEFS.win = \
BSD PC_PATH_SEP PC_DRIVE_LETTERS PC_EXE_EXTS PC_SLASHES
kmk_ash_DEFS.os2 = \
@@ -94,7 +95,10 @@ kmk_ash_SOURCES.solaris = \
sys_signame.c \
strlcpy.c \
setmode.c
-
+kmk_ash_SOURCES.haiku = \
+ sys_signame.c \
+ strlcpy.c \
+ setmode.c
kmk_ash_INTERMEDIATES = \
$(PATH_kmk_ash)/builtins.h \
$(PATH_kmk_ash)/nodes.h \