chiark / gitweb /
perl: Setup File::Spec->tmpdir correctly
[termux-packages] / packages / perl / build.sh
1 # This port uses perl-cross: http://arsv.github.io/perl-cross/index.html
2 TERMUX_PKG_HOMEPAGE=http://www.perl.org/
3 TERMUX_PKG_DESCRIPTION="Capable, feature-rich programming language"
4 # cpan modules will require make:
5 TERMUX_PKG_DEPENDS="make"
6 TERMUX_PKG_VERSION=5.22.1
7 TERMUX_PKG_BUILD_REVISION=2
8 TERMUX_PKG_SRCURL=http://www.cpan.org/src/5.0/perl-${TERMUX_PKG_VERSION}.tar.gz
9 # Does not work with parallell builds:
10 TERMUX_MAKE_PROCESSES=1
11 TERMUX_PKG_RM_AFTER_INSTALL="bin/perl${TERMUX_PKG_VERSION}"
12 TERMUX_PKG_BUILD_IN_SRC="yes"
13
14 termux_step_post_extract_package () {
15         PERLCROSS_VERSION=1.0.2
16         PERLCROSS_FILE=perl-${TERMUX_PKG_VERSION}-cross-${PERLCROSS_VERSION}.tar.gz
17         PERLCROSS_TAR=$TERMUX_PKG_CACHEDIR/$PERLCROSS_FILE
18         test ! -f $PERLCROSS_TAR && curl -o $PERLCROSS_TAR -L https://github.com/arsv/perl-cross/releases/download/$PERLCROSS_VERSION/$PERLCROSS_FILE
19         cd $TERMUX_PKG_SRCDIR
20         tar xf $PERLCROSS_TAR
21         cd perl-${TERMUX_PKG_VERSION}
22         cp -Rf * ../
23
24         # Remove old installation to force fresh:
25         rm -rf $TERMUX_PREFIX/lib/perl5
26 }
27
28 termux_step_configure () {
29         export PATH=$PATH:$TERMUX_STANDALONE_TOOLCHAIN/bin
30
31         ORIG_AR=$AR; unset AR
32         ORIG_AS=$AS; unset AS
33         ORIG_CC=$CC; unset CC
34         ORIG_CXX=$CXX; unset CXX
35         ORIG_CPP=$CPP; unset CPP
36         ORIG_CFLAGS=$CFLAGS; unset CFLAGS
37         ORIG_CPPFLAGS=$CPPFLAGS; unset CPPFLAGS
38         ORIG_CXXFLAGS=$CXXFLAGS; unset CXXFLAGS
39         ORIG_LDFLAGS=$LDFLAGS; unset LDFLAGS
40         ORIG_RANLIB=$RANLIB; unset RANLIB
41         ORIG_LD=$LD; unset LD
42
43         # Since we specify $TERMUX_PREFIX/bin/sh below for the shell
44         # it will be run during the build, so temporarily (removed in
45         # termux_step_post_make_install below) setup symlink:
46         rm -f $TERMUX_PREFIX/bin/sh
47         ln -s /bin/sh $TERMUX_PREFIX/bin/sh
48
49         cd $TERMUX_PKG_BUILDDIR
50         $TERMUX_PKG_SRCDIR/configure \
51                 --target=$TERMUX_HOST_PLATFORM \
52                 -Dsysroot=$TERMUX_STANDALONE_TOOLCHAIN/sysroot \
53                 -Dprefix=$TERMUX_PREFIX \
54                 -Dsh=$TERMUX_PREFIX/bin/sh \
55                 -A ccflags="-specs=$TERMUX_SCRIPTDIR/termux.spec" \
56                 -A ldflags="-specs=$TERMUX_SCRIPTDIR/termux.spec"
57 }
58
59 termux_step_post_make_install () {
60         # Replace hardlinks with symlinks:
61         cd $TERMUX_PREFIX/share/man/man1
62         rm {perlbug.1,c2ph.1}
63         ln -s perlthanks.1 perlbug.1
64         ln -s pstruct.1 c2ph.1
65
66         # Fix reference to termux.spec used only when cross compiling:
67         perl -p -i -e 's@-specs=/home/fornwall/dc/termux.spec@@g' $TERMUX_PREFIX/lib/perl5/*/*-linux/Config_heavy.pl
68
69         # lib/perl5/5.22.0/arm-linux/Config_heavy.pl
70         # Cleanup:
71         rm $TERMUX_PREFIX/bin/sh
72 }