Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | TERMUX_PKG_HOMEPAGE=http://gcc.gnu.org/ |
2 | TERMUX_PKG_DESCRIPTION="GNU C compiler" | |
3 | TERMUX_PKG_DEPENDS="binutils, libgmp, libmpfr, libmpc, ndk-sysroot" | |
3f8951e7 | 4 | TERMUX_PKG_VERSION=4.9.3 |
637f22d1 | 5 | TERMUX_PKG_BUILD_REVISION=4 |
59f0d218 FF |
6 | TERMUX_PKG_SRCURL=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-${TERMUX_PKG_VERSION}/gcc-${TERMUX_PKG_VERSION}.tar.bz2 |
7 | TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--enable-languages=c,c++ --with-system-zlib --disable-multilib --disable-lto" | |
8 | TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-gmp=$TERMUX_PREFIX --with-mpfr=$TERMUX_PREFIX --with-mpc=$TERMUX_PREFIX" | |
9 | # To build gcc as a PIE binary: | |
10 | TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-stage1-ldflags=\"-specs=$TERMUX_SCRIPTDIR/termux.spec\"" | |
11 | if [ "$TERMUX_ARCH" = "arm" ]; then | |
12 | TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-arch=armv7-a --with-fpu=neon --with-float=hard" | |
13 | elif [ "$TERMUX_ARCH" = "i686" ]; then | |
14 | # -mstackrealign -msse3 -m32 | |
15 | TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-arch=i686 --with-tune=atom --with-fpmath=sse" | |
16 | fi | |
17 | TERMUX_PKG_KEEP_STATIC_LIBRARIES="true" | |
5ce2f122 | 18 | TERMUX_PKG_RM_AFTER_INSTALL="bin/gcc-ar bin/gcc-ranlib bin/c++ bin/gcc-nm lib/gcc/*-linux-*/${TERMUX_PKG_VERSION}/plugin lib/gcc/*-linux-*/${TERMUX_PKG_VERSION}/include-fixed lib/gcc/*-linux-*/$TERMUX_PKG_VERSION/install-tools libexec/gcc/*-linux-*/${TERMUX_PKG_VERSION}/plugin libexec/gcc/*-linux-*/${TERMUX_PKG_VERSION}/install-tools share/man/man7" |
59f0d218 FF |
19 | |
20 | export AR_FOR_TARGET="$AR" | |
21 | export AS_FOR_TARGET="$AS" | |
22 | export CC_FOR_TARGET="$CC" | |
23 | export CFLAGS_FOR_TARGET="$CFLAGS" | |
24 | export CPP_FOR_TARGET="$CPP" | |
25 | export CPPFLAGS_FOR_TARGET="$CPPFLAGS" | |
26 | export CXXFLAGS_FOR_TARGET="$CXXFLAGS" | |
27 | export CXX_FOR_TARGET="$CXX" | |
28 | export LDFLAGS_FOR_TARGET="$LDFLAGS" | |
29 | export LD_FOR_TARGET="$LD" | |
30 | export PKG_CONFIG_FOR_TARGET="$PKG_CONFIG" | |
31 | export RANLIB_FOR_TARGET="$RANLIB" | |
32 | ||
33 | unset AR | |
34 | unset AS | |
35 | unset CC | |
36 | unset CFLAGS | |
37 | unset CPP | |
38 | unset CPPFLAGS | |
39 | unset CXXFLAGS | |
40 | unset CXX | |
41 | unset LDFLAGS | |
42 | unset LD | |
43 | unset PKG_CONFIG | |
44 | unset RANLIB | |
45 | ||
46 | termux_step_make () { | |
47 | make -j $TERMUX_MAKE_PROCESSES all-gcc | |
48 | make -j $TERMUX_MAKE_PROCESSES all-target-libgcc | |
49 | } | |
50 | ||
51 | termux_step_make_install () { | |
52 | make install-gcc | |
53 | make install-target-libgcc | |
54 | } | |
55 | ||
56 | termux_step_post_make_install () { | |
e7344047 | 57 | if [ $TERMUX_ARCH = "arm" ]; then |
59f0d218 FF |
58 | # Note that moving to $TERMUX_PREFIX/lib/gcc/arm-linux-androideabi/${TERMUX_PKG_VERSION}/ |
59 | # allows compilation but fails to link at runtime | |
60 | mv $TERMUX_PREFIX/lib/armv7-a/hard/libgcc_s* $TERMUX_PREFIX/lib/ | |
61 | fi | |
62 | ||
63 | # Android 5.0 only supports PIE binaries, so build that by default with a specs file: | |
4d685cb6 FF |
64 | local GCC_SPECS=$TERMUX_PREFIX/lib/gcc/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_VERSION/specs |
65 | cp $TERMUX_SCRIPTDIR/termux.spec $GCC_SPECS | |
66 | ||
67 | if [ $TERMUX_ARCH = "i686" ]; then | |
68 | # See https://github.com/termux/termux-packages/issues/3 | |
69 | # and https://github.com/termux/termux-packages/issues/14 | |
70 | cat >> $GCC_SPECS <<HERE | |
71 | ||
72 | *link_emulation: | |
73 | elf_i386 | |
74 | ||
75 | *dynamic_linker: | |
76 | /system/bin/linker | |
77 | HERE | |
78 | fi | |
59f0d218 | 79 | } |