1 # only tested with autoconf 2.57
3 AC_INIT(src/StepMania.cpp)
4 AC_CONFIG_AUX_DIR(autoconf)
7 AM_INIT_AUTOMAKE(OpenITG, 1.01)
8 AM_CONFIG_HEADER(src/config.h)
11 # We don't want PROG_CC/CXX default settings, but don't ignore explicit settings.
12 test -z "$CFLAGS" && DEFAULT_CFLAGS=yes
13 test -z "$CXXFLAGS" && DEFAULT_CXXFLAGS=yes
14 test -z "$LDFLAGS" && DEFAULT_LDFLAGS=yes
20 test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="-Wall -W -Wno-unused -Wno-switch"
21 test "$DEFAULT_CXXFLAGS" = "yes" && CXXFLAGS="-Wall -W -Wno-unused -Wno-switch"
22 test "$DEFAULT_LDFLAGS" = "yes" && LDFLAGS=""
25 AC_ARG_WITH(debug, AC_HELP_STRING([--with-debug], [Enable debug mode]), with_debug=$withval, with_debug=no)
26 AC_ARG_WITH(fast-compile, AC_HELP_STRING([--with-fast-compile], [Enable fast compile]), with_fast_compile=$withval, with_fast_compile=no)
27 if test "$with_debug" = "yes"; then
30 if test "$with_fast_compile" = "yes"; then
36 test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="$CFLAGS -O3"
37 test "$DEFAULT_CXXFLAGS" = "yes" && CXXFLAGS="$CXXFLAGS -O3"
40 test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="$CFLAGS -g"
41 test "$DEFAULT_CXXFLAGS" = "yes" && CXXFLAGS="$CXXFLAGS -g"
44 test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="$CFLAGS -O2 -fno-inline"
45 test "$DEFAULT_CXXFLAGS" = "yes" && CXXFLAGS="$CXXFLAGS -O2 -fno-inline"
49 # Define UNIX for all Unix-like systems. Don't define it for cross-compiling to
50 # non-Unix-like systems. (-DUNIX selects the archutils and ArchHooks to use; if
51 # your platform doesn't use the Unix ones, you probably don't want to define UNIX.)
54 AC_DEFINE(LINUX, 1, [Linux])
55 AC_DEFINE(UNIX, 1, [Unix])
61 AC_DEFINE(UNIX, 1, [Unix])
65 AM_CONDITIONAL(UNIX, test "$unix" = "yes" )
66 AM_CONDITIONAL(LINUX, test "$linux" = "yes" )
68 # Define macros for individual CPU types, for a few bits of inline assembly.
69 # This is for major, compatible CPU classes--"CPU_X86" includes P2, P3, P4,
70 # AMD, etc. If you need CPU-specific assembly, check at runtime--don't create
71 # separate binaries for each CPU if the binaries themselves are otherwise
75 AC_DEFINE(CPU_X86, 1, [x86])
78 AC_DEFINE(CPU_X86_64, 1, [x86-64])
81 AC_DEFINE(CPU_PPC, 1, [PPC])
87 AC_DEFINE(ENDIAN_BIG, 1, [Big endian]),
88 AC_DEFINE(ENDIAN_LITTLE, 1, [Little endian]),
89 AC_MSG_ERROR([Can't determine endianness]) )
91 AC_ARG_WITH(prof, AC_HELP_STRING([--with-prof], [Enable profiling]), with_prof=$withval, with_prof=no)
92 if test "$with_prof" = "yes"; then
93 test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="$CFLAGS -pg"
94 test "$DEFAULT_CXXFLAGS" = "yes" && CXXFLAGS="$CXXFLAGS -pg"
95 test "$DEFAULT_LDFLAGS" = "yes" && LDFLAGS="$LDFLAGS -pg"
100 AC_ARG_ENABLE(sdl, AC_HELP_STRING([--enable-sdl], [Enable SDL support]), enable_sdl=$enableval, enable_sdl=no)
101 if test "$enable_sdl" = "yes"; then
102 AM_PATH_SDL(1.2.6,have_sdl=yes,have_sdl=no)
104 AM_CONDITIONAL(HAVE_SDL, test "$have_sdl" = "yes")
105 if test "$have_sdl" = "yes"; then
106 AC_DEFINE(HAVE_SDL, 1, [SDL is available])
109 # sdl-config puts -L/usr/lib in the library search path, which reorders things
110 # in a way that breaks some configurations.
111 # Does this still need to be in?
113 # SDL_LIBS="`echo $SDL_LIBS | sed 's_-L/usr/lib/\?[[ $]]__'`"
116 AC_CHECK_LIB(png, png_create_read_struct, [x=y], have_libpng=no, [-lz -lm]) # x=y to stop autoconf from messing with LIBS
117 AC_CHECK_HEADER(png.h, , have_libpng=no)
118 if test "$have_libpng" = "no"; then
120 echo "*** libpng is required to build StepMania; please make sure that"
121 echo "*** it is installed to continue the build process."
124 LIBS="$LIBS -lpng -lz -lm"
126 AC_ARG_WITH(jpeg, AC_HELP_STRING([--without-jpeg], [Disable JPEG support]), with_jpeg=$withval, with_jpeg=yes)
128 if test "$with_jpeg" = "yes"; then
130 AC_CHECK_LIB(jpeg, jpeg_read_scanlines, [x=y], have_libjpeg=no) # x=y to stop autoconf from messing with LIBS
131 AC_CHECK_HEADER(jpeglib.h, , have_libjpeg=no)
133 if test "$have_libjpeg" = "no"; then
134 # Require JPEG by default, so people don't compile without it
135 # by accident and then come asking us why files won't load.
137 [libjpeg is required to build StepMania; please make sure that it is installed
138 to continue the build process. If you really want to compile without JPEG
139 support, pass the "--without-jpeg" flag to configure.])
145 AC_DEFINE(NO_JPEG_SUPPORT, 1, [JPEG support not available])
148 AC_ARG_WITH(network, AC_HELP_STRING([--without-network], [Disable networking]), with_network=$withval, with_network=yes)
149 if test "$with_network" = "no"; then
150 AC_DEFINE(WITHOUT_NETWORKING, 1, [Networking support not available])
152 AM_CONDITIONAL(WITHOUT_NETWORKING, test "$with_network" = "no")
155 AC_ARG_ENABLE(itg-arcade, AC_HELP_STRING([--enable-itg-arcade], [Enable arcade-specific behavior]), itg_arcade=$enableval, itg_arcade=no)
156 if test "$itg_arcade" = "yes"; then
157 AC_DEFINE(ITG_ARCADE, 1, [Use arcade mountpoints and behavior])
159 AM_CONDITIONAL(ITG_ARCADE, test "$itg_arcade" = "yes")
167 # for linux joystick hotplug
169 AC_CHECK_HEADER([sys/inotify.h],
171 AC_DEFINE(HAVE_INOTIFY, 1, [inotify support in kernel])
175 have_libresample=static
178 # search for system libs if not building for arcade
179 if test "$itg_arcade" = "no"; then
180 AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes, have_libavcodec=no)
181 AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes, have_libavformat=no)
182 AC_SEARCH_LIBS(swscale_version, [swscale], have_libswscale=yes, have_libswscale=no)
185 AC_CHECK_LIB(resample, resample_open, [x=y], have_libresample=static, [-lm])
186 if test "$have_libresample" = "yes"; then
187 LIBS="$LIBS -lresample"
190 if test "$have_libavcodec" = "yes"; then
191 AC_MSG_CHECKING([for libavcodec >= 0.5.2])
193 #include <libavcodec/avcodec.h>
196 return ( LIBAVCODEC_VERSION_INT < 0x341401 )? 1:0;
198 ],,have_libavcodec=no,)
199 AC_MSG_RESULT($have_libavcodec)
202 if test "$have_libavformat" = "yes"; then
203 AC_MSG_CHECKING([for libavformat >= 0.5.2])
205 #include <libavformat/avformat.h>
208 return ( LIBAVFORMAT_VERSION_INT < 0x341F00 )? 1:0;
210 ],,have_libavformat=no,)
211 AC_MSG_RESULT($have_libavformat)
214 if test "$have_libswscale" = "yes"; then
215 AC_MSG_CHECKING([for libswscale >= 0.5.2])
217 #include <libswscale/swscale.h>
220 return ( LIBSWSCALE_VERSION_INT < 0x000701 )? 1:0;
222 ],,have_libswscale=no,)
223 AC_MSG_RESULT($have_libswscale)
226 if test "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes" -a "$have_libswscale" = "yes"; then
228 AC_DEFINE(HAVE_FFMPEG, 1, [FFMPEG support available])
231 # test if processor supports SSE2
232 AC_TRY_RUN([int main() { int a,d; asm ("cpuid":"=a"(a),"=d"(d):"0"(1)); return d & (1 << 26) ? 0 : 1; }], have_sse2=yes, have_sse2=no)
235 AM_CONDITIONAL(HAVE_FFMPEG, test "$have_ffmpeg" = "yes")
236 AM_CONDITIONAL(HAVE_LIBRESAMPLE, test "$have_libresample" = "yes")
238 # Don't use SSE2 by default; some GCC versions misoptimise the code, which
239 # causes Heisenbugs, and we don't want to inflict that pain unnecessarily.
240 # Only supply it if the user specifically asks.
242 AC_ARG_WITH(sse2, AC_HELP_STRING([--with-sse2], [Enable SSE2 optimization]), with_sse2=$withval, with_sse2=no)
243 if test "$with_sse2" = "yes"; then
244 CFLAGS="$CFLAGS -msse2"
245 CXXFLAGS="$CXXFLAGS -msse2"
248 SM_CHECK_CRASH_HANDLER
251 AM_PATH_ALSA(0.9.0,AC_DEFINE([HAVE_ALSA],1,[Define presence of ALSA]),alsa=no)
255 AC_ARG_ENABLE(gtk2, AC_HELP_STRING([--disable-gtk2], [Disable GTK support]), enable_gtk2=$enableval, enable_gtk2=yes)
257 if test x$enable_gtk2 = xyes; then
258 AM_PATH_GTK_2_0(2.0.0,AC_DEFINE([HAVE_GTK],1,[Define presence of GTK]),enable_gtk2=no)
261 AC_CHECK_HEADER(sys/soundcard.h, [AC_DEFINE(HAVE_OSS, 1, [OSS support available])])
262 AC_CHECK_DECL(OSS_GETVERSION, AC_DEFINE([HAVE_OSS_GETVERSION],1,[OSS_GETVERSION is defined]), , [#include <sys/soundcard.h>])
263 AC_ARG_ENABLE(force-oss, AC_HELP_STRING([--enable-force-oss], [Force OSS]), force_oss=$enableval, force_oss=no)
264 AC_CHECK_HEADER(stdint.h, , [AC_DEFINE(MISSING_STDINT_H, 1, [stdint.h is missing])])
265 AC_CHECK_HEADERS([inttypes.h endian.h])
267 AC_MSG_CHECKING(if cstdlib breaks llabs)
268 AC_TRY_COMPILE( [#include <stdlib.h>
269 #include <cstdlib> ],
270 [int foo() { return llabs(1); }],
273 AC_DEFINE([NEED_CSTDLIB_WORKAROUND], 1, [cstdlib breaks llabs])]
276 AC_CHECK_LIB( pthread, pthread_create, AC_DEFINE([HAVE_LIBPTHREAD],1,[libpthread is available]) )
277 AC_CHECK_LIB( pthread, pthread_mutex_timedlock, AC_DEFINE([HAVE_PTHREAD_MUTEX_TIMEDLOCK],1,[pthreads has pthread_mutex_timedlock()]) )
278 AC_CHECK_LIB( pthread, pthread_cond_timedwait, AC_DEFINE([HAVE_PTHREAD_COND_TIMEDWAIT],1,[pthreads has pthread_cond_timedwait()]) )
281 AC_DEFINE(_GNU_SOURCE, 1, [Use GNU extensions])
283 AM_CONDITIONAL(HAVE_ALSA, test x$alsa != xno )
284 AM_CONDITIONAL(HAVE_GTK, test "$enable_gtk2" != "no" )
285 AM_CONDITIONAL(HAVE_OSS, test x$ac_cv_header_sys_soundcard_h = xyes )
286 AM_CONDITIONAL(USE_CRASH_HANDLER, test "$use_crash_handler" = "yes" )
288 if test x$force_oss = xyes && test x$ac_cv_header_sys_soundcard_h = xyes; then
289 AC_DEFINE([FORCE_OSS], 1, [Force OSS Usage])
292 AC_CHECK_DECL(powf, , AC_DEFINE([NEED_POWF],1,[Need powf]), [#include <math.h>])
293 AC_CHECK_DECL(sqrtf, , AC_DEFINE([NEED_SQRTF],1,[Need sqrtf]), [#include <math.h>])
294 AC_CHECK_DECL(sinf, , AC_DEFINE([NEED_SINF],1,[Need sinf]), [#include <math.h>])
295 AC_CHECK_DECL(tanf, , AC_DEFINE([NEED_COSF],1,[Need tanf]), [#include <math.h>])
296 AC_CHECK_DECL(cosf, , AC_DEFINE([NEED_TANF],1,[Need cosf]), [#include <math.h>])
297 AC_CHECK_DECL(acosf, , AC_DEFINE([NEED_ACOSF],1,[Need acosf]), [#include <math.h>])
298 AC_CHECK_DECL(roundf, , AC_DEFINE([NEED_ROUNDF],1,[Need roundf]), [#include <math.h>])
299 AC_CHECK_DECL(truncf, , AC_DEFINE([NEED_TRUNCF],1,[Need truncf]), [#include <math.h>])
301 # This doesn't work on glibc math functions:
302 # AC_CHECK_FUNCS([sqrtf sinf tanf cosf acosf roundf truncf])
304 AC_CHECK_DECLS([SIGPWR],,,[#include <signal.h>])
306 AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [Build test programs]), enable_tests=$enableval, enable_tests=no)
307 AM_CONDITIONAL(BUILD_TESTS, test "$enable_tests" = "yes" )
309 AC_CONFIG_FILES(Makefile)
310 AC_CONFIG_FILES(src/Makefile)
312 if test "$have_libresample" = "no"; then
313 # use our own libresample in vain
314 cd src/libresample && autoconf && ./configure && cd ../..
317 AC_CHECK_PROG([have_git], [git], yes, no)
320 if test "$have_git" = "yes"; then
321 if test -d .git; then
324 echo "Warning: This is not a git checkout, can't determine version!"
327 echo "Warning: git is not installed, can't determine version!"
330 if test "$have_git_repo" = "yes"; then
331 build_version=`git tag`
332 build_rev_date=`git log -1 --pretty="format:%ad" --date="short"`
333 build_rev_tag=`git describe`
335 # If the rev_tag and the version are the same, this is
336 # an official release; otherwise, it's a dev build.
337 if test "$build_version" != "$build_rev_tag"; then
338 build_version="$build_version DEV"
341 # HACK: the arcade chroot's git version is too old to understand our
342 # desired YYYY-MM-DD format. If we don't get a date in that format,
343 # fall back to today's date.
345 # HACK x2 COMBO!!: 'expr', in bash 2.05, doesn't seem to parse
346 # {n} for matching n repeats, hence the brain-dead regex.
348 if ! [ expr "$build_rev_date" : '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' > /dev/null ]; then
349 build_rev_date=`date +%Y-%m-%d`
352 build_version="unknown version"
353 build_rev_date="unknown date"
354 build_rev_tag="unknown revision"
357 AC_DEFINE_UNQUOTED(BUILD_VERSION, "$build_version", [Version tag])
358 AC_DEFINE_UNQUOTED(BUILD_DATE, "$build_rev_date", [Date of source revision])
359 AC_DEFINE_UNQUOTED(BUILD_REVISION_TAG, "$build_rev_tag", [ID of source revision])
366 echo "OpenITG $build_version (revision $build_rev_tag, $build_rev_date)"
370 echo "Arcade build $itg_arcade"
371 echo "SSE2 optimizations $with_sse2 (supported: $have_sse2)"
372 echo "SDL $enable_sdl"
373 echo "FFMPEG $have_ffmpeg"
374 echo "libresample $have_libresample"
375 echo "GTK2 $enable_gtk2"
377 echo "OSS $ac_cv_header_sys_soundcard_h (forced: $force_oss)"
378 echo "inotify hotplug $have_inotify"