Diablo-D3's autoconf rework
This commit is contained in:
263
zsnes/src/acinclude.m4
Normal file
263
zsnes/src/acinclude.m4
Normal file
@@ -0,0 +1,263 @@
|
||||
dnl -- Begin zlib autoconf macro
|
||||
dnl Copyright (c) 2002 Patrick McFarland
|
||||
dnl Under the GPL License
|
||||
dnl When copying, include from Begin to End zlib autoconf macro, including
|
||||
dnl those tags, so others can easily copy it too. (Maybe someday this will
|
||||
dnl become zlib.m4?)
|
||||
dnl
|
||||
dnl AM_PATH_ZLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Tests for zlib, outputs ZLIB_VERSION, ZLIB_LIBS, and ZLIB_CFLAGS
|
||||
AC_DEFUN(AM_PATH_ZLIB,
|
||||
[dnl
|
||||
dnl
|
||||
dnl
|
||||
AC_ARG_WITH(zlib-prefix,[ --with-zlib-prefix=PFX Prefix where zlib is installed (optional)], zlib_prefix="$withval", zlib_prefix="")
|
||||
min_zlib_version=ifelse([$1], ,1.1.0,$1)
|
||||
AC_MSG_CHECKING(for zlib - version >= $min_zlib_version)
|
||||
|
||||
dnl Deal with X11R6 stupidity first. Some distros include zlib with X11R6,
|
||||
dnl and we cant use that one. We have to bomb if we find it.
|
||||
|
||||
if test [-e /usr/X11R6/lib/libz.a] ; then
|
||||
AC_MSG_RESULT(error)
|
||||
echo
|
||||
echo configure: Found a copy of zlib from X11R6
|
||||
echo configure: Please delete /usr/X11R6/lib/libz.a and /usr/X11R6/include/unzip.h
|
||||
echo " so we can use the real zlib on your system."
|
||||
AC_MSG_ERROR(Remove these files and rerun this script)
|
||||
fi
|
||||
if test [-e /usr/X11R6/include/unzip.h] ; then
|
||||
AC_MSG_RESULT(error)
|
||||
echo
|
||||
echo configure: Found a copy of zlib from X11R6
|
||||
echo configure: Please delete /usr/X11R6/lib/libz.a and /usr/X11R6/include/unzip.h
|
||||
echo " so we can use the real zlib on your system."
|
||||
AC_MSG_ERROR(Remove these files and rerun this script)
|
||||
fi
|
||||
|
||||
dnl Okay, Stupidy Check is done.
|
||||
|
||||
tempLIBS="$LIBS"
|
||||
tempCFLAGS="$CFLAGS"
|
||||
if test x$zlib_prefix != x ; then
|
||||
ZLIB_LIBS="-L$zlib_prefix"
|
||||
ZLIB_CFLAGS="-I$zlib_prefix"
|
||||
fi
|
||||
ZLIB_LIBS="$ZLIB_LIBS -lz"
|
||||
LIBS="$LIBS $ZLIB_LIBS"
|
||||
CFLAGS="$CFLAGS $ZLIB_CFLAGS"
|
||||
with_zlib=no
|
||||
AC_TRY_RUN([
|
||||
#include <zlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char*
|
||||
my_strdup (char *str)
|
||||
{
|
||||
char *new_str;
|
||||
|
||||
if (str)
|
||||
{
|
||||
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
|
||||
strcpy (new_str, str);
|
||||
}
|
||||
else
|
||||
new_str = NULL;
|
||||
|
||||
return new_str;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int major, minor, micro, zlib_major_version, zlib_minor_version, zlib_micro_version;
|
||||
|
||||
char *zlibver;
|
||||
char *tmp_version;
|
||||
|
||||
zlibver = ZLIB_VERSION;
|
||||
|
||||
{ FILE *fp = fopen("conf.zlibtest", "a");
|
||||
if ( fp ) {
|
||||
fprintf(fp, "%s", zlibver);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = my_strdup("$min_zlib_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string for min_zlib_version.\n", "$min_zlib_version");
|
||||
exit(1);
|
||||
}
|
||||
if (sscanf(zlibver, "%d.%d.%d", &zlib_major_version, &zlib_minor_version, &zlib_micro_version) != 3) {
|
||||
printf("%s, bad version string given by zlib, sometimes due to very old zlibs \n didnt correctly define their version. Please upgrade if you are running \n an old zlib.\n", "zlibver");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((zlib_major_version > major) ||
|
||||
((zlib_major_version == major) && (zlib_minor_version > minor)) ||
|
||||
((zlib_major_version == major) && (zlib_minor_version == minor) && (zlib_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
],with_zlib=yes,,[AC_MSG_WARN(Cross Compiling, Assuming zlib is avalible)])
|
||||
|
||||
if test x$with_zlib = xyes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ZLIB_VERSION=$(<conf.zlibtest)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
ZLIB_CFLAGS=""
|
||||
ZLIB_LIBS=""
|
||||
ZLIB_VERSION=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
LIBS="$tempLIBS"
|
||||
CFLAGS="$tempCFLAGS"
|
||||
rm conf.zlibtest
|
||||
AC_SUBST(ZLIB_CFLAGS)
|
||||
AC_SUBST(ZLIB_VERSION)
|
||||
AC_SUBST(ZLIB_LIBS)
|
||||
])
|
||||
dnl -- End zlib autoconf macro
|
||||
|
||||
dnl ----
|
||||
|
||||
dnl -- Begin libpng autoconf macro
|
||||
dnl Copyright (c) 2002 Patrick McFarland
|
||||
dnl Under the GPL License
|
||||
dnl When copying, include from Begin to End libpng autoconf macro, including
|
||||
dnl those tags, so others can easily copy it too. (Maybe someday this will
|
||||
dnl become libpng.m4?)
|
||||
dnl
|
||||
dnl AM_PATH_LIBPNG([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Tests for libpng, outputs LIBPNG_VERSION, LIBPNG_LIBS, and LIBPNG_CFLAGS
|
||||
AC_DEFUN(AM_PATH_LIBPNG,
|
||||
[dnl
|
||||
dnl
|
||||
dnl
|
||||
|
||||
dnl Comment out this section, and the other labled parts to disable the user
|
||||
dnl having a choice about being able to disable libpng or not. Recommended
|
||||
dnl you use AC_MSG_ERROR(LIBPNG >= 1.0.0 is required) for the
|
||||
dnl ACTION-IF-NOT-FOUND if you plan on disabling user choice.
|
||||
|
||||
dnl <--- disable for no user choice part #1
|
||||
AC_ARG_ENABLE(libpng,[ --disable-libpng Build without libpng support ],,enable_libpng=yes)
|
||||
dnl --->
|
||||
|
||||
AC_ARG_WITH(libpng-prefix,[ --with-libpng-prefix=PFX Prefix where libpng is installed (optional)], libpng_prefix="$withval", libpng_prefix="")
|
||||
|
||||
min_libpng_version=ifelse([$1], ,1.0.0,$1)
|
||||
tempLIBS="$LIBS"
|
||||
tempCFLAGS="$CFLAGS"
|
||||
if test x$libpng_prefix != x ; then
|
||||
LIBPNG_LIBS="-L$libpng_prefix"
|
||||
LIBPNG_CFLAGS="-I$libpng_prefix"
|
||||
fi
|
||||
LIBPNG_LIBS="$LIBPNG_LIBS -lpng"
|
||||
LIBS="$LIBS $LIBPNG_LIBS"
|
||||
CFLAGS="$CFLAGS $LIBPNG_CFLAGS"
|
||||
|
||||
AC_MSG_CHECKING(for libpng - version >= $min_libpng_version)
|
||||
with_libpng=no
|
||||
|
||||
dnl <--- disable for no user choice part #2
|
||||
if test x$enable_libpng != xno; then
|
||||
dnl --->
|
||||
|
||||
AC_TRY_RUN([
|
||||
#include <png.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char*
|
||||
my_strdup (char *str)
|
||||
{
|
||||
char *new_str;
|
||||
|
||||
if (str)
|
||||
{
|
||||
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
|
||||
strcpy (new_str, str);
|
||||
}
|
||||
else
|
||||
new_str = NULL;
|
||||
|
||||
return new_str;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int major, minor, micro, libpng_major_version, libpng_minor_version, libpng_micro_version;
|
||||
|
||||
char *libpngver;
|
||||
char *tmp_version;
|
||||
|
||||
libpngver = PNG_LIBPNG_VER_STRING;
|
||||
|
||||
{ FILE *fp = fopen("conf.libpngtest", "a");
|
||||
if ( fp ) {
|
||||
fprintf(fp, "%s", libpngver);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = my_strdup("$min_libpng_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string for min_libpng_version.\n", "$min_libpng_version");
|
||||
exit(1);
|
||||
}
|
||||
if (sscanf(libpngver, "%d.%d.%d", &libpng_major_version, &libpng_minor_version, &libpng_micro_version) != 3) {
|
||||
printf("%s, bad version string given by libpng, sometimes due to very old libpngs \n didnt correctly define their version. Please upgrade if you are running \n an old libpng.\n", "libpngver");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((libpng_major_version > major) ||
|
||||
((libpng_major_version == major) && (libpng_minor_version > minor)) ||
|
||||
((libpng_major_version == major) && (libpng_minor_version == minor) && (libpng_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
],with_libpng=yes,,[AC_MSG_WARN(Cross Compiling, Assuming libpng is avalible)])
|
||||
|
||||
if test x$with_libpng = xyes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBPNG_VERSION=$(<conf.libpngtest)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
LIBPNG_CFLAGS=""
|
||||
LIBPNG_LIBS=""
|
||||
LIBPNG_VERSION=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
LIBS="$tempLIBS"
|
||||
CFLAGS="$tempCFLAGS"
|
||||
rm conf.libpngtest
|
||||
AC_SUBST(LIBPNG_CFLAGS)
|
||||
AC_SUBST(LIBPNG_VERSION)
|
||||
AC_SUBST(LIBPNG_LIBS)
|
||||
|
||||
dnl <--- disable for no user choice part #3
|
||||
else
|
||||
AC_MSG_RESULT(disabled by user)
|
||||
fi
|
||||
dnl --->
|
||||
])
|
||||
dnl -- End libpng autoconf macro
|
||||
@@ -15,13 +15,22 @@ dnl See also: remarks supplied in the debug checking area below
|
||||
|
||||
AC_INIT(init.asm)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
ISODATE=`date +%Y-%m-%d`
|
||||
AC_SUBST(ISODATE)
|
||||
VERSION=1.36
|
||||
AC_SUBST(VERSION)
|
||||
AC_ARG_WITH(nasm-prefix,[ --with-nasm-prefix=PFX Prefix where nasm is installed (optional)], nasm_prefix="$withval", nasm_prefix="")
|
||||
|
||||
dnl -- Where is our compiler, and who are we compiling for?
|
||||
CFLAGS="-pipe -I. -Wall"
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_PROG_CC
|
||||
AC_PATH_PROG(NASMPATH,nasm,[AC_MSG_ERROR(nasm 0.98 is required)])
|
||||
AC_CHECK_TOOL(NASMPATH,nasm,"no",[$nasm_prefix:$PATH])
|
||||
if test x$nasmpath = xno; then
|
||||
AC_MSG_ERROR(You need NASM installed to compile ZSNES)
|
||||
fi
|
||||
NFLAGS="$NFLAGS -w-orphan-labels"
|
||||
AC_PROG_INSTALL
|
||||
AC_CANONICAL_SYSTEM
|
||||
case "$target" in
|
||||
*-*-linux*)
|
||||
CFLAGS="$CFLAGS -D__LINUX__"
|
||||
@@ -44,87 +53,50 @@ case "$target" in
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Checks for X.
|
||||
|
||||
dnl -- 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.
|
||||
|
||||
dnl -- 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"
|
||||
AM_PATH_ZLIB(1.1.0,,[AC_MSG_ERROR(ZLIB >= 1.1.0 is required)])
|
||||
AM_PATH_LIBPNG(1.0.0,,)
|
||||
|
||||
AC_MSG_CHECKING(for zlib)
|
||||
with_zlib=no
|
||||
AC_TRY_COMPILE([
|
||||
#include <zlib.h>
|
||||
/* Doesnt ac-try-compile ROCK? */
|
||||
],[
|
||||
],[
|
||||
with_zlib=yes
|
||||
])
|
||||
CFLAGS="$CFLAGS $SDL_CFLAGS $ZLIB_CFLAGS $LIBPNG_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $SDL_LIBS $ZLIB_LIBS $LIBPNG_LIBS"
|
||||
|
||||
if test x$with_zlib = xyes; then
|
||||
LDFLAGS="$LDFLAGS -lz"
|
||||
AC_MSG_RESULT(yes)
|
||||
if test x$with_libpng != xyes; then
|
||||
CFLAGS="$CFLAGS -DNO_PNG"
|
||||
NFLAGS="$NFLAGS -DNO_PNG"
|
||||
fi
|
||||
|
||||
dnl -- opengl stuff
|
||||
AC_ARG_ENABLE(opengl,[ --disable-opengl Build without opengl support],,enable_opengl=yes)
|
||||
AC_ARG_WITH(opengl-prefix,[ --with-opengl-prefix=PFX Prefix where opengl is installed (optional)], opengl_prefix="$withval", opengl_prefix="")
|
||||
|
||||
if test x$enable_opengl != xno; then
|
||||
AC_PATH_X
|
||||
CFLAGS="$CFLAGS -I$opengl_prefix/includes -I$x_includes"
|
||||
LDFLAGS="$LDFLAGS -L$opengl_prefix/lib -L$x_libraries"
|
||||
AC_CHECK_LIB(GL, glGetError,found_opengl="yes",,)
|
||||
if test x$found_opengl = xyes; then
|
||||
echo checking for OpenGL... yes
|
||||
LDFLAGS="$LDFLAGS -lGL"
|
||||
CFLAGS="$CFLAGS -D__OPENGL__"
|
||||
NFLAGS="$NFLAGS -D__OPENGL__"
|
||||
GL_DRAW="\${WINDIR}/gl_draw.o"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR(zlib is required)
|
||||
echo checking for OpenGL... no
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(opengl,[ --without-opengl Build without OpenGL support ],with_opengl=$withval)
|
||||
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
|
||||
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)
|
||||
echo checking for OpenGL... disabled by user
|
||||
fi
|
||||
dnl --
|
||||
|
||||
|
||||
|
||||
AC_ARG_WITH(png, [ --without-png Build without PNG screenshot support ],with_png=$withval)
|
||||
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
|
||||
LDFLAGS="$LDFLAGS -lpng"
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT(disabled by user)
|
||||
fi
|
||||
if test x$with_png != xyes; then
|
||||
CFLAGS="$CFLAGS -DNO_PNG"
|
||||
NFLAGS="$NFLAGS -DNO_PNG"
|
||||
fi
|
||||
dnl -- Various debug and optimization option checks
|
||||
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug Build GDB Friendly binary (zsnes-debug) ],debug=yes)
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug Build GDB Friendly binary (zsnesd) ],debug=yes)
|
||||
AC_MSG_CHECKING(if you want gdb friendly executable)
|
||||
if test x$debug = xyes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
@@ -143,7 +115,7 @@ else
|
||||
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"
|
||||
CFLAGS="$CFLAGS -Os -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -ffast-math -fomit-frame-pointer -fstrength-reduce -fthread-jumps -fschedule-insns2 -s"
|
||||
ZSNESEXE="zsnes"
|
||||
fi
|
||||
|
||||
@@ -173,22 +145,40 @@ else
|
||||
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)
|
||||
AC_HEADER_MAJOR
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_SUBST(ZSNESEXE)
|
||||
AC_SUBST(GL_DRAW)
|
||||
AC_SUBST(NFLAGS)
|
||||
AC_SUBST(NASMPATH)
|
||||
AC_OUTPUT(Makefile)
|
||||
echo
|
||||
echo You may now run make to compile $ZSNESEXE
|
||||
echo Make sure you use GNU make when compiling.
|
||||
echo
|
||||
echo ZSNES v$VERSION
|
||||
echo
|
||||
echo "SDL support Version `$SDL_CONFIG --version`"
|
||||
echo "NASM support `nasm -r`"
|
||||
echo "ZLib support Version $ZLIB_VERSION"
|
||||
if test "$with_libpng" = "yes"; then
|
||||
echo "PNG support (png screenshots) Yes, version $LIBPNG_VERSION"
|
||||
elif test "$enable_libpng" = "no"; then
|
||||
echo "PNG support Disabled by user"
|
||||
else
|
||||
echo "PNG support Disabled, library not found"
|
||||
fi
|
||||
if test "$found_opengl" = "yes"; then
|
||||
echo "OpenGL support Yes"
|
||||
elif test "$enable_opengl" = "no"; then
|
||||
echo "OpenGL support Disabled by user"
|
||||
else
|
||||
echo "OpenGL support Disabled, library not found"
|
||||
fi
|
||||
echo
|
||||
echo The binary will be installed in $prefix/bin
|
||||
echo
|
||||
echo Configure complete, now type \'make\' and pray.
|
||||
echo
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user