1# configure.ac for PCem
2#
3
4AC_PREREQ([2.61])
5AC_INIT(PCem, v14, Sarah Walker <pcem@pcem-emulator.co.uk>, pcem)
6
7AC_CANONICAL_HOST
8
9AM_INIT_AUTOMAKE
10AC_PROG_CC
11AC_PROG_CXX
12AM_PROG_CC_C_O
13
14
15
16AC_MSG_CHECKING([whether to build for release])
17AC_ARG_ENABLE(release_build,
18          AC_HELP_STRING([--enable-release-build], [build for release]))
19if test "$enable_release_build" = "yes"; then
20   AC_MSG_RESULT([yes])
21else
22   AC_MSG_RESULT([no])
23fi
24AM_CONDITIONAL(RELEASE_BUILD, [test "$enable_release_build" = "yes"])
25
26AC_MSG_CHECKING([whether to enable debugging])
27AC_ARG_ENABLE(debug,
28          AC_HELP_STRING([--enable-debug], [build debug executable]))
29if test "$enable_debug" = "yes"; then
30   CFLAGS="-Wall -O0 -g -D_DEBUG"
31   CXXFLAGS="-Wall -O0 -g -D_DEBUG"
32   AC_MSG_RESULT([yes])
33else
34   CFLAGS="-O3"
35   CXXFLAGS="-O3"
36   AC_MSG_RESULT([no])
37fi
38
39AC_MSG_CHECKING([whether to enable networking])
40AC_ARG_ENABLE(networking,
41          AC_HELP_STRING([--enable-networking], [enable networking]))
42if test "$enable_networking" = "yes"; then
43   AC_MSG_RESULT([yes])
44else
45   AC_MSG_RESULT([no])
46fi
47
48AC_MSG_CHECKING([whether to use ALSA for MIDI output])
49AC_ARG_ENABLE(alsa,
50          AC_HELP_STRING([--enable-alsa], [use ALSA for MIDI]))
51if test "$enable_alsa" = "yes"; then
52   AC_MSG_RESULT([yes])
53else
54   AC_MSG_RESULT([no])
55fi
56
57AC_MSG_CHECKING([for cpu])
58case "${host_cpu}" in
59    i?86)
60    CPU=i386
61    AC_MSG_RESULT(${host_cpu})
62    ;;
63    x86_64|amd64)
64    CPU=x86_64
65    AC_MSG_RESULT(${host_cpu})
66    ;;
67    *)
68    AC_MSG_ERROR([Unsupported CPU.])
69    ;;
70esac
71
72AM_CONDITIONAL(CPU_I386, test "$CPU" = "i386")
73AM_CONDITIONAL(CPU_X86_64, test "$CPU" = "x86_64")
74
75AC_MSG_CHECKING([for off64_t])
76AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],[[off64_t n=0;]])],[has_lfs="yes"],[has_lfs="no"])
77case "$host" in
78    *-*-freebsd*|*-*-dragonfly*) # has off64_t but no fopen64/etc.
79       has_lfs="no"
80       ;;
81esac
82AC_MSG_RESULT($has_lfs)
83
84#AC_MSG_CHECKING([for libz])
85#AX_CHECK_ZLIB
86
87AM_CONDITIONAL(USE_WX, test "$enable_wx" = "yes")
88AM_CONDITIONAL(USE_NETWORKING, test "$enable_networking" = "yes")
89AM_CONDITIONAL(USE_ALSA, test "$enable_alsa" = "yes")
90
91AM_CONDITIONAL(HAS_OFF64T, test "$has_lfs" = "yes")
92
93SDL_VERSION=2.0.1
94AM_PATH_SDL2($SDL_VERSION,
95   :,
96   AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
97)
98
99AM_OPTIONS_WXCONFIG
100reqwx=3.0.0
101AM_PATH_WXCONFIG($reqwx, wxWin=1)
102if test "$wxWin" != 1; then
103   AC_MSG_ERROR([
104      wxWidgets must be installed on your system.
105
106      Please check that wx-config is in path, the directory
107      where wxWidgets libraries are installed (returned by
108      'wx-config --libs' or 'wx-config --static --libs' command)
109      is in LD_LIBRARY_PATH or equivalent variable and
110      wxWidgets version is $reqwx or above.
111      ])
112fi
113
114if test "$enable_alsa" == "yes"; then
115    AC_CHECK_LIB(asound, snd_pcm_open,
116        [],
117        [echo "You need to install the ALSA library."
118     exit -1])
119fi
120
121AC_CHECK_LIB([pthread], [pthread_create])
122
123build_macosx="no"
124build_linux="no"
125build_win="no"
126build_other="no"
127
128case "$host" in
129    *-*-darwin*)
130       LIBS="$LIBS -framework OpenGL"
131       LIBS="$LIBS -framework OpenAL"
132       build_macosx="yes"
133       ;;
134    *-*-cygwin* | *-*-mingw32*)
135       AC_CHECK_LIB([opengl32], [main], [], \
136           [echo "You need to install the OpenGL library."
137           exit -1])
138       AC_CHECK_LIB([openal], [alGetError], [], \
139          [echo "You need to install the OpenAL library."
140           exit -1])
141       build_win="yes"
142       AC_SUBST(SET_MAKE, 'MAKE=mingw32-make')
143       ;;
144    *-*-linux*)
145       AC_CHECK_LIB([GL], [glGetError], [], \
146           [echo "You need to install the OpenGL library."
147           exit -1])
148       AC_CHECK_LIB([openal], [alGetError], [], \
149           [echo "You need to install the OpenAL library."
150           exit -1])
151       build_linux="yes"
152       ;;
153    *)
154       AC_CHECK_LIB([GL], [glGetError], [], \
155           [echo "You need to install the OpenGL library."
156           exit -1])
157       AC_CHECK_LIB([openal], [alGetError], [], \
158           [echo "You need to install the OpenAL library."
159           exit -1])
160       build_other="yes"
161       ;;
162esac
163
164LIBS="$LIBS $WX_LIBS $SDL_LIBS"
165
166AM_CONDITIONAL(OS_LINUX, [test "$build_linux" = "yes"])
167AM_CONDITIONAL(OS_WINDOWS, [test "$build_win" = "yes"])
168AM_CONDITIONAL(OS_OTHER, [test "$build_other" = "yes"])
169AM_CONDITIONAL(OS_MACOSX, [test "$build_macosx" = "yes"])
170
171AC_OUTPUT([Makefile src/Makefile])
172