aboutsummaryrefslogtreecommitdiff
path: root/patches/sdl/sdl.SlackBuild
blob: 357414cb63327e70e7a097d17019f27344fb3311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
#
# got it from ftp://ftp.slackware.com/pub/slackware/slackware-10.2/source/l/sdl/sdl.SlackBuild
# small changes by rhatto
#

CWD="`pwd`"

if [ -f "/etc/slackbuildrc" ]; then
  source /etc/slackbuildrc
fi

if [ -f "~/.slackbuildrc" ]; then
  source ~/.slackbuildrc
fi

PACKAGE="sdl"
VERSION=${VERSION:=1.2.11}
ARCH=${ARCH:=i486}
BUILD=${BUILD:=1rha}
SRC_DIR=${SRC:=$CWD}
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}

IMAGE=${IMAGE:=1.2.5}
MIXER=${MIXER:=1.2.7}
NET=${NET:=1.2.6}
TTF=${TTF:=2.0.8}

RTOOL="wget"
PACKAGE_EXT="gz"
SRC="SDL-$VERSION.tar.$PACKAGE_EXT"
SRC_image="SDL_image-$IMAGE.tar.gz"
SRC_mixer="SDL_mixer-$MIXER.tar.gz"
SRC_net="SDL_net-$NET.tar.gz"
SRC_ttf="SDL_ttf-$TTF.tar.gz"
URL="http://www.libsdl.org/release/$SRC"
URL_LIB="http://www.libsdl.org/projects"

if [ "$PACKAGE_EXT" == "bz2" ]; then
  tarflag="j"
else
  tarflag="z"
fi

SRC_DIR="$SRC_DIR/$PACKAGE"
TMP="$TMP/$PACKAGE"
mkdir -p $SRC_DIR $TMP

if [ "$RTOOL" == "wget" ]; then
  if [ ! -f "$SRC_DIR/$SRC" ]; then
    wget "$URL/$SRC" -O "$SRC_DIR/$SRC"
  fi
  if [ ! -f "$SRC_DIR/$SRC_image" ]; then  
    wget "$URL_LIB/SDL_image/release/$SRC_image" -O "$SRC_DIR/$SRC_image"
  fi
  if [ ! -f "$SRC_DIR/$SRC_mixer" ]; then  
    wget "$URL_LIB/SDL_mixer/release/$SRC_mixer" -O "$SRC_DIR/$SRC_mixer"
  fi
  if [ ! -f "$SRC_DIR/SDL_net-$NET.tar.gz" ]; then  
    wget "$URL_LIB/SDL_net/release/$SRC_net" -O "$SRC_DIR/$SRC_net"
  fi
  if [ ! -f "$SRC_DIR/SDL_ttf-$TTF.tar.gz" ]; then  
    wget "$URL_LIB/SDL_ttf/release/$SRC_ttf" -O "$SRC_DIR/$SRC_ttf"
  fi
fi

PKG="$TMP/package-$PACKAGE"

LIBDIR=/usr/lib
if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIR=/usr/lib64
fi
rm -rf $PKG
mkdir -p $PKG
cd $TMP
rm -rf sdl-$VERSION
tar xf$tarflag $SRC_DIR/$SRC
cd SDL-$VERSION
if [ "$ARCH" == "x86_64" ]; then
  gzip -dc $CWD/libdir-fix.diff.gz | patch -p1
fi
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-shared=yes \
  --libdir=$LIBDIR \
  --enable-static=no
make -j3
# Spam /, for mixer/image later on:
make install
# install to package:
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/SDL-$VERSION/html
cp -a docs/index.html $PKG/usr/doc/SDL-$VERSION
cp -a docs/html/*.html $PKG/usr/doc/SDL-$VERSION/html
cp -a BUGS COPYING CREDITS INSTALL README* TODO WhatsNew $PKG/usr/doc/SDL-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Add SDL_image:
cd $TMP
rm -rf SDL_image-$IMAGE
tar xf$tarflag $SRC_DIR/$SRC_image
cd SDL_image-$IMAGE
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-shared=yes \
  --libdir=$LIBDIR \
  --enable-static=no
make -j3
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/SDL_image-$IMAGE
cp -a \
  CHANGES COPYING README \
  $PKG/usr/doc/SDL_image-$IMAGE

# Add SDL_mixer:
cd $TMP
rm -rf SDL_mixer-$MIXER
tar xf$tarflag $SRC_DIR/$SRC_mixer
cd SDL_mixer-$MIXER
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-shared=yes \
  --libdir=$LIBDIR \
  --enable-static=no
make -j3
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/SDL_mixer-$MIXER
cp -a \
  CHANGES COPYING README \
  $PKG/usr/doc/SDL_mixer-$MIXER

# Add SDL_net:
cd $TMP
rm -rf SDL_net-$NET
tar xf$tarflag $SRC_DIR/$SRC_net
cd SDL_net-$NET
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-shared=yes \
  --libdir=$LIBDIR \
  --enable-static=no
make -j3
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/SDL_net-$NET
cp -a \
  CHANGES COPYING README \
  $PKG/usr/doc/SDL_net-$NET

# Add SDL_ttf:
cd $TMP
rm -rf SDL_ttf-$TTF
tar xf$tarflag $SRC_DIR/$SRC_ttf
cd SDL_ttf-$TTF
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --enable-shared=yes \
  --libdir=$LIBDIR \
  --enable-static=no
make -j3
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/SDL_ttf-$TTF
cp -a \
  CHANGES COPYING README \
  $PKG/usr/doc/SDL_ttf-$TTF

chown -R root.bin $PKG/usr/bin
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
gzip -9 $PKG/usr/man/man?/*.?

cd $PKG
makepkg -l y -c n $REPOS/sdl-$VERSION-$ARCH-$BUILD.tgz

if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi