-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ac
More file actions
321 lines (282 loc) · 10 KB
/
Copy pathconfigure.ac
File metadata and controls
321 lines (282 loc) · 10 KB
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
dnl configure.ac for blua (Lua 5.5 + raylib + inih)
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([blua], [5.5.0], [], [blua])
AC_CONFIG_SRCDIR([src/lua.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
dnl Clear default CFLAGS set by automake; we build our own below.
: ${CFLAGS=""}
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AM_PROG_AR
dnl Check for C99 support (Lua requires it)
AX_CHECK_COMPILE_FLAG([-std=gnu99], [CFLAGS="$CFLAGS -std=gnu99"])
dnl ==========================================================================
dnl Compiler optimization flag detection
dnl These are optional flags that may not be available on older compilers.
dnl Start with clean CFLAGS and build up from scratch.
dnl ==========================================================================
: ${CFLAGS=""}
CFLAGS=$(echo "$CFLAGS" | sed 's/-g//;s/-O[0-9]*//g;s/^ *//;s/ *$//')
dnl ==========================================================================
dnl Compiler optimization flag detection
dnl These are optional flags that may not be available on older compilers.
dnl ==========================================================================
dnl Check for -Ofast (GCC 4.6+)
AC_MSG_CHECKING([whether to use -Ofast])
AC_ARG_ENABLE([ofast],
[AS_HELP_STRING([--enable-ofast], [use -Ofast optimization @<:@default=auto@:>@])],
[enable_ofast=$enableval],
[enable_ofast=auto])
if test "x$enable_ofast" = "xyes" -o "x$enable_ofast" = "xauto"; then
AX_CHECK_COMPILE_FLAG([-Ofast], [
if test "x$enable_ofast" = "xyes"; then
CFLAGS="$CFLAGS -Ofast"
AC_MSG_RESULT([yes])
else
CFLAGS="$CFLAGS -Ofast"
AC_MSG_RESULT([yes (auto)])
fi
], [
if test "x$enable_ofast" = "xyes"; then
AC_MSG_ERROR([-Ofast is not supported by this compiler])
fi
AC_MSG_RESULT([no (not supported)])
])
else
AC_MSG_RESULT([no (disabled)])
fi
dnl Check for -flto (GCC 4.5+, Clang 3.0+)
AC_MSG_CHECKING([whether to use -flto])
AC_ARG_ENABLE([lto],
[AS_HELP_STRING([--enable-lto], [use link-time optimization @<:@default=auto@:>@])],
[enable_lto=$enableval],
[enable_lto=auto])
if test "x$enable_lto" = "xyes" -o "x$enable_lto" = "xauto"; then
AX_CHECK_COMPILE_FLAG([-flto], [
AX_CHECK_LINK_FLAG([-flto], [
if test "x$enable_lto" = "xyes"; then
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
AC_MSG_RESULT([yes])
else
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
AC_MSG_RESULT([yes (auto)])
fi
], [
if test "x$enable_lto" = "xyes"; then
AC_MSG_ERROR([-flto is not supported by the linker])
fi
AC_MSG_RESULT([no (linker does not support it)])
])
], [
if test "x$enable_lto" = "xyes"; then
AC_MSG_ERROR([-flto is not supported by this compiler])
fi
AC_MSG_RESULT([no (not supported)])
])
else
AC_MSG_RESULT([no (disabled)])
fi
dnl Check for -mtune (GCC supports this on all platforms)
dnl On x86, -march=native is more common; on ARM, -mtune=native works.
dnl We try -march first, then fall back to -mtune.
AC_MSG_CHECKING([for CPU optimization flag])
AC_ARG_WITH([cpu],
[AS_HELP_STRING([--with-cpu=MODEL],
[set CPU model for -march or -mtune @<:@default=native@:>@])],
[cpu_model=$withval],
[cpu_model=native])
cpu_flag=""
if test "x$cpu_model" != "xno"; then
AX_CHECK_COMPILE_FLAG([-march=$cpu_model], [cpu_flag="-march=$cpu_model"], [
AX_CHECK_COMPILE_FLAG([-mtune=$cpu_model], [cpu_flag="-mtune=$cpu_model"])
])
fi
if test -n "$cpu_flag"; then
AC_MSG_RESULT([$cpu_flag])
CFLAGS="$CFLAGS $cpu_flag"
else
AC_MSG_RESULT([none available])
fi
dnl Only add -O3 as baseline if no -O flag was already added
case "$CFLAGS" in
*-O*) ;;
*) AX_CHECK_COMPILE_FLAG([-O3], [CFLAGS="$CFLAGS -O3"]) ;;
esac
dnl Check for common warning flags
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow], [CFLAGS="$CFLAGS -Wno-stringop-overflow"])
dnl Checks for libraries.
AC_CHECK_LIB([m], [sin])
AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_LIB([pthread], [pthread_create])
dnl Define Linux mode for Lua (LUA_USE_LINUX implies LUA_USE_POSIX in luaconf.h).
AC_DEFINE([LUA_USE_LINUX], [1], [Enable Linux-specific Lua features])
dnl Check for raylib
AC_ARG_ENABLE([raylib],
[AS_HELP_STRING([--disable-raylib], [disable raylib support])],
[enable_raylib=$enableval],
[enable_raylib=yes])
AC_ARG_WITH([raylib],
[AS_HELP_STRING([--with-raylib=DIR], [path to raylib installation @<:@default=auto@:>@])],
[raylib_prefix=$withval],
[raylib_prefix=""])
AC_ARG_ENABLE([raylib-kms],
[AS_HELP_STRING([--enable-raylib-kms], [use DRM/KMS backend instead of desktop GL @<:@default=no@:>@])],
[enable_raylib_kms=$enableval],
[enable_raylib_kms=no])
if test "x$enable_raylib" = "xyes"; then
dnl Save original CFLAGS/LIBS/LDFLAGS
raylib_save_CFLAGS="$CFLAGS"
raylib_save_LIBS="$LIBS"
raylib_save_LDFLAGS="$LDFLAGS"
dnl Build candidate flags for raylib search
raylib_CFLAGS=""
raylib_LDFLAGS=""
dnl If a path was given, add it to search paths
if test -n "$raylib_prefix"; then
raylib_CFLAGS="-I$raylib_prefix/include"
raylib_LDFLAGS="-L$raylib_prefix/lib -L$raylib_prefix/lib64"
fi
dnl Also try common locations (skip X11 paths for KMS mode)
if test "x$enable_raylib_kms" = "xno"; then
_raylib_search_dirs="/usr/local /usr /usr/X11R7"
else
_raylib_search_dirs="/usr/local /usr"
fi
for _libdir in $_raylib_search_dirs; do
if test "x$raylib_prefix" != "x$_libdir"; then
if test -d "$_libdir/include" -a -z "$(echo $raylib_CFLAGS | grep $_libdir/include)"; then
raylib_CFLAGS="$raylib_CFLAGS -I$_libdir/include"
fi
if test -d "$_libdir/lib64"; then
raylib_LDFLAGS="$raylib_LDFLAGS -L$_libdir/lib64"
fi
if test -d "$_libdir/lib"; then
raylib_LDFLAGS="$raylib_LDFLAGS -L$_libdir/lib"
fi
fi
done
dnl Temporarily add raylib flags for the check
CFLAGS="$CFLAGS $raylib_CFLAGS"
LDFLAGS="$LDFLAGS $raylib_LDFLAGS"
if test "x$enable_raylib_kms" = "xyes"; then
dnl DRM/KMS backend: -lraylib -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl -latomic
raylib_test_LIBS="-lraylib -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl -latomic"
else
dnl Desktop GL backend: -lraylib -lm -lpthread -lrt -ldl -lX11
raylib_test_LIBS="-lraylib -lm -lpthread -lrt -ldl -lX11"
fi
LIBS="$raylib_test_LIBS $LIBS"
AC_CHECK_LIB([raylib], [InitWindow], [
if test "x$enable_raylib_kms" = "xyes"; then
LIBS="-lraylib -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl -latomic"
else
LIBS="-lraylib -lm -lpthread -lrt -ldl -lX11"
AC_CHECK_LIB([glfw], [glfwInit], [LIBS="$LIBS -lglfw"], [], [-lraylib -lm -lpthread -lrt -ldl -lX11])
AC_CHECK_LIB([GL], [glBegin], [LIBS="$LIBS -lGL"], [], [-lraylib -lm -lpthread -lrt -ldl -lX11 -lglfw])
fi
CFLAGS="$raylib_save_CFLAGS $raylib_CFLAGS"
LDFLAGS="$raylib_save_LDFLAGS $raylib_LDFLAGS"
AC_DEFINE([_RAYLIB], [1], [Enable raylib support])
if test "x$enable_raylib_kms" = "xyes"; then
AC_DEFINE([PLATFORM_DRM], [1], [Use DRM/KMS platform for raylib])
fi
if test -n "$raylib_prefix"; then
AC_MSG_RESULT([using raylib from $raylib_prefix])
fi
], [
AC_MSG_WARN([raylib not found, building without raylib support])
enable_raylib=no
CFLAGS="$raylib_save_CFLAGS"
LIBS="$raylib_save_LIBS"
LDFLAGS="$raylib_save_LDFLAGS"
])
fi
AM_CONDITIONAL([HAVE_RAYLIB], [test "x$enable_raylib" = "xyes"])
dnl Check for FLTK
AC_ARG_ENABLE([fltk],
[AS_HELP_STRING([--disable-fltk], [disable FLTK support @<:@default=yes@:>@])],
[enable_fltk=$enableval],
[enable_fltk=yes])
AC_ARG_WITH([fltk],
[AS_HELP_STRING([--with-fltk=PATH], [path to fltk-config @<:@default=auto@:>@])],
[fltk_config=$withval],
[fltk_config=""])
if test "x$enable_fltk" = "xyes"; then
dnl Find fltk-config
if test -n "$fltk_config"; then
FLTK_CONFIG="$fltk_config"
else
AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no])
fi
if test "x$FLTK_CONFIG" = "xno"; then
AC_MSG_ERROR([fltk-config not found. Install FLTK development files or use --with-fltk=PATH])
fi
AC_MSG_CHECKING([FLTK version])
FLTK_VERSION=$($FLTK_CONFIG --version)
AC_MSG_RESULT([$FLTK_VERSION])
dnl Get flags from fltk-config
FLTK_CXXFLAGS=$($FLTK_CONFIG --cxxflags)
FLTK_LIBS=$($FLTK_CONFIG --ldflags)
AC_SUBST([FLTK_CXXFLAGS])
AC_SUBST([FLTK_LIBS])
AC_DEFINE([_FLTK], [1], [Enable FLTK support])
fi
AM_CONDITIONAL([HAVE_FLTK], [test "x$enable_fltk" = "xyes"])
dnl Check for ncurses
AC_ARG_ENABLE([curses],
[AS_HELP_STRING([--disable-curses], [disable ncurses support @<:@default=yes@:>@])],
[enable_curses=$enableval],
[enable_curses=yes])
if test "x$enable_curses" = "xyes"; then
AC_CHECK_LIB([ncurses], [initscr], [
AC_DEFINE([_NCURSES], [1], [Enable ncurses support])
AC_CHECK_HEADERS([ncurses.h])
], [
AC_MSG_WARN([ncurses not found, building without ncurses support])
enable_curses=no
])
fi
AM_CONDITIONAL([HAVE_NCURSES], [test "x$enable_curses" = "xyes"])
dnl Output files.
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
dnl Print summary
if test "x$enable_raylib" = "xyes"; then
if test "x$enable_raylib_kms" = "xyes"; then
raylib_backend="yes (DRM/KMS)"
else
raylib_backend="yes (Desktop GL)"
fi
else
raylib_backend="no"
fi
echo ""
echo "blua $PACKAGE_VERSION configuration summary:"
echo " C compiler: $CC"
echo " CFLAGS: $CFLAGS"
echo " LDFLAGS: $LDFLAGS"
echo " LIBS: $LIBS"
echo " raylib support: $raylib_backend"
if test "x$enable_fltk" = "xyes"; then
echo " FLTK support: yes (v$FLTK_VERSION)"
echo " FLTK_CXXFLAGS: $FLTK_CXXFLAGS"
echo " FLTK_LIBS: $FLTK_LIBS"
else
echo " FLTK support: no"
fi
if test "x$enable_curses" = "xyes"; then
echo " ncurses support: yes"
else
echo " ncurses support: no"
fi
echo ""