diff --git a/ports/lua/compile.sh b/ports/lua/compile.sh new file mode 100755 index 00000000..23bfab71 --- /dev/null +++ b/ports/lua/compile.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +build_dir=$3 + +cd $build_dir/lua-${Y_PORT_VERSION} +make yggdrasil diff --git a/ports/lua/fetch.sh b/ports/lua/fetch.sh new file mode 100755 index 00000000..aaa5e70f --- /dev/null +++ b/ports/lua/fetch.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +. $Y_PORT_UTILS/sig.sh + +set -e + +SRC_FILENAME="lua-${Y_PORT_VERSION}.tar.gz" +SRC_SHA256="9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30" +RELEASE_BASE="https://www.lua.org/ftp" +RELEASE_URL="$RELEASE_BASE/$SRC_FILENAME" + +build_dir=$3 + +mkdir -p $build_dir +cd $build_dir + +if [ ! -f .source-ready ]; then + curl -LO $RELEASE_URL + verify_sha256 $SRC_SHA256 $SRC_FILENAME + + tar xf $SRC_FILENAME + + cd lua-${Y_PORT_VERSION} + for patch in $1/patches/*.patch; do + echo Apply $patch + patch -p1 <$patch + done + + touch $build_dir/.source-ready +fi diff --git a/ports/lua/install.sh b/ports/lua/install.sh new file mode 100755 index 00000000..d3b7a272 --- /dev/null +++ b/ports/lua/install.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +build_dir=$3 + +mkdir -p $Y_SYSROOT/bin +install -m0755 $build_dir/lua-${Y_PORT_VERSION}/src/lua $Y_SYSROOT/bin/lua +install -m0755 $build_dir/lua-${Y_PORT_VERSION}/src/luac $Y_SYSROOT/bin/luac diff --git a/ports/lua/patches/0001-add-yggdrasil-support.patch b/ports/lua/patches/0001-add-yggdrasil-support.patch new file mode 100644 index 00000000..1cd89ec1 --- /dev/null +++ b/ports/lua/patches/0001-add-yggdrasil-support.patch @@ -0,0 +1,101 @@ +diff -x '*.o' -crB lua-5.4.7-orig/Makefile lua-5.4.7/Makefile +*** lua-5.4.7-orig/Makefile 2024-05-09 00:47:12.000000000 +0300 +--- lua-5.4.7/Makefile 2025-03-08 02:33:23.044385955 +0200 +*************** +*** 36,42 **** + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + + # Convenience platforms targets. +! PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris + + # What to install. + TO_BIN= lua luac +--- 36,42 ---- + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + + # Convenience platforms targets. +! PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris yggdrasil + + # What to install. + TO_BIN= lua luac +Only in lua-5.4.7/src: liblua.a +Only in lua-5.4.7/src: lua +Only in lua-5.4.7/src: luac +diff -x '*.o' -crB lua-5.4.7-orig/src/Makefile lua-5.4.7/src/Makefile +*** lua-5.4.7-orig/src/Makefile 2023-02-03 12:43:14.000000000 +0200 +--- lua-5.4.7/src/Makefile 2025-03-08 02:33:30.698796912 +0200 +*************** +*** 4,18 **** + # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + + # Your platform. See PLATS for possible values. +! PLAT= guess + +! CC= gcc -std=gnu99 +! CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS) +! LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) + LIBS= -lm $(SYSLIBS) $(MYLIBS) + +! AR= ar rcu +! RANLIB= ranlib + RM= rm -f + UNAME= uname + +--- 4,23 ---- + # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + + # Your platform. See PLATS for possible values. +! PLAT= yggdrasil + +! CC=clang +! CFLAGS= -fPIC \ +! -target $(Y_TRIPLE) \ +! --sysroot $(Y_SYSROOT) \ +! -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS) +! LDFLAGS= -target $(Y_TRIPLE) \ +! --sysroot $(Y_SYSROOT) \ +! $(SYSLDFLAGS) $(MYLDFLAGS) + LIBS= -lm $(SYSLIBS) $(MYLIBS) + +! AR= llvm-ar rcu +! RANLIB= llvm-ranlib + RM= rm -f + UNAME= uname + +*************** +*** 26,36 **** + MYOBJS= + + # Special flags for compiler modules; -Os reduces code size. +! CMCFLAGS= + + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + +! PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris + + LUA_A= liblua.a + CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o +--- 31,41 ---- + MYOBJS= + + # Special flags for compiler modules; -Os reduces code size. +! CMCFLAGS= + + # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + +! PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris yggdrasil + + LUA_A= liblua.a + CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o +*************** +*** 120,125 **** +--- 125,133 ---- + ios: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_IOS" + ++ yggdrasil: ++ $(MAKE) $(ALL) SYSCFLAGS="-fPIC -target $(Y_TRIPLE) --sysroot $(Y_SYSROOT)" SYSLDFLAGS="-target $(Y_TRIPLE) --sysroot $(Y_SYSROOT)" ++ + Linux linux: linux-noreadline + + linux-noreadline: diff --git a/ports/lua/port.toml b/ports/lua/port.toml new file mode 100644 index 00000000..3ec90c70 --- /dev/null +++ b/ports/lua/port.toml @@ -0,0 +1,2 @@ +description = "Simple and lightweight scripting language" +version = "5.4.7"