From b1dd5c1e8b422bbe6ae4705584d4256fdc633b9b Mon Sep 17 00:00:00 2001 From: Tee KOBAYASHI Date: Sat, 1 Jan 2022 02:26:39 +0900 Subject: [PATCH] new package: polyml --- .../polyml/Makefile.in.patch.beforehostbuild | 25 ++++++ packages/polyml/build.sh | 78 +++++++++++++++++++ packages/polyml/libpolyml-basicio.cpp.patch | 11 +++ packages/polyml/libpolyml-osmemunix.cpp.patch | 14 ++++ .../polyml/libpolyml-process_env.cpp.patch | 11 +++ ...InfAsInt-Makefile.in.patch.beforehostbuild | 11 +++ 6 files changed, 150 insertions(+) create mode 100644 packages/polyml/Makefile.in.patch.beforehostbuild create mode 100644 packages/polyml/build.sh create mode 100644 packages/polyml/libpolyml-basicio.cpp.patch create mode 100644 packages/polyml/libpolyml-osmemunix.cpp.patch create mode 100644 packages/polyml/libpolyml-process_env.cpp.patch create mode 100644 packages/polyml/modules-IntInfAsInt-Makefile.in.patch.beforehostbuild diff --git a/packages/polyml/Makefile.in.patch.beforehostbuild b/packages/polyml/Makefile.in.patch.beforehostbuild new file mode 100644 index 000000000..3640d6432 --- /dev/null +++ b/packages/polyml/Makefile.in.patch.beforehostbuild @@ -0,0 +1,25 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -1155,11 +1155,11 @@ + + # Unix. + polyexport.o: polyimport bootstrap/Stage1.sml $(POLYIMPORT) +- ./polyimport $(BOOTSTRAP_OPTIONS) $(POLYIMPORT) -I $(srcdir) < $(srcdir)/bootstrap/Stage1.sml ++ polyimport $(BOOTSTRAP_OPTIONS) $(POLYIMPORT) -I $(srcdir) < $(srcdir)/bootstrap/Stage1.sml + + # Windows. When building on Windows make sure that we provide both stdin and stdout to suppress the GUI. + polyexport.obj: polyimport$(EXEEXT) bootstrap/Stage1.sml $(POLYIMPORT) +- ./polyimport $(BOOTSTRAP_OPTIONS) $(POLYIMPORT) -I $(srcdir) < $(srcdir)/bootstrap/Stage1.sml | cat ++ polyimport $(BOOTSTRAP_OPTIONS) $(POLYIMPORT) -I $(srcdir) < $(srcdir)/bootstrap/Stage1.sml | cat + + polyresource.o: PolyML.rc poly.ico + $(WINDRES) -o polyresource.o $(srcdir)/PolyML.rc +@@ -1169,7 +1169,7 @@ + + # Recompiler the compiler using the last step of the bootstrap process. + compiler: all +- ./poly $(BOOTSTRAP_OPTIONS) --error-exit < bootstrap/Stage6.sml ++ poly $(BOOTSTRAP_OPTIONS) --error-exit < bootstrap/Stage6.sml + $(MAKE) + + reboot: compiler diff --git a/packages/polyml/build.sh b/packages/polyml/build.sh new file mode 100644 index 000000000..20d8b8513 --- /dev/null +++ b/packages/polyml/build.sh @@ -0,0 +1,78 @@ +TERMUX_PKG_HOMEPAGE=https://www.polyml.org/ +TERMUX_PKG_DESCRIPTION="A Standard ML implementation" +TERMUX_PKG_LICENSE="LGPL-2.1" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=5.9 +TERMUX_PKG_SRCURL=https://github.com/polyml/polyml/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_SHA256=5aa452a49f2ac0278668772af4ea0b9bf30c93457e60ff7f264c5aec2023c83e +TERMUX_PKG_DEPENDS="libc++, libffi, libgmp" +TERMUX_PKG_HOSTBUILD=true +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +--with-pic +--disable-native-codegeneration +" + +termux_step_host_build() { + _PREFIX_FOR_BUILD=$TERMUX_PKG_HOSTBUILD_DIR/prefix + mkdir -p $_PREFIX_FOR_BUILD + + TERMUX_ORIG_PATH=$PATH + mkdir -p native + pushd native + export PATH=$(pwd):$TERMUX_ORIG_PATH + $TERMUX_PKG_SRCDIR/configure \ + CC="gcc -m${TERMUX_ARCH_BITS}" CXX="g++ -m${TERMUX_ARCH_BITS}" \ + --prefix=$_PREFIX_FOR_BUILD \ + $TERMUX_PKG_EXTRA_CONFIGURE_ARGS + sed -i -e 's/^\(#define HOSTARCHITECTURE\)_X32 1/\1_X86 1/g' config.h + make -j $TERMUX_MAKE_PROCESSES + make install + popd + + local arch + case "$TERMUX_ARCH" in + aarch64 ) + arch=AARCH64 ;; + arm ) + arch=ARM ;; + x86_64 ) + arch=X86_64 ;; + i686 ) + arch=X86 ;; + * ) + echo "ERROR: Unknown architecture: $TERMUX_ARCH" + return 1 ;; + esac + + mkdir -p cross + pushd cross + export PATH=$_PREFIX_FOR_BUILD/bin:$TERMUX_ORIG_PATH + $TERMUX_PKG_SRCDIR/configure \ + CC="gcc -m${TERMUX_ARCH_BITS}" CXX="g++ -m${TERMUX_ARCH_BITS}" \ + --prefix=$(pwd) \ + $TERMUX_PKG_EXTRA_CONFIGURE_ARGS + sed -i -e '/^#define HOSTARCHITECTURE_/d' config.h + echo >> config.h + echo "#define HOSTARCHITECTURE_${arch} 1" >> config.h + make -j $TERMUX_MAKE_PROCESSES -C libpolyml libpolyml.la + make -j $TERMUX_MAKE_PROCESSES polyimport + make -j $TERMUX_MAKE_PROCESSES -C libpolymain libpolymain.la + make -j $TERMUX_MAKE_PROCESSES poly + export PATH=$(pwd):$TERMUX_ORIG_PATH + popd +} + +termux_step_pre_configure() { + _NEED_DUMMY_LIBSTDCXX_SO= + _LIBSTDCXX_SO=$TERMUX_PREFIX/lib/libstdc++.so + if [ ! -e $_LIBSTDCXX_SO ]; then + _NEED_DUMMY_LIBSTDCXX_SO=true + echo 'INPUT(-lc++_shared)' > $_LIBSTDCXX_SO + fi +} + +termux_step_post_make_install() { + if [ $_NEED_DUMMY_LIBSTDCXX_SO ]; then + rm -f $_LIBSTDCXX_SO + fi +} diff --git a/packages/polyml/libpolyml-basicio.cpp.patch b/packages/polyml/libpolyml-basicio.cpp.patch new file mode 100644 index 000000000..f5a9e2c40 --- /dev/null +++ b/packages/polyml/libpolyml-basicio.cpp.patch @@ -0,0 +1,11 @@ +--- a/libpolyml/basicio.cpp ++++ b/libpolyml/basicio.cpp +@@ -993,7 +993,7 @@ + if (buff == 0) raise_syscall(taskData, "Insufficient memory", NOMEMORY); + strcpy(buff, P_tmpdir); + #else +- const char *tmpdir = "/tmp"; ++ const char *tmpdir = "@TERMUX_PREFIX@/tmp"; + TempString buff((char *)malloc(strlen(tmpdir) + strlen(template_subdir) + 1)); + if (buff == 0) raise_syscall(taskData, "Insufficient memory", NOMEMORY); + strcpy(buff, tmpdir); diff --git a/packages/polyml/libpolyml-osmemunix.cpp.patch b/packages/polyml/libpolyml-osmemunix.cpp.patch new file mode 100644 index 000000000..5c0f02583 --- /dev/null +++ b/packages/polyml/libpolyml-osmemunix.cpp.patch @@ -0,0 +1,14 @@ +--- a/libpolyml/osmemunix.cpp ++++ b/libpolyml/osmemunix.cpp +@@ -134,9 +134,9 @@ + fd = openTmpFile(P_tmpdir); + if (fd != -1) return fd; + #endif +- fd = openTmpFile("/tmp"); ++ fd = openTmpFile("@TERMUX_PREFIX@/tmp"); + if (fd != -1) return fd; +- fd = openTmpFile("/var/tmp"); ++ fd = openTmpFile("@TERMUX_PREFIX@/var/tmp"); + if (fd != -1) return fd; + + return -1; diff --git a/packages/polyml/libpolyml-process_env.cpp.patch b/packages/polyml/libpolyml-process_env.cpp.patch new file mode 100644 index 000000000..e01f0502e --- /dev/null +++ b/packages/polyml/libpolyml-process_env.cpp.patch @@ -0,0 +1,11 @@ +--- a/libpolyml/process_env.cpp ++++ b/libpolyml/process_env.cpp +@@ -575,7 +575,7 @@ + sigemptyset(&sigset); + sigprocmask(SIG_SETMASK, &sigset, 0); + // Reset other signals? +- execv("/bin/sh", argv); ++ execv("@TERMUX_PREFIX@/bin/sh", argv); + _exit(1); + } + #endif diff --git a/packages/polyml/modules-IntInfAsInt-Makefile.in.patch.beforehostbuild b/packages/polyml/modules-IntInfAsInt-Makefile.in.patch.beforehostbuild new file mode 100644 index 000000000..c4adde572 --- /dev/null +++ b/packages/polyml/modules-IntInfAsInt-Makefile.in.patch.beforehostbuild @@ -0,0 +1,11 @@ +--- a/modules/IntInfAsInt/Makefile.in ++++ b/modules/IntInfAsInt/Makefile.in +@@ -473,7 +473,7 @@ + -rm -f $(DESTDIR)$(moduledir)/IntInfAsInt + + IntInfAsInt: ../../poly$(EXEEXT) ROOT.sml +- echo "use \"$(srcdir)/ROOT.sml\";" | ../../poly$(EXEEXT) -q -error-exit ++ echo "use \"$(srcdir)/ROOT.sml\";" | poly$(EXEEXT) -q -error-exit + + # Tell versions [3.59,3.63) of GNU make to not export all variables. + # Otherwise a system limit (for SysV at least) may be exceeded.