1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4# Copyright (C) 2007, 2008, 2009 Sylvain Beucler 5 6# This file is part of GNU FreeDink 7 8# GNU FreeDink is free software; you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation; either version 3 of the License, or 11# (at your option) any later version. 12 13# GNU FreeDink is distributed in the hope that it will be useful, but 14# WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16# General Public License for more details. 17 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see 20# <http://www.gnu.org/licenses/>. 21 22AC_PREREQ(2.61) 23AC_INIT([GNU FreeDink],[108.4],[bug-freedink@gnu.org]) 24AC_CONFIG_AUX_DIR(autotools) 25# For future version of aclocal: 26AC_CONFIG_MACRO_DIR(autotools/macros) 27AM_INIT_AUTOMAKE([gnits dist-bzip2 dist-zip]) 28 29AC_CONFIG_HEADERS(config.h) 30# Define $host $host_os + distributes config.guess and config.sub 31AC_CANONICAL_HOST 32# Checks for programs. 33AC_PROG_CC 34AC_PROG_LN_S 35 36# Force binary relocatability by default 37enable_relocatable=1 38 39# We use std=c99 which enables some macros, supports '//' comments, 40# and does not warn about mixed declarations and code. Let's do tests 41# (namely Gnulib tests) with it too. 42CFLAGS="$CFLAGS -Wall -std=c99" 43 44 45# Gnulib - configuration in gnulib/m4/gnulib-cache.m4 46gl_EARLY 47 48AM_CONDITIONAL(PSP, test "$host" == "mipsallegrexel-psp-elf") 49 50PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) 51 52# Check if we can fork&exec (for fallback xmessage errors) 53AC_CHECK_FUNCS(execlp) 54# Check if we've got malloc stats 55AC_CHECK_TYPES([struct mallinfo], [], [], [[#include <malloc.h>]]) 56 57# gettext 58dnl Using [external] because bundling intl/ is deprecated as of 0.18: 59AM_GNU_GETTEXT([external]) 60dnl Not a dependency: only a declaration used by autopoint: 61AM_GNU_GETTEXT_VERSION([0.18.1]) 62dnl Not using ngettext in FreeDink or gnulib as of 2010-11: 63dnl AM_GNU_GETTEXT_NEED(need-ngettext) 64 65 66AC_ARG_VAR([WINDRES], [Resource compiler for woe executables]) 67AC_CHECK_TOOL(WINDRES, windres) 68AM_CONDITIONAL(HAVE_WINDRES, test "$WINDRES" != "") 69 70AC_ARG_ENABLE([embedded-resources], 71 AS_HELP_STRING([--disable-embedded-resources], 72 [don't embed base fonts in the executable - 73 disable this for distros that strip executables and break resources (default is enabled)]), 74 [], [enable_embedded_resources=yes]) 75if test x"$enable_embedded_resources" = x"yes"; then 76AC_CHECK_PROG(ZIP, zip, zip) 77fi 78AM_CONDITIONAL(HAVE_ZIP, test "$ZIP" != "") 79 80AC_ARG_VAR([HELP2MAN], [Manpage generator from '--help' output]) 81AC_PATH_PROG(HELP2MAN, help2man) 82if test -z "$HELP2MAN"; then 83 AC_MSG_WARN([You may need to install help2man (if you're a developer)]) 84 # Set HELP2MAN so 'make' errors will be understandable 85 HELP2MAN="help2man" 86 LACK_HELP2MAN=1 87fi 88 89AC_ARG_VAR([UPX], [Produce self-decompressing executables (if --enable-upx)]) 90AC_ARG_ENABLE([upx], 91 AS_HELP_STRING([--enable-upx], [compress executables (default is disabled)]), 92 [], [enable_upx=no]) 93if test x"$enable_upx" = x"yes"; then 94 AC_PATH_PROG(UPX, upx) 95fi 96AM_CONDITIONAL(HAVE_UPX, test "$UPX" != "") 97 98 99# SDL and core libs 100PKG_CHECK_MODULES([SDL], [sdl >= 1.2 SDL_image SDL_mixer SDL_ttf >= 2.0.9 SDL_gfx], 101 [CFLAGS="$CFLAGS $SDL_CFLAGS"; LIBS="$SDL_LIBS $LIBS"], 102 AC_MSG_WARN($SDL_PKG_ERRORS); LACK_SDL=1) 103 104 105case "${host}" in 106# (cf. (autoconf.info)Using System Type) (2002) 107*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows* \ 108| mipsallegrexel-psp-elf) 109 # Can't search fonts using fontconfig under ms woe 110 # Nor under a PSP 111 use_fontconfig="no" 112 ;; 113*) 114 use_fontconfig="yes" 115 ;; 116esac 117if test x"$use_fontconfig" = x"yes"; then 118 PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.3], 119 AC_DEFINE([HAVE_FONTCONFIG], [], [fontconfig library (-lfontconfig)]), 120 AC_MSG_WARN($FONTCONFIG_PKG_ERRORS); LACK_FONTCONFIG=1) 121 CFLAGS="$CFLAGS $FONTCONFIG_CFLAGS" 122 LIBS="$FONTCONFIG_LIBS $LIBS" 123fi 124 125if test x"$enable_embedded_resources" = x"yes"; then 126 # libzip - cross-compiles well 127 PKG_CHECK_MODULES([LIBZIP], [libzip >= 0.8], 128 AC_DEFINE([HAVE_LIBZIP], [], [libzip library (-lzip)]), 129 AC_MSG_WARN($LIBZIP_PKG_ERRORS [(non-fatal if there's zziplib)]); LACK_LIBZIP=1) 130 CFLAGS="$CFLAGS $LIBZIP_CFLAGS" 131 LIBS="$LIBZIP_LIBS $LIBS" 132 # ZZipLib - doesn't cross-compile well and unstable under woe, but 133 # functional and initially more widespread under GNU/Linux 134 #AC_CHECK_LIB(zzip,zzip_open_ext_io,,AC_MSG_WARN([You need to install zzip]);LACK_LIBZZIP=1) 135 PKG_CHECK_MODULES([ZZIPLIB], [zziplib >= 0.12.83], 136 AC_DEFINE([HAVE_ZZIPLIB], [], [zziplib library (-lzzip)]), 137 AC_MSG_WARN($ZZIPLIB_PKG_ERRORS [(non-fatal if there's libzip)]); LACK_ZZIPLIB=1) 138 CFLAGS="$CFLAGS $ZZIPLIB_CFLAGS" 139 LIBS="$ZZIPLIB_LIBS $LIBS" 140else 141 LACK_LIBZIP=1 142 LACK_ZZIPLIB=1 143fi 144AM_CONDITIONAL(HAVE_LIBZIP, test "$LACK_LIBZIP" != "1") 145AM_CONDITIONAL(HAVE_ZZIPLIB, test "$LACK_ZZIPLIB" != "1") 146 147 148# Dynamic and static builds 149AC_ARG_ENABLE([static], 150 AS_HELP_STRING([--enable-static],[embed SDL and dependencies in the executable (default is disabled)]), 151 [], [enable_static=no]) 152if test x"$enable_static" = x"yes"; then 153 case "${host}" in 154 # (cf. (autoconf.info)Using System Type) (2002) 155 *-*-mingw32* | *-*-cygwin* | *-*-windows*) 156 # LIBS is handled by pkg-config and Libs.private/Requires.private 157 # We still need to force choosing 'libxxx.a' over 'libxxx.dll.a': 158 LDFLAGS="$LDFLAGS -static" 159 ;; 160 mipsallegrexel-psp-elf) 161 # (Only static builds are possible for this architecture AFAIK) 162 # Light version, if dependencies are compiled minimaly 163 #LIBS="$LIBS -lfreetype -lz" 164 # Full version, if planning to support more formats 165 LIBS="-lvorbisidec -lfreetype -lpng -ljpeg -lz $LIBS" 166 #LIBS="$LIBS -lfreetype -lpng -ltiff -ljpeg -lz -lvorbisfile -lvorbis -logg" 167 esac 168fi 169 170 171# Lengthy Gnulib checks 172gl_INIT 173 174 175# BinReloc, if not cross-compiling (tests do not check for cross-compilation) 176if test "$cross_compiling" = "no"; then 177AP_BINRELOC 178fi 179 180 181 182# Somewhat optional. Defines matching contants in config.h 183# (e.g. HAVE_SDL_FRAMERATE_H). Using a temporary CPPFLAGS to include 184# Gnulib's src and build directories ($top_srcdir and $top_builddir 185# not present here for some reason). Also sdl-config lacks a 186# --cppflags switch so we use SDL_CFLAGS. 187# http://lists.gnu.org/archive/html/bug-gnulib/2007-10/msg00157.html 188# http://lists.gnu.org/archive/html/bug-gnulib/2007-12/msg00149.html 189# https://bugs.freedesktop.org/show_bug.cgi?id=47996 190old_CPPFLAGS="$CPPFLAGS" 191CPPFLAGS="$CPPFLAGS $SDL_CFLAGS -I${srcdir}/gnulib/lib -I./gnulib/lib" 192AC_CHECK_HEADERS(SDL.h SDL_rotozoom.h SDL_framerate.h SDL_image.h, 193 [], AC_MSG_WARN([Could not find necessary SDL libs headers]); LACK_HEADERS=1) 194CPPFLAGS="$old_CPPFLAGS" 195 196 197echo 198echo "Errors and warnings recap:" 199error=0 200warning=0 201 202if test "$LACK_SDL" = 1; then 203 echo "* You need to install the SDL libraries:" 204 echo "$SDL_PKG_ERRORS" 205 error=1 206fi 207if test "$USE_NLS" = no; then 208 echo "* You need to install the gettext library and enable NLS" 209 error=1 210fi 211 212if test "$use_fontconfig" = "yes" -a "$LACK_FONTCONFIG" = 1; then 213 echo "* You need to install the fontconfig library" 214 error=1 215fi 216 217if test "$error" = 0 -a "$LACK_HEADERS" = 1; then 218 echo "* Warning: You lack some library headers (.h) - see warnings above." 219 #error=1 220 warning=1 221fi 222 223if test x"$enable_embedded_resources" = x"yes"; then 224 if test "$LACK_LIBZIP" = 1 -a "$LACK_ZZIPLIB" = 1; then 225 echo "* You need to install libzip or ZZipLib (or --disable-embedded-resources)." 226 error=1 227 fi 228 if test -z "$ZIP"; then 229 echo "* The 'zip' utility cannot be found. Please install it (or --disable-embedded-resources)." 230 error=1 231 fi 232fi 233 234if test "$error" = 0 -a "$LACK_HELP2MAN" = 1; then 235 echo -n "* Warning: The 'help2man' utility cannot be found. You won't be able to rebuild manpages" 236 echo " (if you modify the source code)" 237 warning=1 238fi 239 240if test "$enable_upx" = "yes" -a -z "$UPX"; then 241 echo "* UPX is explicitely activated (--enable-upx) but cannot be found" 242 error=1 243fi 244 245if test "$error" = 1; then 246 echo 247 echo "There are errors - stopping. Please check the reports above." 248 echo "If dependencies (such as SDL_gfx) are missing," 249 echo "please check BUILD for distro package names." 250 exit 1 251elif test "$warning" = 1; then 252 echo 253 echo "There were warnings - let's continue for now," 254 echo "but please check make sure nothing is missing." 255else 256 echo "* No errors" 257fi 258echo 259 260 261AC_CONFIG_FILES([Makefile gnulib/lib/Makefile gnulib/po/Makefile.in nsis/Makefile po/Makefile.in share/Makefile share/freedink/Makefile src/Makefile src/woeres.rc]) 262 263AC_OUTPUT 264 265 266echo 267echo "Options summary:" 268echo "* --enable-upx=$enable_upx" 269echo "* --enable-static=$enable_static" 270echo "* --enable-embedded-resources=$enable_embedded_resources" 271echo 272echo "Now you can type 'make' to compile $PACKAGE_STRING" 273