1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2013, 2014 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 | # by: volkerdi@slackware.com |
---|
24 | |
---|
25 | VERSION=1.20.7 |
---|
26 | BUILD=${BUILD:-3} |
---|
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=i486 ;; |
---|
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 | CWD=$(pwd) |
---|
39 | TMP=${TMP:-/tmp} |
---|
40 | PKG=$TMP/package-gpm |
---|
41 | |
---|
42 | if [ "$ARCH" = "i486" ]; then |
---|
43 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
44 | LIBDIRSUFFIX="" |
---|
45 | elif [ "$ARCH" = "s390" ]; then |
---|
46 | SLKCFLAGS="-O2" |
---|
47 | LIBDIRSUFFIX="" |
---|
48 | elif [ "$ARCH" = "x86_64" ]; then |
---|
49 | SLKCFLAGS="-O2 -fPIC" |
---|
50 | LIBDIRSUFFIX="64" |
---|
51 | fi |
---|
52 | |
---|
53 | rm -rf $PKG |
---|
54 | mkdir -p $TMP $PKG |
---|
55 | |
---|
56 | cd $TMP |
---|
57 | rm -rf gpm-$VERSION || exit 1 |
---|
58 | tar xvf $CWD/gpm-$VERSION.tar.xz || exit 1 |
---|
59 | cd gpm-$VERSION || exit 1 |
---|
60 | |
---|
61 | chown -R root:root . |
---|
62 | find . \ |
---|
63 | \( -perm 700 -o -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
64 | -exec chmod 755 {} \; -o \ |
---|
65 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
66 | -exec chmod 644 {} \; |
---|
67 | |
---|
68 | zcat $CWD/gpm-1.20.1-lib-silent.patch.gz | patch -p1 --verbose || exit 1 |
---|
69 | zcat $CWD/gpm-1.20.5-close-fds.patch.gz | patch -p1 --verbose || exit 1 |
---|
70 | zcat $CWD/gpm-1.20.1-select-1.patch.gz | patch -p1 --verbose || exit 1 |
---|
71 | |
---|
72 | sh autogen.sh |
---|
73 | |
---|
74 | # This is *supposed* to prevent linking libgpm.so with -lncurses, |
---|
75 | # but for some reason it doesn't have the desired effect here. |
---|
76 | # Any ideas? The patch is supposed to resolve a circular dependency |
---|
77 | # between libgpm.so and libncurses.so. I don't notice any ill effects |
---|
78 | # here, but perhaps the problem would occur if prelinking was used. |
---|
79 | # Also, ncurses has not shown an ldd link to libgpm for several releases, |
---|
80 | # so perhaps any problem that existed was fixed on their end. |
---|
81 | # NOTE: Since this isn't preventing gpm from linking to ncurses, I'm |
---|
82 | # commenting this patch out until we understand better if it's even |
---|
83 | # useful for anything. Half a patch seems worse than no patch. |
---|
84 | #zcat $CWD/gpm-1.20.1-weak-wgetch.patch.gz | patch -p1 --verbose || exit 1 |
---|
85 | |
---|
86 | # Since we just patched configure.ac, run this again to carry the change |
---|
87 | # into configure: |
---|
88 | autoconf |
---|
89 | |
---|
90 | CFLAGS="$SLKCFLAGS" \ |
---|
91 | ./configure \ |
---|
92 | --prefix=/usr \ |
---|
93 | --sysconfdir=/etc \ |
---|
94 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
95 | --build=$ARCH-slackware-linux |
---|
96 | |
---|
97 | make || exit 1 |
---|
98 | make install DESTDIR=$PKG || exit 1 |
---|
99 | |
---|
100 | # Emacs ships better versions of these: |
---|
101 | rm -rf $PKG/usr/share/emacs |
---|
102 | |
---|
103 | chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/libgpm.so.* |
---|
104 | mkdir $PKG/lib${LIBDIRSUFFIX} |
---|
105 | mv $PKG/usr/lib${LIBDIRSUFFIX}/libgpm.so.* $PKG/lib${LIBDIRSUFFIX} |
---|
106 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libgpm.so |
---|
107 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
108 | ln -sf ../../lib${LIBDIRSUFFIX}/libgpm.so.? libgpm.so ) |
---|
109 | |
---|
110 | zcat $CWD/inputattach.c.gz > inputattach.c |
---|
111 | gcc $SLKCFLAGS -o inputattach inputattach.c || exit |
---|
112 | cat inputattach > $PKG/usr/bin/inputattach |
---|
113 | |
---|
114 | mkdir -p $PKG/etc/rc.d |
---|
115 | |
---|
116 | ( cd conf |
---|
117 | cat gpm-root.conf > $PKG/etc/gpm-root.conf |
---|
118 | cat gpm-syn.conf > $PKG/etc/gpm-syn.conf |
---|
119 | cat gpm-twiddler.conf > $PKG/etc/gpm-twiddler.conf |
---|
120 | ) |
---|
121 | |
---|
122 | mv $PKG/usr/share/{info,man} $PKG/usr |
---|
123 | gzip -9 $PKG/usr/man/man*/*.? |
---|
124 | gzip -9 $PKG/usr/info/* |
---|
125 | |
---|
126 | mkdir -p $PKG/usr/doc/gpm-$VERSION |
---|
127 | cp -a \ |
---|
128 | BUGS COPYING* Changelog Changes MANIFEST README* TODO \ |
---|
129 | doc/{Announce,FAQ,HACK_GPM,README*,changelog} \ |
---|
130 | $PKG/usr/doc/gpm-$VERSION |
---|
131 | |
---|
132 | zcat $CWD/mouseconfig.gz > $PKG/usr/sbin/mouseconfig |
---|
133 | chmod 755 $PKG/usr/bin/* $PKG/usr/sbin/* |
---|
134 | mkdir -p $PKG/var/log/setup |
---|
135 | zcat $CWD/setup.mouse.gz > $PKG/var/log/setup/setup.mouse |
---|
136 | chmod 755 $PKG/var/log/setup/setup.mouse |
---|
137 | |
---|
138 | ( cd $PKG |
---|
139 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
140 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
141 | ) |
---|
142 | |
---|
143 | mkdir -p $PKG/install |
---|
144 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
145 | |
---|
146 | # Build the package: |
---|
147 | cd $PKG |
---|
148 | makepkg -l y -c n $TMP/gpm-$VERSION-$ARCH-$BUILD.txz |
---|
149 | |
---|