new convenient script methods
[chaz/yoink] / win32 / makedeps.sh
1 #!/bin/sh
2
3 #
4 # Yoink
5 # Run this script to download and cross-compile dependencies for win32.
6 #
7 # A directory named deps will be created and/or populated in the current
8 # directory. Upon successful completion (be patient), the compiled
9 # dependencies will be packaged into an archive named deps.tar.bz2 in the
10 # current directory. To install the dependencies, execute this command:
11 #
12 # tar xf deps.tar.bz2 -C $PREFIX
13 #
14 # where $PREFIX is the path to your mingw32 toolchain. If problems occur,
15 # check stdout and stderr for clues. You may be able to easily determine
16 # the problem and make the necessary corrections. These packages will be
17 # downloaded and built:
18 #
19 # SDL 1.2.14
20 # boost 1.42.0 (headers only)
21 # libogg 1.1.4
22 # libpng 1.4.1
23 # libvorbis 1.2.3
24 # lua 5.1.4
25 # openal-soft 1.11.753
26 #
27 # This script requires a working mingw32 toolchain and other basic tools.
28 # You also need zlib which may not have been included with your mingw32
29 # installation; you're on your own for that one. Have fun!
30 #
31 # Example usage:
32 # ./makedeps.sh -H i486-mingw32 -p /usr/i486-mingw32 -m "-j8"
33 #
34 # Bugs: Each time the script is run, all of the dependencies will be
35 # rebuilt, even the ones which were already built successfully.
36 #
37
38 function showhelp()
39 {
40 echo "Download and cross-compile dependencies for win32."
41 echo "Usage: $0 [-h] [-m makeopts] -H host -p prefix"
42 echo ""
43 echo " -H Specify the name of your toolchain, like i486-mingw32."
44 echo " -h Show this help an exit."
45 echo " -m Specify options to be passed to make."
46 echo " -p Specify the path to your toolchain installation."
47 }
48
49 while getopts ":H:hm:p:" opt
50 do
51 case $opt in
52 H)
53 HOST="$OPTARG"
54 ;;
55 h)
56 showhelp
57 exit 0
58 ;;
59 m)
60 MAKEOPTS="$OPTARG"
61 ;;
62 p)
63 PREFIX="$OPTARG"
64 ;;
65 \?)
66 echo "Invalid option: -$OPTARG" >&2
67 showhelp
68 exit 1
69 ;;
70 esac
71 done
72
73 if test x$HOST = x || test x$PREFIX = x
74 then
75 showhelp
76 exit 1
77 fi
78
79
80 function die()
81 {
82 echo "die:" $@
83 exit 1
84 }
85
86 DESTDIR="`pwd`/deps"
87 mkdir -p "$DESTDIR"
88 rm -f "$DESTDIR/README"
89 rm -rf "$DESTDIR/$PREFIX"
90
91
92 PACKAGE="boost_1_42_0"
93 VERSION="1.42.0"
94 cd $DESTDIR
95 test ! -f $PACKAGE.tar.bz2 && (wget "http://sourceforge.net/projects/boost/files/boost/$VERSION/$PACKAGE.tar.bz2/download" || die "downloading $PACKAGE")
96 (md5sum -c <<"EOL"
97 7bf3b4eb841b62ffb0ade2b82218ebe6 boost_1_42_0.tar.bz2
98 EOL
99 ) || die "verifying $PACKAGE"
100 rm -rf $PACKAGE
101 tar xjf $PACKAGE.tar.bz2 || die "unpackaging $PACKAGE"
102 (mkdir -p $DESTDIR/$PREFIX/include && \
103 rm -rf $DESTDIR/$PREFIX/include/boost && \
104 cp -r $PACKAGE/boost $DESTDIR/$PREFIX/include/boost) || die "installing $PACKAGE"
105
106
107 PACKAGE="SDL-1.2.14"
108 cd $DESTDIR
109 test ! -f $PACKAGE.tar.gz && (wget "http://www.libsdl.org/release/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
110 (md5sum -c <<"EOL"
111 e52086d1b508fa0b76c52ee30b55bec4 SDL-1.2.14.tar.gz
112 EOL
113 ) || die "verifying $PACKAGE"
114 rm -rf $PACKAGE
115 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
116 cd $PACKAGE
117 ./configure --host=$HOST --prefix=$PREFIX --disable-stdio-redirect || die "configuring $PACKAGE"
118 make $MAKEOPTS || die "making $PACKAGE"
119 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
120
121
122 PACKAGE="libogg-1.1.4"
123 cd $DESTDIR
124 test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/ogg/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
125 (md5sum -c <<"EOL"
126 10200ec22543841d9d1c23e0aed4e5e9 libogg-1.1.4.tar.gz
127 EOL
128 ) || die "verifying $PACKAGE"
129 rm -rf $PACKAGE
130 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
131 cd $PACKAGE
132 ./configure --host=$HOST --prefix=$PREFIX || die "configuring $PACKAGE"
133 make $MAKEOPTS || die "making $PACKAGE"
134 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
135
136
137 PACKAGE="libvorbis-1.2.3"
138 cd $DESTDIR
139 test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/vorbis/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
140 (md5sum -c <<"EOL"
141 5aa77f55c0e0aab8eb8ed982335daac8 libvorbis-1.2.3.tar.gz
142 EOL
143 ) || die "verifying $PACKAGE"
144 rm -rf $PACKAGE
145 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
146 cd $PACKAGE
147 ./configure --host=$HOST --prefix=$PREFIX \
148 CPPFLAGS="-I$DESTDIR/$PREFIX/include" \
149 LDFLAGS="-L$DESTDIR/$PREFIX/lib" || die "configuring $PACKAGE"
150 make $MAKEOPTS || die "making $PACKAGE"
151 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
152
153
154 PACKAGE="openal-soft-1.11.753-bin"
155 cd $DESTDIR
156 test ! -f $PACKAGE.zip && (wget "http://kcat.strangesoft.net/$PACKAGE.zip" || die "downloading $PACKAGE")
157 (md5sum -c <<"EOL"
158 20747ce5ca0f902ae082fef15d7b41a5 openal-soft-1.11.753-bin.zip
159 EOL
160 ) || die "verifying $PACKAGE"
161 rm -rf $PACKAGE
162 unzip $PACKAGE.zip || die "unpackaging $PACKAGE"
163 cd $PACKAGE
164 (mkdir -p $DESTDIR/$PREFIX/{lib/pkgconfig,include/AL} && \
165 install -p -m 0644 include/AL/* $DESTDIR/$PREFIX/include/AL/ && \
166 install -p -m 0755 Win32/soft_oal.dll $DESTDIR/$PREFIX/bin/OpenAL32.dll && \
167 install -p -m 0755 openal-info.exe $DESTDIR/$PREFIX/bin/ && \
168 install -p -m 0755 lib/Win32/libOpenAL32.dll.a $DESTDIR/$PREFIX/lib/ && \
169 cat >$DESTDIR/$PREFIX/lib/pkgconfig/openal.pc <<EOL
170 prefix=$PREFIX
171 exec_prefix=\${prefix}
172 libdir=\${exec_prefix}/lib
173 includedir=\${prefix}/include
174
175 Name: OpenAL
176 Description: OpenAL is a cross-platform 3D audio API
177 Requires:
178 Version: 1.11.753
179 Libs: -L\${libdir} -lOpenAL32
180 Cflags: -I\${includedir}
181 EOL
182 ) || die "installing $PACKAGE"
183
184
185 #PACKAGE="zlib123-dll"
186 #cd $DESTDIR
187 #test ! -f $PACKAGE.zip && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
188 #(md5sum -c <<"EOL"
189 #cc7fa97f9c19386bb701acc79d0abbca zlib123-dll.zip
190 #EOL
191 #) || die "verifying $PACKAGE"
192 #rm -rf $PACKAGE
193 #unzip -d $PACKAGE $PACKAGE.zip || die "unpackaging $PACKAGE"
194 #cd $PACKAGE
195 #($HOST-dlltool -k -d lib/zlib.def -D zlib1.dll -l libzdll.a && \
196 #$HOST-ranlib libzdll.a && \
197 #mkdir -p $DESTDIR/$PREFIX/{lib,include} && \
198 #install -p -m 0644 include/* $DESTDIR/$PREFIX/include/ && \
199 #install -p -m 0755 zlib1.dll $DESTDIR/$PREFIX/bin/ && \
200 #install -p -m 0755 libzdll.a $DESTDIR/$PREFIX/lib/ && \
201 #cd $DESTDIR/$PREFIX/lib && \
202 #ln -fs libzdll.a libz.dll.a) || die "installing $PACKAGE"
203
204
205 PACKAGE="libpng-1.4.1"
206 cd $DESTDIR
207 test ! -f $PACKAGE.tar.gz && (wget "http://prdownloads.sourceforge.net/libpng/$PACKAGE.tar.gz?download" || die "downloading $PACKAGE")
208 (md5sum -c <<"EOL"
209 fa0b2a84733463f90d3ac9f43ccafabc libpng-1.4.1.tar.gz
210 EOL
211 ) || die "verifying $PACKAGE"
212 rm -rf $PACKAGE
213 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
214 cd $PACKAGE
215 cp scripts/makefile.mingw Makefile && \
216 make $MAKEOPTS prefix="$PREFIX" CC="$HOST-gcc" AR="$HOST-ar" RANLIB="$HOST-ranlib" \
217 ZLIBINC="-I$DESTDIR/$PREFIX/include" \
218 ZLIBLIB="-L$DESTDIR/$PREFIX/lib" libpng.a libpng14.dll || die "making $PACKAGE"
219 make DESTDIR=$DESTDIR install prefix="$PREFIX" || die "installing $PACKAGE"
220
221
222 PACKAGE="lua-5.1.4"
223 cd $DESTDIR
224 test ! -f $PACKAGE.tar.gz && (wget "http://www.lua.org/ftp/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
225 (md5sum -c <<"EOL"
226 d0870f2de55d59c1c8419f36e8fac150 lua-5.1.4.tar.gz
227 EOL
228 ) || die "verifying $PACKAGE"
229 rm -rf $PACKAGE
230 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
231 cd $PACKAGE
232 patch -p1 <<"EOL"
233 diff -ur lua-5.1.4.orig/Makefile lua-5.1.4/Makefile
234 --- lua-5.1.4.orig/Makefile 2008-08-11 18:40:48.000000000 -0600
235 +++ lua-5.1.4/Makefile 2010-03-03 23:11:41.673472345 -0700
236 @@ -13,7 +13,8 @@
237 INSTALL_BIN= $(INSTALL_TOP)/bin
238 INSTALL_INC= $(INSTALL_TOP)/include
239 INSTALL_LIB= $(INSTALL_TOP)/lib
240 -INSTALL_MAN= $(INSTALL_TOP)/man/man1
241 +INSTALL_MAN= $(INSTALL_TOP)/share/man/man1
242 +INSTALL_PC= $(INSTALL_LIB)/pkgconfig
243 #
244 # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
245 # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
246 @@ -41,10 +42,11 @@
247 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
248
249 # What to install.
250 -TO_BIN= lua luac
251 +TO_BIN= lua.exe luac.exe lua51.dll
252 TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
253 -TO_LIB= liblua.a
254 +TO_LIB= liblua.a liblua.dll.a
255 TO_MAN= lua.1 luac.1
256 +TO_PC= lua.pc
257
258 # Lua version and release.
259 V= 5.1
260 @@ -59,11 +61,12 @@
261 src/lua test/hello.lua
262
263 install: dummy
264 - cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
265 + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_PC) $(INSTALL_LMOD) $(INSTALL_CMOD)
266 cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
267 cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
268 cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
269 cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
270 + cd etc && $(INSTALL_DATA) $(TO_PC) $(INSTALL_PC)
271
272 ranlib:
273 cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
274 diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
275 --- lua-5.1.4.orig/src/Makefile 2008-01-19 12:37:58.000000000 -0700
276 +++ lua-5.1.4/src/Makefile 2010-03-03 22:45:47.101159854 -0700
277 @@ -105,7 +105,7 @@
278
279 mingw:
280 $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
281 - "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
282 + "AR=$(CC) -shared -Wl,--out-implib,liblua.dll.a -o" "RANLIB=strip --strip-unneeded" \
283 "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
284 $(MAKE) "LUAC_T=luac.exe" luac.exe
285
286 EOL
287 patch -p1 <<EOL
288 diff -ur lua-5.1.4.orig/etc/lua.pc lua-5.1.4/etc/lua.pc
289 --- lua-5.1.4.orig/etc/lua.pc 2008-08-08 06:46:11.000000000 -0600
290 +++ lua-5.1.4/etc/lua.pc 2010-03-03 22:46:49.160471491 -0700
291 @@ -8,7 +8,7 @@
292 R= 5.1.4
293
294 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
295 -prefix= /usr/local
296 +prefix= $PREFIX
297 INSTALL_BIN= \${prefix}/bin
298 INSTALL_INC= \${prefix}/include
299 INSTALL_LIB= \${prefix}/lib
300 EOL
301 make $MAKEOPTS CC="$HOST-gcc" RANLIB="$HOST-ranlib" mingw || die "making $PACKAGE"
302 make INSTALL_TOP=$DESTDIR/$PREFIX install || die "installing $PACKAGE"
303 chmod 755 $DESTDIR/$PREFIX/lib/liblua.dll.a
304
305
306 # libopengl32 and libglu32 pc files
307 mkdir -p $DESTDIR/$PREFIX/lib/pkgconfig
308 cat >$DESTDIR/$PREFIX/lib/pkgconfig/gl.pc <<EOL
309 prefix=$PREFIX
310 exec_prefix=\${prefix}
311 libdir=\${exec_prefix}/lib
312 includedir=\${prefix}/include
313
314 Name: gl
315 Description: OpenGL library
316 Requires:
317 Version:
318 Libs: -L\${libdir} -lopengl32
319 Cflags: -I\${includedir}
320 EOL
321 cat >$DESTDIR/$PREFIX/lib/pkgconfig/glu.pc <<EOL
322 prefix=$PREFIX
323 exec_prefix=\${prefix}
324 libdir=\${exec_prefix}/lib
325 includedir=\${prefix}/include
326
327 Name: glu
328 Description: OpenGL Utility library
329 Requires: gl
330 Version:
331 Libs: -L\${libdir} -lglu32
332 Cflags: -I\${includedir}
333 EOL
334
335
336 cd $DESTDIR/$PREFIX
337 cat >README <<EOL
338
339 Yoink Win32 Dependencies
340 Created `date +"%d %b %Y"`
341
342 These dependencies were generated automatically by makedeps.sh, a script
343 available in the Yoink repository. You should find here all the header
344 files, DLL's, implibs, and pkgconfig files required to build Yoink that are
345 not provided with the standard mingw32 toolchain. Yoink itself can be
346 built with mingw32 and these installed dependencies like this:
347
348 ./configure --host=$HOST --prefix=$PREFIX \\
349 PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
350 make && make package
351
352 These files are licensed such that their general distribution under
353 reasonable conditions is allowable. The copyrights of these binaries go to
354 their various respective owners. Look up the specific library for specific
355 terms and conditions, or see the file COPYING in the Yoink package.
356
357 EOL
358 tar cjf deps.tar.bz2 * || die "archiving dependencies"
359 mv deps.tar.bz2 $DESTDIR/..
360
361 echo "Done!"
362 echo "The dependencies are packed into the archive deps.tar.bz2."
363
This page took 0.046973 seconds and 4 git commands to generate.