1 | #!/bin/sh |
---|
2 | # Copyright 2006, 2007, 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA |
---|
3 | # All rights reserved. |
---|
4 | # |
---|
5 | # Redistribution and use of this script, with or without modification, is |
---|
6 | # permitted provided that the following conditions are met: |
---|
7 | # |
---|
8 | # 1. Redistributions of this script must retain the above copyright |
---|
9 | # notice, this list of conditions and the following disclaimer. |
---|
10 | # |
---|
11 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
12 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
13 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
14 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
15 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
16 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
17 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
18 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
19 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
20 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
21 | |
---|
22 | |
---|
23 | PKGNAM=bc |
---|
24 | VERSION=${VERSION:-1.06.95} |
---|
25 | BUILD=${BUILD:-3} |
---|
26 | |
---|
27 | # Automatically determine the architecture we're building on: |
---|
28 | if [ -z "$ARCH" ]; then |
---|
29 | case "$( uname -m )" in |
---|
30 | i?86) export ARCH=i486 ;; |
---|
31 | arm*) export ARCH=arm ;; |
---|
32 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
33 | *) export ARCH=$( uname -m ) ;; |
---|
34 | esac |
---|
35 | fi |
---|
36 | |
---|
37 | CWD=$(pwd) |
---|
38 | TMP=${TMP:-/tmp} |
---|
39 | PKG=$TMP/package-${PKGNAM} |
---|
40 | rm -rf $PKG |
---|
41 | mkdir -p $TMP $PKG |
---|
42 | |
---|
43 | if [ "$ARCH" = "i486" ]; then |
---|
44 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
45 | elif [ "$ARCH" = "s390" ]; then |
---|
46 | SLKCFLAGS="-O2" |
---|
47 | elif [ "$ARCH" = "x86_64" ]; then |
---|
48 | SLKCFLAGS="-O2 -fPIC" |
---|
49 | else |
---|
50 | SLKCFLAGS="-O2" |
---|
51 | fi |
---|
52 | |
---|
53 | cd $TMP |
---|
54 | rm -rf ${PKGNAM}-${VERSION} |
---|
55 | tar xjvf $CWD/${PKGNAM}-$VERSION.tar.bz2 || exit 1 |
---|
56 | cd ${PKGNAM}-$VERSION |
---|
57 | |
---|
58 | # Make sure ownerships and permissions are sane: |
---|
59 | chown -R root:root . |
---|
60 | find . \ |
---|
61 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
62 | -exec chmod 755 {} \; -o \ |
---|
63 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
64 | -exec chmod 644 {} \; |
---|
65 | |
---|
66 | # Configure: |
---|
67 | CFLAGS="$SLKCFLAGS" \ |
---|
68 | ./configure \ |
---|
69 | --prefix=/usr \ |
---|
70 | --sysconfdir=/etc \ |
---|
71 | --mandir=/usr/man \ |
---|
72 | --with-readline \ |
---|
73 | --program-prefix= \ |
---|
74 | --program-suffix= \ |
---|
75 | --build=$ARCH-slackware-linux |
---|
76 | |
---|
77 | # Build and install: |
---|
78 | make -j4 || exit 1 |
---|
79 | make install DESTDIR=$PKG || exit 1 |
---|
80 | |
---|
81 | # Strip binaries: |
---|
82 | ( cd $PKG |
---|
83 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
84 | #find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
85 | ) |
---|
86 | |
---|
87 | # Compress and link manpages, if any: |
---|
88 | if [ -d $PKG/usr/man ]; then |
---|
89 | ( cd $PKG/usr/man |
---|
90 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
91 | ( cd $manpagedir |
---|
92 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
93 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
94 | rm $eachpage |
---|
95 | done |
---|
96 | gzip -9 *.* |
---|
97 | ) |
---|
98 | done |
---|
99 | ) |
---|
100 | fi |
---|
101 | |
---|
102 | # Compress info files, if any: |
---|
103 | if [ -d $PKG/usr/info ]; then |
---|
104 | ( cd $PKG/usr/info |
---|
105 | rm -f dir |
---|
106 | gzip -9 * |
---|
107 | ) |
---|
108 | fi |
---|
109 | |
---|
110 | # Add a documentation directory: |
---|
111 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
112 | cp -a \ |
---|
113 | AUTHORS COPYING COPYING.LIB Examples FAQ INSTALL NEWS README Test \ |
---|
114 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
115 | |
---|
116 | mkdir -p $PKG/install |
---|
117 | #zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
118 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
119 | |
---|
120 | cd $PKG |
---|
121 | makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz |
---|
122 | |
---|