strip remaining libraries for the distribution size
[dragora.git] / recipes / devel / perl / recipe
blobf72b57d28ac6ff93097a07542dac6501bc1e7e80
1 # Build recipe for perl.
3 # Copyright (c) 2016-2017 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 program=perl
18 version=5.24.1
19 release=1
21 tarname=${program}-${version}.tar.gz
23 # Remote source(s)
24 fetch=http://www.cpan.org/src/5.0/$tarname
26 description="
27 Practical Extraction and Report Language.
29 Perl 5 is a highly capable, feature-rich programming language with over
30 29 years of development.  Perl 5 runs on over 100 platforms from
31 portables to mainframes and is suitable for both rapid prototyping
32 and large scale development projects.
34 Perl is a language that combines some of the features of C,
35 sed, awk, and the shell.
37 For more information, visit:  http://www.perl.org
40 homepage=http://www.perl.org
41 license="Artistic | GPLv1"
43 # Source documentation
44 docs="AUTHORS Artistic Changes Copying README README.linux"
45 docsdir="${docdir}/${program}-${version}"
47 build()
49     set -e
51     unpack "${tardir}/$tarname"
53     cd "$srcdir"
55     # Don't use -fstack-protector* (troubles)
56     sed -i 's/-fstack-protector/-fnostack-protector/g' ./Configure
58     ./Configure -de \
59      -Dprefix=/usr \
60      -Dinstallprefix=/usr \
61      -Dsiteprefix=/usr/local \
62      -Dprivlib=/usr/share/perl5 \
63      -Darchlib=/usr/lib${libSuffix}/perl5 \
64      -Dsitelib=/usr/local/share/perl5 \
65      -Dsitearch=/usr/local/lib${libSuffix}/perl5 \
66      -Dvendorprefix=/usr \
67      -Dvendorlib=/usr/share/perl5/vendor_perl \
68      -Dvendorarch=/usr/lib${libSuffix}/perl5/vendor_perl \
69      -Dlibpth="/usr/local/lib${libSuffix} /usr/lib${libSuffix} /lib${libSuffix}" \
70      -Dscriptdir=/usr/bin \
71      -Duseshrplib \
72      -Ubincompat5005 \
73      -Uversiononly \
74      -Duselargefiles \
75      -Dusemymalloc=n \
76      -Dusethreads \
77      -A ldflags="$QILDFLAGS" \
78      -Doptimize="$QICFLAGS" \
79      -Dman1dir="${mandir}/man1" \
80      -Dman3dir="${mandir}/man3" \
81      -Dpager="/usr/bin/less -isR" \
82      BUILD_ZLIB="False" BUILD_BZIP2="0"
84     make -j${jobs} BUILD_ZLIB="False" BUILD_BZIP2="0"
85     make -j${jobs} DESTDIR="$destdir" install
87     # Replace hard links on binaries
88     (
89         cd "${destdir}/usr/bin" || exit 1
90         ln -sf perl${version} perl
91         ln -sf c2ph pstruct
92     )
94     # Replace hard links on manual pages
95     ( cd "${destdir}/${mandir}/man1" && ln -sf c2ph.1 pstruct.1 )
97     # Strip remaining binaries and libraries
98     find "$destdir" -type f | xargs file | \
99      awk '/ELF/ && /executable/ || /shared object/' | \
100       cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
102     find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
103      cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true
105     # Compress info documents deleting index file for the package
106     if test -d "${destdir}/$infodir"
107     then
108         rm -f "${destdir}/${infodir}/dir"
109         lzip -9 "${destdir}/${infodir}"/*
110     fi
112     # Compress and link man pages (if needed)
113     if test -d "${destdir}/$mandir"
114     then
115         (
116             cd "${destdir}/$mandir"
117             find . -type f -exec lzip -9 '{}' +
118             find . -type l | while read -r file
119             do
120                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
121                 rm -- "$file"
122             done
123         )
124     fi
126     # Copy documentation
127     mkdir -p "${destdir}${docsdir}"
128     cp -p $docs "${destdir}${docsdir}"