From c8a927f64364c78d799ff7bcbc64d7f23ad7c35d Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Tue, 6 Jun 2017 20:24:03 -0600
Subject: [PATCH] Add GNU make

---
 recipes/gnu-make/make.patch | 81 +++++++++++++++++++++++++++++++++++++
 recipes/gnu-make/recipe.sh  | 49 ++++++++++++++++++++++
 2 files changed, 130 insertions(+)
 create mode 100644 recipes/gnu-make/make.patch
 create mode 100644 recipes/gnu-make/recipe.sh

diff --git a/recipes/gnu-make/make.patch b/recipes/gnu-make/make.patch
new file mode 100644
index 000000000..6ead9108a
--- /dev/null
+++ b/recipes/gnu-make/make.patch
@@ -0,0 +1,81 @@
+diff -ru make-4.2/config/config.sub make-4.2-new/config/config.sub
+--- make-4.2/config/config.sub	2016-05-22 06:27:16.000000000 -0700
++++ make-4.2-new/config/config.sub	2017-05-09 13:36:20.519908366 -0700
+@@ -1376,7 +1376,7 @@
+ 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+-	      | -sym* | -kopensolaris* | -plan9* \
++	      | -sym* | -kopensolaris* | -plan9* | -redox* \
+ 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ 	      | -aos* | -aros* | -cloudabi* | -sortix* \
+ 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+diff -ru make-4.2/glob/glob.c make-4.2-new/glob/glob.c
+--- make-4.2/glob/glob.c	2013-10-20 10:14:38.000000000 -0700
++++ make-4.2-new/glob/glob.c	2017-05-09 14:14:14.319260425 -0700
+@@ -625,9 +625,9 @@
+ #else
+           const char *home_dir = getenv ("HOME");
+ #endif
+-# ifdef _AMIGA
++# if 1
+ 	  if (home_dir == NULL || home_dir[0] == '\0')
+-	    home_dir = "SYS:";
++	    home_dir = "/home/user";
+ # else
+ #  ifdef WINDOWS32
+ 	  if (home_dir == NULL || home_dir[0] == '\0')
+@@ -717,7 +717,7 @@
+ 	      dirname = newp;
+ 	    }
+ 	}
+-# if !defined _AMIGA && !defined WINDOWS32 && !defined VMS
++# if 0
+       else
+ 	{
+ 	  char *end_name = strchr (dirname, '/');
+diff -ru make-4.2/job.c make-4.2-new/job.c
+--- make-4.2/job.c	2016-05-21 13:22:32.000000000 -0700
++++ make-4.2-new/job.c	2017-05-09 13:52:47.806791042 -0700
+@@ -1038,7 +1038,7 @@
+ void
+ block_sigs (void)
+ {
+-#ifdef POSIX
++#if 0
+   (void) sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0);
+ #else
+ # ifdef HAVE_SIGSETMASK
+@@ -1051,9 +1051,11 @@
+ void
+ unblock_sigs (void)
+ {
++/*
+   sigset_t empty;
+   sigemptyset (&empty);
+   sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0);
++*/
+ }
+ #endif
+ 
+diff -ru make-4.2/read.c make-4.2-new/read.c
+--- make-4.2/read.c	2016-05-21 13:22:32.000000000 -0700
++++ make-4.2-new/read.c	2017-05-09 13:55:08.237484319 -0700
+@@ -2937,7 +2937,7 @@
+           free (home_dir);
+           home_dir = getenv ("HOME");
+         }
+-# if !defined(_AMIGA) && !defined(WINDOWS32)
++# if 0
+       if (home_dir == 0 || home_dir[0] == '\0')
+         {
+           char *logname = getlogin ();
+@@ -2958,7 +2958,7 @@
+           return new;
+         }
+     }
+-# if !defined(_AMIGA) && !defined(WINDOWS32)
++# if 0
+   else
+     {
+       struct passwd *pwent;
diff --git a/recipes/gnu-make/recipe.sh b/recipes/gnu-make/recipe.sh
new file mode 100644
index 000000000..fe52243c5
--- /dev/null
+++ b/recipes/gnu-make/recipe.sh
@@ -0,0 +1,49 @@
+VERSION=4.2.1
+TAR=https://ftp.gnu.org/gnu/make/make-$VERSION.tar.gz
+
+HOST=x86_64-elf-redox
+
+export AR="${HOST}-ar"
+export AS="${HOST}-as"
+export CC="${HOST}-gcc"
+export CXX="${HOST}-g++"
+export LD="${HOST}-ld"
+export NM="${HOST}-nm"
+export OBJCOPY="${HOST}-objcopy"
+export OBJDUMP="${HOST}-objdump"
+export RANLIB="${HOST}-ranlib"
+export READELF="${HOST}-readelf"
+export STRIP="${HOST}-strip"
+
+function recipe_version {
+    echo "$VERSION"
+    return 1
+}
+
+function recipe_update {
+    echo "skipping update"
+    return 1
+}
+
+function recipe_build {
+    patch -p1 < ../make.patch
+    ./configure --host=${HOST} --prefix=/ CFLAGS=-DPOSIX --without-guile
+    make
+    return 1
+}
+
+function recipe_test {
+    echo "skipping test"
+    return 1
+}
+
+function recipe_clean {
+    make clean
+    return 1
+}
+
+function recipe_stage {
+    dest="$(realpath $1)"
+    make DESTDIR="$dest" install
+    return 1
+}
-- 
GitLab