From 1c07b74e6de3246e7ebfc7e65dcb592b9f5b4425 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Sat, 8 Mar 2025 01:58:43 +0200 Subject: [PATCH] ports: add GNU make port --- ports/gnu-make/compile.sh | 18 ++ ports/gnu-make/fetch.sh | 31 +++ ports/gnu-make/install.sh | 5 + .../patches/0001-add-yggdrasil-support.patch | 201 ++++++++++++++++++ ports/gnu-make/port.toml | 2 + userspace/etc/profile | 2 +- userspace/lib/ygglibc/include/assert.h | 5 + 7 files changed, 263 insertions(+), 1 deletion(-) create mode 100755 ports/gnu-make/compile.sh create mode 100755 ports/gnu-make/fetch.sh create mode 100755 ports/gnu-make/install.sh create mode 100644 ports/gnu-make/patches/0001-add-yggdrasil-support.patch create mode 100644 ports/gnu-make/port.toml diff --git a/ports/gnu-make/compile.sh b/ports/gnu-make/compile.sh new file mode 100755 index 00000000..e445ee58 --- /dev/null +++ b/ports/gnu-make/compile.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +source_dir=$2 +build_dir=$3 + +mkdir -p $build_dir +cd $build_dir + +if [ ! -f Makefile ]; then + CC="clang" CFLAGS="-DNO_ARCHIVES -fPIC -target $Y_TRIPLE --sysroot $Y_SYSROOT" \ + $source_dir/make-${Y_PORT_VERSION}/configure \ + --prefix=/usr \ + --build=x86_64-pc-linux-gnu \ + --host=x86_64-unknown-yggdrasil \ + --disable-job-server +fi + +make -j diff --git a/ports/gnu-make/fetch.sh b/ports/gnu-make/fetch.sh new file mode 100755 index 00000000..d917834c --- /dev/null +++ b/ports/gnu-make/fetch.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +. $Y_PORT_UTILS/sig.sh + +set -e + +SRC_FILENAME="make-${Y_PORT_VERSION}.tar.gz" +SRC_SHA256="dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3" +RELEASE_BASE="https://ftp.gnu.org/gnu/make" +RELEASE_URL="$RELEASE_BASE/$SRC_FILENAME" + +source_dir=$2 +build_dir=$3 + +mkdir -p $source_dir +cd $source_dir + +if [ ! -f .source-ready ]; then + curl -LO $RELEASE_URL + verify_sha256 $SRC_SHA256 $SRC_FILENAME + + tar xf $SRC_FILENAME + + cd make-${Y_PORT_VERSION} + for patch in $1/patches/*.patch; do + echo Apply $patch + patch -p1 <$patch + done + + touch $source_dir/.source-ready +fi diff --git a/ports/gnu-make/install.sh b/ports/gnu-make/install.sh new file mode 100755 index 00000000..b8d6f327 --- /dev/null +++ b/ports/gnu-make/install.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +build_dir=$3 +cd $build_dir +make -j install DESTDIR=$Y_SYSROOT >/dev/null diff --git a/ports/gnu-make/patches/0001-add-yggdrasil-support.patch b/ports/gnu-make/patches/0001-add-yggdrasil-support.patch new file mode 100644 index 00000000..624c1756 --- /dev/null +++ b/ports/gnu-make/patches/0001-add-yggdrasil-support.patch @@ -0,0 +1,201 @@ +Only in make-4.4.1-modified: build +diff -crB make-4.4.1/build-aux/config.sub make-4.4.1-modified/build-aux/config.sub +*** make-4.4.1/build-aux/config.sub 2023-02-18 17:38:13.000000000 +0200 +--- make-4.4.1-modified/build-aux/config.sub 2025-03-07 16:27:04.815267725 +0200 +*************** +*** 1758,1764 **** + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +! | fiwix* | mlibc* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +--- 1758,1764 ---- + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +! | fiwix* | mlibc* | yggdrasil* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +diff -crB make-4.4.1/lib/fnmatch.c make-4.4.1-modified/lib/fnmatch.c +*** make-4.4.1/lib/fnmatch.c 2023-02-26 18:04:31.000000000 +0200 +--- make-4.4.1-modified/lib/fnmatch.c 2025-03-07 16:30:06.124123594 +0200 +*************** +*** 124,132 **** + extern char *getenv (); + # endif + +! # ifndef errno + extern int errno; +! # endif + + /* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ +--- 124,132 ---- + extern char *getenv (); + # endif + +! #if !defined(__yggdrasil__) && !defined(errno) + extern int errno; +! #endif + + /* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ +diff -crB make-4.4.1/src/dir.c make-4.4.1-modified/src/dir.c +*** make-4.4.1/src/dir.c 2023-01-12 02:53:26.000000000 +0200 +--- make-4.4.1-modified/src/dir.c 2025-03-07 17:50:37.250231175 +0200 +*************** +*** 818,823 **** +--- 818,831 ---- + const char *dirname; + const char *slash; + ++ #if defined(__yggdrasil__) ++ if (access(name, F_OK) == 0) { ++ return 1; ++ } else { ++ return 0; ++ } ++ #endif ++ + #ifndef NO_ARCHIVES + if (ar_name (name)) + return ar_member_date (name) != (time_t) -1; +diff -crB make-4.4.1/src/job.c make-4.4.1-modified/src/job.c +*** make-4.4.1/src/job.c 2023-02-22 03:53:48.000000000 +0200 +--- make-4.4.1-modified/src/job.c 2025-03-08 01:44:31.408362666 +0200 +*************** +*** 144,150 **** + # include "findprog.h" + #endif + +! #if !defined (wait) && !defined (POSIX) + int wait (); + #endif + +--- 144,150 ---- + # include "findprog.h" + #endif + +! #if !defined (wait) && !defined (POSIX) && !defined(__yggdrasil__) + int wait (); + #endif + +*************** +*** 2598,2603 **** +--- 2598,2606 ---- + environ = envp; + execvpe(argv[0], argv, envp); + ++ # elif defined(__yggdrasil__) ++ fprintf(stderr, "yggdrasil/make: execvp() not implemented yet\n"); ++ abort(); + # else + + /* Run the program. Don't use execvpe() as we want the search for argv[0] +*************** +*** 2668,2673 **** +--- 2671,2679 ---- + # elif MK_OS_ZOS + /* In z/OS we can't set environ in ASCII mode. */ + execvpe(shell, new_argv, envp); ++ # elif defined(__yggdrasil__) ++ fprintf(stderr, "yggdrasil/make: execvp() not implemented yet\n"); ++ abort(); + # else + execvp (shell, new_argv); + # endif +diff -crB make-4.4.1/src/makeint.h make-4.4.1-modified/src/makeint.h +*** make-4.4.1/src/makeint.h 2023-02-19 15:51:55.000000000 +0200 +--- make-4.4.1-modified/src/makeint.h 2025-03-07 16:41:27.642799477 +0200 +*************** +*** 78,84 **** + + #include + +! #ifndef errno + extern int errno; + #endif + +--- 78,84 ---- + + #include + +! #if !defined(__yggdrasil__) && !defined(errno) + extern int errno; + #endif + +*************** +*** 159,164 **** +--- 159,168 ---- + unsigned int get_path_max (void); + #endif + ++ #if defined(__yggdrasil__) ++ #define alloca __builtin_alloca ++ #endif ++ + #ifndef CHAR_BIT + # define CHAR_BIT 8 + #endif +*************** +*** 246,254 **** +--- 250,261 ---- + # ifdef HAVE_STDLIB_H + # include + # else ++ ++ #if !defined(__yggdrasil__) + void *malloc (int); + void *realloc (void *, int); + void free (void *); ++ #endif + + void abort (void) NORETURN; + void exit (int) NORETURN; +*************** +*** 682,693 **** + + #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32) + +! # ifndef VMS + long int lseek (); + # endif + + # ifdef HAVE_GETCWD +! # if !defined(VMS) && !defined(__DECC) + char *getcwd (void); + # endif + # else +--- 689,700 ---- + + #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32) + +! # if !defined(VMS) && !defined(__yggdrasil__) + long int lseek (); + # endif + + # ifdef HAVE_GETCWD +! # if !defined(VMS) && !defined(__DECC) && !defined(__yggdrasil__) + char *getcwd (void); + # endif + # else +diff -crB make-4.4.1/src/read.c make-4.4.1-modified/src/read.c +*** make-4.4.1/src/read.c 2023-01-01 17:06:01.000000000 +0200 +--- make-4.4.1-modified/src/read.c 2025-03-07 17:39:55.042702952 +0200 +*************** +*** 240,246 **** +--- 240,250 ---- + #ifdef WINDOWS32 + { "GNUmakefile", "makefile", "Makefile", "makefile.mak", 0 }; + #else /* !Amiga && !VMS && !WINDOWS32 */ ++ #ifdef __yggdrasil__ ++ { "Makefile", "makefile", 0 }; ++ #else + { "GNUmakefile", "makefile", "Makefile", 0 }; ++ #endif + #endif /* !Amiga && !VMS && !WINDOWS32 */ + #endif /* AMIGA */ + #endif /* VMS */ diff --git a/ports/gnu-make/port.toml b/ports/gnu-make/port.toml new file mode 100644 index 00000000..5e2b72f6 --- /dev/null +++ b/ports/gnu-make/port.toml @@ -0,0 +1,2 @@ +description = "GNU make implementation for build automation" +version = "4.4.1" diff --git a/userspace/etc/profile b/userspace/etc/profile index bd2129e4..7e931ac2 100644 --- a/userspace/etc/profile +++ b/userspace/etc/profile @@ -1 +1 @@ -export PATH=/mnt/bin:/bin:/sbin +export PATH=/mnt/usr/bin:/mnt/bin:/bin:/sbin diff --git a/userspace/lib/ygglibc/include/assert.h b/userspace/lib/ygglibc/include/assert.h index 1822b180..5c3df984 100644 --- a/userspace/lib/ygglibc/include/assert.h +++ b/userspace/lib/ygglibc/include/assert.h @@ -3,8 +3,13 @@ #define __ASSERT_VOID_CAST (void) +#if !defined(NDEBUG) #define assert(expr) \ ((expr) ? __ASSERT_VOID_CAST(0) : __assert_fail(__FILE__, __LINE__, #expr)) +#else +#define assert(expr) \ + ((void) 0) +#endif #if defined(__cplusplus) extern "C" {