chiark / gitweb /
cd90e2b20b6d276dcebcc7518f1486fe1b61dbab
[termux-packages] / packages / nodejs-current / build.sh
1 TERMUX_PKG_HOMEPAGE=https://nodejs.org/
2 TERMUX_PKG_DESCRIPTION="Platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications"
3 TERMUX_PKG_VERSION=8.4.0
4 TERMUX_PKG_SHA256=641a15fa822710ef2dc99793fec48d2a8ef75de0040b86568563d4ab296137ef
5 TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.gz
6 # Note that we do not use a shared libuv to avoid an issue with the Android
7 # linker, which does not use symbols of linked shared libraries when resolving
8 # symbols on dlopen(). See https://github.com/termux/termux-packages/issues/462.
9 TERMUX_PKG_DEPENDS="openssl, c-ares"
10 TERMUX_PKG_RM_AFTER_INSTALL="lib/node_modules/npm/html lib/node_modules/npm/make.bat share/systemtap lib/dtrace"
11 TERMUX_PKG_BUILD_IN_SRC=yes
12 TERMUX_PKG_CONFLICTS="nodejs"
13
14 termux_step_configure () {
15         # See https://github.com/nodejs/build/issues/266 about enabling snapshots
16         # when cross compiling. We use {CC,CXX}_host for compilation of code to
17         # be run on the build maching (snapshots when cross compiling are
18         # generated using a CPU emulator provided by v8) and {CC,CXX} for the
19         # cross compile. We unset flags such as CFLAGS as they would affect
20         # both the host and cross compiled build.
21         # Remaining issue to be solved before enabling snapshots by removing
22         # the --without-snapshot flag is that pkg-config picks up cross compilation
23         # flags which breaks the host build.
24         export CC_host="gcc -pthread"
25         export CXX_host="g++ -pthread"
26         export CC="$CC $CFLAGS $CPPFLAGS $LDFLAGS"
27         export CXX="$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS"
28         export CFLAGS="-Os"
29         export CXXFLAGS="-Os"
30         unset CPPFLAGS LDFLAGS
31
32         if [ $TERMUX_ARCH = "arm" ]; then
33                 DEST_CPU="arm"
34         elif [ $TERMUX_ARCH = "i686" ]; then
35                 DEST_CPU="ia32"
36         elif [ $TERMUX_ARCH = "aarch64" ]; then
37                 DEST_CPU="arm64"
38         elif [ $TERMUX_ARCH = "x86_64" ]; then
39                 DEST_CPU="x64"
40         else
41                 termux_error_exit "Unsupported arch '$TERMUX_ARCH'"
42         fi
43
44         export GYP_DEFINES="host_os=linux"
45
46         # See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv.
47         ./configure \
48                 --prefix=$TERMUX_PREFIX \
49                 --dest-cpu=$DEST_CPU \
50                 --dest-os=android \
51                 --shared-cares \
52                 --shared-openssl \
53                 --shared-zlib \
54                 --without-inspector \
55                 --without-intl \
56                 --cross-compiling
57 }