5 # if user sets custom CFLAGS, don't enforce our optimization flags
6 test -n "$CFLAGS" && enable_optimize=no
14 CFLAGS="$CFLAGS -Wno-unused-function -Wno-deprecated-declarations -Wno-overlength-strings"
15 AC_TRY_COMPILE([], [typedef int foo;], [], [CFLAGS="$old_cflags"])
17 test "$cross_compiling" = "yes" || AC_C_BIGENDIAN
18 test "$ac_cv_c_bigendian" = "no" && ENDIAN="-DIS_LITTLE_ENDIAN"
19 test "$cross_compiling" = "yes" || LIBS="$LIBS -L/usr/X11R6/lib"
20 test x"$host" = x && host=`$CC -dumpmachine`
23 AC_ARG_WITH(fb, [ --with-fb build framebuffer device interface], [], [with_fb=yes])
24 AC_ARG_WITH(svgalib, [ --with-svgalib build Linux svgalib interface], [], [with_svgalib=yes])
25 AC_ARG_WITH(sdl, [ --with-sdl build SDL interface], [], [with_sdl=auto])
26 AC_ARG_WITH(sdl2, [ --with-sdl2 build SDL2 interface], [], [with_sdl2=yes])
27 AC_ARG_WITH(sound, [ --with-sound=no,oss,sdl,ao select sound interface], [], [with_sound=yes])
34 if test "$with_sound" != "no" ; then
35 if test "$with_sound" = "yes" || test "$with_sound" = "ao" ; then
36 AC_CHECK_HEADERS(ao/ao.h, [SOUND=sys/ao/ao.o ; LIBS="$LIBS -Wl,--as-needed -lao -Wl,--no-as-needed"])
38 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "sdl" ) ; then
39 AC_CHECK_HEADERS(SDL/SDL.h, [SOUND=sys/sdl/sdl-audio.o ; LIBS="$LIBS -lSDL"])
41 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "oss" ) ; then
42 AC_CHECK_HEADERS(sys/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SYS_SOUNDCARD_H"], [
43 AC_CHECK_HEADERS(machine/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_MACHINE_SOUNDCARD_H"], [
44 AC_CHECK_HEADERS(soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SOUNDCARD_H"], [
45 test "$with_sound" = "oss" && AC_MSG_WARN(oss selected but required headers not found)
52 AC_CHECK_HEADERS(linux/joystick.h, [JOY=sys/linux/joy.o])
53 test "$with_fb" = "no" || AC_CHECK_HEADERS(linux/fb.h, [with_fb=linux])
55 test "$SOUND" || SOUND=sys/dummy/nosound.o
56 test "$JOY" || JOY=sys/dummy/nojoy.o
64 linux) FB_OBJS="sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o" ;;
65 *) FB_OBJS="" ; with_fb=no ;;
68 if test "$with_svgalib" != "no" ; then
69 AC_CHECK_LIB(vga, vga_init, [
70 AC_CHECK_HEADERS(vga.h vgakeyboard.h, ,[
71 AC_MSG_WARN(svgalib found but headers are missing!!)
73 ])], [with_svgalib=no])
76 if test "$with_sdl2" != no ; then
78 AC_CHECK_LIB(SDL2, SDL_Init, [
79 AC_CHECK_HEADERS(SDL2/SDL.h, [
82 AC_MSG_WARN(SDL2 found but headers are missing!!)
85 ], [with_sdl2=no], $SDL2_LIBS)
88 if test "$with_sdl2" = "no" && test "$with_sdl" != "no" ; then
90 AC_CHECK_LIB(SDL, SDL_Init, [
91 AC_CHECK_HEADERS(SDL/SDL.h, [
94 AC_MSG_WARN(SDL found but headers are missing!!)
97 ], [with_sdl=no], $SDL2_LIBS)
102 if test "$with_sdl" != yes && test "$with_sdl2" != yes ; then
103 AC_CHECK_FUNCS(usleep, ,[
104 AC_CHECK_FUNCS(select, ,[
105 AC_MSG_ERROR(your system must support either usleep or select)
111 AH_TEMPLATE(HAVE_LIBXEXT)
112 if test "$no_x" != "yes" ; then
114 AC_CHECK_LIB(Xext, XShmCreateImage, [AC_DEFINE(HAVE_LIBXEXT)])
115 AC_CHECK_HEADERS(sys/ipc.h sys/shm.h X11/Xlib.h X11/Xutil.h X11/keysym.h X11/extensions/XShm.h, [], [], [[
116 #include <X11/Xlib.h>
117 #include <X11/Xutil.h>
118 #include <X11/keysym.h>
120 #define _XOPEN_SOURCE
122 test "$x_includes" && XINCS="-I$x_includes"
123 test "$x_libraries" && XLIBS="-L$x_libraries"
130 test "$with_x" = "no" || TARGETS="$TARGETS xgnuboy"
131 test "$with_fb" = "no" || TARGETS="$TARGETS fbgnuboy"
132 test "$with_svgalib" = "no" || TARGETS="$TARGETS sgnuboy"
133 test "$with_sdl" = "no" || TARGETS="$TARGETS sdlgnuboy"
134 test "$with_sdl2" = "no" || TARGETS="$TARGETS sdl2gnuboy"
145 AC_ARG_ENABLE(warnings, [ --enable-warnings enable selected compiler warnings], [], [enable_warnings=yes])
146 AC_ARG_ENABLE(debug, [ --enable-debug include debugging symbols], [])
147 AC_ARG_ENABLE(profile, [ --enable-profile enable performance profiling], [])
148 AC_ARG_ENABLE(arch, [ --enable-arch compile for specific host cpu architecture], [], [enable_arch=no])
149 AC_ARG_ENABLE(optimize, [ --enable-optimize=LEVEL select optimization level (full,low,none)], [], [enable_optimize=yes])
150 AC_ARG_ENABLE(asm, [ --enable-asm use hand-optimized asm cores], [], [enable_asm=no])
153 if test "$enable_warnings" = yes ; then
155 AC_MSG_RESULT(enabling selected compiler warnings)
156 CFLAGS="$CFLAGS -Wall" ;;
158 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
162 if test "$enable_debug" = yes ; then
163 AC_MSG_RESULT(including debugging symbols)
167 if test "$enable_profile" = yes ; then
168 AC_MSG_RESULT(enabling performance profiling)
172 if test "$enable_arch" = yes ; then
173 CFLAGS="$CFLAGS -march=native"
176 case "$enable_optimize" in
178 AC_MSG_RESULT(producing heavily optimized code)
183 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
187 *gcc*) CFLAGS="$CFLAGS -fstrength-reduce -fthread-jumps \
188 -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop \
189 -fexpensive-optimizations -fforce-addr" ;;
192 if test "$enable_debug" != yes -a "$enable_profile" != yes ; then
193 CFLAGS="$CFLAGS -fomit-frame-pointer"
194 LDFLAGS="$LDFLAGS -s"
199 AC_MSG_RESULT(using minimal optimizations)
200 CFLAGS="$CFLAGS -O3" ;;
204 if test "$enable_asm" = yes ; then
207 AC_MSG_RESULT(using optimized i386 cores)
208 ASM="-DUSE_ASM -I./asm/i386" ; ASM_OBJS="asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.s" ;;
210 AC_MSG_RESULT(no optimized asm core available for $host) ;;
215 *-*-mingw* | *-*-cygwin* | *-*-windows* ) SYS_OBJS=sys/windows/windows.o ;;
216 *-*-dos* ) SYS_OBJS=sys/dos/dos.o ;;
217 *) SYS_OBJS=sys/nix/nix.o ;;
236 AC_CONFIG_HEADER(sys/nix/config.h)