1AC_INIT([src/mednafen.cpp]) 2AC_GNU_SOURCE 3AC_USE_SYSTEM_EXTENSIONS 4AC_CONFIG_MACRO_DIR([m4]) 5 6# 7# Avoid trailing and leading zeroes in the decimal version components to avoid confusing not-so-learned people. 8# 9MEDNAFEN_VERSION='1.26.1' 10MEDNAFEN_VERSION_NUMERIC=0x00102601 11# 0xJJJnnnRR 12 13AC_CANONICAL_HOST 14AM_INIT_AUTOMAKE([mednafen], $MEDNAFEN_VERSION) 15m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) 16AC_CONFIG_HEADERS([include/config.h:include/config.h.in]) 17 18AC_PROG_CC 19AC_PROG_CPP 20AM_PROG_AS 21AM_PROG_CC_C_O 22AC_PROG_CXX 23AC_PROG_CXXCPP 24AC_LANG_CPLUSPLUS 25 26CXX="$CXX -std=gnu++11" 27CXXCPP="$CXXCPP -std=gnu++11" 28CC="$CC -std=gnu99" 29CPP="$CPP -std=gnu99" 30 31AX_CFLAGS_GCC_OPTION([-fsigned-char], CC) 32AX_CXXFLAGS_GCC_OPTION([-fsigned-char], CXX) 33 34AC_PROG_INSTALL 35 36gl_VISIBILITY 37 38AC_SYS_LARGEFILE 39AC_FUNC_FSEEKO 40AC_DEFINE(_LARGEFILE64_SOURCE, [1], [Define for largefile support through extra functions.]) 41AC_DEFINE(_LARGEFILE_SOURCE, [1], [Define for fseeko and ftello on some hosts.]) 42 43# sizeof tests need to come after largefile support macros 44 45AC_CHECK_TYPE(ptrdiff_t,long) 46AC_TYPE_SIZE_T 47AC_CHECK_SIZEOF(char) 48AC_CHECK_SIZEOF(short) 49AC_CHECK_SIZEOF(int) 50AC_CHECK_SIZEOF(long) 51AC_CHECK_SIZEOF(long long) 52AC_CHECK_SIZEOF(__int64) 53AC_CHECK_SIZEOF(void *) 54AC_CHECK_SIZEOF(size_t) 55AC_CHECK_SIZEOF(ptrdiff_t) 56AC_CHECK_SIZEOF(off_t) 57AC_C_CONST 58AC_CHECK_FUNCS(memcmp memcpy memmove memset mmap munmap madvise signal sigaction fork pipe dup2 fcntl getenv putenv setenv gettimeofday getpwuid getuid strerror strerror_r ftello fopen64 fseeko64 ftello64 fstat64 ftruncate64 __mingw_get_crt_info) 59 60AC_SEARCH_LIBS(fmodl, [m]) 61 62# 63# Check for any libraries that need to be linked against for clock_gettime(). 64# 65# (posix4 is apparently used by much older versions of Solaris according to tar, pre-7, so maybe it's not necessary 66# for Mednafen?) 67AC_SEARCH_LIBS(clock_gettime, [rt posix4]) 68AC_CHECK_FUNCS(clock_gettime nanosleep usleep localtime_r gmtime_r) 69 70AC_CHECK_HEADERS(fcntl.h) 71AC_CHECK_HEADERS(stdint.h inttypes.h) 72AC_FUNC_MKDIR 73PKG_PROG_PKG_CONFIG 74 75AC_CHECK_FUNCS(round nearbyint nearbyintf rint rintf) 76AC_CHECK_HEADERS(fenv.h) 77 78 79AC_DEFINE(MINILZO_HAVE_CONFIG_H, [1], [Define if config.h is present]) 80 81AM_ICONV 82AM_GNU_GETTEXT 83 84AC_SUBST(LIBICONV) 85AC_SUBST(LIBINTL) 86 87dnl Check for zlib 88AC_CHECK_LIB([z], [zlibVersion], ZLIB_LIBS="-lz", AC_MSG_ERROR([*** zlib not found!])) 89AC_SUBST([ZLIB_LIBS]) 90 91 92ENABLE_LIBXXX_MODE=false 93AC_ARG_ENABLE(libxxx-mode, AC_HELP_STRING([--enable-libxxx-mode], [dev use only])) 94if test x$enable_libxxx_mode = xyes; then 95 ENABLE_LIBXXX_MODE=true 96fi 97 98AC_ARG_ENABLE(dev-build, 99 AC_HELP_STRING([--enable-dev-build], [enable expensive Mednafen developer features [[default=no]]]), 100 , enable_dev_build=no) 101 102if test x$enable_dev_build = xyes; then 103 AC_DEFINE([MDFN_ENABLE_DEV_BUILD], [1], [Define if we are compiling with expensive Mednafen developer features enabled.]) 104fi 105 106dnl -fno-fast-math and -fno-unsafe-math-optimizations to make sure it's disabled, as the fast-math feature on certain older 107dnl versions of gcc produces horribly broken code(and even when it's working correctly, it can have somewhat unpredictable effects). 108dnl 109dnl -fno-aggressive-loop-optimizations because I don't trust gcc's aggressive loop optimizations, and there miiight be old code 110dnl in Mednafen that would cause problems. 111dnl 112dnl -fomit-frame-pointer is required for some x86 inline assembly to compile. 113dnl 114dnl -fstrict-aliasing for OpenBSD 115dnl 116OPTIMIZER_FLAGS="" 117AX_CFLAGS_GCC_OPTION([-fno-fast-math], OPTIMIZER_FLAGS) 118AX_CFLAGS_GCC_OPTION([-fno-unsafe-math-optimizations], OPTIMIZER_FLAGS) 119AX_CFLAGS_GCC_OPTION([-fno-aggressive-loop-optimizations], OPTIMIZER_FLAGS) 120AX_CFLAGS_GCC_OPTION([-fno-ipa-icf], OPTIMIZER_FLAGS) 121AX_CFLAGS_GCC_OPTION([-fno-printf-return-value], OPTIMIZER_FLAGS) 122AX_CFLAGS_GCC_OPTION([-fomit-frame-pointer], OPTIMIZER_FLAGS) 123AX_CFLAGS_GCC_OPTION([-fstrict-aliasing], OPTIMIZER_FLAGS) 124 125dnl 126dnl Aggressively try to disable PIC and PIE, as it has a significant performance overhead and will 127dnl break some code(with compile-time failures or run-time assert()s triggering). 128dnl 129dnl Use -fwrapv instead of -fno-strict-overflow; -fno-strict-overflow is buggy on gcc and does not work as documented/implied. 130dnl 131dnl -mfunction-return=keep, -mindirect-branch=keep, -mno-indirect-branch-register to disable performance-murdering Spectre mitigations. 132dnl 133CODEGEN_FLAGS="" 134 135AX_CFLAGS_GCC_OPTION([-fno-pic], CODEGEN_FLAGS) 136AX_CFLAGS_GCC_OPTION([-fno-pie], CODEGEN_FLAGS) 137AX_CFLAGS_GCC_OPTION([-fno-PIC], CODEGEN_FLAGS) 138AX_CFLAGS_GCC_OPTION([-fno-PIE], CODEGEN_FLAGS) 139AX_CFLAGS_GCC_OPTION([-nopie], CODEGEN_FLAGS) 140AX_CFLAGS_GCC_OPTION([-no-pie], CODEGEN_FLAGS) 141 142AX_CFLAGS_GCC_OPTION([-fwrapv], CODEGEN_FLAGS) 143AX_CFLAGS_GCC_OPTION([-fjump-tables], CODEGEN_FLAGS) 144AX_CFLAGS_GCC_OPTION([-mfunction-return=keep], CODEGEN_FLAGS) 145AX_CFLAGS_GCC_OPTION([-mindirect-branch=keep], CODEGEN_FLAGS) 146AX_CFLAGS_GCC_OPTION([-mno-indirect-branch-register], CODEGEN_FLAGS) 147AX_CFLAGS_GCC_OPTION([-mno-retpoline], CODEGEN_FLAGS) 148 149CODEGEN_CFLAGS="" 150 151CODEGEN_CXXFLAGS="" 152AX_CXXFLAGS_GCC_OPTION([-fexceptions], CODEGEN_CXXFLAGS) 153 154WARNING_FLAGS="" 155AX_CFLAGS_GCC_OPTION([-Wall], WARNING_FLAGS) 156AX_CFLAGS_GCC_OPTION([-Wshadow], WARNING_FLAGS) 157AX_CFLAGS_GCC_OPTION([-Wempty-body], WARNING_FLAGS) 158AX_CFLAGS_GCC_OPTION([-Wignored-qualifiers], WARNING_FLAGS) 159AX_CFLAGS_GCC_OPTION([-Wvla], WARNING_FLAGS) 160AX_CFLAGS_GCC_OPTION([-Wvariadic-macros], WARNING_FLAGS) 161AX_CFLAGS_GCC_OPTION([-Wdisabled-optimization], WARNING_FLAGS) 162AX_CFLAGS_GCC_OPTION([-Werror=write-strings], WARNING_FLAGS) 163AC_SUBST(WARNING_FLAGS) 164 165################################# 166# 167# Used as needed in Makefile.am: 168# 169NO_STACK_PROTECTOR_FLAGS="" 170AX_CFLAGS_GCC_OPTION([-fno-stack-protector], NO_STACK_PROTECTOR_FLAGS) 171AX_CFLAGS_GCC_OPTION([-fno-stack-protector-all], NO_STACK_PROTECTOR_FLAGS) 172AX_CFLAGS_GCC_OPTION([-fno-stack-protector-strong], NO_STACK_PROTECTOR_FLAGS) 173AC_SUBST(NO_STACK_PROTECTOR_FLAGS) 174 175# Used for ngp and quicklz 176NO_STRICT_ALIASING_FLAGS="" 177AX_CFLAGS_GCC_OPTION([-fno-strict-aliasing], NO_STRICT_ALIASING_FLAGS) 178AC_SUBST(NO_STRICT_ALIASING_FLAGS) 179 180# ----------------------------------- 181# Begin snes flags 182# 183SNES_EXTRA_FLAGS="" 184SNES_EXTRA_CXXFLAGS="" 185AX_CFLAGS_GCC_OPTION([-Wno-unused], SNES_EXTRA_FLAGS) 186AX_CFLAGS_GCC_OPTION([-Wno-shadow], SNES_EXTRA_FLAGS) 187AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], SNES_EXTRA_FLAGS) 188AX_CFLAGS_GCC_OPTION([-Wno-uninitialized], SNES_EXTRA_FLAGS) 189AX_CFLAGS_GCC_OPTION([-Wno-parentheses], SNES_EXTRA_FLAGS) 190AX_CFLAGS_GCC_OPTION([-Wno-switch], SNES_EXTRA_FLAGS) 191AC_SUBST(SNES_EXTRA_FLAGS) 192AC_SUBST(SNES_EXTRA_CXXFLAGS) 193# 194# End snes flags 195# ----------------------------------- 196 197# ----------------------------------- 198# Begin ss flags 199# 200SS_EXTRA_FLAGS="" 201AX_CFLAGS_GCC_OPTION([-mtune=haswell], SS_EXTRA_FLAGS) 202AC_SUBST(SS_EXTRA_FLAGS) 203# 204# End ss flags 205# ----------------------------------- 206# 207# End used-as-needed flags 208######################################## 209 210AM_CONDITIONAL(WANT_DEBUGGER, false) 211AM_CONDITIONAL(WANT_FANCY_SCALERS, false) 212 213AC_ARG_ENABLE(debugger, 214 AC_HELP_STRING([--enable-debugger], [build with internal debugger [[default=yes]]]), 215 , enable_debugger=yes) 216 217if test x$enable_debugger = xyes; then 218 AC_DEFINE([WANT_DEBUGGER], [1], [Define if we are compiling with debugger.]) 219 AM_CONDITIONAL(WANT_DEBUGGER, true) 220fi 221 222AC_ARG_ENABLE(cjk-fonts, 223 AC_HELP_STRING([--enable-cjk-fonts], [build with internal CJK(Chinese, Japanese, Korean) fonts [[default=yes]]]), 224 , enable_cjk_fonts=yes) 225 226if test x$enable_cjk_fonts = xyes; then 227 AC_DEFINE([WANT_INTERNAL_CJK], [1], [Define if we are compiling with internal CJK fonts.]) 228fi 229 230AC_ARG_ENABLE(fancy-scalers, 231 AC_HELP_STRING([--enable-fancy-scalers], [build with fancy(2xsai, hq2x, etc.) CPU-intensive software video scalers [[default=yes]]]), 232 , enable_fancy_scalers=yes) 233 234if test x$enable_fancy_scalers = xyes; then 235 AC_DEFINE([WANT_FANCY_SCALERS], [1], [Define if we are compiling with with fancy CPU-intensive software video scalers.]) 236 AM_CONDITIONAL(WANT_FANCY_SCALERS, true) 237fi 238 239dnl 240dnl The code that uses $enable_altivec is lower, in the CPU architecture section. 241dnl 242AC_ARG_ENABLE(altivec, 243 AC_HELP_STRING([--enable-altivec], [use AltiVec extensions on PowerPC/POWER ISA processors [[default=yes]]]), 244 , enable_altivec=yes) 245 246 247AM_CONDITIONAL(WANT_APPLE2_EMU, false) 248AM_CONDITIONAL(WANT_GB_EMU, false) 249AM_CONDITIONAL(WANT_GBA_EMU, false) 250AM_CONDITIONAL(WANT_LYNX_EMU, false) 251AM_CONDITIONAL(WANT_MD_EMU, false) 252AM_CONDITIONAL(WANT_SMS_EMU, false) 253AM_CONDITIONAL(WANT_NES_EMU, false) 254AM_CONDITIONAL(WANT_NES_NEW_EMU, false) 255AM_CONDITIONAL(WANT_NGP_EMU, false) 256AM_CONDITIONAL(WANT_PCE_EMU, false) 257AM_CONDITIONAL(WANT_PCE_FAST_EMU, false) 258AM_CONDITIONAL(WANT_PCFX_EMU, false) 259AM_CONDITIONAL(WANT_PSX_EMU, false) 260AM_CONDITIONAL(WANT_SMS_EMU, false) 261AM_CONDITIONAL(WANT_SNES_EMU, false) 262AM_CONDITIONAL(WANT_SNES_FAUST_EMU, false) 263AM_CONDITIONAL(WANT_SS_EMU, false) 264AM_CONDITIONAL(WANT_SSFPLAY_EMU, false) 265AM_CONDITIONAL(WANT_VB_EMU, false) 266AM_CONDITIONAL(WANT_WSWAN_EMU, false) 267 268AM_CONDITIONAL(NEED_BLIP_BUFFER, false) 269 270AM_CONDITIONAL(NEED_GB_APU_EMU, false) 271AM_CONDITIONAL(NEED_YM2413_EMU, false) 272AM_CONDITIONAL(NEED_YM2612_EMU, false) 273AM_CONDITIONAL(NEED_PCE_PSG_EMU, false) 274AM_CONDITIONAL(NEED_SMS_APU_EMU, false) 275 276AM_CONDITIONAL(NEED_68K_EMU, false) 277AM_CONDITIONAL(NEED_Z80_EMU, false) 278AM_CONDITIONAL(NEED_V810_EMU, false) 279 280AM_CONDITIONAL(NEED_HUC6270_EMU, false) 281AM_CONDITIONAL(NEED_ARCADE_CARD_EMU, false) 282 283AC_ARG_ENABLE(apple2, 284 AC_HELP_STRING([--enable-apple2], [build with Apple II+ emulation [[default=yes]]]), 285 , enable_apple2=yes) 286 287if test x$enable_apple2 = xyes; then 288 AC_DEFINE([WANT_APPLE2_EMU], [1], [Define if we are compiling with Apple II+ emulation.]) 289 AM_CONDITIONAL(WANT_APPLE2_EMU, true) 290fi 291 292AC_ARG_ENABLE(gb, 293 AC_HELP_STRING([--enable-gb], [build with GameBoy emulation [[default=yes]]]), 294 , enable_gb=yes) 295 296if test x$enable_gb = xyes; then 297 AC_DEFINE([WANT_GB_EMU], [1], [Define if we are compiling with GB emulation.]) 298 AM_CONDITIONAL(WANT_GB_EMU, true) 299 AM_CONDITIONAL(NEED_GB_APU_EMU, true) 300 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 301fi 302 303AC_ARG_ENABLE(gba, 304 AC_HELP_STRING([--enable-gba], [build with GameBoy Advance emulation [[default=yes]]]), 305 , enable_gba=yes) 306 307if test x$enable_gba = xyes; then 308 AC_DEFINE([WANT_GBA_EMU], [1], [Define if we are compiling with GBA emulation.]) 309 AM_CONDITIONAL(WANT_GBA_EMU, true) 310 AM_CONDITIONAL(NEED_GB_APU_EMU, true) 311 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 312fi 313 314AC_ARG_ENABLE(lynx, 315 AC_HELP_STRING([--enable-lynx], [build with Atari Lynx emulation [[default=yes]]]), 316 , enable_lynx=yes) 317 318if test x$enable_lynx = xyes; then 319 AC_DEFINE([WANT_LYNX_EMU], [1], [Define if we are compiling with Lynx emulation.]) 320 AM_CONDITIONAL(WANT_LYNX_EMU, true) 321 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 322fi 323 324AC_ARG_ENABLE(md, 325 AC_HELP_STRING([--enable-md], [build with Sega Genesis/MegaDrive emulation [[default=yes]]]), 326 , enable_md=yes) 327 328if test x$enable_md = xyes; then 329 AC_DEFINE([WANT_MD_EMU], [1], [Define if we are compiling with Sega Genesis/MegaDrive emulation.]) 330 AM_CONDITIONAL(WANT_MD_EMU, true) 331 AM_CONDITIONAL(NEED_68K_EMU, true) 332 AM_CONDITIONAL(NEED_Z80_EMU, true) 333 AM_CONDITIONAL(NEED_YM2612_EMU, true) 334 AM_CONDITIONAL(NEED_SMS_APU_EMU, true) 335 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 336fi 337 338AC_ARG_ENABLE(nes, 339 AC_HELP_STRING([--enable-nes], [build with Nintendo Entertainment System emulation [[default=yes]]]), 340 , enable_nes=yes) 341 342if test x$enable_nes = xyes; then 343 AC_DEFINE([WANT_NES_EMU], [1], [Define if we are compiling with NES emulation.]) 344 AM_CONDITIONAL(WANT_NES_EMU, true) 345fi 346 347#AC_ARG_ENABLE(nes_new, 348# AC_HELP_STRING([--enable-nes-new], [build with experimental, alternate new(ish) NES emulation [[default=yes]]]), 349# , enable_nes_new=yes) 350# 351#if test x$enable_nes_new = xyes; then 352# AC_DEFINE([WANT_NES_NEW_EMU], [1], [Define if we are compiling with experimental, alternate new(ish) NES emulation.]) 353# AM_CONDITIONAL(WANT_NES_NEW_EMU, true) 354#fi 355 356AC_ARG_ENABLE(ngp, 357 AC_HELP_STRING([--enable-ngp], [build with Neo Geo Pocket emulation [[default=yes]]]), 358 , enable_ngp=yes) 359 360if test x$enable_ngp = xyes; then 361 AC_DEFINE([WANT_NGP_EMU], [1], [Define if we are compiling with NGP emulation.]) 362 AM_CONDITIONAL(WANT_NGP_EMU, true) 363 AM_CONDITIONAL(NEED_Z80_EMU, true) 364 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 365fi 366 367AC_ARG_ENABLE(pce, 368 AC_HELP_STRING([--enable-pce], [build with PC Engine(TurboGrafx 16) emulation [[default=yes]]]), 369 , enable_pce=yes) 370 371if test x$enable_pce = xyes; then 372 AC_DEFINE([WANT_PCE_EMU], [1], [Define if we are compiling with PCE emulation.]) 373 AM_CONDITIONAL(WANT_PCE_EMU, true) 374 AM_CONDITIONAL(NEED_PCE_PSG_EMU, true) 375 AM_CONDITIONAL(NEED_HUC6270_EMU, true) 376 AM_CONDITIONAL(NEED_ARCADE_CARD_EMU, true) 377fi 378 379AC_ARG_ENABLE(pce-fast, 380 AC_HELP_STRING([--enable-pce-fast], [build the separate, fast PC Engine(TurboGrafx 16) emulation [[default=yes]]]), 381 , enable_pce_fast=yes) 382 383if test x$enable_pce_fast = xyes; then 384 AC_DEFINE([WANT_PCE_FAST_EMU], [1], [Define if we are compiling with separate fast PCE emulation.]) 385 AM_CONDITIONAL(WANT_PCE_FAST_EMU, true) 386 AM_CONDITIONAL(NEED_ARCADE_CARD_EMU, true) 387 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 388fi 389 390AC_ARG_ENABLE(pcfx, 391 AC_HELP_STRING([--enable-pcfx], [build with PC-FX emulation [[default=yes]]]), 392 , enable_pcfx=yes) 393 394if test x$enable_pcfx = xyes; then 395 AC_DEFINE([WANT_PCFX_EMU], [1], [Define if we are compiling with PC-FX emulation.]) 396 AM_CONDITIONAL(WANT_PCFX_EMU, true) 397 AM_CONDITIONAL(NEED_V810_EMU, true) 398 AM_CONDITIONAL(NEED_PCE_PSG_EMU, true) 399 AM_CONDITIONAL(NEED_HUC6270_EMU, true) 400fi 401 402AC_ARG_ENABLE(psx, 403 AC_HELP_STRING([--enable-psx], [build with PlayStation emulation [[default=yes]]]), 404 , enable_psx=yes) 405 406if test x$enable_psx = xyes; then 407 AC_DEFINE([WANT_PSX_EMU], [1], [Define if we are compiling with PlayStation emulation.]) 408 AM_CONDITIONAL(WANT_PSX_EMU, true) 409fi 410 411AC_ARG_ENABLE(sms, 412 AC_HELP_STRING([--enable-sms], [build with SMS+GG emulation [[default=yes]]]), 413 , enable_sms=yes) 414 415if test x$enable_sms = xyes; then 416 AC_DEFINE([WANT_SMS_EMU], [1], [Define if we are compiling with SMS+GG emulation.]) 417 AM_CONDITIONAL(WANT_SMS_EMU, true) 418 AM_CONDITIONAL(NEED_Z80_EMU, true) 419 AM_CONDITIONAL(NEED_SMS_APU_EMU, true) 420 AM_CONDITIONAL(NEED_YM2413_EMU, true) 421 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 422fi 423 424AC_ARG_ENABLE(snes, 425 AC_HELP_STRING([--enable-snes], [build with SNES emulation [[default=yes]]]), 426 , enable_snes=yes) 427 428if test x$enable_snes = xyes; then 429 AC_DEFINE([WANT_SNES_EMU], [1], [Define if we are compiling with SNES emulation.]) 430 AM_CONDITIONAL(WANT_SNES_EMU, true) 431fi 432 433AC_ARG_ENABLE(snes-faust, 434 AC_HELP_STRING([--enable-snes-faust], [build with experimental fast SNES emulation [[default=yes]]]), 435 , enable_snes_faust=yes) 436 437if test x$enable_snes_faust = xyes; then 438 AC_DEFINE([WANT_SNES_FAUST_EMU], [1], [Define if we are compiling with experimental fast SNES emulation.]) 439 AM_CONDITIONAL(WANT_SNES_FAUST_EMU, true) 440fi 441 442AC_ARG_ENABLE(ss, 443 AC_HELP_STRING([--enable-ss], [build with Sega Saturn emulation [[default=x86_64 amd64 aarch64* arm64* ppc64* powerpc64*]]]), 444 , [enable_ss="x86_64 amd64 aarch64* arm64* ppc64* powerpc64*"]) 445for i in $enable_ss; do case $host_cpu in $i) enable_ss=yes ;; esac; done 446 447if test "x$enable_ss" = "xyes"; then 448 AC_DEFINE([WANT_SS_EMU], [1], [Define if we are compiling with Sega Saturn emulation.]) 449 AM_CONDITIONAL(WANT_SS_EMU, true) 450 AM_CONDITIONAL(NEED_68K_EMU, true) 451fi 452 453AC_ARG_ENABLE(ssfplay, 454 AC_HELP_STRING([--enable-ssfplay], [build with SSF playback support [[default=yes]]]), 455 , enable_ssfplay=yes) 456 457if test x$enable_ssfplay = xyes; then 458 AC_DEFINE([WANT_SSFPLAY_EMU], [1], [Define if we are compiling with SSF playback support.]) 459 AM_CONDITIONAL(WANT_SSFPLAY_EMU, true) 460 AM_CONDITIONAL(NEED_68K_EMU, true) 461fi 462 463AC_ARG_ENABLE(vb, 464 AC_HELP_STRING([--enable-vb], [build with Virtual Boy emulation [[default=yes]]]), 465 , enable_vb=yes) 466 467if test x$enable_vb = xyes; then 468 AC_DEFINE([WANT_VB_EMU], [1], [Define if we are compiling with Virtual Boy emulation.]) 469 AM_CONDITIONAL(WANT_VB_EMU, true) 470 AM_CONDITIONAL(NEED_V810_EMU, true) 471 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 472fi 473 474 475AC_ARG_ENABLE(wswan, 476 AC_HELP_STRING([--enable-wswan], [build with WonderSwan emulation [[default=yes]]]), 477 , enable_wswan=yes) 478 479if test x$enable_wswan = xyes; then 480 AC_DEFINE([WANT_WSWAN_EMU], [1], [Define if we are compiling with WonderSwan emulation.]) 481 AM_CONDITIONAL(WANT_WSWAN_EMU, true) 482 AM_CONDITIONAL(NEED_BLIP_BUFFER, true) 483fi 484 485## 486## ALSA and JACK checking code ripped from SDL's autoconf file, with heavy modifications 487## 488# 489# ALSA 490# 491AM_CONDITIONAL(HAVE_ALSA, false) 492AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]), 493 [], 494 [enable_alsa=yes]) 495if test x$enable_alsa = xyes; then 496 AM_PATH_ALSA(1.0.0, have_alsa=yes, have_alsa=no) 497 498 # Restore all flags from before the ALSA detection runs 499 CFLAGS="$alsa_save_CFLAGS" 500 LDFLAGS="$alsa_save_LDFLAGS" 501 LIBS="$alsa_save_LIBS" 502 503 if test x$have_alsa = xyes; then 504 AM_CONDITIONAL(HAVE_ALSA, true) 505 AC_DEFINE([HAVE_ALSA], [1], [Define if we are compiling with ALSA support.]) 506 fi 507fi 508AC_SUBST([ALSA_LIBS]) 509AC_SUBST([ALSA_CFLAGS]) 510 511 512# 513# JACK 514# 515AM_CONDITIONAL(HAVE_JACK, false) 516AC_ARG_ENABLE(jack, AC_HELP_STRING([--enable-jack], [support the JACK audio API [[default=yes]]]), 517 [], 518 [enable_jack=yes]) 519if test x$enable_jack = xyes; then 520 PKG_CHECK_MODULES(JACK, jack, [have_jack=yes], [have_jack=no]) 521 522 if test x$have_jack = xyes; then 523 AM_CONDITIONAL(HAVE_JACK, true) 524 AC_DEFINE([HAVE_JACK], [1], [Define if we are compiling with JACK support.]) 525 fi 526fi 527AC_SUBST([JACK_LIBS]) 528AC_SUBST([JACK_CFLAGS]) 529 530 531# 532# OpenBSD Audio 533# 534AM_CONDITIONAL(HAVE_OPENBSD_AUDIO, false) 535AC_MSG_CHECKING([for OpenBSD audio]) 536AC_TRY_COMPILE([ 537 #include <sys/types.h> 538 #include <sys/ioctl.h> 539 #include <sys/audioio.h> 540 #include <string.h> 541 ], 542 [ 543 struct audio_swpar par; 544 struct audio_pos pos; 545 struct audio_status status; 546 AUDIO_INITPAR(&par); 547 ], 548 [AC_MSG_RESULT([yes]) 549 AM_CONDITIONAL(HAVE_OPENBSD_AUDIO, true) 550 AC_DEFINE([HAVE_OPENBSD_AUDIO], [1], [Define if we are compiling with OpenBSD audio support.])], 551 [AC_MSG_RESULT([no])]) 552 553# 554# mpcdec 555# 556AM_CONDITIONAL(HAVE_EXTERNAL_MPCDEC, false) 557AC_ARG_WITH([external-mpcdec], [AS_HELP_STRING([--with-external-mpcdec], [compile and link with external mpcdec @<:@default=no@:>@])], 558 [], 559 [with_external_mpcdec=no]) 560if test x$with_external_mpcdec = xyes; then 561 AC_CHECK_LIB([mpcdec], [mpc_demux_init], [], AC_MSG_ERROR([*** mpcdec not found!])) 562 AC_CHECK_HEADER([mpc/mpcdec.h], [], AC_MSG_ERROR([*** mpcdec not found!])) 563 564 AC_DEFINE([HAVE_EXTERNAL_MPCDEC], [1], [Define if we are compiling and linking with external mpcdec.]) 565 AM_CONDITIONAL(HAVE_EXTERNAL_MPCDEC, true) 566 AC_SUBST([MPCDEC_LIBS], ["-lmpcdec"]) 567else 568 AC_DEFINE([MPC_FIXED_POINT], [1], [Define to use fixed-point MPC decoder.]) 569fi 570 571# 572# tremor 573# 574AM_CONDITIONAL(HAVE_EXTERNAL_TREMOR, false) 575AC_ARG_WITH([external-tremor], [AS_HELP_STRING([--with-external-tremor], [compile and link with external tremor @<:@default=no@:>@])], 576 [], 577 [with_external_tremor=no]) 578if test x$with_external_tremor = xyes; then 579 AC_CHECK_LIB([vorbisidec], [ov_read], [], AC_MSG_ERROR([*** libvorbisidec not found!])) 580 AC_CHECK_HEADER([tremor/ivorbisfile.h], [], AC_MSG_ERROR([*** libvorbisidec not found!])) 581 582 AC_DEFINE([HAVE_EXTERNAL_TREMOR], [1], [Define if we are compiling and linking with external tremor.]) 583 AM_CONDITIONAL(HAVE_EXTERNAL_TREMOR, true) 584 AC_SUBST([TREMOR_LIBS], ["-lvorbisidec"]) 585fi 586 587# 588# trio 589# 590AM_CONDITIONAL(HAVE_EXTERNAL_TRIO, false) 591AC_ARG_WITH([external-trio], [AS_HELP_STRING([--with-external-trio], [compile and link with external trio @<:@default=no@:>@])], 592 [], 593 [with_external_trio=no]) 594if test x$with_external_trio = xyes; then 595 AC_CHECK_LIB([trio], [trio_printf], [], AC_MSG_ERROR([*** libtrio not found!])) 596 AC_CHECK_HEADER([trio.h], [], AC_MSG_ERROR([*** libtrio not found!])) 597 598 AC_DEFINE([HAVE_EXTERNAL_TRIO], [1], [Define if we are compiling and linking with external trio.]) 599 AM_CONDITIONAL(HAVE_EXTERNAL_TRIO, true) 600 AC_SUBST([TRIO_LIBS], ["-ltrio"]) 601 trio_include_symsrc="include/trio_external" 602else 603 trio_include_symsrc="src/trio" 604fi 605AC_CONFIG_LINKS([include/trio/triodef.h:$trio_include_symsrc/triodef.h]) 606AC_CONFIG_LINKS([include/trio/trio.h:$trio_include_symsrc/trio.h]) 607AC_CONFIG_LINKS([include/trio/trionan.h:$trio_include_symsrc/trionan.h]) 608AC_CONFIG_LINKS([include/trio/triop.h:$trio_include_symsrc/triop.h]) 609AC_CONFIG_LINKS([include/trio/triostr.h:$trio_include_symsrc/triostr.h]) 610 611# 612# minilzo/lzo 613# 614AM_CONDITIONAL(HAVE_EXTERNAL_LZO2, false) 615AC_ARG_WITH([external-lzo], [AS_HELP_STRING([--with-external-lzo], [compile and link with external LZO @<:@default=no@:>@])], 616 [], 617 [with_external_lzo=no]) 618if test x$with_external_lzo = xyes; then 619 PKG_CHECK_MODULES(LZO2, lzo2 >= 2.0.9, [], AC_MSG_ERROR([*** lzo2 >= 2.0.9 not found!])) 620 AC_SUBST([LZO2_LIBS]) 621 AC_SUBST([LZO2_CFLAGS]) 622 AC_DEFINE([HAVE_EXTERNAL_LZO2], [1], [Define if we are compiling and linking with external LZO.]) 623 AM_CONDITIONAL(HAVE_EXTERNAL_LZO2, true) 624 minilzo_include_symsrc="include/minilzo_external" 625else 626 minilzo_include_symsrc="include/minilzo_internal" 627fi 628AC_CONFIG_LINKS([include/minilzo/minilzo.h:$minilzo_include_symsrc/minilzo.h]) 629 630# 631# libsndfile 632# 633AM_CONDITIONAL(HAVE_LIBSNDFILE, false) 634AC_ARG_WITH([libsndfile], 635 [AS_HELP_STRING([--with-libsndfile], 636 [support various sound file formats in ripped CD images @<:@default=yes@:>@])], 637 [], 638 [with_libsndfile=yes]) 639if test x$with_libsndfile = xyes; then 640 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, [], AC_MSG_ERROR([*** libsndfile >= 1.0.2 not found!])) 641 AC_DEFINE([HAVE_LIBSNDFILE], [1], [Define if we are compiling with libsndfile support.]) 642 AM_CONDITIONAL(HAVE_LIBSNDFILE, true) 643fi 644AC_SUBST([SNDFILE_LIBS]) 645AC_SUBST([SNDFILE_CFLAGS]) 646 647AM_CONDITIONAL(HAVE_OSSDSP, false) 648AM_CONDITIONAL(HAVE_DIRECTSOUND, false) 649AM_CONDITIONAL(HAVE_WASAPI, false) 650AM_CONDITIONAL(HAVE_SDL, false) 651AM_CONDITIONAL(DOS, false) 652AM_CONDITIONAL(WIN32, false) 653AM_CONDITIONAL(UNIX, false) 654AM_CONDITIONAL(HAVE_LINUX_JOYSTICK, false) 655AM_CONDITIONAL(ENABLE_LIBXXX_MODE, false) 656NEED_SDL=true 657 658if $ENABLE_LIBXXX_MODE; then 659 NEED_SDL=false 660 AC_DEFINE([ENABLE_LIBXXX_MODE], [1], [Define if we are compiling in libxxx mode.]) 661 AM_CONDITIONAL(ENABLE_LIBXXX_MODE, true) 662fi 663 664if expr x"$host" : 'x.*-mingw*' > /dev/null; then 665 AC_CHECK_TOOL([WINDRES], [windres]) 666 667 if test x$host_cpu != xx86_64; then 668 # Enable larger address space support(for the 32-bit build). 669 LDFLAGS="$LDFLAGS -Wl,--large-address-aware" 670 AX_CFLAGS_GCC_OPTION([-march=i686], OPTIMIZER_FLAGS) 671 AX_CFLAGS_GCC_OPTION([-mtune=pentium3], OPTIMIZER_FLAGS) 672 else 673 AX_CFLAGS_GCC_OPTION([-mtune=amdfam10], OPTIMIZER_FLAGS) 674 fi 675 676 # Always build with DirectSound support. 677 AM_CONDITIONAL(HAVE_DIRECTSOUND,true) 678 AC_DEFINE([HAVE_DIRECTSOUND], [1], [Define if we are compiling with DirectSound support.]) 679 LIBS="-ldxguid -lwinmm -ldsound $LIBS" 680 681 # Always build with WASAPI support. 682 AM_CONDITIONAL(HAVE_WASAPI,true) 683 AC_DEFINE([HAVE_WASAPI], [1], [Define if we are compiling with WASAPI support.]) 684 LIBS="-lole32 $LIBS" 685 686 AC_DEFINE([PSS_STYLE],[2], [Defines the filesystem path-separator type.]) 687 AC_DEFINE([WIN32], [1], [Define if we are compiling for Win32.]) 688 AM_CONDITIONAL(WIN32, true) 689 690 LIBS="-mconsole -lws2_32 -ldxguid -lwinmm -ldinput $LIBS -lwinmm" 691 CPPFLAGS="-D_LFS64_LARGEFILE=1 $CPPFLAGS" 692elif expr x"$host" : 'x.*djgpp' > /dev/null; then 693 AC_DEFINE([PSS_STYLE],[2], [Defines the filesystem path-separator type.]) 694 AC_DEFINE([DOS], [1], [Define if we are compiling for DOS.]) 695 AM_CONDITIONAL(DOS, true) 696 NEED_SDL=false 697else 698 AC_DEFINE([PSS_STYLE],[1], [Defines the filesystem path-separator type.]) 699 700 # 701 # POSIX threads 702 # 703 AC_SEARCH_LIBS(pthread_create, [pthread]) 704 AC_CHECK_FUNCS(pthread_create sem_init, [], AC_MSG_ERROR([*** pthreads not found!])) 705 AC_CHECK_FUNCS(sem_timedwait sem_timedwait_monotonic sem_clockwait sem_clockwait_np pthread_condattr_setclock pthread_setname_np pthread_set_name_np pthread_getaffinity_np pthread_setaffinity_np pthread_cond_timedwait_relative_np) 706 AC_CHECK_HEADERS(pthread.h sched.h) 707 AC_CHECK_HEADERS(pthread_np.h, [], [], [ 708 #include <pthread.h> 709 ]) 710 AC_MSG_CHECKING([type for pthread affinity setting]) 711 AC_TRY_COMPILE( 712 [ 713 #include <pthread.h> 714 715 #if defined HAVE_SCHED_H 716 #include <sched.h> 717 #endif 718 719 #if defined(HAVE_PTHREAD_NP_H) 720 #include <pthread_np.h> 721 #endif 722 ], 723 [ 724 cpu_set_t c; 725 int result; 726 727 CPU_ZERO(&c); 728 729 result = pthread_setaffinity_np(pthread_self(), sizeof(c), &c); 730 result = pthread_getaffinity_np(pthread_self(), sizeof(c), &c); 731 ], 732 [ 733 AC_MSG_RESULT([cpu_set_t]) 734 AC_DEFINE([PTHREAD_AFFINITY_NP], [cpu_set_t], [Define to CPU set type if we are compiling with pthreads affinity setting support.]) 735 ], 736 AC_TRY_COMPILE( 737 [ 738 #include <pthread.h> 739 740 #if defined HAVE_SCHED_H 741 #include <sched.h> 742 #endif 743 744 #if defined(HAVE_PTHREAD_NP_H) 745 #include <pthread_np.h> 746 #endif 747 ], 748 [ 749 cpuset_t c; 750 int result; 751 752 CPU_ZERO(&c); 753 754 result = pthread_setaffinity_np(pthread_self(), sizeof(c), &c); 755 result = pthread_getaffinity_np(pthread_self(), sizeof(c), &c); 756 ], 757 [ 758 AC_MSG_RESULT([cpuset_t]) 759 AC_DEFINE([PTHREAD_AFFINITY_NP], [cpuset_t], [Define to CPU set type if we are compiling with pthreads affinity setting support.]) 760 ], 761 [ 762 AC_MSG_RESULT([unknown]) 763 ])) 764 765 766 AC_CHECK_HEADER([sys/soundcard.h],[AM_CONDITIONAL(HAVE_OSSDSP,true) AC_DEFINE([HAVE_OSSDSP], [1], [Define if we are compiling with OSS support.])]) 767 768 # 769 # Linux joystick 770 # 771 AC_MSG_CHECKING([for Linux joystick APIs]) 772 AC_TRY_COMPILE([], 773 [ 774 #ifndef __linux__ 775 #error "error" 776 #endif 777 ], 778 [ 779 AC_TRY_COMPILE([ 780 #include <linux/joystick.h> 781 #include <linux/input.h> 782 ], 783 [ 784 struct js_event dummy0; 785 struct ff_effect dummy1; 786 ], 787 [ 788 AC_MSG_RESULT([yes]) 789 AM_CONDITIONAL(HAVE_LINUX_JOYSTICK, true) 790 AC_DEFINE([HAVE_LINUX_JOYSTICK], [1], [Define if we are compiling with Linux joystick support.]) 791 ], 792 AC_MSG_ERROR([*** Linux joystick APIs not found!])) 793 ], 794 [AC_MSG_RESULT([no])]) 795fi 796 797if $NEED_SDL 798then 799 SDL_VERSION=2.0.5 800 AM_PATH_SDL2($SDL_VERSION, HAVE_SDL=true, HAVE_SDL=false) 801 if $HAVE_SDL 802 then 803 AM_CONDITIONAL(HAVE_SDL, true) 804 AC_DEFINE([HAVE_SDL], [1], [Define if we are compiling with SDL.]) 805 AC_SUBST(SDL_LIBS) 806 AC_SUBST(SDL_CFLAGS) 807 else 808 AC_MSG_ERROR([*** SDL >= 2.0.5 not found!]) 809 fi 810fi 811 812 813dnl 814dnl FIXME: Make sure POSIX/BSD sockets API detection doesn't have any false positives(like when targeting Windows). 815dnl 816AM_CONDITIONAL(HAVE_POSIX_SOCKETS, false) 817dnl 818dnl 819HAVE_POSIX_SOCKETS=yes 820 821dnl 822dnl Solaris may require "nsl" and "socket" libraries. 823dnl 824AC_SEARCH_LIBS([gethostbyname], [nsl]) 825AC_SEARCH_LIBS([socket], [socket network]) 826 827AC_CHECK_FUNCS(socket bind listen connect accept send recv close gethostbyname gethostbyaddr getaddrinfo freeaddrinfo gai_strerror select poll getsockopt setsockopt, [], 828 [HAVE_POSIX_SOCKETS=no]) 829 830if test x$HAVE_POSIX_SOCKETS = xyes; then 831 AM_CONDITIONAL(HAVE_POSIX_SOCKETS, true) 832 AC_DEFINE([HAVE_POSIX_SOCKETS], [1], [Define if we are compiling with POSIX sockets support.]) 833fi 834 835AM_CONDITIONAL(ARCH_X86, false) 836AM_CONDITIONAL(ARCH_X86_32, false) 837AM_CONDITIONAL(ARCH_X86_64, false) 838AM_CONDITIONAL(ARCH_POWERPC, false) 839 840TRIO_CFLAGS="" 841 842dnl OpenBSD... 843AC_TRY_COMPILE([], [asm volatile("vcvtss2si %xmm6,%ecx\n\tvhaddps %ymm7,%ymm7,%ymm7\n\tvzeroupper\n\t");], 844 AC_DEFINE([HAVE_INLINEASM_AVX], [1], [Define if GNU-style AVX inline assembly is supported.]), 845 []) 846 847case "$host_cpu" in 848 x86_64|amd64) 849 AC_DEFINE([ARCH_X86], [1], [Define if we are compiling for 32-bit or 64-bit x86 architectures.]) 850 AM_CONDITIONAL(ARCH_X86, true) 851 AC_DEFINE([ARCH_X86_64], [1], [Define if we are compiling for 64-bit x86 architectures.]) 852 AM_CONDITIONAL(ARCH_X86_64, true) 853 AX_CFLAGS_GCC_OPTION([-mcmodel=small], CODEGEN_FLAGS) 854 ;; 855 856 i*86) 857 AC_DEFINE([ARCH_X86], [1], [Define if we are compiling for 32-bit or 64-bit x86 architectures.]) 858 AM_CONDITIONAL(ARCH_X86, true) 859 AC_DEFINE([ARCH_X86_32], [1], [Define if we are compiling for 32-bit x86 architectures.]) 860 AM_CONDITIONAL(ARCH_X86_32, true) 861 ;; 862 863 powerpc*) 864 AC_DEFINE([ARCH_POWERPC], [1], [Define if we are compiling for PPC architectures.]) 865 AM_CONDITIONAL(ARCH_POWERPC, true) 866 867 if test x$enable_altivec = xyes; then 868 ALTIVEC_FLAGS="" 869 AX_CFLAGS_GCC_OPTION([-faltivec], ALTIVEC_FLAGS) 870 AX_CFLAGS_GCC_OPTION([-maltivec], ALTIVEC_FLAGS) 871 if test "x$ALTIVEC_FLAGS" != "x"; then 872 altivec_save_CPPFLAGS="$CPPFLAGS" 873 CPPFLAGS="$CPPFLAGS $ALTIVEC_FLAGS" 874 AC_CHECK_HEADER([altivec.h], 875 AC_DEFINE([HAVE_ALTIVEC_H], [1], [Define if altivec.h is present and usable.]), 876 [] ) 877 CPPFLAGS="$altivec_save_CPPFLAGS" 878 fi 879 fi 880 ;; 881 882 alpha*) 883 AX_CFLAGS_GCC_OPTION([-mieee], TRIO_CFLAGS) 884 ;; 885esac 886AC_SUBST(TRIO_CFLAGS) 887 888AC_C_BIGENDIAN([AC_DEFINE([MSB_FIRST],[1],[Define on big-endian platforms.])], 889[ 890 AC_DEFINE([LSB_FIRST],[1],[Define on little-endian platforms.]) 891]) 892AC_DEFINE_UNQUOTED([MEDNAFEN_VERSION],"$MEDNAFEN_VERSION", [Mednafen version definition.]) 893AC_DEFINE_UNQUOTED([MEDNAFEN_VERSION_NUMERIC],$MEDNAFEN_VERSION_NUMERIC, [Mednafen version numeric.]) 894 895AC_SUBST([AM_CFLAGS], "$ALTIVEC_FLAGS $OPTIMIZER_FLAGS $WARNING_FLAGS $CODEGEN_FLAGS $CODEGEN_CFLAGS") 896AC_SUBST([AM_CXXFLAGS], "$ALTIVEC_FLAGS $OPTIMIZER_FLAGS $WARNING_FLAGS $CODEGEN_FLAGS $CODEGEN_CXXFLAGS") 897 898dnl Output Makefiles 899AC_OUTPUT([Makefile po/Makefile.in intl/Makefile src/Makefile src/drivers/Makefile src/drivers_libxxx/Makefile src/drivers_dos/Makefile src/sexyal/Makefile src/ss/Makefile]) 900