-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfigure
executable file
·274 lines (232 loc) · 7.97 KB
/
configure
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/bash
LINEHELPER[0]="--with-gamemod add fersal gamemod support"
LINEHELPER[1]="--debug add -g, maybe more latter"
LINEHELPER[2]="--ndebug no debug mode, for realease"
LINEHELPER[3]="--hell-march optimise for native architecturet"
LINEHELPER[4]="--asan compile with adress sanitazer"
LINEHELPER[5]="--analyzer Use gcc 10+ --fanalyzer"
LINEHELPER[6]="--disable-tcc disable tcc scripting"
LINEHELPER[7]="--disable-s7 disable s7 scripting"
LINEHELPER[8]="--disable-ph7 disable ph7 scripting"
LINEHELPER[9]="--disable-perl disable perl scripting"
LINEHELPER[10]="--system-sdl-mixer use sdl2_mixer from system"
source configure-helper.sh
args=$@
env | grep EMSCRIPTEN_TOOLS >> /dev/null 2>&1
if [ $? == 0 ]; then
args="--disable-tcc --disable-perl"
EMCMAKE=emcmake
EMMAKE=emmake
EMCONFIGURE=emconfigure
LUA_LIB=./lua-git/liblua.a
LUA_CFLAGS=-I./lua-git/
LUA_RULE=lua-git/liblua.a
WERROR="-Wno-unreachable-code-generic-assoc"
JSON_C_LD=json-c-build/libjson-c.a
JSON_C_CFLAGS='-I./json-c -I./json-c-build -I./json-c-git'
JSON_C_RULE=json-c-build/libjson-c.a
EMPORT="-sUSE_SDL_TTF=2 -sUSE_SDL_IMAGE=2 -sUSE_WEBGL2=1"
SDL_MIXER_BUILD_CFLAGS=""
SDL_MIXER_LDFLAGS=""
SDL_MIXER_CFLAGS=""
SDL_MIXER_DEP=""
CMAKE_ARGS="-DEMSCRIPTEN=1 -DDISABLE_GLES_1=1 -DCMAKE_C_FLAGS=\"-fPIC\""
EMCFLAGS="-DUSING_EMCC=1"
WITH_SOUND=2
COMMON_CFLAGS+="-O2"
fi
for arg in $args; do
echo $( echo "$arg" | cut -d '=' -f 1)
if [ "--with-gamemod" = $arg ]; then
COMMON_CFLAGS+="-DGAMEMOD"
fi
if [ "--debug" = $arg ]; then
COMMON_CFLAGS+="-g"
fi
if [ "--analyzer" = $arg ]; then
ANALYZER_FLAG="-fanalyzer"
fi
if [ "--asan" = $arg ]; then
SANITAZERS=1
fi
if [ "--ndebug" = $arg ]; then
COMMON_CFLAGS+="-O2"
WERROR=""
fi
if [ "--hell-march" = $arg ]; then
COMMON_CFLAGS+=" -march=native"
fi
if [ "--system-sdl-mixer" = $arg ]; then
echo "use system sdl2-mixer"
var_add SDL_MIXER_LDFLAGS "`pkg-config --libs SDL2_mixer`"
var_add SDL_MIXER_CFLAGS "`pkg-config --cflags SDL2_mixer`"
var_add SDL_MIXER_DEP ""
fi
if [ "--prefix" = $( echo "$arg" | cut -d '=' -f 1) ]; then
PREFIX=$( echo $arg | cut -f 2 -d '=' )
echo "PREFIX FOUND IT'S: "$PREFIX
fi
if [ "--clone-sdl-mixer" = $arg ]; then
echo "option remove, use git submodule update --init"
fi
if [ "--disable-tcc" = $arg ]; then
TCC_LIB_NAME=""
TCC_LIB_PATH=""
TCC_CFLAGS="-DTCC_ENABLE=0"
fi
if [ "--disable-s7" = $arg ]; then
S7_SOURCE=""
S7_CFLAGS="-DS7_ENABLE=0"
fi
if [ "--disable-ph7" = $arg ]; then
PH7_SOURCE=""
PH7_CFLAGS="-DPH7_ENABLE=0"
fi
if [ "--disable-perl" = $arg ]; then
PERL_LD=" "
PERL_SRC=""
PERL_CFLAGS="-DPERL_ENABLE=0"
fi
done
add_toolchain mingw-i686
function mingw-i686 {
export TCC_LIB_NAME="libtcc.a"
export LIBEXTENSION=dll
export IS_UNIX=0
export YIRL_LINKING="\$(LIBNAME).a"
export BINARY_LINKING="\$(LIBNAME).a"
export SDL_MIXER_LDFLAGS="`pkg-config --libs SDL2_mixer`"
export SDL_MIXER_CFLAGS="`pkg-config --cflags SDL2_mixer`"
export SDL_MIXER_DEP=""
export CMAKE_ARGS="-G 'MSYS Makefiles' -DCMAKE_C_FLAGS=-fPIC"
export SDL_GPU_LDFLAGS="$PWD/sdl-gpu-build/SDL_gpu-MINGW/lib/libSDL2_gpu_s.a"
export SDL_GPU_CFLAGS="$PWD/sdl-gpu-build/SDL_gpu-MINGW/include/"
export WIN_SDL_EXTRA="opus vorbis libmpg123 opusfile vorbisfile libmodplug msmpi fluidsynth"
export WIN_SDL_EXTRA2="-lfreeglut -lopengl32 -lFLAC -lwinmm"
var_add BIN_EXT .exe
}
add_toolchain mingw-64
function mingw-64 {
export TCC_LIB_NAME="libtcc.a"
export LIBEXTENSION=dll
export IS_UNIX=0
export YIRL_LINKING="\$(LIBNAME).a"
export BINARY_LINKING="\$(LIBNAME).a"
export SDL_MIXER_LDFLAGS="`pkg-config --libs SDL2_mixer`"
export SDL_MIXER_CFLAGS="`pkg-config --cflags SDL2_mixer`"
export SDL_MIXER_DEP=""
export CMAKE_ARGS="-G 'MSYS Makefiles' -DCMAKE_C_FLAGS=-fPIC"
export SDL_GPU_LDFLAGS="$PWD/sdl-gpu-build/SDL_gpu-MINGW/lib/libSDL2_gpu_s.a"
export SDL_GPU_CFLAGS="$PWD/sdl-gpu-build/SDL_gpu-MINGW/include/"
export WIN_SDL_EXTRA="opus vorbis libmpg123 opusfile vorbisfile libmodplug msmpi fluidsynth"
export WIN_SDL_EXTRA2="-lfreeglut -lopengl32 -lFLAC -lwinmm"
var_add BIN_EXT .exe
}
add_toolchain ubuntu
function ubuntu {
export LUA_LIB="`pkg-config --libs lua53`"
export LUA_CFLAGS="`pkg-config --cflags lua53`"
}
add_toolchain centos
function centos {
export LUA_LIB="`pkg-config --libs lua-5.3`"
export LUA_CFLAGS="`pkg-config --cflags lua-5.3`"
export CC=clang
}
parse_args $@
var_add SDL_MIXER_ARFLAGS ""
var_add SDL_MIXER_LDFLAGS "$PWD/SDL_mixer/build/.libs/libSDL2_mixer.a"
var_add SDL_MIXER_CFLAGS "-I$PWD/SDL_mixer/include/"
var_add SDL_MIXER_DEP "SDL_mixer/build/.libs/libSDL2_mixer.a"
var_add SDL_GPU_LDFLAGS "$PWD/sdl-gpu-build/SDL_gpu/lib/libSDL2_gpu.a"
var_add SDL_GPU_CFLAGS "$PWD/sdl-gpu-build/SDL_gpu/include/"
var_add WIN_SDL_EXTRA ""
var_add WIN_SDL_EXTRA2 ""
var_add AR ar
var_add PKG_CONFIG pkg-config
var_add SCRIPT_DIR "core/script"
var_add UTIL_DIR "core/util"
var_add WID_DIR "core/widget"
var_add ENTITY_DIR "core/entity"
var_add GAME_DIR "core/game"
var_add SDL_WID_DIR "$WID_DIR/sdl2"
var_add TESTS_DIR "tests/"
var_add DESCRIPTION_DIR "core/description"
var_add BYTECODE_DIR "core/ybytecode"
var_add GEN_LOADER_DIR "core/generic-loader"
var_add LIBEXTENSION so
var_add LDFLAGS_EXT ""
var_add PREFIX "/usr/"
SOUND_DIR="core/sound"
define_add WITH_SOUND 1
if [ $WITH_SOUND -eq 1 ]; then
var_add SOUND_SRC "\"$SOUND_DIR/sdl.c $SOUND_DIR/sound.c\""
define_add defaultSoundDriver sdlDriver
elif [ $WITH_SOUND -eq 2 ]; then
var_add SOUND_SRC "\"$SOUND_DIR/js.c $SOUND_DIR/sound.c\""
define_add defaultSoundDriver jsDriver
else
var_add SOUND_SRC "\"$SOUND_DIR/sound.c\""
define_add defaultSoundDriver noSound
fi
var_add IS_UNIX 1
if [ $IS_UNIX -eq 1 ]; then
var_append LDFLAGS_EXT "-ldl"
fi
var_add SANITAZERS 0
if [ $SANITAZERS -eq 1 ]; then
var_add LIBS_SAN "-lasan -lubsan"
var_add FLAGS_SAN "-fsanitize=leak -fsanitize=undefined"
export YIRL_LINKING="\$(LIBNAME).a"
export BINARY_LINKING="\$(LIBNAME).a"
fi
var_add ANALYZER_FLAG ""
var_add LUA_LIB "\"`pkg-config --libs lua`\""
var_add LUA_CFLAGS "\"`pkg-config --cflags lua`\""
var_add LUA_RULE ""
var_add LUA_GIT "https://github.com/lua/lua.git"
var_add JSON_C_LD "\"`pkg-config --libs json-c`\""
var_add JSON_C_CFLAGS "-DJSON_C_FULL_INCLUDE_PATH=1"
var_add JSON_C_GIT "https://github.com/json-c/json-c.git"
var_add JSON_C_RULE ""
var_add SDL_MIXER_BUILD_CFLAGS "-fPIC"
# emconfigure ./configure CFLAGS="-fPIC -sUSE_MPG123=1 -sUSE_OGG=1 -sUSE_VORBIS=1"
str_define_add YIRL_MODULES_PATH "modules/"
var_add YIRL_INCLUDE_PATH2 $PWD/include/
var_add YIRL_INCLUDE_PATH $YIRL_INCLUDE_PATH2/yirl/
var_add TCC_LIB_PATH $PWD/tinycc/
var_add TCC_LIB_NAME libtcc.a
if [ -z "$TCC_CFLAGS" ]; then
TCC_CFLAGS="-I${TCC_LIB_PATH} -DTCC_ENABLE=1"
fi
echo TCC_CFLAGS=${TCC_CFLAGS} >> config.mk
var_add S7_SOURCE "${SCRIPT_DIR}/s7.c"
var_add S7_CFLAGS "-DS7_ENABLE=1"
var_add PH7_SOURCE "ph7/ph7.c"
var_add PH7_CFLAGS "-DPH7_ENABLE=1"
if [ -z "$PERL_LD" ]; then
PERL_LD="$(perl -MExtUtils::Embed -e ldopts)"
fi
echo PERL_LD=${PERL_LD} >> config.mk
var_add PERL_SRC "${SCRIPT_DIR}/perl.c"
PERL_CFLAGS="$(perl -MExtUtils::Embed -e ccopts) -DPERL_ENABLE=1"
# var_add is a little broken, so I can't output variable
var_add YIRL_LINKING "libyirl.so"
var_add BINARY_LINKING "-lyirl"
var_add WERROR "-Werror"
uname -a | grep -i linux >> /dev/null 2>&1
if [ $? -ne 0 ]; then
var_add HSEARCH_SRC libc_hsearch_r/search_hsearch_r.c
HSEARCH_CFLAGS="-I./libc_hsearch_r/include/ -DINCLUDE_HSEARCH=1"
echo HSEARCH_CFLAGS=${HSEARCH_CFLAGS} >> config.mk
echo HSEARCH_CFLAGS=${HSEARCH_CFLAGS}
fi
echo PERL_CFLAGS=$PERL_CFLAGS
echo PERL_CFLAGS=$PERL_CFLAGS >> config.mk
var_add EMCMAKE ""
var_add EMCONFIGURE ""
var_add EMMAKE ""
var_add EMPORT ""
var_add EMCFLAGS ""
var_add CMAKE_ARGS "-DCMAKE_C_FLAGS=\"-fPIC\""
var_add SDL_MIXER_CFG ""