1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2010, 2011, 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 | |
---|
24 | # I really do not like to package source under a different name than upstream, |
---|
25 | # but in this case there is a media player frontend that is well-known as |
---|
26 | # mpc already, and it appears that other projects are packaging this mpc as |
---|
27 | # libmpc instead. It is probably best to follow suit. |
---|
28 | SRCNAM=mpc |
---|
29 | PKGNAM=libmpc |
---|
30 | VERSION=${VERSION:-$(echo $SRCNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
31 | BUILD=${BUILD:-1} |
---|
32 | |
---|
33 | # Automatically determine the architecture we're building on: |
---|
34 | if [ -z "$ARCH" ]; then |
---|
35 | case "$( uname -m )" in |
---|
36 | i?86) export ARCH=i486 ;; |
---|
37 | arm*) export ARCH=arm ;; |
---|
38 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
39 | *) export ARCH=$( uname -m ) ;; |
---|
40 | esac |
---|
41 | fi |
---|
42 | |
---|
43 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
44 | |
---|
45 | if [ "$ARCH" = "i486" ]; then |
---|
46 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
47 | LIBDIRSUFFIX="" |
---|
48 | elif [ "$ARCH" = "s390" ]; then |
---|
49 | SLKCFLAGS="-O2" |
---|
50 | LIBDIRSUFFIX="" |
---|
51 | elif [ "$ARCH" = "x86_64" ]; then |
---|
52 | SLKCFLAGS="-O2 -fPIC" |
---|
53 | LIBDIRSUFFIX="64" |
---|
54 | else |
---|
55 | SLKCFLAGS="-O2" |
---|
56 | LIBDIRSUFFIX="" |
---|
57 | fi |
---|
58 | |
---|
59 | CWD=$(pwd) |
---|
60 | TMP=${TMP:-/tmp} |
---|
61 | PKG=$TMP/package-$SRCNAM |
---|
62 | rm -rf $PKG |
---|
63 | mkdir -p $TMP $PKG |
---|
64 | |
---|
65 | cd $TMP |
---|
66 | rm -rf $SRCNAM-$VERSION |
---|
67 | tar xvf $CWD/$SRCNAM-$VERSION.tar.?z* || exit 1 |
---|
68 | cd $SRCNAM-$VERSION |
---|
69 | chown -R root:root . |
---|
70 | |
---|
71 | CFLAGS="$SLKCFLAGS" \ |
---|
72 | ./configure \ |
---|
73 | --prefix=/usr \ |
---|
74 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
75 | --infodir=/usr/info \ |
---|
76 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
77 | --enable-static=yes \ |
---|
78 | --enable-shared=yes \ |
---|
79 | --build=$ARCH-slackware-linux |
---|
80 | |
---|
81 | make $NUMJOBS || make || exit 1 |
---|
82 | make install DESTDIR=$PKG || exit 1 |
---|
83 | |
---|
84 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
85 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
86 | |
---|
87 | # Hardly a savings doing this... |
---|
88 | #strip -g $PKG/usr/lib${LIBDIRSUFFIX}/*.a |
---|
89 | |
---|
90 | rm -f $PKG/usr/info/dir |
---|
91 | gzip -9 $PKG/usr/info/* |
---|
92 | |
---|
93 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
94 | cp -a \ |
---|
95 | AUTHORS COPYING* INSTALL NEWS README* TODO \ |
---|
96 | $PKG/usr/doc/$PKGNAM-$VERSION |
---|
97 | |
---|
98 | # If there's a ChangeLog, installing at least part of the recent history |
---|
99 | # is useful, but don't let it get totally out of control: |
---|
100 | if [ -r ChangeLog ]; then |
---|
101 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
102 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
103 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
104 | fi |
---|
105 | |
---|
106 | mkdir -p $PKG/install |
---|
107 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
108 | |
---|
109 | cd $PKG |
---|
110 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-${VERSION}-${ARCH}-${BUILD}.txz |
---|
111 | |
---|