1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2015 Patrick J. Volkerding, Sebeka, Minnesota, 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 | # Thanks to Jan Rafaj for contributing the original reference script. |
---|
24 | # Remark: - The GSS support (for secure RPC) is currently not built, as it |
---|
25 | # Remark: requires Kerberos 5 libraries. If you need it, install |
---|
26 | # Remark: Kerberos 5, remove '--disable-gssapi' from the configure flags |
---|
27 | # Remark: below and rebuild. |
---|
28 | |
---|
29 | PKGNAM=libtirpc |
---|
30 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
31 | BUILD=${BUILD:-2} |
---|
32 | |
---|
33 | # To build with GSS support (requires Kerberos 5 libraries), pass any value |
---|
34 | # other than "NO" in the environment, or edit the line below: |
---|
35 | WITH_GSS=${WITH_GSS:-NO} |
---|
36 | |
---|
37 | # Automatically determine the architecture we're building on: |
---|
38 | if [ -z "$ARCH" ]; then |
---|
39 | case "$(uname -m)" in |
---|
40 | i?86) ARCH=i586 ;; |
---|
41 | arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; |
---|
42 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
43 | *) ARCH=$(uname -m) ;; |
---|
44 | esac |
---|
45 | export ARCH |
---|
46 | fi |
---|
47 | |
---|
48 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
49 | |
---|
50 | if [ "$ARCH" = "i386" ]; then |
---|
51 | SLKCFLAGS="-O2 -march=i386 -mcpu=i686" |
---|
52 | LIBDIRSUFFIX="" |
---|
53 | elif [ "$ARCH" = "i486" ]; then |
---|
54 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
55 | LIBDIRSUFFIX="" |
---|
56 | elif [ "$ARCH" = "i586" ]; then |
---|
57 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
58 | LIBDIRSUFFIX="" |
---|
59 | elif [ "$ARCH" = "i686" ]; then |
---|
60 | SLKCFLAGS="-O2 -march=i686" |
---|
61 | LIBDIRSUFFIX="" |
---|
62 | elif [ "$ARCH" = "s390" ]; then |
---|
63 | SLKCFLAGS="-O2" |
---|
64 | LIBDIRSUFFIX="" |
---|
65 | elif [ "$ARCH" = "x86_64" ]; then |
---|
66 | SLKCFLAGS="-O2 -fPIC" |
---|
67 | LIBDIRSUFFIX="64" |
---|
68 | elif [ "$ARCH" = "armv7hl" ]; then |
---|
69 | SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16" |
---|
70 | LIBDIRSUFFIX="" |
---|
71 | else |
---|
72 | SLKCFLAGS="-O2" |
---|
73 | LIBDIRSUFFIX="" |
---|
74 | fi |
---|
75 | |
---|
76 | CWD=$(pwd) |
---|
77 | TMP=${TMP:-/tmp} |
---|
78 | PKG=$TMP/package-$PKGNAM |
---|
79 | |
---|
80 | rm -rf $PKG |
---|
81 | mkdir -p $TMP $PKG |
---|
82 | |
---|
83 | cd $TMP |
---|
84 | rm -rf $PKGNAM-$VERSION |
---|
85 | tar xvf $CWD/$PKGNAM-$VERSION.tar.?z* || exit 1 |
---|
86 | cd $PKGNAM-$VERSION |
---|
87 | |
---|
88 | chown -R root:root . |
---|
89 | find . \ |
---|
90 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
91 | -exec chmod 755 {} \; -o \ |
---|
92 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
93 | -exec chmod 644 {} \; |
---|
94 | |
---|
95 | # Set proper GSS option: |
---|
96 | if [ "$WITH_GSS" = "NO" ]; then |
---|
97 | GSSAPI="--disable-gssapi" |
---|
98 | else |
---|
99 | GSSAPI="--enable-gssapi" |
---|
100 | fi |
---|
101 | |
---|
102 | # Configure: |
---|
103 | CFLAGS="$SLKCFLAGS" \ |
---|
104 | ./configure \ |
---|
105 | --prefix=/usr \ |
---|
106 | --sysconfdir=/etc \ |
---|
107 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
108 | --mandir=/usr/man \ |
---|
109 | --disable-static \ |
---|
110 | $GSSAPI \ |
---|
111 | --build=$ARCH-slackware-linux |
---|
112 | |
---|
113 | # Build and install: |
---|
114 | make $NUMJOBS || make || exit 1 |
---|
115 | make install DESTDIR=$PKG || exit 1 |
---|
116 | |
---|
117 | # Make etc/netconfig file a .new: |
---|
118 | mv $PKG/etc/netconfig $PKG/etc/netconfig.new |
---|
119 | |
---|
120 | # Move library to /lib${LIBDIRSUFFIX} as it might be needed to mount /usr: |
---|
121 | mkdir $PKG/lib${LIBDIRSUFFIX} |
---|
122 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
123 | for file in lib*.so.?.* ; do |
---|
124 | mv $file ../../lib${LIBDIRSUFFIX} |
---|
125 | ln -sf ../../lib${LIBDIRSUFFIX}/$file . |
---|
126 | done |
---|
127 | cp -a lib*.so.? ../../lib${LIBDIRSUFFIX} |
---|
128 | ) |
---|
129 | |
---|
130 | # Strip binaries: |
---|
131 | ( cd $PKG |
---|
132 | #find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
133 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
134 | ) |
---|
135 | |
---|
136 | # Add a documentation directory: |
---|
137 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
138 | cp -a \ |
---|
139 | AUTHORS COPYING* NEWS README* THANKS TODO \ |
---|
140 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
141 | |
---|
142 | # Don't use .3t man page suffix: |
---|
143 | if [ -d $PKG/usr/man/man3 ]; then |
---|
144 | ( cd $PKG/usr/man/man3 |
---|
145 | for file in *.3t ; do |
---|
146 | mv $file $(basename $file .3t).3 |
---|
147 | done |
---|
148 | ) |
---|
149 | fi |
---|
150 | |
---|
151 | # Compress manual pages: |
---|
152 | find $PKG/usr/man -type f -exec gzip -9 {} \; |
---|
153 | for i in $( find $PKG/usr/man -type l ) ; do |
---|
154 | ln -s $( readlink $i ).gz $i.gz |
---|
155 | rm $i |
---|
156 | done |
---|
157 | |
---|
158 | mkdir -p $PKG/install |
---|
159 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
160 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
161 | |
---|
162 | cd $PKG |
---|
163 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|
164 | |
---|