~random-stuff/random-stuff/snes9x-OLD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
AC_INIT([snes9x-gtk], 1.54.1)

AC_CONFIG_MACRO_DIR([macros])

if test -z "$CFLAGS"; then
    CFLAGS="-Os -pipe"
fi
if test -z "$CXXFLAGS"; then
    CXXFLAGS="$CFLAGS"
fi

EXTRA_FLAGS="-Wall -W -pedantic -Wno-unused-parameter -Wno-unused-but-set-variable"
CFLAGS="$CFLAGS $EXTRA_FLAGS"
CXXFLAGS="$CXXFLAGS $EXTRA_FLAGS"

AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_LANG_CPLUSPLUS

AX_CXX_COMPILE_STDCXX([11], [noext], [optional])

AC_PROG_INSTALL
AM_INIT_AUTOMAKE([foreign subdir-objects])

m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

AM_PROG_CC_C_O
IT_PROG_INTLTOOL([0.37.0])
GETTEXT_PACKAGE=[snes9x-gtk]
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")

AM_GLIB_GNU_GETTEXT

snes9xlocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(snes9xlocaledir)

AC_ARG_WITH(debug,
  [AS_HELP_STRING([--with(out)-debug],
    [Leave debug information in the final binary (default: without)])],
  [],
  [with_debug=no])

AC_ARG_WITH(opengl,
  [AS_HELP_STRING([--with(out)-opengl],
    [Use OpenGL for output (default: with)])],
  [],
  [with_opengl=yes])

AC_ARG_WITH(joystick, 
  [AS_HELP_STRING([--with(out)-joystick],
    [Enable joystick support if available (default: with)])],
  [],
  [with_joystick=yes])

AC_ARG_WITH(xv, 
  [AS_HELP_STRING([--with(out)-xv],
    [Enable XVideo output on GTK (default: with)])],
  [],
  [with_xv=yes])

AC_ARG_WITH(xrandr, 
  [AS_HELP_STRING([--with(out)-xrandr],
    [Enable XRandR support on GTK (default: with)])],
  [],
  [with_xrandr=yes])

AC_ARG_WITH(portaudio, 
  [AS_HELP_STRING([--with(out)-portaudio],
    [Enable PortAudio sound driver support (default: with)])],
  [],
  [with_portaudio=yes])

AC_ARG_WITH(oss, 
  [AS_HELP_STRING([--with(out)-oss],
    [Enable OSS sound driver support (default: with)])],
  [],
  [with_oss=yes])

AC_ARG_WITH(alsa,
  [AS_HELP_STRING([--with(out)-alsa],
     [Enable ALSA sound driver support (default: with)])],
  [],
  [with_alsa=yes])

AC_ARG_WITH(pulseaudio,
  [AS_HELP_STRING([--with(out)-pulseaudio],
    [Enable PulseAudio sound driver support (default: with)])],
  [],
  [with_pulseaudio=yes])

AC_ARG_WITH(debugger, 
  [AS_HELP_STRING([--with(out)-debugger],
    [Enable debugger (default: without)])],
  [],
  [with_debugger=no])

AC_ARG_WITH(sdd1-decomp,
  [AS_HELP_STRING([--with(out)-sdd1-decomp],
    [Use SDD1 decompression (default: with)])],
  [],
  [with_sdd1_decomp=yes])

AC_ARG_WITH(hq2x, 
  [AS_HELP_STRING([--with(out)-hq2x],
    [Enable support for the HQ2x family of filters (default: with)])],
  [],
  [with_hq2x=yes])

AC_ARG_WITH(xbrz, 
  [AS_HELP_STRING([--with(out)-xbrz],
    [Enable support for the xBRZ filter (default: with)])],
  [],
  [with_xbrz=yes])

AC_ARG_WITH(netplay,
  [AS_HELP_STRING([--with(out)-netplay],
    [Enable netplay support (default: without)])],
  [],
  [with_netplay=yes])

AC_ARG_WITH(jma-decomp, 
  [AS_HELP_STRING([--with(out)-jma-decomp],
    [Enable JMA archive decompression (default: with)])],
  [],
  [with_jma_decomp=yes])

AC_ARG_WITH(newblend,
  [AS_HELP_STRING([--with(out)-newblend],
    [New colour blender (default: with)])],
  [],
  [with_newblend=yes])

AC_ARG_WITH(zlib,
  [AS_HELP_STRING([--with(out)-zlib],
    [Support gzip decompression])],
  [],
  [with_zlib=yes])

AC_ARG_WITH(screenshot,
  [AS_HELP_STRING([--with(out)-screenshot],
    [Screenshot support through libpng if available (default: with)])],
  [],
  [with_screenshot=yes])

