new package: polyml

This commit is contained in:
Tee KOBAYASHI 2022-01-01 02:26:39 +09:00 committed by Leonid Pliushch
parent 0613596c3b
commit b1dd5c1e8b
6 changed files with 150 additions and 0 deletions

View File

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

78
packages/polyml/build.sh Normal file
View File

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

View File

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

View File

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

View File

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

View File

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