win32 dependency script to build without syncing
[chaz/yoink] / win32 / tools / makedeps.sh
1 #!/bin/bash
2
3 # Download and cross-compile dependencies for Yoink. This script requires
4 # bash, wget, md5sum, unzip, tar, patch, make and install. Have fun!
5
6 HOST="i686-mingw32"
7 PREFIX="/usr/$HOST/usr"
8
9 MAKEOPTS="-j8"
10
11 #####
12
13 function die()
14 {
15 echo "die:" $@
16 exit 1
17 }
18
19 DESTDIR="`pwd`/deps"
20 mkdir -p $DESTDIR
21 rm -f $DESTDIR/README
22
23
24 PACKAGE="boost_1_42_0"
25 VERSION="1.42.0"
26 cd $DESTDIR
27 [[ ! -f $PACKAGE.tar.bz2 ]] && (wget "http://sourceforge.net/projects/boost/files/boost/$VERSION/$PACKAGE.tar.bz2/download" || die "downloading $PACKAGE")
28 (md5sum -c <<"EOL"
29 7bf3b4eb841b62ffb0ade2b82218ebe6 boost_1_42_0.tar.bz2
30 EOL
31 ) || die "verifying $PACKAGE"
32 rm -rf $PACKAGE
33 tar xjf $PACKAGE.tar.bz2 || die "unpackaging $PACKAGE"
34 (mkdir -p $DESTDIR/$PREFIX/include && \
35 rm -rf $DESTDIR/$PREFIX/include/boost && \
36 cp -r $PACKAGE/boost $DESTDIR/$PREFIX/include/boost) || die "installing $PACKAGE"
37
38
39 PACKAGE="SDL-1.2.14"
40 cd $DESTDIR
41 [[ ! -f $PACKAGE.tar.gz ]] && (wget "http://www.libsdl.org/release/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
42 (md5sum -c <<"EOL"
43 e52086d1b508fa0b76c52ee30b55bec4 SDL-1.2.14.tar.gz
44 EOL
45 ) || die "verifying $PACKAGE"
46 rm -rf $PACKAGE
47 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
48 cd $PACKAGE
49 ./configure --host=$HOST --prefix=$PREFIX --disable-stdio-redirect || die "configuring $PACKAGE"
50 make $MAKEOPTS || die "making $PACKAGE"
51 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
52
53
54 PACKAGE="libogg-1.1.4"
55 cd $DESTDIR
56 [[ ! -f $PACKAGE.tar.gz ]] && (wget "http://downloads.xiph.org/releases/ogg/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
57 (md5sum -c <<"EOL"
58 10200ec22543841d9d1c23e0aed4e5e9 libogg-1.1.4.tar.gz
59 EOL
60 ) || die "verifying $PACKAGE"
61 rm -rf $PACKAGE
62 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
63 cd $PACKAGE
64 ./configure --host=$HOST --prefix=$PREFIX || die "configuring $PACKAGE"
65 make $MAKEOPTS || die "making $PACKAGE"
66 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
67
68
69 PACKAGE="libvorbis-1.2.3"
70 cd $DESTDIR
71 [[ ! -f $PACKAGE.tar.gz ]] && (wget "http://downloads.xiph.org/releases/vorbis/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
72 (md5sum -c <<"EOL"
73 5aa77f55c0e0aab8eb8ed982335daac8 libvorbis-1.2.3.tar.gz
74 EOL
75 ) || die "verifying $PACKAGE"
76 rm -rf $PACKAGE
77 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
78 cd $PACKAGE
79 ./configure --host=$HOST --prefix=$PREFIX \
80 CPPFLAGS="-I$DESTDIR/$PREFIX/include" \
81 LDFLAGS="-L$DESTDIR/$PREFIX/lib" || die "configuring $PACKAGE"
82 make $MAKEOPTS || die "making $PACKAGE"
83 make DESTDIR=$DESTDIR install || die "installing $PACKAGE"
84
85
86 PACKAGE="openal-soft-1.11.753-bin"
87 cd $DESTDIR
88 [[ ! -f $PACKAGE.zip ]] && (wget "http://kcat.strangesoft.net/$PACKAGE.zip" || die "downloading $PACKAGE")
89 (md5sum -c <<"EOL"
90 20747ce5ca0f902ae082fef15d7b41a5 openal-soft-1.11.753-bin.zip
91 EOL
92 ) || die "verifying $PACKAGE"
93 rm -rf $PACKAGE
94 unzip $PACKAGE.zip || die "unpackaging $PACKAGE"
95 cd $PACKAGE
96 (mkdir -p $DESTDIR/$PREFIX/{lib/pkgconfig,include/AL} && \
97 install -p -m 0644 include/AL/* $DESTDIR/$PREFIX/include/AL/ && \
98 install -p -m 0755 Win32/soft_oal.dll $DESTDIR/$PREFIX/bin/OpenAL32.dll && \
99 install -p -m 0755 openal-info.exe $DESTDIR/$PREFIX/bin/ && \
100 install -p -m 0755 lib/Win32/libOpenAL32.dll.a $DESTDIR/$PREFIX/lib/ && \
101 cat >$DESTDIR/$PREFIX/lib/pkgconfig/openal.pc <<EOL
102 prefix=$PREFIX
103 exec_prefix=\${prefix}
104 libdir=\${exec_prefix}/lib
105 includedir=\${prefix}/include
106
107 Name: OpenAL
108 Description: OpenAL is a cross-platform 3D audio API
109 Requires:
110 Version: 1.11.753
111 Libs: -L\${libdir} -lOpenAL32
112 Cflags: -I\${includedir}
113 EOL
114 ) || die "installing $PACKAGE"
115
116
117 PACKAGE="zlib123-dll"
118 cd $DESTDIR
119 [[ ! -f $PACKAGE.zip ]] && (wget "http://www.zlib.net/$PACKAGE.zip" || die "downloading $PACKAGE")
120 (md5sum -c <<"EOL"
121 cc7fa97f9c19386bb701acc79d0abbca zlib123-dll.zip
122 EOL
123 ) || die "verifying $PACKAGE"
124 rm -rf $PACKAGE
125 unzip -d $PACKAGE $PACKAGE.zip || die "unpackaging $PACKAGE"
126 cd $PACKAGE
127 ($HOST-dlltool -d lib/zlib.def -l libzdll.a && \
128 mkdir -p $DESTDIR/$PREFIX/{lib,include} && \
129 install -p -m 0644 include/* $DESTDIR/$PREFIX/include/ && \
130 install -p -m 0755 zlib1.dll $DESTDIR/$PREFIX/bin/ && \
131 install -p -m 0755 libzdll.a $DESTDIR/$PREFIX/lib/ && \
132 cd $DESTDIR/$PREFIX/lib && \
133 ln -fs libzdll.a libz.dll.a) || die "installing $PACKAGE"
134
135
136 PACKAGE="libpng-1.4.1"
137 cd $DESTDIR
138 [[ ! -f $PACKAGE.tar.gz ]] && (wget "http://prdownloads.sourceforge.net/libpng/$PACKAGE.tar.gz?download" || die "downloading $PACKAGE")
139 (md5sum -c <<"EOL"
140 fa0b2a84733463f90d3ac9f43ccafabc libpng-1.4.1.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="lua-5.1.4"
154 cd $DESTDIR
155 [[ ! -f $PACKAGE.tar.gz ]] && (wget "http://www.lua.org/ftp/$PACKAGE.tar.gz" || die "downloading $PACKAGE")
156 (md5sum -c <<"EOL"
157 d0870f2de55d59c1c8419f36e8fac150 lua-5.1.4.tar.gz
158 EOL
159 ) || die "verifying $PACKAGE"
160 rm -rf $PACKAGE
161 tar xzf $PACKAGE.tar.gz || die "unpackaging $PACKAGE"
162 cd $PACKAGE
163 patch -p1 <<"EOL"
164 diff -ur lua-5.1.4.orig/Makefile lua-5.1.4/Makefile
165 --- lua-5.1.4.orig/Makefile 2008-08-11 18:40:48.000000000 -0600
166 +++ lua-5.1.4/Makefile 2010-03-03 23:11:41.673472345 -0700
167 @@ -13,7 +13,8 @@
168 INSTALL_BIN= $(INSTALL_TOP)/bin
169 INSTALL_INC= $(INSTALL_TOP)/include
170 INSTALL_LIB= $(INSTALL_TOP)/lib
171 -INSTALL_MAN= $(INSTALL_TOP)/man/man1
172 +INSTALL_MAN= $(INSTALL_TOP)/share/man/man1
173 +INSTALL_PC= $(INSTALL_LIB)/pkgconfig
174 #
175 # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
176 # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
177 @@ -41,10 +42,11 @@
178 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
179
180 # What to install.
181 -TO_BIN= lua luac
182 +TO_BIN= lua.exe luac.exe
183 TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
184 -TO_LIB= liblua.a
185 +TO_LIB= liblua.a liblua.dll.a
186 TO_MAN= lua.1 luac.1
187 +TO_PC= lua.pc
188
189 # Lua version and release.
190 V= 5.1
191 @@ -59,11 +61,12 @@
192 src/lua test/hello.lua
193
194 install: dummy
195 - cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
196 + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_PC) $(INSTALL_LMOD) $(INSTALL_CMOD)
197 cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
198 cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
199 cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
200 cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
201 + cd etc && $(INSTALL_DATA) $(TO_PC) $(INSTALL_PC)
202
203 ranlib:
204 cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
205 diff -ur lua-5.1.4.orig/src/Makefile lua-5.1.4/src/Makefile
206 --- lua-5.1.4.orig/src/Makefile 2008-01-19 12:37:58.000000000 -0700
207 +++ lua-5.1.4/src/Makefile 2010-03-03 22:45:47.101159854 -0700
208 @@ -105,7 +105,7 @@
209
210 mingw:
211 $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
212 - "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
213 + "AR=$(CC) -shared -Wl,--out-implib,liblua.dll.a -o" "RANLIB=strip --strip-unneeded" \
214 "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
215 $(MAKE) "LUAC_T=luac.exe" luac.exe
216
217 EOL
218 patch -p1 <<EOL
219 diff -ur lua-5.1.4.orig/etc/lua.pc lua-5.1.4/etc/lua.pc
220 --- lua-5.1.4.orig/etc/lua.pc 2008-08-08 06:46:11.000000000 -0600
221 +++ lua-5.1.4/etc/lua.pc 2010-03-03 22:46:49.160471491 -0700
222 @@ -8,7 +8,7 @@
223 R= 5.1.4
224
225 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
226 -prefix= /usr/local
227 +prefix= $PREFIX
228 INSTALL_BIN= \${prefix}/bin
229 INSTALL_INC= \${prefix}/include
230 INSTALL_LIB= \${prefix}/lib
231 EOL
232 make $MAKEOPTS CC="$HOST-gcc" RANLIB="$HOST-ranlib" mingw || die "making $PACKAGE"
233 make INSTALL_TOP=$DESTDIR/$PREFIX install || die "installing $PACKAGE"
234 chmod 755 $DESTDIR/$PREFIX/lib/liblua.dll.a
235
236
237 # libopengl32 and libglu32 pc files
238 mkdir -p $DESTDIR/$PREFIX/lib/pkgconfig
239 cat >$DESTDIR/$PREFIX/lib/pkgconfig/gl.pc <<EOL
240 prefix=$PREFIX
241 exec_prefix=\${prefix}
242 libdir=\${exec_prefix}/lib
243 includedir=\${prefix}/include
244
245 Name: gl
246 Description: OpenGL library
247 Requires:
248 Version:
249 Libs: -L\${libdir} -lopengl32
250 Cflags: -I\${includedir}
251 EOL
252 cat >$DESTDIR/$PREFIX/lib/pkgconfig/glu.pc <<EOL
253 prefix=$PREFIX
254 exec_prefix=\${prefix}
255 libdir=\${exec_prefix}/lib
256 includedir=\${prefix}/include
257
258 Name: glu
259 Description: OpenGL Utility library
260 Requires: gl
261 Version:
262 Libs: -L\${libdir} -lglu32
263 Cflags: -I\${includedir}
264 EOL
265
266
267 cd $DESTDIR/$PREFIX
268 cat >README <<EOL
269
270 Yoink Win32 Dependencies
271 Created `date +"%d %b %Y"`
272
273 These dependencies were generated automatically by makedeps.sh, a script
274 available in the Yoink repository. You should find here all the header
275 files, DLL's, implibs, and pkgconfig files required to build Yoink that are
276 not provided with the standard mingw32 toolchain. Yoink itself can be
277 built with mingw32 and these installed dependencies like this:
278
279 ./configure --host=$HOST --prefix=$PREFIX \\
280 PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
281 make && make package
282
283 These files are licensed such that their general distribution under
284 reasonable conditions is allowable. The copyrights of these binaries go to
285 their various respective owners. Look up the specific library for specific
286 terms and conditions, or see the file COPYING in the Yoink package.
287
288 EOL
289 tar cjf deps.tar.bz2 * || die "archiving dependencies"
290 mv deps.tar.bz2 $DESTDIR/..
291
292 echo "Done!"
293 echo "The dependencies are packed into the archive deps.tar.bz2."
294
This page took 0.044192 seconds and 4 git commands to generate.