1dnl Process this file with autoconf to produce a configure script.
2
3AC_SUBST(CONSOLE_DRIVER)
4AC_SUBST(SOUND_DRIVER)
5AC_SUBST(FILEIO_DRIVER)
6AC_SUBST(MAIN_FILE)
7AC_SUBST(CROSS_PREFIX)
8
9AC_INIT(src/core/agi.c)
10AC_CONFIG_AUX_DIR(./scripts)
11AC_CANONICAL_HOST
12
13if test "${target}" = NONE -o "x${target}" = "x"; then
14	target=${host}
15	target_cpu=${host_cpu}
16	target_vendor=${host_vendor}
17	target_os=${host_os}
18else
19	[ target_cpu=`echo $target | sed 's/^\([^-]*\)-[^-]*-.*$/\1/'` ]
20	[ target_vendor=`echo $target | sed 's/^[^-]*-\([^-]*\)-.*$/\1/'` ]
21	[ target_os=`echo $target | sed 's/^[^-]*-[^-]*-\(.*\)$/\1/'` ]
22fi
23
24echo "        target: ${target}"
25echo "    target CPU: ${target_cpu}"
26echo " target vendor: ${target_vendor}"
27echo "     target OS: ${target_os}"
28
29if test "${target_cpu}" != "${host_cpu}" -o \
30	"${target_os}" != "${host_os}"; then
31	if test "x$CC" = "x"; then
32		CROSS_PREFIX="${target_cpu}-${target_os}-"
33		CC="${CROSS_PREFIX}gcc"
34	fi
35fi
36
37
38AC_PROG_CC
39AC_PROG_CPP
40AC_PROG_RANLIB
41AC_PROG_INSTALL
42AC_PROG_MAKE_SET
43
44AC_ARG_WITH(sdl,    [  --with-sdl              use the Simple DirectMedia Layer])
45AC_ARG_WITH(svgalib,[  --with-svgalib          use SVGAlib for graphics])
46AC_ARG_WITH(alsa,   [  --with-alsa             use ALSA for sound output])
47AC_ARG_WITH(win32,  [  --with-win32            use Win32 console/sound drivers])
48AC_ARG_WITH(amiga,  [  --with-amiga            use Amiga console/sound drivers])
49
50if test "${GCC-no}" = yes; then
51	CFLAGS="${CFLAGS} -Wall"
52fi
53
54MAIN_FILE="main"
55
56case "${target_os}" in
57beos*)
58	CFLAGS="$CFLAGS -I/boot/develop/tools/gnupro/include"
59	CPPFLAGS="$CPPFLAGS -I/boot/develop/tools/gnupro/include"
60	with_sdl="yes"
61	;;
62nto*)
63	AC_CHECK_HEADERS(Pt.h Ph.h)
64	;;
65cygwin*|mingw*)
66	AC_CHECK_HEADERS(wingdi.h)
67	MAIN_FILE="winmain"
68	with_win32="yes"
69	;;
70palmos*)
71	CFLAGS="$CFLAGS -DPALMOS"
72	MAIN_FILE="palmos"
73	;;
74amiga*)
75	CFLAGS="$CFLAGS -DAMIGA -D__AMIGA__ -Uamiga"
76	;;
77esac
78
79
80if test "${with_win32}" = "yes"; then
81	CFLAGS="${CFLAGS} -DELIDE_CODE"
82fi
83
84dnl ----------------------------------------------
85dnl Checks for header files.
86dnl ----------------------------------------------
87
88AC_HEADER_STDC
89AC_CHECK_HEADERS(string.h getopt.h dirent.h time.h)
90
91
92dnl ----------------------------------------------
93dnl Check graphics support.
94dnl ----------------------------------------------
95
96AC_CHECKING([for graphics support])
97CONSOLE_DRIVER="none"
98
99if test "${ac_cv_header_Ph_h}" = "yes"; then
100	CONSOLE_DRIVER="photon"
101	LIBS="${LIBS} -lph -lphrender"
102elif test "${with_win32}" = "yes"; then
103	CONSOLE_DRIVER="win32"
104	AC_CHECK_LIB(cygwin, usleep)
105	LIBS="-lgdi32 ${LIBS} -lcomdlg32"
106elif test "${with_sdl}" = "yes"; then
107	AC_CHECK_HEADERS(SDL SDL/SDL.h)
108	if test "${ac_cv_header_SDL_h}" = "yes"; then
109		CONSOLE_DRIVER="sdl"
110		CFLAGS="`sdl-config --cflags` ${CFLAGS}"
111		if test "${ac_cv_prog_cc_cross}" = "yes"; then
112			LIBS="-lSDL ${LIBS}"
113		else
114			LIBS="`sdl-config --libs` ${LIBS}"
115		fi
116	fi
117	if test "${ac_cv_header_SDL_SDL_h}" = "yes"; then
118		CONSOLE_DRIVER="sdl"
119		CFLAGS="`sdl-config --cflags` ${CFLAGS} -ISDL"
120		if test "${ac_cv_prog_cc_cross}" = "yes"; then
121			LIBS="-lSDL ${LIBS}"
122		else
123			LIBS="`sdl-config --libs` ${LIBS}"
124		fi
125	fi
126	with_x="no"
127elif test "${with_svgalib}" = "yes"; then
128	AC_CHECK_HEADERS(vga.h)
129	if test "${ac_cv_header_vga_h}" = "yes"; then
130		CONSOLE_DRIVER="svgalib"
131		LIBS="-lvga ${LIBS}"
132	fi
133elif test "${with_amiga}" = "yes"; then
134	CONSOLE_DRIVER="amiga"
135	AC_CHECK_LIB(amiga, usleep)
136	LIBS="-m68020 -noixemul -ldebug -lm ${LIBS}"
137else
138	AC_PATH_X
139	if test ! -z "${ac_cv_have_x}"; then
140		CONSOLE_DRIVER="x11"
141		AC_PATH_XTRA
142		AC_CHECK_HEADERS(X11/extensions/XShm.h)
143dnl		AC_CHECK_HEADERS(X11/extensions/xf86dga.h \
144dnl			X11/extensions/xf86vmode.h)
145
146		if test "${ac_cv_header_X11_extensions_XShm_h}" = "yes"; then
147			CFLAGS="${CFLAGS} -DMITSHM"
148			X_LIBS="${X_LIBS} -lXext -lX11"
149		else
150			X_LIBS="${X_LIBS} -lX11"
151		fi
152
153dnl		if test "${ac_cv_header_X11_extensions_xf86dga_h}" = "yes" -a \
154dnl			"${ac_cv_header_X11_extensions_xf86vmode_h}" = "yes";
155dnl		then
156dnl			AC_CHECK_LIB(Xxf86dga,XF86DGAGetVideo,
157dnl			AC_CHECK_LIB(Xxf86vm,XF86VidModeSwitchToMode,
158dnl			CFLAGS="${CFLAGS} -DXF86DGA"))
159dnl		fi
160	fi
161fi
162
163
164dnl ----------------------------------------------
165dnl Check sound support
166dnl ----------------------------------------------
167
168AC_CHECKING([for sound support])
169SOUND_DRIVER="dummy"
170if test "${with_sdl}" = "yes"; then
171	SOUND_DRIVER="sdl"
172else case ${target_os} in
173linux*)
174	case ${target_cpu} in
175	sparc)
176		SOUND_DRIVER="bsd"
177		;;
178	i*86|powerpc|alpha*)
179		AC_CHECK_HEADERS(sys/soundcard.h)
180		AC_CHECK_HEADERS(sys/asoundlib.h)
181		if test "${ac_cv_header_sys_soundcard_h}" = "yes" -a \
182		    "${with_alsa}" != "yes"; then
183			SOUND_DRIVER="oss"
184		elif test "${ac_cv_header_sys_asoundlib_h}" = "yes"; then
185			SOUND_DRIVER="alsa"
186			AC_CHECK_LIB(asound, snd_pcm_open)
187		fi
188		;;
189	esac
190	;;
191freebsd*)
192	SOUND_DRIVER="freebsd"
193	LIBS="${LIBS} -pthread"
194	;;
195nto*)
196	AC_CHECK_HEADERS(sys/asoundlib.h)
197	SOUND_DRIVER="qnx"
198	;;
199hpux*)
200	AC_CHECK_HEADERS(sys/audio.h)
201	if test "${ac_cv_header_sys_audio_h}" = "yes"; then
202		SOUND_DRIVER="hpux"
203	fi
204	;;
205solaris*)
206	AC_CHECK_HEADERS(sys/audioio.h)
207	if test "${ac_cv_header_sys_audioio_h}" = "yes"; then
208		SOUND_DRIVER="solaris"
209	fi
210	;;
211netbsd*|openbsd*)
212	AC_CHECK_HEADERS(sys/audioio.h sys/audio.h)
213	if test "${ac_cv_header_sys_audioio_h}" = "yes"; then
214		SOUND_DRIVER="bsd"
215	fi
216	if test "${ac_cv_header_sys_audio_h}" = "yes"; then
217		SOUND_DRIVER="bsd"
218	fi
219	;;
220irix*)
221	AC_CHECK_HEADERS(dmedia/audio.h)
222	if test "${ac_cv_header_dmedia_audio_h}" = "yes"; then
223		SOUND_DRIVER="sgi"
224		LIBS="${LIBS} -laudio"
225	fi
226	;;
227cygwin*)
228	LDFLAGS="${LDFLAGS} -Wl,--subsystem,windows,-e,_mainCRTStartup"
229	LIBS="-lwinmm ${LIBS}"
230	SOUND_DRIVER="win32"
231	;;
232amiga*)
233	SOUND_DRIVER="amiga"
234	;;
235*)
236	SOUND_DRIVER="dummy"
237	;;
238esac
239fi
240
241case "${SOUND_DRIVER}" in
242dummy|win32|sdl|freebsd|qnx|amiga)
243	;;
244*)
245	AC_CHECK_LIB(pthread, pthread_create,[
246		CFLAGS="${CFLAGS} -D_REENTRANT"
247		LIBS="-lpthread ${LIBS}"
248	], [
249		SOUND_DRIVER="dummy"
250	])
251	;;
252esac
253
254case "${target_os}" in
255nto*)
256	if test "${ac_cv_header_sys_asoundlib_h}" = "yes"; then
257		SOUND_DRIVER="alsa"
258		AC_CHECK_LIB(asound, snd_pcm_open)
259	fi
260	;;
261esac
262
263dnl ----------------------------------------------
264dnl Check for file globbing support
265dnl ----------------------------------------------
266
267AC_CHECKING([for file globbing support])
268FILEIO_DRIVER="unix"
269AC_CHECK_FUNC(_dos_findfirst,[FILEIO_DRIVER="msdos"])
270AC_CHECK_FUNC(_findfirst,[FILEIO_DRIVER="win32"])
271dnl AC_CHECK_FUNC(glob,[FILEIO_DRIVER="unix"])
272
273
274dnl ----------------------------------------------
275dnl Checks for typedefs, structures, and compiler
276dnl characteristics.
277dnl ----------------------------------------------
278
279AC_C_CONST
280AC_C_INLINE
281AC_HEADER_TIME
282
283if test "${ac_cv_c_inline}" != "no"; then
284	CFLAGS="${CFLAGS} -DINLINE=${ac_cv_c_inline}";		\
285fi
286
287
288dnl ----------------------------------------------
289dnl Checks for library functions.
290dnl ----------------------------------------------
291
292AC_PROG_GCC_TRADITIONAL
293AC_FUNC_MEMCMP
294dnl AC_TYPE_SIGNAL
295AC_FUNC_VPRINTF
296AC_CHECK_FUNCS(vsnprintf gettimeofday getopt_long)
297
298AC_MSG_RESULT([----------------------------------------------------------])
299AC_MSG_RESULT([using console driver: ${CONSOLE_DRIVER}])
300AC_MSG_RESULT([using sound driver: ${SOUND_DRIVER}])
301AC_MSG_RESULT([using file globbing method: ${FILEIO_DRIVER}])
302AC_MSG_RESULT([cflags: ${CFLAGS}])
303AC_MSG_RESULT([libs: ${LIBS}])
304AC_MSG_RESULT([----------------------------------------------------------])
305
306AC_OUTPUT(Rules)
307
308