dnl Process this file with autoconf to produce a configure script. dnl To: The Ports Teams for the various BSD Distributions dnl CC: Anyone else who cares dnl From: A FreeBSD user who wrote this autoconf setup. dnl dnl Please do not use global cflags for zsnes, they are dnl not optimized (especially -O other than -Os, and dnl -funroll-loops) This has been tested on very many dnl different processors of the x86 architecture, and dnl this has been proven correct, and I doubt you want dnl to annoy your users by having ports build un- dnl optimized binaries. dnl See also: remarks supplied in the debug checking area below AC_INIT(init.asm) echo -- Where is our compiler, and who are we compiling for? CFLAGS="-pipe -I. -Wall" AC_PROG_CC AC_PROG_CXX AC_PATH_PROG(NASMPATH,nasm,[AC_MSG_ERROR(nasm 0.98 is required)]) NFLAGS="$NFLAGS -w-orphan-labels" AC_PROG_INSTALL AC_CANONICAL_SYSTEM case "$target" in *-*-linux*) CFLAGS="$CFLAGS -D__LINUX__" NFLAGS="$NFLAGS -D__LINUX__ -f elf" ;; *-*-*bsd*) CFLAGS="$CFLAGS -D__LINUX__ -D__FreeBSD__" NFLAGS="$NFLAGS -D__LINUX__ -D__FreeBSD__ -f elf" ;; *-*-cygwin* | *-*-*ming*) CFLAGS="$CFLAGS -D__LINUX__" NFLAGS="$NFLAGS -D__LINUX__ -f win32" ;; *) AC_MSG_ERROR(This Target is Not Supported) ;; esac dnl Checks for X. echo -- Do we have X, and where is it? Needed for Mesa Checking AC_PATH_X CFLAGS="$CFLAGS -I$x_includes" LDFLAGS="$LDFLAGS -L$x_libraries" dnl Checks for libraries. echo -- Where is libSDL and zlib, and do we want/have libPNG and OpenGL support? AM_PATH_SDL(1.2.0,,[AC_MSG_ERROR(SDL >= 1.2.0 is required)]) CFLAGS="$CFLAGS $SDL_CFLAGS" LDFLAGS="$LDFLAGS $SDL_LIBS" AC_MSG_CHECKING(for zlib) with_zlib=no AC_TRY_COMPILE([ #include /* Doesnt ac-try-compile ROCK? */ ],[ ],[ with_zlib=yes ]) if test x$with_zlib = xyes; then LDFLAGS="$LDFLAGS -lz" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_ERROR(zlib is required) fi AC_ARG_WITH(opengl,[ --without-opengl Build without OpenGL support ],with_opengl=yes) AC_MSG_CHECKING(for OpenGL support) if test x$with_opengl != xno; then with_opengl=no AC_TRY_COMPILE([ #include /* Doesnt ac-try-compile ROCK? */ ],[ ],[ with_opengl=yes ]) AC_MSG_RESULT($with_opengl) if test x$with_opengl = xyes; then LDFLAGS="$LDFLAGS -lGL" CFLAGS="$CFLAGS -D__OPENGL__" NFLAGS="$NFLAGS -D__OPENGL__" GL_DRAW="\${WINDIR}/gl_draw.o" fi else AC_MSG_RESULT(disabled by user) fi AC_ARG_ENABLE(png, [ --without-png Build without PNG screenshot support ],with_png=no) AC_MSG_CHECKING(for libPNG support) if test x$with_png != xno; then with_png=no AC_TRY_COMPILE([ #include /* Doesnt ac-try-compile ROCK? */ ],[ ],[ with_png=yes ]) AC_MSG_RESULT($with_png) if test x$with_png = xyes; then LDFLAGS="$LDFLAGS -lpng" fi else AC_MSG_RESULT(disabled by user) fi echo -- Various debug and optimization option checks AC_ARG_ENABLE(debug, [ --enable-debug Build GDB Friendly binary (zsnes-debug) ],debug=yes) AC_MSG_CHECKING(if you want gdb friendly executable) if test x$debug = xyes; then AC_MSG_RESULT(yes) dnl It is actually easier to debug zsnes with no optimization dnl enabled. CFLAGS="$CFLAGS -DDEBUG -O0 -fno-omit-frame-pointer -ggdb3" NFLAGS="$NFLAGS -DDEBUG -g -s" ZSNESEXE="zsnesd" else AC_MSG_RESULT(no) dnl DONT TOUCH THESE CFLAGS! THESE ARE OPTIMIZED! dnl Because of the way zsnes is written, these options make dnl zsnes more easily deal with small instruction caches, and more dnl effectivly use branch prediction. CFLAGS="$CFLAGS -Os -ffast-math -fomit-frame-pointer -fschedule-insns2 -s" ZSNESEXE="zsnes" fi AC_MSG_CHECKING(which processor class to optimize for) if test x$debug != xyes; then case "$target" in i486-*-*) CFLAGS="$CFLAGS -march=i486" AC_MSG_RESULT(486) ;; i586-*-*) CFLAGS="$CFLAGS -march=pentium" AC_MSG_RESULT(Pentium) ;; i686-*-*) CFLAGS="$CFLAGS -march=pentiumpro" AC_MSG_RESULT(PPro/P2) ;; *) AC_MSG_RESULT(386) AC_MSG_WARN(*** This is probably not what you want use --target) ;; esac else AC_MSG_RESULT(no optimization because debug enabled) fi dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h unistd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_HEADER_TIME AC_CHECK_HEADERS(sys/time.h) dnl Checks for library functions. AC_SUBST(ZSNESEXE) AC_SUBST(GL_DRAW) AC_SUBST(NFLAGS) AC_OUTPUT(Makefile) echo echo You may now run make to compile $ZSNESEXE echo Make sure you use GNU make when compiling.