1AC_INIT([snes9x-gtk], 1.54.1)
2
3AC_CONFIG_MACRO_DIR([macros])
4
5if test -z "$CFLAGS"; then
6    CFLAGS="-Os -pipe"
7fi
8if test -z "$CXXFLAGS"; then
9    CXXFLAGS="$CFLAGS"
10fi
11
12EXTRA_FLAGS="-Wall -W -pedantic -Wno-unused-parameter -Wno-unused-but-set-variable"
13CFLAGS="$CFLAGS $EXTRA_FLAGS"
14CXXFLAGS="$CXXFLAGS $EXTRA_FLAGS"
15
16AC_PROG_CC
17AC_PROG_CXX
18AC_PROG_RANLIB
19AC_LANG_CPLUSPLUS
20
21AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
22
23AC_PROG_INSTALL
24AM_INIT_AUTOMAKE([foreign subdir-objects])
25
26m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
27
28AM_PROG_CC_C_O
29IT_PROG_INTLTOOL([0.37.0])
30GETTEXT_PACKAGE=[snes9x-gtk]
31AC_SUBST(GETTEXT_PACKAGE)
32AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")
33
34AM_GLIB_GNU_GETTEXT
35
36snes9xlocaledir='${prefix}/${DATADIRNAME}/locale'
37AC_SUBST(snes9xlocaledir)
38
39AC_ARG_WITH(debug,
40  [AS_HELP_STRING([--with(out)-debug],
41    [Leave debug information in the final binary (default: without)])],
42  [],
43  [with_debug=no])
44
45AC_ARG_WITH(opengl,
46  [AS_HELP_STRING([--with(out)-opengl],
47    [Use OpenGL for output (default: with)])],
48  [],
49  [with_opengl=yes])
50
51AC_ARG_WITH(joystick,
52  [AS_HELP_STRING([--with(out)-joystick],
53    [Enable joystick support if available (default: with)])],
54  [],
55  [with_joystick=yes])
56
57AC_ARG_WITH(xv,
58  [AS_HELP_STRING([--with(out)-xv],
59    [Enable XVideo output on GTK (default: with)])],
60  [],
61  [with_xv=yes])
62
63AC_ARG_WITH(xrandr,
64  [AS_HELP_STRING([--with(out)-xrandr],
65    [Enable XRandR support on GTK (default: with)])],
66  [],
67  [with_xrandr=yes])
68
69AC_ARG_WITH(portaudio,
70  [AS_HELP_STRING([--with(out)-portaudio],
71    [Enable PortAudio sound driver support (default: with)])],
72  [],
73  [with_portaudio=yes])
74
75AC_ARG_WITH(oss,
76  [AS_HELP_STRING([--with(out)-oss],
77    [Enable OSS sound driver support (default: with)])],
78  [],
79  [with_oss=yes])
80
81AC_ARG_WITH(alsa,
82  [AS_HELP_STRING([--with(out)-alsa],
83     [Enable ALSA sound driver support (default: with)])],
84  [],
85  [with_alsa=yes])
86
87AC_ARG_WITH(pulseaudio,
88  [AS_HELP_STRING([--with(out)-pulseaudio],
89    [Enable PulseAudio sound driver support (default: with)])],
90  [],
91  [with_pulseaudio=yes])
92
93AC_ARG_WITH(debugger,
94  [AS_HELP_STRING([--with(out)-debugger],
95    [Enable debugger (default: without)])],
96  [],
97  [with_debugger=no])
98
99AC_ARG_WITH(sdd1-decomp,
100  [AS_HELP_STRING([--with(out)-sdd1-decomp],
101    [Use SDD1 decompression (default: with)])],
102  [],
103  [with_sdd1_decomp=yes])
104
105AC_ARG_WITH(hq2x,
106  [AS_HELP_STRING([--with(out)-hq2x],
107    [Enable support for the HQ2x family of filters (default: with)])],
108  [],
109  [with_hq2x=yes])
110
111AC_ARG_WITH(xbrz,
112  [AS_HELP_STRING([--with(out)-xbrz],
113    [Enable support for the xBRZ filter (default: with)])],
114  [],
115  [with_xbrz=yes])
116
117AC_ARG_WITH(netplay,
118  [AS_HELP_STRING([--with(out)-netplay],
119    [Enable netplay support (default: without)])],
120  [],
121  [with_netplay=yes])
122
123AC_ARG_WITH(jma-decomp,
124  [AS_HELP_STRING([--with(out)-jma-decomp],
125    [Enable JMA archive decompression (default: with)])],
126  [],
127  [with_jma_decomp=yes])
128
129AC_ARG_WITH(newblend,
130  [AS_HELP_STRING([--with(out)-newblend],
131    [New colour blender (default: with)])],
132  [],
133  [with_newblend=yes])
134
135AC_ARG_WITH(zlib,
136  [AS_HELP_STRING([--with(out)-zlib],
137    [Support gzip decompression])],
138  [],
139  [with_zlib=yes])
140
141AC_ARG_WITH(screenshot,
142  [AS_HELP_STRING([--with(out)-screenshot],
143    [Screenshot support through libpng if available (default: with)])],
144  [],
145  [with_screenshot=yes])
146
147AC_ARG_WITH(gtk3,
148  [AS_HELP_STRING([--with(out)-gtk3],
149    [Build with GTK+ 3 if available (default: without)])],
150  [],
151  [with_gtk3=no])
152
153if test yes = "$with_debug" ; then
154  CFLAGS="$CFLAGS -g"
155else
156  CFLAGS="$CFLAGS -fomit-frame-pointer"
157fi
158
159LIBS="$LIBS -lX11  -lXext"
160
161ZSNESFX='#ZSNESFX=yes'
162ZSNESC4='#ZSNESC4=yes'
163ASMCPU=''
164SDD1_DECOMP='#SDD1_DECOMP=yes'
165JMA='#JMA=yes'
166SPC700ASM=''
167I386SPC=''
168CPUINC=''
169NETPLAY='#NETPLAY=yes'
170
171SYSLIBS=''
172NASM='not_found'
173
174OPENGL=0
175
176if test yes = "$with_opengl" ; then
177  OPENGL=yes
178fi
179
180GTK=yes
181snes9x_info_display="GTK"
182
183GTK3_WARNING=no
184if test yes = "$with_gtk3" ; then
185    GTK_VERSION="gtk+-3.0"
186    GTK3_WARNING=yes
187    CFLAGS="$CFLAGS -DUSE_GTK3"
188else
189    GTK_VERSION="gtk+-2.0 >= 2.16"
190fi
191
192PKG_CHECK_MODULES([GTK], ["$GTK_VERSION"])
193PKG_CHECK_MODULES([GLIB], [gthread-2.0 >= 2.6 gobject-2.0 >= 2.6])
194PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.0])
195
196if test yes = "$with_opengl" ; then
197
198    AC_CHECK_LIB(GL,glGetString,[
199        OPENGL=yes
200        CFLAGS="$CFLAGS -DUSE_OPENGL"
201        LIBS="$LIBS -lGL"
202    ],[
203        OPENGL=0
204    ])
205fi
206
207GTKJOY=0
208SDL_CFLAGS=""
209SDL_LIBS=""
210if test yes = "$with_joystick"; then
211    PKG_CHECK_MODULES([SDL],[sdl2],[
212        GTKJOY=yes
213        CFLAGS="$CFLAGS -DUSE_JOYSTICK"
214    ],[
215        AC_CHECK_PROG(SDLCONFIGFOUND,[sdl2-config],yes,no)
216
217        if test yes = "$SDLCONFIGFOUND" ; then
218            SDL_CFLAGS="-DUSE_JOYSTICK `sdl2-config --cflags`"
219            SDL_LIBS="`sdl2-config --libs`"
220            GTKJOY=yes
221        else
222            echo "Cannot find SDL. Disabling joystick support."
223        fi
224    ])
225fi
226
227XV=0
228XV_CFLAGS=""
229XV_LIBS=""
230if test yes = "$with_xv" ; then
231    PKG_CHECK_MODULES([XV],[xv],[
232        XV=yes
233        CFLAGS="$CFLAGS -DUSE_XV"
234    ],[
235        echo "Cannot find libXv. Make sure the X11 development headers are installed."
236        echo "--> Disabling Xv support"
237    ])
238fi
239
240PORTAUDIO=0
241PORTAUDIO_CFLAGS=""
242PORTAUDIO_LIBS=""
243if test yes = "$with_portaudio" ; then
244    PKG_CHECK_MODULES([PORTAUDIO], [portaudio-2.0 >= 10],[
245        PORTAUDIO=yes
246        CFLAGS="$CFLAGS -DUSE_PORTAUDIO"
247    ],[
248        echo "Cannot find PortAudio."
249        echo "--> Disabling PortAudio support"
250    ])
251fi
252
253OSS=0
254if test yes = "$with_oss" ; then
255
256    AC_CHECK_HEADER(sys/soundcard.h, [
257      CFLAGS="$CFLAGS -DUSE_OSS"
258      OSS=yes
259    ],[
260        echo "Cannot find OSS headers."
261        echo "--> Disabling OSS support"
262    ])
263fi
264
265ALSA=0
266ALSA_CFLAGS=""
267ALSA_LIBS=""
268if test yes = "$with_alsa" ; then
269
270    PKG_CHECK_MODULES([ALSA], [alsa],[
271        ALSA=yes
272        CFLAGS="$CFLAGS -DUSE_ALSA"
273    ],[
274        echo "Cannot find ALSA development support."
275        echo "--> Disabling ALSA"
276    ])
277fi
278
279PULSEAUDIO=0
280PULSEAUDIO_CFLAGS=""
281PULSEAUDIO_LIBS=""
282if test yes = "$with_pulseaudio" ; then
283    PKG_CHECK_MODULES([PULSEAUDIO], [libpulse-simple],[
284        PULSEAUDIO=yes
285        CFLAGS="$CFLAGS -DUSE_PULSEAUDIO"
286    ],[
287        echo "Cannot find PulseAudio library."
288        echo "--> Disabling PulseAudio"
289    ])
290fi
291
292XRANDR=0
293XRANDR_CFLAGS=""
294XRANDR_LIBS=""
295if test yes = "$with_xrandr" ; then
296    PKG_CHECK_MODULES([XRANDR],[xrandr],[
297        XRANDR=yes
298        CFLAGS="$CFLAGS -DUSE_XRANDR"
299    ],[
300        echo "Cannot find libXrandr. Make sure the X11 development headers are installed."
301        echo "--> Disabling Xrandr support."
302    ])
303fi
304
305LIBPNG_CFLAGS=""
306LIBPNG_LIBS=""
307if test yes = "$with_screenshot"; then
308    PKG_CHECK_MODULES([LIBPNG],[libpng],[
309        CFLAGS="$CFLAGS -DHAVE_LIBPNG"
310    ],[
311        echo "Cannot find libpng."
312        echo "--> Disabling screenshot support."
313    ])
314fi
315
316if test yes = "$with_hq2x" ; then
317    HQ2X=yes
318    CFLAGS="$CFLAGS -DUSE_HQ2X"
319else
320    HQ2X=0
321fi
322
323if test yes = "$with_xbrz" ; then
324    XBRZ=yes
325    CFLAGS="$CFLAGS -DUSE_XBRZ"
326else
327    XBRZ=0
328fi
329
330CFLAGS="$CFLAGS $GTK_CFLAGS $GLIB_CFLAGS $LIBXML_CFLAGS $PORTAUDIO_CFLAGS $LIBPNG_CFLAGS $SDL_CFLAGS $XV_CFLAGS $XRANDR_CFLAGS $ALSA_CFLAGS $PULSEAUDIO_CFLAGS"
331LIBS="$LIBS $GTK_LIBS $GLIB_LIBS $LIBXML_LIBS $PORTAUDIO_LIBS $LIBPNG_LIBS $SDL_LIBS $XV_LIBS $XRANDR_LIBS $ALSA_LIBS $PULSEAUDIO_LIBS"
332
333NASM="not_found"
334ZSNESC4=no
335ZSNESFX=no
336
337CFLAGS="$CFLAGS -DCORRECT_VRAM_READS"
338CORRECT_VRAM_READS=1
339
340if test yes = "$with_debugger"; then
341   CFLAGS="$CFLAGS -DDEBUGGER"
342fi
343
344dnl Enable SDD1 decompression if requested
345if test yes = "$with_sdd1_decomp"; then
346   CFLAGS="$CFLAGS -DSDD1_DECOMP"
347   SDD1_DECOMP=yes
348fi
349
350dnl Enable Netplay support if requested
351if test yes = "$with_netplay"; then
352   CFLAGS="$CFLAGS -DNETPLAY_SUPPORT"
353   NETPLAY=yes
354fi
355
356dnl Enable jma decompression (nachs own format)
357if test yes = "$with_jma_decomp"; then
358   CFLAGS="$CFLAGS -DJMA_SUPPORT"
359   JMA=yes
360fi
361
362if test yes = "$with_zlib"; then
363  AC_CHECK_HEADERS(zlib.h)
364  AC_CHECK_LIB(z, gzread, [
365        CFLAGS="$CFLAGS -DZLIB"
366        LIBS="$LIBS -lz"
367      ], ,)
368fi
369
370dnl Check for functions
371AC_CHECK_FUNC(mkstemp, [
372  CFLAGS="$CFLAGS -DHAVE_MKSTEMP"
373])
374
375dnl Check for headers
376
377AC_CHECK_HEADER(strings.h, [
378  CFLAGS="$CFLAGS -DHAVE_STRINGS_H"
379])
380
381AC_CHECK_HEADER(sys/ioctl.h, [
382  CFLAGS="$CFLAGS -DHAVE_SYS_IOCTL_H"
383])
384
385AC_CHECK_HEADER(stdint.h, [
386  CFLAGS="$CFLAGS -DHAVE_STDINT_H"
387])
388
389
390dnl Check SAR
391
392AC_DEFUN([AC_MY_CHECK_SAR],
393[
394AC_MSG_CHECKING([if rightshift $1 is arithmetic])
395AC_CACHE_VAL(ac_cv_my_sar_$1,
396[
397AC_TRY_RUN([
398#include "../port.h"
399
400int main(void){
401    $1 i;
402
403    i=-1;
404    i>>=1;
405    return(i<0?0:1);
406}
407],ac_cv_my_sar_$1=yes,ac_cv_my_sar_$1=no,ac_cv_my_sar_%1=no)
408])
409
410if test $ac_cv_my_sar_$1 = no; then
411  AC_MSG_RESULT(no)
412else
413  CFLAGS="$CFLAGS -DRIGHTSHIFT_$1_IS_SAR"
414  AC_MSG_RESULT(yes)
415fi
416])
417
418AC_MSG_CHECKING(if sizeof(void *) == sizeof(int))
419AC_TRY_RUN([
420  int main()
421  {
422   return(!(sizeof(void *) == sizeof(int)));
423  }
424], snes9x_ptr_is_int=yes)
425if test x$snes9x_ptr_is_int = xyes; then
426  AC_MSG_RESULT(yes)
427else
428  AC_MSG_RESULT(no)
429  CFLAGS="$CFLAGS -DPTR_NOT_INT"
430fi
431
432AC_MY_CHECK_SAR(int8)
433AC_MY_CHECK_SAR(int16)
434AC_MY_CHECK_SAR(int32)
435AC_MY_CHECK_SAR(int64)
436if test $ac_cv_my_sar_int8 = yes && \
437   test $ac_cv_my_sar_int16 = yes && \
438   test $ac_cv_my_sar_int32 = yes && \
439   test $ac_cv_my_sar_int64 = yes ; then
440  CFLAGS="$CFLAGS -DRIGHTSHIFT_IS_SAR"
441fi
442
443CFLAGS="$CFLAGS -DUNZIP_SUPPORT -DSPC700_C -I. -I.. -I../unzip"
444
445CXXFLAGS="$CFLAGS"
446
447CCASFLAGS="$CFLAGS -I.. -I../i386"
448
449AM_CONDITIONAL(ZSNESFX, [test yes = "$ZSNESFX"])
450AM_CONDITIONAL(ZSNESC4, [test yes = "$ZSNESC4"])
451AM_CONDITIONAL(ASMCPU, [test yes = "$ASMCPU"])
452AM_CONDITIONAL(SDD1_DECOMP, [test yes = "$SDD1_DECOMP"])
453AM_CONDITIONAL(NETPLAY, [test yes = "$NETPLAY"])
454AM_CONDITIONAL(JMA, [test yes = "$JMA"])
455AM_CONDITIONAL(OPENGL, [test yes = "$OPENGL"])
456AM_CONDITIONAL(XV, [test yes = "$XV"])
457AM_CONDITIONAL(PORTAUDIO, [test yes = "$PORTAUDIO"])
458AM_CONDITIONAL(OSS, [test yes = "$OSS"])
459AM_CONDITIONAL(DEBUG, [test yes = "$with_debug" ])
460AM_CONDITIONAL(SDL, [test yes = "$GTKJOY"])
461AM_CONDITIONAL(ALSA, [test yes = "$ALSA"])
462AM_CONDITIONAL(PULSEAUDIO, [test yes = "$PULSEAUDIO"])
463AM_CONDITIONAL(HQ2X, [test yes = "$HQ2X"])
464AM_CONDITIONAL(XBRZ, [test yes = "$XBRZ"])
465
466AC_SUBST(NASM)
467AC_SUBST(NASM_FLAGS)
468
469AC_OUTPUT(Makefile data/Makefile po/Makefile.in)
470
471echo ""
472echo "Snes9x will build with support for the following:"
473echo ""
474
475if test yes = "$GTK3_WARNING" ; then
476    echo "    GTK+ 3.0 (experimental)"
477else
478    echo "    GTK+ 2.0"
479fi
480
481if test yes = "$ALSA" ; then
482    echo "    ALSA"
483fi
484
485if test yes = "$PULSEAUDIO" ; then
486    echo "    PulseAudio"
487fi
488
489if test yes = "$OPENGL" ; then
490    echo "    OpenGL"
491else
492    if test yes = "$with_opengl" ; then
493        echo "!!! NOT able to use OpenGL support"
494    fi
495fi
496
497if test yes = "$XV" ; then
498    echo "    XVideo"
499else
500    if test yes = "$with_xv" ; then
501        echo "!!! NOT able to use XVideo support"
502        echo "--- Needs recent X11 libraries and headers"
503    fi
504fi
505
506if test yes = "$XRANDR" ; then
507    echo "    XRandR"
508else
509    if test yes = "$with_xrandr" ; then
510        echo "!!! NOT able to use XRandR support"
511        echo "--- Needs recent X11 libraries and headers"
512    fi
513fi
514
515if test yes = "$GTKJOY" ; then
516    echo "    Joysticks"
517else
518    if test yes = "$with_joystick" ; then
519        echo "!!! NOT able to use joystick support"
520        echo "--- Needs SDL libraries and headers"
521    fi
522fi
523
524if test yes = "$NETPLAY" ; then
525    echo "    NetPlay"
526else
527    if test yes = "$with_netplay" ; then
528        echo "!!! NOT able to build NetPlay support"
529
530    fi
531fi
532
533echo ""
534
535if ! test yes = "$PORTAUDIO" ; then
536    if ! test yes = "$OSS" ; then
537        if ! test yes = "$SDL"; then
538            if ! test yes = "$ALSA"; then
539                echo "ERROR: No audio driver is selected or available. Snes9x will probably not build."
540            fi
541        fi
542    fi
543fi
544
545if ! test yes = "$HQ2X"; then
546    echo "HQ2x filter compilation is disabled."
547fi
548
549if ! test yes = "$XBRZ"; then
550    echo "xBRZ filter compilation is disabled."
551fi
552