implement new "toggle" rc command
[rofl0r-gnuboy.git] / configure.ac
blob7d70b4c4e06cc21cb1949d4f719225d1ca5874a4
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="$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])
31 SOUND=""
32 JOY=""
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)
46   ])
47  ])
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
63 case "$with_fb" in
64 linux) FB_OBJS="sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o" ;;
65 *) FB_OBJS="" ; with_fb=no ;;
66 esac
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!!)
72 with_svgalib=no
73 ])], [with_svgalib=no])
76 if test "$with_sdl2" != no ; then
77 SDL2_LIBS=-lSDL2
78 AC_CHECK_LIB(SDL2, SDL_Init, [
79  AC_CHECK_HEADERS(SDL2/SDL.h, [
80    with_sdl2=yes
81   ], [
82    AC_MSG_WARN(SDL2 found but headers are missing!!)
83    with_sdl2=no
84  ])
85 ], [with_sdl2=no], $SDL2_LIBS)
88 if test "$with_sdl2" = "no" && test "$with_sdl" != "no" ; then
89  SDL_LIBS=-lSDL
90  AC_CHECK_LIB(SDL, SDL_Init, [
91   AC_CHECK_HEADERS(SDL/SDL.h, [
92     with_sdl=yes
93    ], [
94     AC_MSG_WARN(SDL found but headers are missing!!)
95     with_sdl=no
96   ])
97  ], [with_sdl=no], $SDL2_LIBS)
98 else
99  with_sdl=no
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)
106 ])])
109 AC_PATH_X
111 AH_TEMPLATE(HAVE_LIBXEXT)
112 if test "$no_x" != "yes" ; then
113 with_x=yes
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>
119 #define _SVID_SOURCE
120 #define _XOPEN_SOURCE
122 test "$x_includes" && XINCS="-I$x_includes"
123 test "$x_libraries" && XLIBS="-L$x_libraries"
124 else
125 with_x=no
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
154 case "$CC" in *gcc*)
155 AC_MSG_RESULT(enabling selected compiler warnings)
156 CFLAGS="$CFLAGS -Wall" ;;
158 AC_MSG_RESULT(disabling warnings for non-gcc compiler) ;;
159 esac
162 if test "$enable_debug" = yes ; then
163 AC_MSG_RESULT(including debugging symbols)
164 CFLAGS="$CFLAGS -g"
167 if test "$enable_profile" = yes ; then
168 AC_MSG_RESULT(enabling performance profiling)
169 CFLAGS="$CFLAGS -pg"
172 if test "$enable_arch" = yes ; then
173 CFLAGS="$CFLAGS -march=native"
176 case "$enable_optimize" in
177 yes|full)
178 AC_MSG_RESULT(producing heavily optimized code)
180 CFLAGS="$CFLAGS -O3"
182 case "$host" in
183 x86_64*|i?86*) CFLAGS="$CFLAGS -DALLOW_UNALIGNED_IO" ;;
184 esac
186 case "$CC" in
187 *gcc*) CFLAGS="$CFLAGS -fstrength-reduce -fthread-jumps \
188  -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop \
189  -fexpensive-optimizations -fforce-addr" ;;
190 esac
192 if test "$enable_debug" != yes -a "$enable_profile" != yes ; then
193 CFLAGS="$CFLAGS -fomit-frame-pointer"
194 LDFLAGS="$LDFLAGS -s"
195 fi ;;
197 low)
199 AC_MSG_RESULT(using minimal optimizations)
200 CFLAGS="$CFLAGS -O3" ;;
202 esac
204 if test "$enable_asm" = yes ; then
205 case "$host" in
206 i?86*)
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) ;;
211 esac
214 case "$host" in
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 ;;
218 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(SYS_OBJS)
228 AC_SUBST(FB_OBJS)
229 AC_SUBST(SDL_CFLAGS)
230 AC_SUBST(SDL_LIBS)
231 AC_SUBST(SDL2_LIBS)
232 AC_SUBST(TARGETS)
233 AC_SUBST(XINCS)
234 AC_SUBST(XLIBS)
236 AC_CONFIG_HEADER(sys/nix/config.h)
237 AC_OUTPUT(Makefile)