New autoconf support!
This commit is contained in:
210
zsnes/src/configure.in
Normal file
210
zsnes/src/configure.in
Normal file
@@ -0,0 +1,210 @@
|
||||
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"
|
||||
AC_PROG_CC
|
||||
AC_PATH_PROG(NASMPATH,nasm,[AC_MSG_ERROR(nasm 0.98 is required)])
|
||||
NASMD="$NASMD -w-orphan-labels"
|
||||
AC_PROG_INSTALL
|
||||
AC_CANONICAL_SYSTEM
|
||||
case "$target" in
|
||||
*-*-linux* | *-*-*bsd*)
|
||||
CFLAGS="$CFLAGS -D__LINUX__"
|
||||
NASMD="$NASMD -D__LINUX__ -f elf"
|
||||
;;
|
||||
*-*-cygwin* | *-*-*ming*)
|
||||
CFLAGS="$CFLAGS -D__LINUX__"
|
||||
NASMD="$NASMD -D__LINUX__ -f win32"
|
||||
ZSNESEXE=".exe"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
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"
|
||||
LIBS="$LIBS -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"
|
||||
LIBS="$LIBS $SDL_LIBS"
|
||||
|
||||
AC_MSG_CHECKING(for zlib)
|
||||
with_zlib=no
|
||||
AC_TRY_COMPILE([
|
||||
#include <zlib.h>
|
||||
/* Doesnt ac-try-compile ROCK? */
|
||||
],[
|
||||
],[
|
||||
with_zlib=yes
|
||||
])
|
||||
|
||||
if test x$with_zlib = xyes; then
|
||||
LIBS="$LIBS -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 <GL/gl.h>
|
||||
/* Doesnt ac-try-compile ROCK? */
|
||||
],[
|
||||
],[
|
||||
with_opengl=yes
|
||||
])
|
||||
AC_MSG_RESULT($with_opengl)
|
||||
if test x$with_opengl = xyes; then
|
||||
LIBS="$LIBS -lGL"
|
||||
CFLAGS="$CFLAGS -D__OPENGL__"
|
||||
NASMD="$NASMD -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 <png.h>
|
||||
/* Doesnt ac-try-compile ROCK? */
|
||||
],[
|
||||
],[
|
||||
with_png=yes
|
||||
])
|
||||
AC_MSG_RESULT($with_png)
|
||||
if test x$with_png = xyes; then
|
||||
LIBS="$LIBS -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 -Wall -O0 -fno-omit-frame-pointer -ggdb3"
|
||||
NASMD="$NASMD -g -s"
|
||||
ZSNESEXE="zsnes-debug$ZSNESEXE"
|
||||
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 -s -Os -ffast-math -fomit-frame-pointer -fschedule-insns2"
|
||||
ZSNESEXE="zsnes$ZSNESEXE"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(force-386,[ --enable-force-386 Force 386 Optimization],wantforce=386)
|
||||
AC_ARG_ENABLE(force-486,[ --enable-force-486 Force 486 Optimization],wantforce=486)
|
||||
AC_ARG_ENABLE(force-586,[ --enable-force-586 Force Pentium Optimization],wantforce=586)
|
||||
AC_ARG_ENABLE(force-686,[ --enable-force-686 Force PPro/P2 Optimization],wantforce=668)
|
||||
|
||||
AC_MSG_CHECKING(which processor class to optimize for)
|
||||
if test x$debug != xyes; then
|
||||
case "$wantforce" in
|
||||
386)
|
||||
AC_MSG_RESULT(forced to 386)
|
||||
CFLAGS="$CFLAGS -march=i386"
|
||||
;;
|
||||
486)
|
||||
AC_MSG_RESULT(forced to 486)
|
||||
CFLAGS="$CFLAGS -march=i486"
|
||||
;;
|
||||
586)
|
||||
AC_MSG_RESULT(forced to Pentium)
|
||||
CFLAGS="$CFLAGS -march=pentium"
|
||||
;;
|
||||
686)
|
||||
AC_MSG_RESULT(forced to PPro/P2)
|
||||
CFLAGS="$CFLAGS -march=pentiumpro"
|
||||
;;
|
||||
*)
|
||||
case "$target" in
|
||||
i486-*-*)
|
||||
CFLAGS="$CFLAGS -march=i486"
|
||||
AC_MSG_RESULT(detected 486)
|
||||
;;
|
||||
i586-*-*)
|
||||
CFLAGS="$CFLAGS -march=pentium"
|
||||
AC_MSG_RESULT(detected Pentium)
|
||||
;;
|
||||
i686-*-*)
|
||||
CFLAGS="$CFLAGS -march=pentiumpro"
|
||||
AC_MSG_RESULT(detected PPro/P2)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(detected 386)
|
||||
AC_MSG_WARN(*** This is probably not what you want use --enable-force-486/586/686)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
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 strings.h sys/ioctl.h sys/time.h unistd.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_UTIME_NULL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS(getcwd gethostname mkdir mktime rmdir select socket)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(NASMD)
|
||||
AC_SUBST(ZSNESEXE)
|
||||
AC_SUBST(GL_DRAW)
|
||||
AC_OUTPUT(Makefile)
|
||||
echo
|
||||
echo You may now type gmake to compile $ZSNESEXE
|
||||
echo Please make sure you use gmake, as other makes tend not to function
|
||||
echo correctly with zsnes\'s makefiles.
|
||||
|
||||
Reference in New Issue
Block a user