AC_ARG_WITH(gtk3,
  [AS_HELP_STRING([--with(out)-gtk3],
    [Build with GTK+ 3 if available (default: without)])],
  [],
  [with_gtk3=no])

if test yes = "$with_debug" ; then
  CFLAGS="$CFLAGS -g"
else
  CFLAGS="$CFLAGS -fomit-frame-pointer"
fi

LIBS="$LIBS -lX11 -ldl -lXext"

ZSNESFX='#ZSNESFX=yes'
ZSNESC4='#ZSNESC4=yes'
ASMCPU=''
SDD1_DECOMP='#SDD1_DECOMP=yes'
JMA='#JMA=yes'
SPC700ASM=''
I386SPC=''
CPUINC=''
NETPLAY='#NETPLAY=yes'

SYSLIBS=''
NASM='not_found'

OPENGL=0

if test yes = "$with_opengl" ; then
  OPENGL=yes
fi

GTK=yes
snes9x_info_display="GTK"

GTK3_WARNING=no
if test yes = "$with_gtk3" ; then
    GTK_VERSION="gtk+-3.0"
    GTK3_WARNING=yes
    CFLAGS="$CFLAGS -DUSE_GTK3"
else
    GTK_VERSION="gtk+-2.0 >= 2.16"
fi

PKG_CHECK_MODULES([GTK], ["$GTK_VERSION"])
PKG_CHECK_MODULES([GLIB], [gthread-2.0 >= 2.6 gobject-2.0 >= 2.6])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.0])

if test yes = "$with_opengl" ; then

    AC_CHECK_LIB(GL,glGetString,[
        OPENGL=yes
        CFLAGS="$CFLAGS -DUSE_OPENGL"
        LIBS="$LIBS -lGL"
    ],[
        OPENGL=0
    ])
fi

GTKJOY=0
SDL_CFLAGS=""
SDL_LIBS=""
if test yes = "$with_joystick"; then
    PKG_CHECK_MODULES([SDL],[sdl],[
        GTKJOY=yes
        CFLAGS="$CFLAGS -DUSE_JOYSTICK"
    ],[
        AC_CHECK_PROG(SDLCONFIGFOUND,[sdl-config],yes,no)
        
        if test yes = "$SDLCONFIGFOUND" ; then
            SDL_CFLAGS="-DUSE_JOYSTICK `sdl-config --cflags`"
            SDL_LIBS="`sdl-config --libs`"
            GTKJOY=yes
        else
            echo "Cannot find SDL. Disabling joystick support."
        fi
    ])
fi

XV=0
XV_CFLAGS=""
XV_LIBS=""
if test yes = "$with_xv" ; then
    PKG_CHECK_MODULES([XV],[xv],[
        XV=yes
        CFLAGS="$CFLAGS -DUSE_XV"
    ],[
        echo "Cannot find libXv. Make sure the X11 development headers are installed."
        echo "--> Disabling Xv support"
    ])
fi

PORTAUDIO=0
PORTAUDIO_CFLAGS=""
PORTAUDIO_LIBS=""
if test yes = "$with_portaudio" ; then
    PKG_CHECK_MODULES([PORTAUDIO], [portaudio-2.0 >= 10],[
        PORTAUDIO=yes
        CFLAGS="$CFLAGS -DUSE_PORTAUDIO"
    ],[
        echo "Cannot find PortAudio."
        echo "--> Disabling PortAudio support"
    ])
fi

OSS=0
if test yes = "$with_oss" ; then

    AC_CHECK_HEADER(sys/soundcard.h, [
      CFLAGS="$CFLAGS -DUSE_OSS"
      OSS=yes
    ],[
        echo "Cannot find OSS headers."
        echo "--> Disabling OSS support"
    ])    
fi

ALSA=0
ALSA_CFLAGS=""
ALSA_LIBS=""
if test yes = "$with_alsa" ; then

    PKG_CHECK_MODULES([ALSA], [alsa],[
        ALSA=yes
        CFLAGS="$CFLAGS -DUSE_ALSA"
    ],[
        echo "Cannot find ALSA development support."
        echo "--> Disabling ALSA"
    ])
fi

PULSEAUDIO=0
PULSEAUDIO_CFLAGS=""
PULSEAUDIO_LIBS=""
if test yes = "$with_pulseaudio" ; then
    PKG_CHECK_MODULES([PULSEAUDIO], [libpulse-simple],[
        PULSEAUDIO=yes
        CFLAGS="$CFLAGS -DUSE_PULSEAUDIO"
    ],[
        echo "Cannot find PulseAudio library."
        echo "--> Disabling PulseAudio"
    ])
