1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2011, 2013, 2014, 2015 Patrick J. Volkerding, Sebeka, MN, USA |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use of this script, with or without modification, is |
---|
7 | # permitted provided that the following conditions are met: |
---|
8 | # |
---|
9 | # 1. Redistributions of this script must retain the above copyright |
---|
10 | # notice, this list of conditions and the following disclaimer. |
---|
11 | # |
---|
12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
22 | |
---|
23 | |
---|
24 | PKGNAM=pcre |
---|
25 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
26 | BUILD=${BUILD:-1} |
---|
27 | |
---|
28 | # Automatically determine the architecture we're building on: |
---|
29 | if [ -z "$ARCH" ]; then |
---|
30 | case "$( uname -m )" in |
---|
31 | i?86) export ARCH=i586 ;; |
---|
32 | arm*) export ARCH=arm ;; |
---|
33 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
34 | *) export ARCH=$( uname -m ) ;; |
---|
35 | esac |
---|
36 | fi |
---|
37 | |
---|
38 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
39 | |
---|
40 | if [ "$ARCH" = "i586" ]; then |
---|
41 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
42 | LIBDIRSUFFIX="" |
---|
43 | elif [ "$ARCH" = "s390" ]; then |
---|
44 | SLKCFLAGS="-O2" |
---|
45 | LIBDIRSUFFIX="" |
---|
46 | elif [ "$ARCH" = "x86_64" ]; then |
---|
47 | SLKCFLAGS="-O2 -fPIC" |
---|
48 | LIBDIRSUFFIX="64" |
---|
49 | else |
---|
50 | SLKCFLAGS="-O2" |
---|
51 | LIBDIRSUFFIX="" |
---|
52 | fi |
---|
53 | |
---|
54 | CWD=$(pwd) |
---|
55 | TMP=${TMP:-/tmp} |
---|
56 | PKG=$TMP/package-pcre |
---|
57 | |
---|
58 | rm -rf $PKG |
---|
59 | mkdir -p $TMP $PKG |
---|
60 | |
---|
61 | cd $TMP |
---|
62 | rm -rf pcre-$VERSION |
---|
63 | tar xvf $CWD/pcre-$VERSION.tar.?z* || exit 1 |
---|
64 | cd pcre-$VERSION |
---|
65 | |
---|
66 | chown -R root:root . |
---|
67 | |
---|
68 | find . \ |
---|
69 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
70 | -exec chmod 755 {} \; -o \ |
---|
71 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
72 | -exec chmod 644 {} \; |
---|
73 | |
---|
74 | CFLAGS="$SLKCFLAGS" \ |
---|
75 | ./configure \ |
---|
76 | --prefix=/usr \ |
---|
77 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
78 | --mandir=/usr/man \ |
---|
79 | --enable-utf8 \ |
---|
80 | --enable-pcre16 \ |
---|
81 | --enable-pcre32 \ |
---|
82 | --enable-jit \ |
---|
83 | --enable-unicode-properties \ |
---|
84 | --enable-pcregrep-libz \ |
---|
85 | --enable-pcregrep-libbz2 \ |
---|
86 | --disable-static \ |
---|
87 | --build=$ARCH-slackware-linux |
---|
88 | |
---|
89 | CFLAGS="$SLKCFLAGS" make $NUMJOBS || make || exit 1 |
---|
90 | make install DESTDIR=$PKG || exit 1 |
---|
91 | |
---|
92 | chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/libpcre.so.* \ |
---|
93 | $PKG/usr/lib${LIBDIRSUFFIX}/libpcreposix.so.* |
---|
94 | |
---|
95 | # Move libraries, as they might be needed before /usr is available: |
---|
96 | mkdir $PKG/lib${LIBDIRSUFFIX} |
---|
97 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
98 | for file in lib*.so.?.* ; do |
---|
99 | mv $file ../../lib${LIBDIRSUFFIX} |
---|
100 | ln -sf ../../lib${LIBDIRSUFFIX}/$file . |
---|
101 | done |
---|
102 | cp -a lib*.so.? ../../lib${LIBDIRSUFFIX} |
---|
103 | ) |
---|
104 | |
---|
105 | ( cd $PKG |
---|
106 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
107 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
108 | find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs strip -g 2> /dev/null || true |
---|
109 | ) |
---|
110 | |
---|
111 | # Compress and if needed symlink the man pages: |
---|
112 | if [ -d $PKG/usr/man ]; then |
---|
113 | ( cd $PKG/usr/man |
---|
114 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
115 | ( cd $manpagedir |
---|
116 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
117 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
118 | rm $eachpage |
---|
119 | done |
---|
120 | gzip -9 *.? |
---|
121 | ) |
---|
122 | done |
---|
123 | ) |
---|
124 | fi |
---|
125 | |
---|
126 | # Eliminate redundant docs: |
---|
127 | rm -rf $PKG/usr/share/doc |
---|
128 | rmdir $PKG/usr/share |
---|
129 | |
---|
130 | mkdir -p $PKG/usr/doc/pcre-$VERSION |
---|
131 | cp -a \ |
---|
132 | AUTHORS COPYING* INSTALL HACKING LICENCE NEWS NON-UNIX-USE README* \ |
---|
133 | $PKG/usr/doc/pcre-$VERSION |
---|
134 | #( cd doc ; cp -a Tech.Notes html $PKG/usr/doc/pcre-$VERSION ) |
---|
135 | |
---|
136 | # If there's a ChangeLog, installing at least part of the recent history |
---|
137 | # is useful, but don't let it get totally out of control: |
---|
138 | if [ -r ChangeLog ]; then |
---|
139 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
140 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
141 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
142 | fi |
---|
143 | |
---|
144 | mkdir -p $PKG/install |
---|
145 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
146 | |
---|
147 | cd $PKG |
---|
148 | /sbin/makepkg -l y -c n $TMP/pcre-$VERSION-$ARCH-$BUILD.txz |
---|
149 | |
---|