# https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Linux
# and
# https://github.com/neurocyte/ghc-android
-#
-# Status: Currently fails at "error: cannot find -lpthread"
-# right after message about building bin/hpc.
-# As libpthread does not exist on Android (pthread
-# is built into libc, this needs to be patched away.
TERMUX_PKG_HOMEPAGE=https://www.haskell.org/ghc/
TERMUX_PKG_DESCRIPTION="The Glasgow Haskell Compilation system"
TERMUX_PKG_VERSION=8.0.1
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-iconv-includes=$TERMUX_PREFIX/include -with-iconv-libraries=$TERMUX_PREFIX/lib"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-curses-includes=$TERMUX_PREFIX/include/ncursesw -with-curses-libraries=$TERMUX_PREFIX/lib"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --host=${TERMUX_HOST_PLATFORM}"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --target=${TERMUX_HOST_PLATFORM}"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --host=x86_64-unknown-linux --build=x86_64-unknown-linux"
-ORIG_CFLAGS="$CFLAGS"
-ORIG_CPPFLAGS="$CPPFLAGS"
-ORIG_LDFLAGS="$LDFLAGS"
+termux_step_post_extract_package() {
+ ORIG_CFLAGS="$CFLAGS"
+ ORIG_CPPFLAGS="$CPPFLAGS"
+ ORIG_LDFLAGS="$LDFLAGS"
-unset AR
-unset AS
-unset CC
-export CFLAGS=""
-unset CPP
-export CPPFLAGS=""
-unset CXXFLAGS
-unset CXX
-export LDFLAGS=""
-unset LD
-unset PKG_CONFIG
-unset RANLIB
+ unset AR
+ unset AS
+ unset CC
+ export CFLAGS=""
+ unset CPP
+ export CPPFLAGS=""
+ unset CXXFLAGS
+ unset CXX
+ export LDFLAGS=""
+ unset LD
+ unset PKG_CONFIG
+ unset RANLIB
+
+ TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --target=${TERMUX_HOST_PLATFORM}"
+}
termux_step_pre_configure () {
echo "INTEGER_LIBRARY = integer-simple" > mk/build.mk
--- /dev/null
+diff -u -r ../ghc-8.0.1/compiler/main/DriverPipeline.hs ./compiler/main/DriverPipeline.hs
+--- ../ghc-8.0.1/compiler/main/DriverPipeline.hs 2016-05-16 13:08:53.000000000 -0400
++++ ./compiler/main/DriverPipeline.hs 2016-09-07 03:37:48.321941122 -0400
+@@ -1831,10 +1831,7 @@
+ | WayThreaded `elem` ways dflags =
+ let os = platformOS (targetPlatform dflags)
+ in if os == OSOsf3 then ["-lpthread", "-lexc"]
+- else if os `elem` [OSMinGW32, OSFreeBSD, OSOpenBSD,
+- OSNetBSD, OSHaiku, OSQNXNTO, OSiOS, OSDarwin]
+- then []
+- else ["-lpthread"]
++ else []
+ | otherwise = []
+
+ rc_objs <- maybeCreateManifest dflags output_fn