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])
28 AC_ARG_WITH(x11, [ --with-x build x11 interface], [], [with_x11=auto])
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 test -z "$PKG_CONFIG" && PKG_CONFIG=pkg-config
78 if test "$with_sdl2" != no ; then
80 AC_CHECK_LIB(SDL2, SDL_Init, [
81 AC_CHECK_HEADERS(SDL2/SDL.h, [
84 AC_MSG_WARN(SDL2 found but headers are missing!!)
88 AC_MSG_WARN(testing pkg-config for SDL2)
89 if "$PKG_CONFIG" --libs sdl2 >/dev/null 2>&1 ; then
91 SDL2_LIBS=$("$PKG_CONFIG" --libs sdl2)
98 if test "$with_sdl2" = "no" && test "$with_sdl" != "no" ; then
100 AC_CHECK_LIB(SDL, SDL_Init, [
101 AC_CHECK_HEADERS(SDL/SDL.h, [
104 AC_MSG_WARN(SDL found but headers are missing!!)
107 ], [with_sdl=no], $SDL2_LIBS)
112 if test "$with_sdl" != yes && test "$with_sdl2" != yes ; then
113 AC_CHECK_FUNCS(usleep, ,[
114 AC_CHECK_FUNCS(select, ,[
115 AC_MSG_ERROR(your system must support either usleep or select)
119 if test "$with_x" != "no" ; then
121 if test "$cross_compiling" != "yes" ; then
125 AH_TEMPLATE(HAVE_LIBXEXT)
126 if test "$no_x" != "yes" ; then
128 AC_CHECK_LIB(Xext, XShmCreateImage, [AC_DEFINE(HAVE_LIBXEXT)])
129 AC_CHECK_HEADERS(sys/ipc.h sys/shm.h X11/Xlib.h X11/Xutil.h X11/keysym.h X11/extensions/XShm.h, [], [], [[
130 #include <X11/Xlib.h>
131 #include <X11/Xutil.h>
132 #include <X11/keysym.h>
134 #define _XOPEN_SOURCE
136 test "$x_includes" && XINCS="-I$x_includes"
137 test "$x_libraries" && XLIBS="-L$x_libraries"
144 test "$with_x" = "no" || TARGETS="$TARGETS xgnuboy"
145 test "$with_fb" = "no" || TARGETS="$TARGETS fbgnuboy"
146 test "$with_svgalib" = "no" || TARGETS="$TARGETS sgnuboy"
147 test "$with_sdl" = "no" || TARGETS="$TARGETS sdlgnuboy"
148 test "$with_sdl2" = "no" || TARGETS="$TARGETS sdl2gnuboy"
159 AC_ARG_ENABLE(warnings, [ --enable-warnings enable selected compiler warnings], [], [enable_warnings=yes])
160 AC_ARG_ENABLE(debug, [ --enable-debug include debugging symbols], [])
161 AC_ARG_ENABLE(profile, [ --enable-profile enable performance profiling], [])
162 AC_ARG_ENABLE(arch, [ --enable-arch compile for specific host cpu architecture], [], [enable_arch=no])
163 AC_ARG_ENABLE(optimize, [ --enable-optimize=LEVEL select optimization level (full,low,none)], [], [enable_optimize=yes])
164 AC_ARG_ENABLE(asm, [ --enable-asm use hand-optimized asm cores], [], [enable_asm=no])
167 if test "$enable_warnings" = yes ; then
169 AC_MSG_RESULT(enabling selected compiler warnings)
170 CFLAGS="$CFLAGS -Wall" ;;
172 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
176 if test "$enable_debug" = yes ; then
177 AC_MSG_RESULT(including debugging symbols)
181 if test "$enable_profile" = yes ; then
182 AC_MSG_RESULT(enabling performance profiling)
186 if test "$enable_arch" = yes ; then
187 CFLAGS="$CFLAGS -march=native"
190 case "$enable_optimize" in
192 AC_MSG_RESULT(producing heavily optimized code)
197 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
201 *gcc*) CFLAGS="$CFLAGS -fstrength-reduce -fthread-jumps \
202 -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop \
203 -fexpensive-optimizations -fforce-addr" ;;
206 if test "$enable_debug" != yes -a "$enable_profile" != yes ; then
207 CFLAGS="$CFLAGS -fomit-frame-pointer"
208 LDFLAGS="$LDFLAGS -s"
213 AC_MSG_RESULT(using minimal optimizations)
214 CFLAGS="$CFLAGS -O3" ;;
218 if test "$enable_asm" = yes ; then
221 AC_MSG_RESULT(using optimized i386 cores)
222 ASM="-DUSE_ASM -I./asm/i386" ; ASM_OBJS="asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.s" ;;
224 AC_MSG_RESULT(no optimized asm core available for $host) ;;
229 *-*-mingw* | *-*-cygwin* | *-*-windows* ) SYS_OBJS=sys/windows/windows.o ;;
230 *-*-dos* ) SYS_OBJS=sys/dos/dos.o ;;
231 *) SYS_OBJS=sys/nix/nix.o ;;
250 AC_CONFIG_HEADER(sys/nix/config.h)