summaryrefslogtreecommitdiff
path: root/mingw-get-libs.sh (plain)
blob: a265f84047d5016d7b125ea71919bc080de63f6c
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
#!/bin/bash
if [ "$1" != "--with-jit" ] && [ "$1" != "--without-jit" ]; then echo "
This script installs required libraries that aren't in MinGW by default.

First, update both MinGW and MSYS to the most recent stable version. Really.

If you don't have wget, go to http://users.ugent.be/~bpuype/wget/ and put
wget.exe into /mingw/bin (or somewhere else in your \$PATH). wget will then
be used to download all the other libraries.

You can install LuaJIT instead of Lua. If you want to, run:
  ./mingw-get-libs.sh --with-jit
Otherwise, run:
  ./mingw-get-libs.sh --without-jit
"; exit 1
fi

echo ' *** PART 1. system check '
if ! type file >/dev/null 2>/dev/null; then
  echo "ERROR: Old MSYS version."
  echo "Download an update from http://sourceforge.net/projects/mingw/"
  exit 1
fi
if [ "$BASH_VERSION" ] && [ "${BASH_VERSION:0:1}"  -lt 3 ]; then
  echo "ERROR: Old MSYS version."
  echo "Download an update from http://sourceforge.net/projects/mingw/"
  exit 1
fi
echo "MSYS version up to date."
if ! type wget >/dev/null 2>/dev/null; then
  echo "ERROR: wget not found. Please download wget.exe from"
  echo "http://users.ugent.be/~bpuype/wget/ and place it in /mingw/bin."
  exit 1
fi
echo "wget found."

set -e

mkdir -p mingwlibs
cd mingwlibs

dowget () {
  local link; local -a tmp; tmp=($2); [ -f "${tmp[0]}" ] && export "$1=${tmp[0]}" && return
  if [ "$4" ]; then
    link="`wget -nv -O- "$3" | grep -i href".*$4" | sed q |
      sed 's/^.*href=\("[^"]*\|'"'[^']*"'\).*$/\1/I'`"
  else link=.$3; fi
  wget -B "$3" -i- <<<"${link:1}" || exit 1
  tmp=($2); export "$1=${tmp[0]}"
}

echo $'\n *** PART 2. unzip \n'
if ! type unzip &>/dev/null; then
  dowget unzipm "unz600xn.exe" ftp://ftp.info-zip.org/pub/infozip/win32/unz600xn.exe
  ./unz600xn.exe unzip.exe
  echo "*** Installing unzip in /mingw/bin/"
  install unzip.exe /mingw/bin/unzip.exe
fi

echo $'\n *** PART 3. SDL \n'
dowget sdl "SDL-devel-*-mingw32*.t*" http://libsdl.org/download-1.2.php mingw32
rm -rf SDL-*/; tar xf "$sdl"
cd SDL-*/; make install-sdl prefix=/mingw; cd ..

echo $'\n *** PART 4. SDL_image \n'
dowget sdl_image "SDL_image-devel-*.zip" http://libsdl.org/projects/SDL_image/ devel.*zip
rm -rf SDL_image-*/; unzip "$sdl_image"
cp -r SDL_image-*/include /mingw/; cp SDL_image-*/lib/*.dll /mingw/bin/

echo $'\n *** PART 5. SDL_mixer \n'
dowget sdl_mixer "SDL_mixer-devel-*.zip" http://libsdl.org/projects/SDL_mixer/ devel.*zip
rm -rf SDL_mixer-*/; unzip "$sdl_mixer"
cp -r SDL_mixer-*/include /mingw/; cp SDL_mixer-*/lib/*.dll /mingw/bin/

echo $'\n *** PART 6. zlib \n'
dowget zlib "zlib*-dll.zip" http://www.zlib.net/zlib123-dll.zip
rm -rf zlib; mkdir zlib; cd zlib
unzip ../"$zlib"
cp -r include lib /mingw/; cp *.dll /mingw/bin/
cd ..

echo $'\n *** PART 7. freetype \n'
# gnuwin32's freetype-config isn't usable under MinGW
dowget freetype "freetype-2*.tar.gz" "http://savannah.nongnu.org/download/freetype/?C=M;O=D" "freetype-2.*gz[^.]"
rm -rf freetype-*/; tar xf "$freetype"
cd freetype-*/; ./configure --prefix=/mingw; make; make install; cd ..

if [ "$1" == "--with-jit" ]; then
  echo $'\n *** PART 8. LuaJIT \n' 
  dowget luajit "LuaJIT*.zip" http://luajit.org/download.html LuaJIT.*zip
  rm -rf LuaJIT-*/; unzip "$luajit"; cd LuaJIT-*/
  make generic
  echo "*** Installing LuaJIT in /mingw and /mingw/share/lua/jit/"
  install src/luajit.exe /mingw/bin/lua.exe
  install src/{lua.h,luaconf.h,lualib.h,lauxlib.h} /mingw/include/
  install src/liblua.a /mingw/lib/
  mkdir -p /mingw/share/lua/jit
  install jit/*.lua /mingw/share/lua/jit/
  cd ..
else
  echo $'\n *** PART 8. Lua \n'
  dowget luasrc "lua-*.tar.gz" http://lua.org/download.html ftp/lua-
  rm -rf lua-*/; tar xf "$luasrc"; cd lua-*/
  make generic
  mkdir -p /mingw/man/man1 /mingw/share/lua /mingw/lib/lua
  install src/{lua.exe,luac.exe} /mingw/bin/
  install src/{lua.h,luaconf.h,lualib.h,lauxlib.h} /mingw/include/
  install src/liblua.a /mingw/lib/
  install doc/{lua.1,luac.1} /mingw/man/man1/
fi

echo $'\n *** FINISHED \n'