1AC_PREREQ([2.60]) 2AC_INIT([Snes9x], [1.60], [], [snes9x]) 3AC_REVISION([$Revision: 1.60 $]) 4 5AC_CONFIG_SRCDIR([unix.cpp]) 6 7AC_CANONICAL_TARGET 8 9AC_PROG_CC 10AC_PROG_CXX 11AC_LANG([C++]) 12 13S9XFLGS="" 14S9XDEFS="" 15S9XLIBS="" 16 17AC_DEFUN([AC_S9X_COMPILER_FLAG], 18[ 19 AC_MSG_CHECKING([whether g++ accepts $1]) 20 21 AC_CACHE_VAL([snes9x_cv_option_$2], 22 [ 23 OLD_CXXFLAGS="[$]CXXFLAGS" 24 CXXFLAGS="[$]OLD_CXXFLAGS $1" 25 26 AC_TRY_RUN( 27 [ 28 int foo; 29 30 int main (int argc, char **argv) 31 { 32 /* The following code triggs gcc:s generation of aline opcodes, 33 which some versions of as does not support. */ 34 35 if (argc > 0) 36 argc = 0; 37 38 return (argc); 39 } 40 ], 41 [snes9x_cv_option_$2="yes"], [snes9x_cv_option_$2="no"]) 42 ]) 43 44 CXXFLAGS="[$]OLD_CXXFLAGS" 45 46 if test "x[$]snes9x_cv_option_$2" = "xyes"; then 47 S9XFLGS="[$]S9XFLGS $1" 48 AC_MSG_RESULT([yes]) 49 else 50 AC_MSG_RESULT([no]) 51 $3 52 fi 53]) 54 55# ***************************** 56# *** Execution begins here *** 57# ***************************** 58 59# Test what compiler flags we should use. 60 61AC_ARG_ENABLE([debug], 62 [AS_HELP_STRING([--enable-debug], 63 [leave debug information in the final binary (default: no)])], 64 [], [enable_debug="no"]) 65 66if test "x$enable_debug" = "xyes"; then 67 AC_S9X_COMPILER_FLAG([-g], [g]) 68 AC_S9X_COMPILER_FLAG([-O0], [o0]) 69else 70 AC_S9X_COMPILER_FLAG([-O3], [o3], [ 71 AC_S9X_COMPILER_FLAG([-O2], [o2], [ 72 AC_S9X_COMPILER_FLAG([-O1], [o1])])]) 73 AC_S9X_COMPILER_FLAG([-fomit-frame-pointer], [omit_frame_pointer]) 74fi 75 76AC_ARG_ENABLE([mtune], 77 [AS_HELP_STRING([--enable-mtune], 78 [use the specified value for the -mtune/-mcpu flag (default: no)])], 79 [], [enable_mtune="no"]) 80 81if test "x$enable_mtune" != "xno"; then 82 AC_S9X_COMPILER_FLAG([-mtune="$enable_mtune"], [mtune], 83 [ 84 AC_MSG_WARN([-mtune failed, trying -mcpu...]) 85 AC_S9X_COMPILER_FLAG([-mcpu="$enable_mtune"], [mcpu], 86 [AC_MSG_ERROR([Please specify a working value for --enable-mtune.])]) 87 ]) 88fi 89 90AC_S9X_COMPILER_FLAG([-fno-exceptions], [no_exceptions]) 91AC_S9X_COMPILER_FLAG([-fno-rtti], [no_rtti]) 92AC_S9X_COMPILER_FLAG([-pedantic], [pedantic]) 93AC_S9X_COMPILER_FLAG([-Wall], [Wall]) 94AC_S9X_COMPILER_FLAG([-W], [W]) 95AC_S9X_COMPILER_FLAG([-Wno-unused-parameter], [Wno_unused_parameter]) 96 97# Enable SSE4.1 98AC_ARG_ENABLE([sse41], 99 [AS_HELP_STRING([--enable-sse41], 100 [enable SSE4.1 if available (default: no)])], 101 [], [enable_sse41="no"]) 102 103if test "x$enable_sse41" = "xyes"; then 104 AC_S9X_COMPILER_FLAG([-msse4.1], [sse41]) 105 if test "x$snes9x_cv_option_sse41" != "xyes"; then 106 enable_sse41="no" 107 fi 108fi 109 110# Enable AVX2 111AC_ARG_ENABLE([avx2], 112 [AS_HELP_STRING([--enable-avx2], 113 [enable AVX2 if available (default: no)])], 114 [], [enable_avx2="no"]) 115 116if test "x$enable_avx2" = "xyes"; then 117 AC_S9X_COMPILER_FLAG([-mavx2], [avx2]) 118 if test "x$snes9x_cv_option_avx2" != "xyes"; then 119 enable_avx2="no" 120 fi 121fi 122 123# Enable ARM NEON 124AC_ARG_ENABLE([neon], 125 [AS_HELP_STRING([--enable-neon], 126 [enable NEON if available (default: no)])], 127 [], [enable_neon="no"]) 128 129if test "x$enable_neon" = "xyes"; then 130 AC_S9X_COMPILER_FLAG([-mfpu=neon], [neon]) 131 if test "x$snes9x_cv_option_neon" != "xyes"; then 132 enable_neon="no" 133 fi 134fi 135 136# Check if the OS is Linux. 137 138AC_MSG_CHECKING([whether the OS is Linux]) 139 140AC_CACHE_VAL([snes9x_cv_linux_os], 141[ 142 case "$target" in 143 *-*-linux*) 144 snes9x_cv_linux_os="yes" 145 ;; 146 *) 147 snes9x_cv_linux_os="no" 148 ;; 149 esac 150]) 151 152AC_MSG_RESULT([$snes9x_cv_linux_os]) 153 154# Enable gamepad support on Linux. 155 156AC_ARG_ENABLE([gamepad], 157 [AS_HELP_STRING([--enable-gamepad], 158 [enable gamepad support if available (default: yes)])], 159 [], [enable_gamepad="yes"]) 160 161if test "x$enable_gamepad" = "xyes"; then 162 if test "x$snes9x_cv_linux_os" = "xyes"; then 163 S9XDEFS="$S9XDEFS -DJOYSTICK_SUPPORT" 164 else 165 AC_MSG_WARN([Your OS is not Linux. Build without gamepad support.]) 166 enable_gamepad="no" 167 fi 168fi 169 170# Enable debugger. 171 172S9XDEBUGGER="#S9XDEBUGGER=1" 173 174AC_ARG_ENABLE([debugger], 175 [AS_HELP_STRING([--enable-debugger], 176 [enable debugger (default: no)])], 177 [], [enable_debugger="no"]) 178 179if test "x$enable_debugger" = "xyes"; then 180 S9XDEBUGGER="S9XDEBUGGER=1" 181 S9XDEFS="$S9XDEFS -DDEBUGGER" 182fi 183 184# Enable netplay support if requested. 185 186S9XNETPLAY="#S9XNETPLAY=1" 187 188AC_ARG_ENABLE([netplay], 189 [AS_HELP_STRING([--enable-netplay], 190 [enable netplay support (default: no)])], 191 [], [enable_netplay="no"]) 192 193if test "x$enable_netplay" = "xyes"; then 194 S9XNETPLAY="S9XNETPLAY=1" 195 S9XDEFS="$S9XDEFS -DNETPLAY_SUPPORT" 196fi 197 198# Enable GZIP support through zlib. 199 200AC_CACHE_VAL([snes9x_cv_zlib], 201[ 202 AC_CHECK_HEADER([zlib.h], 203 [AC_CHECK_LIB([z], [gzread], [snes9x_cv_zlib="yes"], [snes9x_cv_zlib="no"])], 204 [snes9x_cv_zlib="no"]) 205]) 206 207AC_ARG_ENABLE([gzip], 208 [AS_HELP_STRING([--enable-gzip], 209 [enable GZIP support through zlib (default: yes)])], 210 [], [enable_gzip="yes"]) 211 212if test "x$enable_gzip" = "xyes"; then 213 if test "x$snes9x_cv_zlib" = "xyes"; then 214 S9XDEFS="$S9XDEFS -DZLIB" 215 S9XLIBS="$S9XLIBS -lz" 216 else 217 AC_MSG_WARN([zlib not found. Build without GZIP support.]) 218 enable_gzip="no" 219 fi 220fi 221 222# Enable ZIP support through zlib. 223 224S9XZIP="#S9XZIP=1" 225 226AC_ARG_ENABLE([zip], 227 [AS_HELP_STRING([--enable-zip], 228 [enable ZIP support through zlib (default: yes)])], 229 [], [enable_zip="yes"]) 230 231S9X_SYSTEM_ZIP="#SYSTEM_ZIP=1" 232 233AC_ARG_WITH([system-zip], 234 [AS_HELP_STRING([--with-system-zip], 235 [Use system zip (default: check)])], 236 [], [with_system_zip="check"]) 237 238if test "x$enable_zip" = "xyes"; then 239 if test "x$with_system_zip" != "xno"; then 240 PKG_CHECK_MODULES( 241 SYSTEM_ZIP, 242 minizip, 243 S9XZIP="S9XZIP=1" 244 S9XDEFS="$S9XDEFS -DUNZIP_SUPPORT" 245 S9X_SYSTEM_ZIP="SYSTEM_ZIP=1" 246 S9XLIBS="$S9XLIBS $SYSTEM_ZIP_LIBS" 247 if test "x$enable_gzip" = "xno"; then 248 S9XLIBS="$S9XLIBS -lz" 249 fi 250 S9XDEFS="$S9XDEFS -DSYSTEM_ZIP", 251 if test "x${with_system_zip}" != "xcheck"; then 252 AC_MSG_ERROR([--with-system-zip requested but no proper minizip lib found.]) 253 else 254 AC_MSG_WARN([minizip not found. Build without SYSTEM_ZIP support.]) 255 fi 256 ) 257 else 258 if test "x$snes9x_cv_zlib" = "xyes"; then 259 S9XZIP="S9XZIP=1" 260 S9XDEFS="$S9XDEFS -DUNZIP_SUPPORT" 261 if test "x$enable_gzip" = "xno"; then 262 S9XLIBS="$S9XLIBS -lz" 263 fi 264 else 265 AC_MSG_WARN([zlib not found. Build without ZIP support.]) 266 enable_zip="no" 267 fi 268 fi 269fi 270 271# Enable JMA support. 272 273S9XJMA="#S9XJMA=1" 274 275AC_ARG_ENABLE([jma], 276 [AS_HELP_STRING([--enable-jma], 277 [enable JMA support (default: yes)])], 278 [], [enable_jma="yes"]) 279 280if test "x$enable_jma" = "xyes"; then 281 S9XJMA="S9XJMA=1" 282 S9XDEFS="$S9XDEFS -DJMA_SUPPORT" 283fi 284 285# Enable screenshot support through libpng. 286 287AC_CACHE_VAL([snes9x_cv_libpng], 288[ 289 AC_CHECK_HEADER([png.h], 290 [AC_CHECK_LIB([png], [png_init_io], [snes9x_cv_libpng="yes"], [snes9x_cv_libpng="no"])], 291 [snes9x_cv_libpng="no"]) 292]) 293 294AC_ARG_ENABLE([screenshot], 295 [AS_HELP_STRING([--enable-screenshot], 296 [enable screenshot support through libpng (default: yes)])], 297 [], [enable_screenshot="yes"]) 298 299if test "x$enable_screenshot" = "xyes"; then 300 if test "x$snes9x_cv_libpng" = "xyes"; then 301 S9XDEFS="$S9XDEFS -DHAVE_LIBPNG" 302 S9XLIBS="$S9XLIBS -lpng" 303 else 304 AC_MSG_WARN([libpng not found. Build without screenshot support.]) 305 enable_screenshot="no" 306 fi 307fi 308 309# Check for functions 310 311AC_CHECK_FUNC([mkstemp], 312[ 313 S9XDEFS="$S9XDEFS -DHAVE_MKSTEMP" 314]) 315 316# Check X11 317 318AC_PATH_XTRA 319if test "x$no_x" = "xyes"; then 320 AC_MSG_ERROR([X11 is required.]) 321else 322 S9XFLGS="$S9XFLGS $X_CFLAGS" 323 S9XLIBS="$S9XLIBS $X_PRE_LIBS -lX11 -lXext $X_LIBS $X_EXTRA_LIBS" 324fi 325 326# Check for headers 327 328snes9x_have_stdint_h=""; 329 330AC_CHECK_HEADER([strings.h], 331[ 332 S9XDEFS="$S9XDEFS -DHAVE_STRINGS_H" 333]) 334 335AC_CHECK_HEADER([sys/ioctl.h], 336[ 337 S9XDEFS="$S9XDEFS -DHAVE_SYS_IOCTL_H" 338]) 339 340AC_CHECK_HEADER([stdint.h], 341[ 342 S9XDEFS="$S9XDEFS -DHAVE_STDINT_H" 343 snes9x_have_stdint_h="-DHAVE_STDINT_H" 344]) 345 346AC_CHECK_HEADERS([unistd.h sys/socket.h]) 347 348# Check whether the size of pointer is int. 349 350if test "x$snes9x_have_stdint_h" = "x"; then 351 AC_MSG_CHECKING([whether the size of pointer is int]) 352 353 AC_TRY_RUN( 354 [ 355 int main (void) 356 { 357 return (!(sizeof(void *) == sizeof(int))); 358 } 359 ], 360 [snes9x_ptr_is_int="yes"], [snes9x_ptr_is_int="no"]) 361 362 if test "x$snes9x_ptr_is_int" = "xyes"; then 363 AC_MSG_RESULT(yes) 364 else 365 AC_MSG_RESULT(no) 366 S9XDEFS="$S9XDEFS -DPTR_NOT_INT" 367 fi 368fi 369 370# Check whether right shift is arithmetic or not 371 372AC_DEFUN([AC_S9X_CHECK_SAR], 373[ 374 AC_MSG_CHECKING([whether right shift $1 is arithmetic]) 375 376 OLD_CXXFLAGS="[$]CXXFLAGS" 377 CXXFLAGS="[$]OLD_CXXFLAGS $snes9x_have_stdint_h" 378 379 AC_TRY_RUN( 380 [ 381 #ifdef HAVE_STDINT_H 382 #include <stdint.h> 383 typedef int8_t int8; 384 typedef int16_t int16; 385 typedef int32_t int32; 386 typedef int64_t int64; 387 #else 388 typedef signed char int8; 389 typedef signed short int16; 390 typedef signed int int32; 391 #ifdef __GNUC__ 392 __extension__ 393 #endif 394 typedef long long int64; 395 #endif 396 397 int main (void) 398 { 399 $1 i; 400 401 i = -1; 402 i >>= 1; 403 404 return (i < 0 ? 0 : 1); 405 } 406 ], 407 [snes9x_sar_$1="yes"], [snes9x_sar_$1="no"]) 408 409 CXXFLAGS="[$]OLD_CXXFLAGS" 410 411 if test "x$snes9x_sar_$1" = "xno"; then 412 AC_MSG_RESULT([no]) 413 else 414 S9XDEFS="$S9XDEFS -DRIGHTSHIFT_$1_IS_SAR" 415 AC_MSG_RESULT([yes]) 416 fi 417]) 418 419AC_S9X_CHECK_SAR([int8]) 420AC_S9X_CHECK_SAR([int16]) 421AC_S9X_CHECK_SAR([int32]) 422AC_S9X_CHECK_SAR([int64]) 423 424if test "x$snes9x_sar_int8" = "xyes" -a "x$snes9x_sar_int16" = "xyes" -a "x$snes9x_sar_int32" = "xyes" -a "x$snes9x_sar_int64" = "xyes"; then 425 S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/-DRIGHTSHIFT_int8_IS_SAR//'`" 426 S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/-DRIGHTSHIFT_int16_IS_SAR//'`" 427 S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/-DRIGHTSHIFT_int32_IS_SAR//'`" 428 S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/-DRIGHTSHIFT_int64_IS_SAR//'`" 429 S9XDEFS="$S9XDEFS -DRIGHTSHIFT_IS_SAR" 430fi 431 432# Check if we can build with Xvideo acceleration support 433AC_ARG_ENABLE([xvideo], 434 [AS_HELP_STRING([--enable-xvideo], 435 [enable Xvideo if available (default: yes)])], 436 [], [enable_xvideo="yes"]) 437 438if test "x$enable_xvideo" = "xyes"; then 439 enable_xvideo="no" 440 AC_CHECK_HEADER([X11/extensions/Xv.h], 441 [ 442 enable_xvideo="yes" 443 S9XLIBS="$S9XLIBS -lXv" 444 S9XDEFS="$S9XDEFS -DUSE_XVIDEO" 445 ]) 446fi 447 448# Check if we can build with Xinerama multi-monitor support 449AC_ARG_ENABLE([xinerama], 450 [AS_HELP_STRING([--enable-xinerama], 451 [enable Xinerama if available (default: yes)])], 452 [], [enable_xinerama="yes"]) 453 454if test "x$enable_xinerama" = "xyes"; then 455 enable_xinerama="no" 456 AC_CHECK_HEADER([X11/extensions/Xinerama.h], 457 [ 458 enable_xinerama="yes" 459 S9XLIBS="$S9XLIBS -lXinerama" 460 S9XDEFS="$S9XDEFS -DUSE_XINERAMA" 461 ]) 462fi 463 464# Check if we have sound code for this platform. 465 466AC_ARG_ENABLE([sound], 467 [AS_HELP_STRING([--enable-sound], 468 [enable sound if available (default: yes)])], 469 [], [enable_sound="yes"]) 470 471if test "x$enable_sound" = "xyes"; then 472 AC_MSG_CHECKING([whether sound is supported on this platform]) 473 if test "x$snes9x_cv_linux_os" = "xyes"; then 474 AC_MSG_RESULT([yes]) 475 else 476 AC_MSG_RESULT([no]) 477 AC_MSG_WARN([Your OS is not Linux. Build without sound support.]) 478 enable_sound="no" 479 fi 480fi 481 482if test "x$enable_sound" = "xyes"; then 483 AC_CHECK_HEADER([pthread.h], 484 [ 485 S9XDEFS="$S9XDEFS -DUSE_THREADS" 486 S9XLIBS="$S9XLIBS -lpthread" 487 ]) 488else 489 S9XDEFS="$S9XDEFS -DNOSOUND" 490fi 491 492# Output. 493 494S9XFLGS="$CXXFLAGS $CPPFLAGS $LDFLAGS $S9XFLGS" 495S9XLIBS="$LIBS $S9XLIBS" 496 497S9XFLGS="`echo \"$S9XFLGS\" | sed -e 's/ */ /g'`" 498S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/ */ /g'`" 499S9XLIBS="`echo \"$S9XLIBS\" | sed -e 's/ */ /g'`" 500S9X_SYSTEM_ZIP="`echo \"$S9X_SYSTEM_ZIP\" | sed -e 's/ */ /g'`" 501S9XFLGS="`echo \"$S9XFLGS\" | sed -e 's/^ *//'`" 502S9XDEFS="`echo \"$S9XDEFS\" | sed -e 's/^ *//'`" 503S9XLIBS="`echo \"$S9XLIBS\" | sed -e 's/^ *//'`" 504S9X_SYSTEM_ZIP="`echo \"$S9X_SYSTEM_ZIP\" | sed -e 's/^ *//'`" 505 506AC_SUBST(S9XFLGS) 507AC_SUBST(S9XDEFS) 508AC_SUBST(S9XLIBS) 509AC_SUBST(S9XXVIDEO) 510AC_SUBST(S9XDEBUGGER) 511AC_SUBST(S9XNETPLAY) 512AC_SUBST(S9XZIP) 513AC_SUBST(S9XJMA) 514AC_SUBST(S9X_SYSTEM_ZIP) 515 516rm config.info 2>/dev/null 517 518cat >config.info <<EOF 519 520build information: 521cc...............,,,. $CC 522c++.................. $CXX 523options.............. $S9XFLGS 524defines.............. $S9XDEFS 525libs................. $S9XLIBS 526 527features: 528Xvideo support....... $enable_xvideo 529Xinerama support..... $enable_xinerama 530sound support........ $enable_sound 531screenshot support... $enable_screenshot 532netplay support...... $enable_netplay 533gamepad support...... $enable_gamepad 534GZIP support......... $enable_gzip 535ZIP support.......... $enable_zip 536SYSTEM_ZIP........... $with_system_zip 537JMA support.......... $enable_jma 538SSE4.1............... $enable_sse41 539AVX2................. $enable_avx2 540NEON................. $enable_neon 541debugger............. $enable_debugger 542 543EOF 544 545cat config.info 546 547AC_OUTPUT(Makefile) 548