'g'o should not miss items in corners anymore
[k8-i-v-a-n.git] / 0build.sh
blobed605782fad25efadf62d04221495a9719a4954f
1 #!/bin/sh
2 # WARNING! SHITTY CODE!
5 defines="-DWIZARD -DLOCAL_SAVES"
6 cflags="-Wno-narrowing -Isrc/felib -m32"
7 cflags="${cflags} -fno-aggressive-loop-optimizations -fno-delete-null-pointer-checks -fno-strict-aliasing -fno-strict-overflow -fwrapv"
8 lflags="-lm"
9 objects=""
10 have_package=""
11 BUILD_DIR="_build"
12 shitdoze="ona"
13 FORCE="ona"
14 linkflags=""
16 while [ $# -gt 0 ]; do
17 if [ "z$1" = "zshitdoze" ]; then
18 shitdoze="tan"
19 elif [ "z$1" = "zforce" ]; then
20 FORCE="tan"
21 else
22 echo "FATAL: unknown arg: $1"
23 exit 1
25 shift
26 done
29 if [ $shitdoze = tan ]; then
30 ARCH="i686-w64-mingw32.static-"
31 BINSUFF=".exe"
32 defines="${defines} -DSHITDOZE"
33 BUILD_DIR="${BUILD_DIR}_shitdoze"
34 linkflags="-Wl,-subsystem,windows"
35 else
36 ARCH=""
37 BINSUFF=""
38 cflags="${cflags} -Wno-misleading-indentation"
41 GCC="${ARCH}gcc"
42 GPP="${ARCH}g++"
43 PKGCONFIG="${ARCH}pkg-config"
46 find_package() {
47 if [ "z$2" != "z" ]; then
48 $PKGCONFIG --silence-errors $1 --atleast-version=$2
49 else
50 $PKGCONFIG --silence-errors $1
52 if [ "$?" = "0" ]; then
53 cflags="${cflags} `$PKGCONFIG $1 --cflags`"
54 lflags="${lflags} `$PKGCONFIG $1 --libs`"
55 #echo "MSG: package '$1' found"
56 have_package="tan"
57 else
58 #echo "MSG: no package '$1'"
59 have_package="ona"
64 # $1: srcdir
65 # $2: srcfile
66 # $3: use gcc if not empty
67 compile() {
68 local obj
69 local xname
70 local gppopt
71 local fstime
72 local fotime
74 obj=`basename $2 .cpp`
75 obj=`basename $obj .c`
76 obj="${obj}.o"
77 obj="${BUILD_DIR}/${obj}"
78 objects="${objects} ${obj}"
79 xname=`basename -s .c "$2"`
80 if [ "z$xname" = "z$2" ]; then
81 echo "C++ $2"
82 gppopt="-std=gnu++14 -fpermissive"
83 else
84 echo "CC $2"
85 gppopt=""
87 if [ $FORCE != tan ]; then
88 if [ -e ${obj} ]; then
89 fstime=`stat '--format=%Y' "$1/$2"`
90 fotime=`stat '--format=%Y' ${obj}`
91 if [ $fotime -ge $fstime ]; then
92 return
96 $GCC -pipe -c -O2 -Wall -Isrc/game ${gppopt} ${defines} ${cflags} -o ${obj} "$1/$2"
97 if [ "$?" != "0" ]; then
98 echo "FATAL: compilation failed!"
99 exit 1
104 link() {
105 echo "LINK ivan${BINSUFF}"
106 #echo "============="
107 #echo "${objects}"
108 #echo "============="
109 #echo "${lflags}"
110 #echo "============="
111 $GPP -pipe -s -o ivan${BINSUFF} ${objects} ${lflags} ${linkflags}
112 if [ "$?" != "0" ]; then
113 echo "FATAL: linking failed!"
114 exit 1
116 ${ARCH}strip -s ivan${BINSUFF}
120 find_package sdl 1.2
121 if [ "$have_package" != "tan" ]; then
122 echo "FATAL: you need SDL development package installed, version 1.2 or above!"
123 exit 1
126 find_package gl
127 if [ "$have_package" = "tan" ]; then
128 echo "MSG: OpenGL renderer enabled"
129 else
130 echo "FATAL: you need OpenGL development package installed!"
131 exit 1
134 find_package libpng 1.6
135 if [ "$have_package" = "tan" ]; then
136 echo "MSG: libpng found"
137 else
138 find_package libpng16 1.6
139 if [ "$have_package" = "tan" ]; then
140 echo "MSG: libpng found"
141 else
142 echo "FATAL: you need libpng v1.6 development package installed!"
143 exit 1
147 find_package SDL_mixer 1.2
148 if [ "$have_package" != "tan" ]; then
149 echo "MSG: no SDL_mixer package found, sound disabled"
150 defines="${defines} -DDISABLE_SOUND"
151 else
152 echo "MSG: sound support enabled"
155 find_package zlib 1.2
156 if [ "$have_package" = "tan" ]; then
157 defines="${defines} -DUSE_ZLIB"
158 echo "MSG: compressed saves enabled"
161 find_package alsa
162 if [ "$have_package" = "tan" ]; then
163 echo "MSG: ALSA silencing enabled"
164 defines="${defines} -DENABLE_ALSA"
167 #echo "CFLAGS: ${cflags}"
168 #echo "DEFINES: ${defines}"
170 mkdir ${BUILD_DIR} 2>/dev/null
172 compile src/felib bitmap.cpp
173 compile src/felib config.cpp
174 compile src/felib feerror.cpp
175 compile src/felib feio.cpp
176 compile src/felib felist.cpp
177 compile src/felib femain.cpp
178 compile src/felib femath.cpp
179 compile src/felib festring.cpp
180 compile src/felib fetime.cpp
181 compile src/felib graphics.cpp
182 compile src/felib hscore.cpp
183 compile src/felib rawbit.cpp
184 compile src/felib fesave.cpp
185 compile src/felib feparse.cpp
186 compile src/felib whandler.cpp
187 compile src/felib regex.c
189 compile src/game ivancommon.cpp
190 compile src/game actset.cpp
191 compile src/game areaset.cpp
192 compile src/game charset.cpp
193 compile src/game command.cpp
194 compile src/game coreset.cpp
195 compile src/game dataset.cpp
196 compile src/game dungeon.cpp
197 compile src/game game.cpp
198 compile src/game godset.cpp
199 compile src/game iconf.cpp
200 compile src/game id.cpp
201 compile src/game igraph.cpp
202 compile src/game itemset.cpp
203 compile src/game levelset.cpp
204 compile src/game main.cpp
205 compile src/game materset.cpp
206 compile src/game message.cpp
207 compile src/game object.cpp
208 compile src/game roomset.cpp
209 compile src/game script.cpp
210 compile src/game slotset.cpp
211 compile src/game trapset.cpp
212 compile src/game wmapset.cpp
213 compile src/game wskill.cpp
216 link