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