inflate: mute compiler warning
[rofl0r-gnuboy.git] / configure.ac
blob95b28ef3cbe5f3e8cc10df4666025834fab6bca1
2 AC_INIT(cpu.c)
4 CFLAGS="$CFLAGS"
5 # if user sets custom CFLAGS, don't enforce our optimization flags
6 test -n "$CFLAGS" && enable_optimize=no
8 AC_PROG_CC
9 AC_PROG_CPP
10 AC_PROG_INSTALL
13 test "$cross_compiling" = "yes" || AC_C_BIGENDIAN
14 test "$ac_cv_c_bigendian" = "no" && ENDIAN="-DIS_LITTLE_ENDIAN"
18 AC_CHECK_FUNCS(usleep, ,[
19 AC_CHECK_FUNCS(select, ,[
20 AC_MSG_ERROR(your system must support either usleep or select)
21 ])])
26 test "$cross_compiling" = "yes" || LIBS="$LIBS -L/usr/X11R6/lib"
32 AC_ARG_WITH(fb,      [  --with-fb                       build framebuffer device interface], [], [with_fb=yes])
33 AC_ARG_WITH(svgalib, [  --with-svgalib                  build Linux svgalib interface], [], [with_svgalib=yes])
34 AC_ARG_WITH(sdl,     [  --with-sdl                      build SDL interface], [], [with_sdl=yes])
35 AC_ARG_WITH(sdl,     [  --with-sdl2                     build SDL2 interface], [], [with_sdl2=yes])
36 AC_ARG_WITH(sound,   [  --with-sound=no,oss,sdl,ao      select sound interface], [], [with_sound=yes])
41 SOUND=""
42 JOY=""
44 if test "$with_sound" != "no" ; then
45 if test "$with_sound" = "yes" || test "$with_sound" = "ao" ; then
46 AC_CHECK_HEADERS(ao/ao.h, [SOUND=sys/ao/ao.o ; LIBS="$LIBS -Wl,--as-needed -lao -Wl,--no-as-needed"])
48 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "sdl" ) ; then
49 AC_CHECK_HEADERS(SDL/SDL.h, [SOUND=sys/sdl/sdl-audio.o ; LIBS="$LIBS -lSDL"])
51 if test -z "$SOUND" && ( test "$with_sound" = "yes" || test "$with_sound" = "oss" ) ; then
52 AC_CHECK_HEADERS(sys/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SYS_SOUNDCARD_H"], [
53  AC_CHECK_HEADERS(machine/soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_MACHINE_SOUNDCARD_H"], [
54   AC_CHECK_HEADERS(soundcard.h, [SOUND=sys/oss/oss.o ; CPPFLAGS="$CPPFLAGS -DHAVE_SOUNDCARD_H"], [
55    test "$with_sound" = "oss" && AC_MSG_WARN(oss selected but required headers not found)
56   ])
57  ])
62 AC_CHECK_HEADERS(linux/joystick.h, [JOY=sys/linux/joy.o])
63 test "$with_fb" = "no" || AC_CHECK_HEADERS(linux/fb.h, [with_fb=linux])
65 test "$SOUND" || SOUND=sys/dummy/nosound.o
66 test "$JOY" || JOY=sys/dummy/nojoy.o
73 case "$with_fb" in
74 linux) FB_OBJS="sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o" ;;
75 *) FB_OBJS="" ; with_fb=no ;;
76 esac
78 if test "$with_svgalib" != "no" ; then
79 AC_CHECK_LIB(vga, vga_init, [
80 AC_CHECK_HEADERS(vga.h vgakeyboard.h, ,[
81 AC_MSG_WARN(svgalib found but headers are missing!!)
82 with_svgalib=no
83 ])], [with_svgalib=no])
86 if test "$with_sdl2" != no ; then
87 SDL2_LIBS=-lSDL2
88 AC_CHECK_LIB(SDL2, SDL_Init, [
89 AC_CHECK_HEADERS(SDL2/SDL.h, ,[
90 AC_MSG_WARN(SDL2 found but headers are missing!!)
91 with_sdl2=no
92 ])], [with_sdl2=no], $SDL2_LIBS)
95 if test "$with_sdl" != "no" ; then
96 AC_CHECK_PROG(SDL_CONFIG, sdl-config, yes)
97 if test "$SDL_CONFIG" ; then
98 SDL_LIBS="`sdl-config --libs`"
99 SDL_CFLAGS="`sdl-config --cflags`"
100 old_incs="$INCS"
101 INCS="$INCS $SDL_CFLAGS"
102 AC_CHECK_LIB(SDL, SDL_Init, [
103 AC_CHECK_HEADERS(SDL/SDL.h, ,[
104 AC_MSG_WARN(SDL found but headers are missing!!)
105 with_sdl=no
106 ])], [with_sdl=no], $SDL_LIBS)
107 INCS="$old_incs"
108 else
109 with_sdl=no
113 AC_PATH_X
115 AH_TEMPLATE(HAVE_LIBXEXT)
116 if test "$no_x" != "yes" ; then
117 with_x=yes
118 AC_CHECK_LIB(Xext, XShmCreateImage, [AC_DEFINE(HAVE_LIBXEXT)])
119 AC_CHECK_HEADERS(sys/ipc.h sys/shm.h X11/Xlib.h X11/Xutil.h X11/keysym.h X11/extensions/XShm.h, [], [], [[
120 #include <X11/Xlib.h>
121 #include <X11/Xutil.h>
122 #include <X11/keysym.h>
123 #define _SVID_SOURCE
124 #define _XOPEN_SOURCE
126 test "$x_includes" && XINCS="-I$x_includes"
127 test "$x_libraries" && XLIBS="-L$x_libraries"
128 else
129 with_x=no
134 test "$with_x" = "no" || TARGETS="$TARGETS xgnuboy"
135 test "$with_fb" = "no" || TARGETS="$TARGETS fbgnuboy"
136 test "$with_svgalib" = "no" || TARGETS="$TARGETS sgnuboy"
137 test "$with_sdl" = "no" || TARGETS="$TARGETS sdlgnuboy"
138 test "$with_sdl2" = "no" || TARGETS="$TARGETS sdl2gnuboy"
149 AC_ARG_ENABLE(warnings, [  --enable-warnings       enable selected compiler warnings], [], [enable_warnings=yes])
150 AC_ARG_ENABLE(debug,    [  --enable-debug          include debugging symbols], [])
151 AC_ARG_ENABLE(profile,  [  --enable-profile        enable performance profiling], [])
152 AC_ARG_ENABLE(arch,     [  --enable-arch           compile for specific host cpu architecture], [], [enable_arch=no])
153 AC_ARG_ENABLE(optimize, [  --enable-optimize=LEVEL select optimization level (full,low,none)], [], [enable_optimize=yes])
154 AC_ARG_ENABLE(asm,      [  --enable-asm            use hand-optimized asm cores], [], [enable_asm=yes])
157 if test "$enable_warnings" = yes ; then
158 case "$CC" in *gcc*)
159 AC_MSG_RESULT(enabling selected compiler warnings)
160 CFLAGS="$CFLAGS -ansi -pedantic -Wall" ;;
162 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
163 esac
166 if test "$enable_debug" = yes ; then
167 AC_MSG_RESULT(including debugging symbols)
168 CFLAGS="$CFLAGS -g"
171 if test "$enable_profile" = yes ; then
172 AC_MSG_RESULT(enabling performance profiling)
173 CFLAGS="$CFLAGS -pg"
176 if test "$enable_arch" = yes ; then
177 CFLAGS="$CFLAGS -march=native"
180 case "$enable_optimize" in
181 yes|full)
182 AC_MSG_RESULT(producing heavily optimized code)
184 CFLAGS="$CFLAGS -O3"
186 case `$CC -dumpmachine` in
187 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
188 esac
190 CFLAGS="$CFLAGS -fstrength-reduce -fthread-jumps \
191  -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop \
192  -fexpensive-optimizations -fforce-addr"
194 if test "$enable_debug" != yes -a "$enable_profile" != yes ; then
195 CFLAGS="$CFLAGS -fomit-frame-pointer"
196 LDFLAGS="$LDFLAGS -s"
197 fi ;;
199 low)
201 AC_MSG_RESULT(using minimal optimizations)
202 CFLAGS="$CFLAGS -O3" ;;
204 esac
206 if test "$enable_asm" = yes ; then
207 case `$CC -dumpmachine` in
208 i?86*)
209 AC_MSG_RESULT(using optimized i386 cores)
210 ASM="-DUSE_ASM -I./asm/i386" ; ASM_OBJS="asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.s" ;;
212 AC_MSG_RESULT(no optimized asm core available for `$CC -dumpmachine`) ;;
213 esac
217 AC_SUBST(SYS_DEFS)
218 AC_SUBST(ENDIAN)
219 AC_SUBST(SOUND)
220 AC_SUBST(JOY)
221 AC_SUBST(ASM)
222 AC_SUBST(ASM_OBJS)
223 AC_SUBST(FB_OBJS)
224 AC_SUBST(SDL_CFLAGS)
225 AC_SUBST(SDL_LIBS)
226 AC_SUBST(SDL2_LIBS)
227 AC_SUBST(TARGETS)
228 AC_SUBST(XINCS)
229 AC_SUBST(XLIBS)
231 AC_CONFIG_HEADER(sys/nix/config.h)
232 AC_OUTPUT(Makefile)