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"
22 AC_CHECK_FUNCS(usleep, ,[
23 AC_CHECK_FUNCS(select, ,[
24 AC_MSG_ERROR(your system must support either usleep or select)
30 test "$cross_compiling" = "yes" || LIBS="$LIBS -L/usr/X11R6/lib"
36 AC_ARG_WITH(fb, [ --with-fb build framebuffer device interface], [], [with_fb=yes])
37 AC_ARG_WITH(svgalib, [ --with-svgalib build Linux svgalib interface], [], [with_svgalib=yes])
38 AC_ARG_WITH(sdl, [ --with-sdl build SDL interface], [], [with_sdl=yes])
39 AC_ARG_WITH(sdl, [ --with-sdl2 build SDL2 interface], [], [with_sdl2=yes])
40 AC_ARG_WITH(sound, [ --with-sound=no,oss,sdl,ao select sound interface], [], [with_sound=yes])
48 if test "$with_sound" != "no" ; then
49 if test "$with_sound" = "yes" || test "$with_sound" = "ao" ; then
50 AC_CHECK_HEADERS(ao/ao.h, [SOUND=sys/ao/ao.o ; LIBS="$LIBS -Wl,--as-needed -lao -Wl,--no-as-needed"])
52 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "sdl" ) ; then
53 AC_CHECK_HEADERS(SDL/SDL.h, [SOUND=sys/sdl/sdl-audio.o ; LIBS="$LIBS -lSDL"])
55 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "oss" ) ; then
56 AC_CHECK_HEADERS(sys/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SYS_SOUNDCARD_H"], [
57 AC_CHECK_HEADERS(machine/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_MACHINE_SOUNDCARD_H"], [
58 AC_CHECK_HEADERS(soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SOUNDCARD_H"], [
59 test "$with_sound" = "oss" && AC_MSG_WARN(oss selected but required headers not found)
66 AC_CHECK_HEADERS(linux/joystick.h, [JOY=sys/linux/joy.o])
67 test "$with_fb" = "no" || AC_CHECK_HEADERS(linux/fb.h, [with_fb=linux])
69 test "$SOUND" || SOUND=sys/dummy/nosound.o
70 test "$JOY" || JOY=sys/dummy/nojoy.o
78 linux) FB_OBJS="sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o" ;;
79 *) FB_OBJS="" ; with_fb=no ;;
82 if test "$with_svgalib" != "no" ; then
83 AC_CHECK_LIB(vga, vga_init, [
84 AC_CHECK_HEADERS(vga.h vgakeyboard.h, ,[
85 AC_MSG_WARN(svgalib found but headers are missing!!)
87 ])], [with_svgalib=no])
90 if test "$with_sdl2" != no ; then
92 AC_CHECK_LIB(SDL2, SDL_Init, [
93 AC_CHECK_HEADERS(SDL2/SDL.h, ,[
94 AC_MSG_WARN(SDL2 found but headers are missing!!)
96 ])], [with_sdl2=no], $SDL2_LIBS)
99 if test "$with_sdl" != "no" ; then
100 AC_CHECK_PROG(SDL_CONFIG, sdl-config, yes)
101 if test "$SDL_CONFIG" ; then
102 SDL_LIBS="`sdl-config --libs`"
103 SDL_CFLAGS="`sdl-config --cflags`"
105 INCS="$INCS $SDL_CFLAGS"
106 AC_CHECK_LIB(SDL, SDL_Init, [
107 AC_CHECK_HEADERS(SDL/SDL.h, ,[
108 AC_MSG_WARN(SDL found but headers are missing!!)
110 ])], [with_sdl=no], $SDL_LIBS)
119 AH_TEMPLATE(HAVE_LIBXEXT)
120 if test "$no_x" != "yes" ; then
122 AC_CHECK_LIB(Xext, XShmCreateImage, [AC_DEFINE(HAVE_LIBXEXT)])
123 AC_CHECK_HEADERS(sys/ipc.h sys/shm.h X11/Xlib.h X11/Xutil.h X11/keysym.h X11/extensions/XShm.h, [], [], [[
124 #include <X11/Xlib.h>
125 #include <X11/Xutil.h>
126 #include <X11/keysym.h>
128 #define _XOPEN_SOURCE
130 test "$x_includes" && XINCS="-I$x_includes"
131 test "$x_libraries" && XLIBS="-L$x_libraries"
138 test "$with_x" = "no" || TARGETS="$TARGETS xgnuboy"
139 test "$with_fb" = "no" || TARGETS="$TARGETS fbgnuboy"
140 test "$with_svgalib" = "no" || TARGETS="$TARGETS sgnuboy"
141 test "$with_sdl" = "no" || TARGETS="$TARGETS sdlgnuboy"
142 test "$with_sdl2" = "no" || TARGETS="$TARGETS sdl2gnuboy"
153 AC_ARG_ENABLE(warnings, [ --enable-warnings enable selected compiler warnings], [], [enable_warnings=yes])
154 AC_ARG_ENABLE(debug, [ --enable-debug include debugging symbols], [])
155 AC_ARG_ENABLE(profile, [ --enable-profile enable performance profiling], [])
156 AC_ARG_ENABLE(arch, [ --enable-arch compile for specific host cpu architecture], [], [enable_arch=no])
157 AC_ARG_ENABLE(optimize, [ --enable-optimize=LEVEL select optimization level (full,low,none)], [], [enable_optimize=yes])
158 AC_ARG_ENABLE(asm, [ --enable-asm use hand-optimized asm cores], [], [enable_asm=yes])
161 if test "$enable_warnings" = yes ; then
163 AC_MSG_RESULT(enabling selected compiler warnings)
164 CFLAGS="$CFLAGS -ansi -pedantic -Wall" ;;
166 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
170 if test "$enable_debug" = yes ; then
171 AC_MSG_RESULT(including debugging symbols)
175 if test "$enable_profile" = yes ; then
176 AC_MSG_RESULT(enabling performance profiling)
180 if test "$enable_arch" = yes ; then
181 CFLAGS="$CFLAGS -march=native"
184 case "$enable_optimize" in
186 AC_MSG_RESULT(producing heavily optimized code)
190 case `$CC -dumpmachine` in
191 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
194 CFLAGS="$CFLAGS -fstrength-reduce -fthread-jumps \
195 -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop \
196 -fexpensive-optimizations -fforce-addr"
198 if test "$enable_debug" != yes -a "$enable_profile" != yes ; then
199 CFLAGS="$CFLAGS -fomit-frame-pointer"
200 LDFLAGS="$LDFLAGS -s"
205 AC_MSG_RESULT(using minimal optimizations)
206 CFLAGS="$CFLAGS -O3" ;;
210 if test "$enable_asm" = yes ; then
211 case `$CC -dumpmachine` in
213 AC_MSG_RESULT(using optimized i386 cores)
214 ASM="-DUSE_ASM -I./asm/i386" ; ASM_OBJS="asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.s" ;;
216 AC_MSG_RESULT(no optimized asm core available for `$CC -dumpmachine`) ;;
235 AC_CONFIG_HEADER(sys/nix/config.h)