forked from schismtracker/schismtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
337 lines (283 loc) · 11.5 KB
/
configure.ac
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
dnl Process this file with autoconf to produce a configure script.
dnl Schism Tracker - a cross-platform Impulse Tracker clone
dnl copyright (c) 2003-2005 Storlek <storlek@rigelseven.com>
dnl copyright (c) 2005-2008 Mrs. Brisby <mrs.brisby@nimh.org>
dnl copyright (c) 2009 Storlek & Mrs. Brisby
dnl copyright (c) 2010-2012 Storlek
dnl URL: http://schismtracker.org/
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl PACKAGE_VERSION will be either "" if not using git, or date of the last git commit in the form YYYYMMDD
m4_define([last_git_commit], patsubst(m4_esyscmd([git log -n 1 --date=short --format=format:%cd]), [[^0-9]]))
AC_INIT([schismtracker], [last_git_commit])
AC_CONFIG_SRCDIR([schism/main.c])
AM_INIT_AUTOMAKE([-Wall subdir-objects])
AC_CONFIG_HEADERS([config.h])
dnl -----------------------------------------------------------------------
dnl Check for standard programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CC_C99
dnl do we have Git
AC_CHECK_TOOL([GIT], [git])
AC_SUBST(GIT)
AM_CONDITIONAL([HAVE_GIT], [test "x$GIT" != "x"])
dnl Windows poop
AC_CHECK_TOOL([WINDRES], [windres])
AC_SUBST(WINDRES)
AM_CONDITIONAL([HAVE_WINDRES], [test "x$WINDRES" != "x"])
dnl Necessary for building the internal help.
AM_PATH_PYTHON([2.4])
dnl We're using C
AC_LANG([C])
dnl check endianness
AC_C_BIGENDIAN
dnl Check for SDL libs
AM_PATH_SDL(1.2.10, , AC_MSG_ERROR([*** SDL version >= 1.2.10 not found.]))
dnl Libs
AC_CHECK_LIB([dl], [dlopen])
dnl Functions
AC_CHECK_FUNCS(strchr memmove strerror strtol strcasecmp strncasecmp strverscmp stricmp strnicmp strcasestr strptime asprintf vasprintf memcmp mmap nice unsetenv dup fnmatch mkstemp)
AM_CONDITIONAL([NEED_ASPRINTF], [test "$ac_cv_func_asprintf" = "no"])
AM_CONDITIONAL([NEED_VASPRINTF], [test "$ac_cv_func_vasprintf" = "no"])
AM_CONDITIONAL([NEED_MEMCMP], [test "$ac_cv_func_memcmp" = "no"])
AM_CONDITIONAL([NEED_STRPTIME], [test "$ac_cv_func_strptime" = "no"])
AM_CONDITIONAL([NEED_MKSTEMP], [test "$ac_cv_func_mkstemp" = "no"])
AM_CONDITIONAL([USE_MMAP], [test "$ac_cv_func_mmap" = "yes"])
dnl Headers, typedef crap, et al.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_CHECK_HEADERS(inttypes.h fcntl.h limits.h signal.h unistd.h sys/param.h sys/ioctl.h sys/kd.h linux/fb.h byteswap.h sys/soundcard.h)
AM_CONDITIONAL([USE_OSS], [test "$ac_cv_header_sys_soundcard_h" = yes])
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_SEARCH_LIBS([powf], [m])
dnl -----------------------------------------------------------------------
dnl Always use x11 by default unless overriden later per-platform
dnl (this is stupid, and only needed because the x11 check is dysfunctional)
defaultx11=yes
dnl CoreMIDI (Mac OS X)
AC_MSG_CHECKING(for CoreAudio/CoreMIDI Framework)
if echo "$SDL_LIBS" | grep -- -framework >/dev/null 2>&1; then
AC_MSG_RESULT(found)
dnl frameworks aren't part of sdl... should be a separate variable
SDL_LIBS="$SDL_LIBS -framework CoreAudio -framework CoreMIDI -framework IOKit -framework OpenGL"
AC_SUBST(SDL_LIBS)
AM_CONDITIONAL([USE_MACOSX], true)
AM_CONDITIONAL([am__fastdepOBJC], true)
defaultx11=no
else
AC_MSG_RESULT(not found)
AM_CONDITIONAL([USE_MACOSX], false)
AM_CONDITIONAL([am__fastdepOBJC], false)
fi
dnl winmm testing...
AC_CHECK_HEADERS(winsock.h winsock2.h windows.h)
if test "X$ac_cv_header_windows_h" = "Xyes"; then
AM_CONDITIONAL([USE_WIN32], true)
SDL_LIBS="$SDL_LIBS -lwinmm"
AC_SUBST(SDL_LIBS)
defaultx11=no
else
AM_CONDITIONAL([USE_WIN32], false)
fi
dnl Wii crap
AC_CHECK_LIB(ogc, IOS_ReloadIOS, libogc_found=yes, libogc_found=no, [-mrvl -L${DEVKITPRO}/libogc/lib/wii])
if test x"$libogc_found" = "xyes"; then
AM_CONDITIONAL([USE_WII], true)
wii_machdep="-DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
CFLAGS="$CFLAGS $wii_machdep -I${DEVKITPRO}/libogc/include"
LIBS="$LIBS $wii_machdep -L${DEVKITPRO}/libogc/lib/wii"
SDL_CFLAGS="$SDL_CFLAGS -I${DEVKITPRO}/libogc/include/SDL"
SDL_LIBS="$SDL_LIBS -lSDL -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard"
AC_SUBST(CFLAGS)
AC_SUBST(LIBS)
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
EXEEXT=.elf
AC_SUBST(EXEEXT)
defaultx11=no
else
AM_CONDITIONAL([USE_WII], false)
fi
dnl should probably have some AC_MSG_CHECKING here, but meh
if test "x$defaultx11" = "xno"; then
if test "x$with_x" = "x"; then
AC_MSG_NOTICE([X11 disabled by default; use --with-x if you really want it])
dnl (you don't want it, because it's probably broken anyway)
with_x=no
fi
fi
dnl OpenGL crud - it doesn't always exist
saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
AC_CHECK_HEADER([SDL_opengl.h], [AC_DEFINE([USE_OPENGL], 1, [Define to 1 if SDL's OpenGL works])])
CPPFLAGS=$saved_cppflags
dnl -----------------------------------------------------------------------
saved_libs=$LIBS
alsa=no
AC_CHECK_LIB(asound, snd_seq_open,[alsa=yes])
alsadltrick=no
if test "$alsa" = "yes"; then
if test "$ac_cv_header_sys_soundcard_h" = "yes"; then
alsadltrick=yes
LIBS=$saved_libs
fi
fi
AM_CONDITIONAL([USE_ALSA], [test "$alsa" = yes])
AM_CONDITIONAL([USE_ALSA_DLTRICK], [test "$alsadltrick" = yes])
AC_PATH_XTRA()
if test "$no_x" = "yes"; then
dnl no X11
AM_CONDITIONAL([USE_X11], [false])
AM_CONDITIONAL([USE_XV], [false])
else
AM_CONDITIONAL([USE_X11], [true])
SDL_LIBS="$SDL_LIBS -lX11 -lXext"
AC_SUBST(SDL_LIBS)
LIBS="$LIBS $X_LIBS"
AC_SUBST(LIBS)
dnl this previously checked X11/extensions/XKB.h, but nothing
dnl ever used it (xkb.c still included X11/XKBlib.h even when
dnl autoconf reported it as nonexistent -- weird!)
AC_CHECK_HEADERS(X11/Xlib.h X11/XKBlib.h)
AC_CHECK_LIB(Xv, XvQueryExtension,,,-lX11 -lXext)
if test "$ac_cv_lib_Xv_XvQueryExtension" = "yes"; then
AC_CHECK_HEADERS(X11/extensions/Xvlib.h,,,[[
#include <X11/Xlib.h>
]])
if test "$ac_cv_header_X11_extensions_xvlib_h" = "yes"; then
SDL_LIBS="$SDL_LIBS -lXv -lXext"
AC_SUBST(SDL_LIBS)
AM_CONDITIONAL([USE_XV], [true])
elif test "$ac_cv_header_X11_extensions_Xvlib_h" = "yes"; then
SDL_LIBS="$SDL_LIBS -lXv -lXext"
AC_SUBST(SDL_LIBS)
AM_CONDITIONAL([USE_XV], [true])
else
AM_CONDITIONAL([USE_XV], [false])
fi
else
AM_CONDITIONAL([USE_XV], [false])
fi
fi
dnl asdjklfjklasdfaskdfjklads
saved_LIBS="$LIBS"
AC_SEARCH_LIBS(socket, socket network)
LIBS="$saved_LIBS"
if test "x$ac_cv_search_socket" = "xno"; then
dnl Windows sucks (I don't even know what this is about, but it apparently works)
AC_CHECK_HEADERS(winsock.h winsock2.h)
if test "x$ac_cv_header_winsock_h" = "xyes"; then
socketlib="-lwsock32"
elif test "x$ac_cv_header_winsock2_h" = "xyes"; then
socketlib="-lws2_32"
fi
if test "x$socketlib" = "x"; then
echo "*** No sockets for you!"
AM_CONDITIONAL([USE_NETWORK], false)
else
AM_CONDITIONAL([USE_NETWORK], true)
SDL_LIBS="$SDL_LIBS $socketlib"
AC_SUBST(SDL_LIBS)
fi
elif test "x$ac_cv_search_socket" = "xnone required"; then
dnl free networking
AM_CONDITIONAL([USE_NETWORK], true)
else
SDL_LIBS="$SDL_LIBS $ac_cv_search_socket"
AC_SUBST(SDL_LIBS)
AM_CONDITIONAL([USE_NETWORK], true)
fi
#AC_CHECK_LIB(kernel32, GetConsoleMode, SDL_LIBS="$SDL_LIBS -Wl,--subsystem,console")
dnl wee...
dnl this completely sucks...
OBJC=$CC
OBJCFLAGS=$CFLAGS
AC_SUBST(OBJC)
AC_SUBST(OBJCFLAGS)
dnl -----------------------------------------------------------------------
dnl (This ought to be above AC_PROG_CC, but that causes configure to fail
dnl when all the insane warnings are are enabled.)
AC_ARG_ENABLE(extra-opt,
AS_HELP_STRING([--enable-extra-opt], [Add extra, system-dependent optimizations (do not use this together with debug or even profiling)]),
ADD_OPT=$enableval,
ADD_OPT=no)
AC_ARG_ENABLE(all-warnings,
AS_HELP_STRING([--enable-all-warnings], [Enable ridiculous compiler warnings]),
ADD_WARN=$enableval,
ADD_WARN=no)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debug flags]),
ADD_DEBUG=$enableval,
ADD_DEBUG=no)
AC_ARG_ENABLE(profiling,
AS_HELP_STRING([--enable-profiling], [Enable profiling flags (slows things down), debugging (--enable-debug) is also enabled by this]),
ADD_PROFILING=$enableval,
ADD_PROFILING=no)
AC_ARG_ENABLE(ludicrous-mode,
AS_HELP_STRING([--enable-ludicrous-mode], [Enable all warnings, and treat as errors]),
ADD_LUDICROUS=$enableval,
ADD_LUDICROUS=no)
AC_ARG_ENABLE(fortify-source,
AS_HELP_STRING([--enable-fortify-source], [Build with FORTIFY_SOURCE]),
ADD_FORTIFY=$enableval,
ADD_FORTIFY=no)
dnl fortify needs -O; do this early so ADD_OPT can override with higher -O level
if test x$ADD_FORTIFY \!= xno; then
CFLAGS="$CFLAGS -O -D_FORTIFY_SOURCE=2"
fi
dnl place extra optimizations after existing cflags so that they can override
dnl override whatever flags might exist by default (-g -O2 usually)
if test x$ADD_OPT \!= xno; then
if test x$ADD_DEBUG \!= xno || test x$ADD_PROFILING \!= xno; then
AC_MSG_NOTICE([You aren't supposed to use --enable-debug or --enable-profiling together with --enable-extra-opt!!])
fi
ADD_OPT="-Ofast -g0 -s -fno-exceptions -march=native"
CFLAGS="$CFLAGS $ADD_OPT"
fi
if test x$ADD_LUDICROUS \!= xno; then
ADD_WARN=yes
CFLAGS="$CFLAGS -Werror"
fi
dnl ... but put the warnings first, to make it possible to quiet certain
dnl warnings if necessary, while still providing most of the benefit
if test x$ADD_WARN \!= xno; then
ADD_WARN="-Wall -Wextra -Winline -Wshadow -Wwrite-strings -Waggregate-return -Wpacked"
ADD_WARN="$ADD_WARN -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
CFLAGS="$ADD_WARN $CFLAGS"
fi
if test x$ADD_PROFILING \!= xno || test x$ADD_DEBUG \!= xno; then
CFLAGS="$CFLAGS -g -O0"
OBJCFLAGS="$OBJCFLAGS -g -O0"
SDL_LIBS="$SDL_LIBS -g -O0"
AC_SUBST(SDL_LIBS)
fi
if test x$ADD_PROFILING \!= xno; then
CFLAGS="$CFLAGS -pg"
OBJCFLAGS="$OBJCFLAGS -pg"
SDL_LIBS="$SDL_LIBS -pg"
AC_SUBST(SDL_LIBS)
fi
dnl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AC_CONFIG_FILES([Makefile])
AC_OUTPUT