now can create win32 portable packages
[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 # zlib 1.2.3
27 #
28 # This script requires a working mingw32 toolchain and other basic tools.
29 # 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
90
91 PACKAGE="boost_1_42_0"
92 VERSION="1.42.0"
93 cd $DESTDIR
94 test ! -f $PACKAGE.tar.bz2 && (wget "http://sourceforge.net/projects/boost/files/boost/$VERSION/$PACKAGE.tar.bz2/download" || die "downloading $PACKAGE")
95 (md5sum -c <<"EOL"
96 7bf3b4eb841b62ffb0ade2b82218ebe6 boost_1_42_0.tar.bz2
97 EOL
98 ) || die "verifying $PACKAGE"
99 rm -rf $PACKAGE
100 tar xjf $PACKAGE.tar.bz2 || die "unpackaging $PACKAGE"
101 (mkdir -p $DESTDIR/$PREFIX/include && \
102 rm -rf $DESTDIR/$PREFIX/include/boost && \
103 cp -r $PACKAGE/boost $DESTDIR/$PREFIX/include/boost) || die "installing $PACKAGE"
104
105
106 PACKAGE="SDL-1.2.14"
107 cd $DESTDIR
108 test ! -f $PACKAGE.tar.gz && (wget "http://www.libsdl.org/release/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
109 (md5sum -c <<"EOL"
110 e52086d1b508fa0b76c52ee30b55bec4 SDL-1.2.14.tar.gz
111 EOL
112 ) || die "verifying $PACKAGE"
113 rm -rf $PACKAGE
114 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
115 cd $PACKAGE
116 ./configure --host=$HOST --prefix=$PREFIX --disable-stdio-redirect || die "configuring $PACKAGE"
117 make $MAKEOPTS || die "making $PACKAGE"
118 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
119
120
121 PACKAGE="libogg-1.1.4"
122 cd $DESTDIR
123 test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/ogg/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
124 (md5sum -c <<"EOL"
125 10200ec22543841d9d1c23e0aed4e5e9 libogg-1.1.4.tar.gz
126 EOL
127 ) || die "verifying $PACKAGE"
128 rm -rf $PACKAGE
129 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
130 cd $PACKAGE
131 ./configure --host=$HOST --prefix=$PREFIX || die "configuring $PACKAGE"
132 make $MAKEOPTS || die "making $PACKAGE"
133 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
134
135
136 PACKAGE="libvorbis-1.2.3"
137 cd $DESTDIR
138 test ! -f $PACKAGE.tar.gz && (wget "http://downloads.xiph.org/releases/vorbis/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
139 (md5sum -c <<"EOL"
140 5aa77f55c0e0aab8eb8ed982335daac8 libvorbis-1.2.3.tar.gz
141 EOL
142 ) || die "verifying $PACKAGE"
143 rm -rf $PACKAGE
144 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
145 cd $PACKAGE
146 ./configure --host=$HOST --prefix=$PREFIX \
147 CPPFLAGS="-I$DESTDIR/$PREFIX/include" \
148 LDFLAGS="-L$DESTDIR/$PREFIX/lib" || die "configuring $PACKAGE"
149 make $MAKEOPTS || die "making $PACKAGE"
150 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
151
152
153 PACKAGE="openal-soft-1.11.753-bin"
154 cd $DESTDIR
155 test ! -f $PACKAGE.zip && (wget "http://kcat.strangesoft.net/$PACKAGE.zip" || die "downloading $PACKAGE")
156 (md5sum -c <<"EOL"
157 20747ce5ca0f902ae082fef15d7b41a5 openal-soft-1.11.753-bin.zip
158 EOL
159 ) || die "verifying $PACKAGE"
160 rm -rf $PACKAGE
161 unzip $PACKAGE.zip || die "unpackaging $PACKAGE"
162 cd $PACKAGE
163 (mkdir -p $DESTDIR/$PREFIX/{lib/pkgconfig,include/AL} && \
164 install -p -m 0644 include/AL/* $DESTDIR/$PREFIX/include/AL/ && \
165 install -p -m 0755 Win32/soft_oal.dll $DESTDIR/$PREFIX/bin/OpenAL32.dll && \
166 install -p -m 0755 openal-info.exe $DESTDIR/$PREFIX/bin/ && \
167 install -p -m 0755 lib/Win32/libOpenAL32.dll.a $DESTDIR/$PREFIX/lib/ && \
168 cat >$DESTDIR/$PREFIX/lib/pkgconfig/openal.pc <<EOL
169 prefix=$PREFIX
170 exec_prefix=\${prefix}
171 libdir=\${exec_prefix}/lib
172 includedir=\${prefix}/include
173
174 Name: OpenAL
175 Description: OpenAL is a cross-platform 3D audio API
176 Requires:
177 Version: 1.11.753
178 Libs: -L\${libdir} -lOpenAL32
179 Cflags: -I\${includedir}
180 EOL
181 ) || die "installing $PACKAGE"
182
183
184 PACKAGE="zlib123-dll"
185 cd $DESTDIR
186 test ! -f $PACKAGE.zip && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
187 (md5sum -c <<"EOL"
188 cc7fa97f9c19386bb701acc79d0abbca zlib123-dll.zip
189 EOL
190 ) || die "verifying $PACKAGE"
191 rm -rf $PACKAGE
192 unzip -d $PACKAGE $PACKAGE.zip || die "unpackaging $PACKAGE"
193 cd $PACKAGE
194 ($HOST-dlltool -d lib/zlib.def -l libzdll.a && \
195 mkdir -p $DESTDIR/$PREFIX/{lib,include} && \
196 install -p -m 0644 include/* $DESTDIR/$PREFIX/include/ && \
197 install -p -m 0755 zlib1.dll $DESTDIR/$PREFIX/bin/ && \
198 install -p -m 0755 libzdll.a $DESTDIR/$PREFIX/lib/ && \
199 cd $DESTDIR/$PREFIX/lib && \
200 ln -fs libzdll.a libz.dll.a) || die "installing $PACKAGE"
201
202
203 PACKAGE="libpng-1.4.1"
204 cd $DESTDIR
205 test ! -f $PACKAGE.tar.gz && (wget "http://prdownloads.sourceforge.net/libpng/$PACKAGE.tar.gz?download" || die "downloading $PACKAGE")
206 (md5sum -c <<"EOL"
207 fa0b2a84733463f90d3ac9f43ccafabc libpng-1.4.1.tar.gz
208 EOL
209 ) || die "verifying $PACKAGE"
210 rm -rf $PACKAGE
211 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
212 cd $PACKAGE
213 ./configure --host=$HOST --prefix=$PREFIX \
214 CPPFLAGS="-I$DESTDIR/$PREFIX/include" \
215 LDFLAGS="-L$DESTDIR/$PREFIX/lib" || die "configuring $PACKAGE"
216 make $MAKEOPTS || die "making $PACKAGE"
217 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
218
219
220 PACKAGE="lua-5.1.4"
221 cd $DESTDIR
222 test ! -f $PACKAGE.tar.gz && (wget "http://www.lua.org/ftp/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
223 (md5sum -c <<"EOL"
224 d0870f2de55d59c1c8419f36e8fac150 lua-5.1.4.tar.gz
225 EOL
226 ) || die "verifying $PACKAGE"
227 rm -rf $PACKAGE
228 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
229 cd $PACKAGE
230 patch -p1 <<"EOL"
231 diff -ur lua-5.1.4.orig/Makefile lua-5.1.4/Makefile
232 --- lua-5.1.4.orig/Makefile 2008-08-11 18:40:48.000000000 -0600
233 +++ lua-5.1.4/Makefile 2010-03-03 23:11:41.673472345 -0700
234 @@ -13,7 +13,8 @@
235 INSTALL_BIN= $(INSTALL_TOP)/bin
236 INSTALL_INC= $(INSTALL_TOP)/include
237 INSTALL_LIB= $(INSTALL_TOP)/lib
238 -INSTALL_MAN= $(INSTALL_TOP)/man/man1
239 +INSTALL_MAN= $(INSTALL_TOP)/share/man/man1
240 +INSTALL_PC= $(INSTALL_LIB)/pkgconfig
241 #
242 # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
243 # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
244 @@ -41,10 +42,11 @@
245 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
246
247 # What to install.
248 -TO_BIN= lua luac
249 +TO_BIN= lua.exe luac.exe lua51.dll
250 TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
251 -TO_LIB= liblua.a
252 +TO_LIB= liblua.a liblua.dll.a
253 TO_MAN= lua.1 luac.1
254 +TO_PC= lua.pc
255
256 # Lua version and release.
257 V= 5.1
258 @@ -59,11 +61,12 @@
259 src/lua test/hello.lua
260
261 install: dummy
262 - cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
263 + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_PC) $(INSTALL_LMOD) $(INSTALL_CMOD)
264 cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
265 cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
266 cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
267 cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
268 + cd etc && $(INSTALL_DATA) $(TO_PC) $(INSTALL_PC)
269
270 ranlib:
271 cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
272 diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
273 --- lua-5.1.4.orig/src/Makefile 2008-01-19 12:37:58.000000000 -0700
274 +++ lua-5.1.4/src/Makefile 2010-03-03 22:45:47.101159854 -0700
275 @@ -105,7 +105,7 @@
276
277 mingw:
278 $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
279 - "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
280 + "AR=$(CC) -shared -Wl,--out-implib,liblua.dll.a -o" "RANLIB=strip --strip-unneeded" \
281 "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
282 $(MAKE) "LUAC_T=luac.exe" luac.exe
283
284 EOL
285 patch -p1 <<EOL
286 diff -ur lua-5.1.4.orig/etc/lua.pc lua-5.1.4/etc/lua.pc
287 --- lua-5.1.4.orig/etc/lua.pc 2008-08-08 06:46:11.000000000 -0600
288 +++ lua-5.1.4/etc/lua.pc 2010-03-03 22:46:49.160471491 -0700
289 @@ -8,7 +8,7 @@
290 R= 5.1.4
291
292 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
293 -prefix= /usr/local
294 +prefix= $PREFIX
295 INSTALL_BIN= \${prefix}/bin
296 INSTALL_INC= \${prefix}/include
297 INSTALL_LIB= \${prefix}/lib
298 EOL
299 make $MAKEOPTS CC="$HOST-gcc" RANLIB="$HOST-ranlib" mingw || die "making $PACKAGE"
300 make INSTALL_TOP=$DESTDIR/$PREFIX install || die "installing $PACKAGE"
301 chmod 755 $DESTDIR/$PREFIX/lib/liblua.dll.a
302
303
304 # libopengl32 and libglu32 pc files
305 mkdir -p $DESTDIR/$PREFIX/lib/pkgconfig
306 cat >$DESTDIR/$PREFIX/lib/pkgconfig/gl.pc <<EOL
307 prefix=$PREFIX
308 exec_prefix=\${prefix}
309 libdir=\${exec_prefix}/lib
310 includedir=\${prefix}/include
311
312 Name: gl
313 Description: OpenGL library
314 Requires:
315 Version:
316 Libs: -L\${libdir} -lopengl32
317 Cflags: -I\${includedir}
318 EOL
319 cat >$DESTDIR/$PREFIX/lib/pkgconfig/glu.pc <<EOL
320 prefix=$PREFIX
321 exec_prefix=\${prefix}
322 libdir=\${exec_prefix}/lib
323 includedir=\${prefix}/include
324
325 Name: glu
326 Description: OpenGL Utility library
327 Requires: gl
328 Version:
329 Libs: -L\${libdir} -lglu32
330 Cflags: -I\${includedir}
331 EOL
332
333
334 cd $DESTDIR/$PREFIX
335 cat >README <<EOL
336
337 Yoink Win32 Dependencies
338 Created `date +"%d %b %Y"`
339
340 These dependencies were generated automatically by makedeps.sh, a script
341 available in the Yoink repository. You should find here all the header
342 files, DLL's, implibs, and pkgconfig files required to build Yoink that are
343 not provided with the standard mingw32 toolchain. Yoink itself can be
344 built with mingw32 and these installed dependencies like this:
345
346 ./configure --host=$HOST --prefix=$PREFIX \\
347 PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
348 make && make package
349
350 These files are licensed such that their general distribution under
351 reasonable conditions is allowable. The copyrights of these binaries go to
352 their various respective owners. Look up the specific library for specific
353 terms and conditions, or see the file COPYING in the Yoink package.
354
355 EOL
356 tar cjf deps.tar.bz2 * || die "archiving dependencies"
357 mv deps.tar.bz2 $DESTDIR/..
358
359 echo "Done!"
360 echo "The dependencies are packed into the archive deps.tar.bz2."
361
This page took 0.046203 seconds and 4 git commands to generate.