Merge pull request #2 from danielt3/master
[BennuGD.git] / build-static.sh
blob2abb2b6a584b726b12c3f189cfd5e1c26f27b5e9
1 #!/bin/sh
3 # Copyright © 2006-2013 SplinterGU (Fenix/Bennugd)
5 # This file is part of Bennu - Game Development
7 # This software is provided 'as-is', without any express or implied
8 # warranty. In no event will the authors be held liable for any damages
9 # arising from the use of this software.
11 # Permission is granted to anyone to use this software for any purpose,
12 # including commercial applications, and to alter it and redistribute it
13 # freely, subject to the following restrictions:
15 # 1. The origin of this software must not be misrepresented; you must not
16 # claim that you wrote the original software. If you use this software
17 # in a product, an acknowledgment in the product documentation would be
18 # appreciated but is not required.
20 # 2. Altered source versions must be plainly marked as such, and must not be
21 # misrepresented as being the original software.
23 # 3. This notice may not be removed or altered from any source
24 # distribution.
28 TARGET=i386-linux-gnu-static
30 cflags()
32 for i in $(ls -d $PWD/modules/*|grep -v mathi); do if [ -d $i ]; then echo -n " -I$i "; fi; done
35 ldflags()
37 for i in $(find modules -name '*.a'|grep -v mod_mathi); do echo -n "-L$PWD/$(dirname $i) -l$(basename $i .a) "|sed 's/-llib/-l/g'; done
40 echo "#### building necessaries files ####"
42 cd 3rdparty/des-4.04b > /dev/null 2> /dev/null
43 case $1 in
44 release)
45 make -f Makefile.uni clean
47 esac
48 make -f Makefile.uni
49 cd - > /dev/null 2> /dev/null
51 COMMON_LDFLAGS="-L$PWD/3rdparty/des-4.04b -ldes"
52 COMMON_CFLAGS="-I$PWD/3rdparty/des-4.04b -DUSE_LIBDES"
54 EXTRA_STATIC_CFLAGS="$(sdl-config --cflags)"
55 export EXTRA_STATIC_CFLAGS
57 EXTRA_STATIC_LDFLAGS=$(ldflags)
58 export EXTRA_STATIC_LDFLAGS
60 cd core > /dev/null 2> /dev/null
61 ./make-fakedl.sh
63 case $1 in
64 release)
65 ./configure --enable-static COMMON_LDFLAGS="$COMMON_LDFLAGS" COMMON_CFLAGS="$COMMON_CFLAGS" CFLAGS="$COMMON_CFLAGS" && make clean
66 make clean
68 esac
70 cd bgdrtm > /dev/null 2> /dev/null
71 make
72 if [ $? -ne 0 ]; then
73 echo "*** ABORT ***"
74 exit 1
76 cd - > /dev/null 2> /dev/null
78 cd ../modules > /dev/null 2> /dev/null
79 case $1 in
80 release)
81 ./configure --enable-static COMMON_LDFLAGS="$COMMON_LDFLAGS" COMMON_CFLAGS="$COMMON_CFLAGS" CFLAGS="$COMMON_CFLAGS" && make clean
83 esac
84 make
85 if [ $? -ne 0 ]; then
86 echo "*** ABORT ***"
87 exit 1
89 cd .. > /dev/null 2> /dev/null
91 EXTRA_STATIC_CFLAGS="$(cflags) $(sdl-config --cflags)"
93 rm -Rf core/bgdi/src/bgdi core/bgdc/src/bgdc
95 cd core/bgdc > /dev/null 2> /dev/null
96 case $1 in
97 release)
98 make clean
100 esac
101 make
102 if [ $? -ne 0 ]; then
103 echo "*** ABORT ***"
104 exit 1
106 cd - > /dev/null 2> /dev/null
108 cd core/bgdi > /dev/null 2> /dev/null
109 case $1 in
110 release)
111 make clean
113 esac
114 make
115 if [ $? -ne 0 ]; then
116 echo "*** ABORT ***"
117 exit 1
119 cd - > /dev/null 2> /dev/null
121 echo "### Copying files to bin folder ###"
123 mkdir -p bin/$TARGET 2>/dev/null
124 #cp 3rdparty/des-4.04b/libdes.so bin/$TARGET
125 cp core/bgdi/src/bgdi bin/$TARGET
126 cp core/bgdc/src/bgdc bin/$TARGET
128 echo "### Build done! ###"
130 exit 0