fi

XRANDR=0
XRANDR_CFLAGS=""
XRANDR_LIBS=""
if test yes = "$with_xrandr" ; then
    PKG_CHECK_MODULES([XRANDR],[xrandr],[
        XRANDR=yes
        CFLAGS="$CFLAGS -DUSE_XRANDR"
    ],[
        echo "Cannot find libXrandr. Make sure the X11 development headers are installed."
        echo "--> Disabling Xrandr support."
    ])
fi

LIBPNG_CFLAGS=""
LIBPNG_LIBS=""
if test yes = "$with_screenshot"; then
    PKG_CHECK_MODULES([LIBPNG],[libpng],[
        CFLAGS="$CFLAGS -DHAVE_LIBPNG"
    ],[
        echo "Cannot find libpng."
        echo "--> Disabling screenshot support."
    ])
fi

if test yes = "$with_hq2x" ; then
    HQ2X=yes
    CFLAGS="$CFLAGS -DUSE_HQ2X"
else
    HQ2X=0
fi

if test yes = "$with_xbrz" ; then
    XBRZ=yes
    CFLAGS="$CFLAGS -DUSE_XBRZ"
else
    XBRZ=0
fi

CFLAGS="$CFLAGS $GTK_CFLAGS $GLIB_CFLAGS $LIBXML_CFLAGS $PORTAUDIO_CFLAGS $LIBPNG_CFLAGS $SDL_CFLAGS $XV_CFLAGS $XRANDR_CFLAGS $ALSA_CFLAGS $PULSEAUDIO_CFLAGS"
LIBS="$LIBS $GTK_LIBS $GLIB_LIBS $LIBXML_LIBS $PORTAUDIO_LIBS $LIBPNG_LIBS $SDL_LIBS $XV_LIBS $XRANDR_LIBS $ALSA_LIBS $PULSEAUDIO_LIBS"

NASM="not_found"
ZSNESC4=no
ZSNESFX=no

CFLAGS="$CFLAGS -DCORRECT_VRAM_READS"
CORRECT_VRAM_READS=1

if test yes = "$with_debugger"; then
   CFLAGS="$CFLAGS -DDEBUGGER"
fi

dnl Enable SDD1 decompression if requested
if test yes = "$with_sdd1_decomp"; then
   CFLAGS="$CFLAGS -DSDD1_DECOMP"
   SDD1_DECOMP=yes
fi

dnl Enable Netplay support if requested
if test yes = "$with_netplay"; then
   CFLAGS="$CFLAGS -DNETPLAY_SUPPORT"
   NETPLAY=yes
fi

dnl Enable jma decompression (nachs own format)
if test yes = "$with_jma_decomp"; then
   CFLAGS="$CFLAGS -DJMA_SUPPORT"
   JMA=yes
fi

if test yes = "$with_zlib"; then
  AC_CHECK_HEADERS(zlib.h)
  AC_CHECK_LIB(z, gzread, [
        CFLAGS="$CFLAGS -DZLIB"
        LIBS="$LIBS -lz"
      ], ,)
fi

dnl Check for functions
AC_CHECK_FUNC(mkstemp, [
  CFLAGS="$CFLAGS -DHAVE_MKSTEMP"
])

dnl Check for headers

AC_CHECK_HEADER(strings.h, [
  CFLAGS="$CFLAGS -DHAVE_STRINGS_H"
])

AC_CHECK_HEADER(sys/ioctl.h, [
  CFLAGS="$CFLAGS -DHAVE_SYS_IOCTL_H"
])

AC_CHECK_HEADER(stdint.h, [
  CFLAGS="$CFLAGS -DHAVE_STDINT_H"
])


dnl Check SAR

AC_DEFUN([AC_MY_CHECK_SAR],
[
AC_MSG_CHECKING([if rightshift $1 is arithmetic])
AC_CACHE_VAL(ac_cv_my_sar_$1,
[
AC_TRY_RUN([
#include "../port.h"

int main(void){
    $1 i;

    i=-1;
    i>>=1;
    return(i<0?0:1);
}
],ac_cv_my_sar_$1=yes,ac_cv_my_sar_$1=no,ac_cv_my_sar_%1=no)
])

if test $ac_cv_my_sar_$1 = no; then
  AC_MSG_RESULT(no)
else
  CFLAGS="$CFLAGS -DRIGHTSHIFT_$1_IS_SAR"
  AC_MSG_RESULT(yes)
fi
])

