ports: add GNU make port

This commit is contained in:
Mark Poliakov 2025-03-08 01:58:43 +02:00
parent 8ffc223a2b
commit 1c07b74e6d
7 changed files with 263 additions and 1 deletions

18
ports/gnu-make/compile.sh Executable file
View File

@ -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

31
ports/gnu-make/fetch.sh Executable file
View File

@ -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

5
ports/gnu-make/install.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
build_dir=$3
cd $build_dir
make -j install DESTDIR=$Y_SYSROOT >/dev/null

View File

@ -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 <errno.h>
! #ifndef errno
extern int errno;
#endif
--- 78,84 ----
#include <errno.h>
! #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 <stdlib.h>
# 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 */

2
ports/gnu-make/port.toml Normal file
View File

@ -0,0 +1,2 @@
description = "GNU make implementation for build automation"
version = "4.4.1"

View File

@ -1 +1 @@
export PATH=/mnt/bin:/bin:/sbin
export PATH=/mnt/usr/bin:/mnt/bin:/bin:/sbin

View File

@ -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" {