configure: mute some warnings by default
[rofl0r-gnuboy.git] / configure.ac
blob6486849164cfbe9a5636862631c35517a46a0ba0
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
9 AC_PROG_CC
10 AC_PROG_CPP
11 AC_PROG_INSTALL
13 old_cflags="$CFLAGS"
14 CFLAGS="$CLAGS -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)
25 ])])
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])
45 SOUND=""
46 JOY=""
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)
60   ])
61  ])
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
77 case "$with_fb" in
78 linux) FB_OBJS="sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o" ;;
79 *) FB_OBJS="" ; with_fb=no ;;
80 esac
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!!)
86 with_svgalib=no
87 ])], [with_svgalib=no])
90 if test "$with_sdl2" != no ; then
91 SDL2_LIBS=-lSDL2
92 AC_CHECK_LIB(SDL2, SDL_Init, [
93 AC_CHECK_HEADERS(SDL2/SDL.h, ,[
94 AC_MSG_WARN(SDL2 found but headers are missing!!)
95 with_sdl2=no
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`"
104 old_incs="$INCS"
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!!)
109 with_sdl=no
110 ])], [with_sdl=no], $SDL_LIBS)
111 INCS="$old_incs"
112 else
113 with_sdl=no
117 AC_PATH_X
119 AH_TEMPLATE(HAVE_LIBXEXT)
120 if test "$no_x" != "yes" ; then
121 with_x=yes
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>
127 #define _SVID_SOURCE
128 #define _XOPEN_SOURCE
130 test "$x_includes" && XINCS="-I$x_includes"
131 test "$x_libraries" && XLIBS="-L$x_libraries"
132 else
133 with_x=no
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
162 case "$CC" in *gcc*)
163 AC_MSG_RESULT(enabling selected compiler warnings)
164 CFLAGS="$CFLAGS -ansi -pedantic -Wall" ;;
166 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
167 esac
170 if test "$enable_debug" = yes ; then
171 AC_MSG_RESULT(including debugging symbols)
172 CFLAGS="$CFLAGS -g"
175 if test "$enable_profile" = yes ; then
176 AC_MSG_RESULT(enabling performance profiling)
177 CFLAGS="$CFLAGS -pg"
180 if test "$enable_arch" = yes ; then
181 CFLAGS="$CFLAGS -march=native"
184 case "$enable_optimize" in
185 yes|full)
186 AC_MSG_RESULT(producing heavily optimized code)
188 CFLAGS="$CFLAGS -O3"
190 case `$CC -dumpmachine` in
191 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
192 esac
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"
201 fi ;;
203 low)
205 AC_MSG_RESULT(using minimal optimizations)
206 CFLAGS="$CFLAGS -O3" ;;
208 esac
210 if test "$enable_asm" = yes ; then
211 case `$CC -dumpmachine` in
212 i?86*)
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`) ;;
217 esac
221 AC_SUBST(SYS_DEFS)
222 AC_SUBST(ENDIAN)
223 AC_SUBST(SOUND)
224 AC_SUBST(JOY)
225 AC_SUBST(ASM)
226 AC_SUBST(ASM_OBJS)
227 AC_SUBST(FB_OBJS)
228 AC_SUBST(SDL_CFLAGS)
229 AC_SUBST(SDL_LIBS)
230 AC_SUBST(SDL2_LIBS)
231 AC_SUBST(TARGETS)
232 AC_SUBST(XINCS)
233 AC_SUBST(XLIBS)
235 AC_CONFIG_HEADER(sys/nix/config.h)
236 AC_OUTPUT(Makefile)