AC_MSG_CHECKING(if sizeof(void *) == sizeof(int))
AC_TRY_RUN([
  int main()
  {
   return(!(sizeof(void *) == sizeof(int)));
  }
], snes9x_ptr_is_int=yes)
if test x$snes9x_ptr_is_int = xyes; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  CFLAGS="$CFLAGS -DPTR_NOT_INT"
fi

AC_MY_CHECK_SAR(int8)
AC_MY_CHECK_SAR(int16)
AC_MY_CHECK_SAR(int32)
AC_MY_CHECK_SAR(int64)
if test $ac_cv_my_sar_int8 = yes && \
   test $ac_cv_my_sar_int16 = yes && \
   test $ac_cv_my_sar_int32 = yes && \
   test $ac_cv_my_sar_int64 = yes ; then
  CFLAGS="$CFLAGS -DRIGHTSHIFT_IS_SAR"
fi

CFLAGS="$CFLAGS -DUNZIP_SUPPORT -DSPC700_C -I. -I.. -I../unzip"

CXXFLAGS="$CFLAGS"

CCASFLAGS="$CFLAGS -I.. -I../i386"

AM_CONDITIONAL(ZSNESFX, [test yes = "$ZSNESFX"])
AM_CONDITIONAL(ZSNESC4, [test yes = "$ZSNESC4"])
AM_CONDITIONAL(ASMCPU, [test yes = "$ASMCPU"])
AM_CONDITIONAL(SDD1_DECOMP, [test yes = "$SDD1_DECOMP"])
AM_CONDITIONAL(NETPLAY, [test yes = "$NETPLAY"])
AM_CONDITIONAL(JMA, [test yes = "$JMA"])
AM_CONDITIONAL(OPENGL, [test yes = "$OPENGL"])
AM_CONDITIONAL(XV, [test yes = "$XV"])
AM_CONDITIONAL(PORTAUDIO, [test yes = "$PORTAUDIO"])
AM_CONDITIONAL(OSS, [test yes = "$OSS"])
AM_CONDITIONAL(DEBUG, [test yes = "$with_debug" ])
AM_CONDITIONAL(SDL, [test yes = "$GTKJOY"])
AM_CONDITIONAL(ALSA, [test yes = "$ALSA"])
AM_CONDITIONAL(PULSEAUDIO, [test yes = "$PULSEAUDIO"])
AM_CONDITIONAL(HQ2X, [test yes = "$HQ2X"])
AM_CONDITIONAL(XBRZ, [test yes = "$XBRZ"])

AC_SUBST(NASM)
AC_SUBST(NASM_FLAGS)

AC_OUTPUT(Makefile data/Makefile po/Makefile.in)

echo ""
echo "Snes9x will build with support for the following:"
echo ""

if test yes = "$GTK3_WARNING" ; then
    echo "    GTK+ 3.0 (experimental)"
else
    echo "    GTK+ 2.0"
fi

if test yes = "$ALSA" ; then
    echo "    ALSA"
fi

if test yes = "$PULSEAUDIO" ; then
    echo "    PulseAudio"
fi

if test yes = "$OPENGL" ; then
    echo "    OpenGL"
else
    if test yes = "$with_opengl" ; then
        echo "!!! NOT able to use OpenGL support"
    fi
fi

if test yes = "$XV" ; then
    echo "    XVideo"
else
    if test yes = "$with_xv" ; then
        echo "!!! NOT able to use XVideo support"
        echo "--- Needs recent X11 libraries and headers"
    fi
fi

if test yes = "$XRANDR" ; then
    echo "    XRandR"
else
    if test yes = "$with_xrandr" ; then
        echo "!!! NOT able to use XRandR support"
        echo "--- Needs recent X11 libraries and headers"
    fi
fi

if test yes = "$GTKJOY" ; then
    echo "    Joysticks"
else
    if test yes = "$with_joystick" ; then
        echo "!!! NOT able to use joystick support"
        echo "--- Needs SDL libraries and headers"
    fi
fi

if test yes = "$NETPLAY" ; then
    echo "    NetPlay"
else
    if test yes = "$with_netplay" ; then
        echo "!!! NOT able to build NetPlay support"

    fi
fi

echo ""

if ! test yes = "$PORTAUDIO" ; then
    if ! test yes = "$OSS" ; then
        if ! test yes = "$SDL"; then
            if ! test yes = "$ALSA"; then
                echo "ERROR: No audio driver is selected or available. Snes9x will probably not build."
            fi
        fi
    fi
fi

if ! test yes = "$HQ2X"; then
    echo "HQ2x filter compilation is disabled."
fi

if ! test yes = "$XBRZ"; then
    echo "xBRZ filter compilation is disabled."
fi