1 | #!/bin/bash |
---|
2 | |
---|
3 | # Slackware build script for pcre2 |
---|
4 | |
---|
5 | # Copyright 2016-2017 Larry Hajali <larryhaja[at]gmail[dot]com> |
---|
6 | # Copyright 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA |
---|
7 | # All rights reserved. |
---|
8 | # |
---|
9 | # Redistribution and use of this script, with or without modification, is |
---|
10 | # permitted provided that the following conditions are met: |
---|
11 | # |
---|
12 | # 1. Redistributions of this script must retain the above copyright |
---|
13 | # notice, this list of conditions and the following disclaimer. |
---|
14 | # |
---|
15 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
---|
16 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
17 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
18 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
19 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
20 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
21 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
22 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
23 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
24 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
25 | |
---|
26 | cd $(dirname $0) ; CWD=$(pwd) |
---|
27 | |
---|
28 | PKGNAM=pcre2 |
---|
29 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
30 | BUILD=${BUILD:-1} |
---|
31 | |
---|
32 | if [ -z "$ARCH" ]; then |
---|
33 | case "$( uname -m )" in |
---|
34 | i?86) ARCH=i586 ;; |
---|
35 | arm*) ARCH=arm ;; |
---|
36 | *) ARCH=$( uname -m ) ;; |
---|
37 | esac |
---|
38 | fi |
---|
39 | |
---|
40 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
41 | # the name of the created package would be, and then exit. This information |
---|
42 | # could be useful to other scripts. |
---|
43 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
44 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
45 | exit 0 |
---|
46 | fi |
---|
47 | |
---|
48 | NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
49 | |
---|
50 | TMP=${TMP:-/tmp} |
---|
51 | PKG=$TMP/package-$PKGNAM |
---|
52 | |
---|
53 | if [ "$ARCH" = "i586" ]; then |
---|
54 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
55 | LIBDIRSUFFIX="" |
---|
56 | elif [ "$ARCH" = "i686" ]; then |
---|
57 | SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
58 | LIBDIRSUFFIX="" |
---|
59 | elif [ "$ARCH" = "x86_64" ]; then |
---|
60 | SLKCFLAGS="-O2 -fPIC" |
---|
61 | LIBDIRSUFFIX="64" |
---|
62 | else |
---|
63 | SLKCFLAGS="-O2" |
---|
64 | LIBDIRSUFFIX="" |
---|
65 | fi |
---|
66 | |
---|
67 | rm -rf $PKG |
---|
68 | mkdir -p $TMP $PKG |
---|
69 | cd $TMP |
---|
70 | rm -rf $PKGNAM-$VERSION |
---|
71 | tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1 |
---|
72 | cd $PKGNAM-$VERSION || exit 1 |
---|
73 | chown -R root:root . |
---|
74 | find -L . \ |
---|
75 | \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ |
---|
76 | -o -perm 511 \) -exec chmod 755 {} \+ -o \ |
---|
77 | \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ |
---|
78 | -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+ |
---|
79 | |
---|
80 | CFLAGS="$SLKCFLAGS" \ |
---|
81 | CXXFLAGS="$SLKCFLAGS" \ |
---|
82 | ./configure \ |
---|
83 | --prefix=/usr \ |
---|
84 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
85 | --mandir=/usr/man \ |
---|
86 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
87 | --disable-silent-rules \ |
---|
88 | --enable-static=no \ |
---|
89 | --enable-pcre2-16 \ |
---|
90 | --enable-pcre2-32 \ |
---|
91 | --enable-jit \ |
---|
92 | --enable-pcre2grep-libz \ |
---|
93 | --enable-pcre2grep-libbz2 \ |
---|
94 | --enable-pcre2test-libreadline \ |
---|
95 | --build=$ARCH-slackware-linux || exit 1 |
---|
96 | |
---|
97 | make $NUMJOBS || make || exit 1 |
---|
98 | make install DESTDIR=$PKG || exit 1 |
---|
99 | |
---|
100 | # Don't ship .la files: |
---|
101 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la |
---|
102 | |
---|
103 | find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
104 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true |
---|
105 | |
---|
106 | # Compress and link manpages, if any: |
---|
107 | if [ -d $PKG/usr/man ]; then |
---|
108 | ( cd $PKG/usr/man |
---|
109 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
110 | ( cd $manpagedir |
---|
111 | for eachpage in $( find . -type l -maxdepth 1 | grep -v '\.gz$') ; do |
---|
112 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
113 | rm $eachpage |
---|
114 | done |
---|
115 | gzip -9 *.? |
---|
116 | ) |
---|
117 | done |
---|
118 | ) |
---|
119 | fi |
---|
120 | |
---|
121 | # Add a documentation directory: |
---|
122 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
123 | cp -a \ |
---|
124 | AUTHORS COPYING* ChangeLog HACKING INSTALL LICENCE* NEWS* NON-AUTOTOOLS-BUILD README* \ |
---|
125 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
126 | |
---|
127 | # If there's a ChangeLog, installing at least part of the recent history |
---|
128 | # is useful, but don't let it get totally out of control: |
---|
129 | if [ -r ChangeLog ]; then |
---|
130 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
131 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
132 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
133 | fi |
---|
134 | |
---|
135 | mkdir -p $PKG/install |
---|
136 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
137 | |
---|
138 | cd $PKG |
---|
139 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|