1dnl This configuration script was based on that of Tuxracer. 2dnl http://www.tuxracer.com/ 3 4dnl Process this file with autoconf to produce a configure script. 5AC_INIT(src/scourge.h) 6AM_INIT_AUTOMAKE(scourge, "0.21") 7AM_CONFIG_HEADER(config.h) 8 9dnl internationalization macros 10AC_GNU_SOURCE 11AM_GNU_GETTEXT 12# AM_GNU_GETTEXT_VERSION 13 14dnl Check system type 15AC_CANONICAL_HOST 16 17dnl Check for compilers. We set CFLAGS and CXXFLAGS to null if unset, so 18dnl that these macros won't set them to default values that we don't want. 19if test "x${CFLAGS-notset}" = "xnotset" ; then 20 export CFLAGS 21 CFLAGS="" 22fi 23AC_PROG_CC 24 25if test "x${CXXFLAGS-notset}" = "xnotset" ; then 26 export CXXFLAGS 27 CXXFLAGS="" 28fi 29AC_PROG_CXX 30 31dnl Check for ranlib 32AC_PROG_RANLIB 33 34dnl we'll compile subdirectories into .la files. 35dnl AM_PROG_LIBTOOL 36 37dnl run make in subdirectories 38AC_PROG_MAKE_SET 39 40dnl Checks for header files. 41AC_HEADER_STDC 42AC_CHECK_HEADERS(sys/time.h unistd.h) 43 44dnl Checks for typedefs, structures, and compiler characteristics. 45AC_C_CONST 46AC_HEADER_TIME 47 48dnl Checks for library functions. 49AC_CHECK_FUNCS(getcwd gettimeofday strdup) 50 51dnl Check for non-standard floating point functions and headers 52AC_CHECK_FUNCS(finite isnan) 53AC_CHECK_FUNCS(_finite _isnan) 54AC_CHECK_HEADERS(ieeefp.h) 55 56# Set up binreloc (for a relocatable autopackage file) 57AM_BINRELOC 58 59dnl -------------------------------------------------------------------------- 60dnl General options 61dnl -------------------------------------------------------------------------- 62 63 64TR_CPPFLAGS="" 65TR_CFLAGS="$CFLAGS" 66TR_CXXFLAGS="$CXXFLAGS" 67TR_LIBS="" 68 69dnl Only override CXXFLAGS and CFLAGS if not already defined 70if test "x$CXXFLAGS" = "x" -a "x$CFLAGS" = "x" ; then 71 TR_CPPFLAGS="" 72 TR_CFLAGS="" 73 TR_CXXFLAGS="" 74 TR_LIBS="" 75fi 76 77AC_ARG_ENABLE([optimized], 78 AS_HELP_STRING([--enable-optimized], [enable compiler optimizations]), 79 [if test "x${enableval}" = "xyes" ; then 80 TR_CPPFLAGS="" 81 TR_CFLAGS="-O3 -Wall -Wno-deprecated -fomit-frame-pointer -ffast-math -fexpensive-optimizations" 82 TR_CXXFLAGS="-O3 -Wall -Wno-deprecated -fomit-frame-pointer -ffast-math -fexpensive-optimizations" 83 TR_LIBS="" 84 85 case "$host" in 86 i*86-*-*) TR_CFLAGS="$TR_CFLAGS -falign-loops=2 -falign-jumps=2 -falign-functions=2"; 87 TR_CXXFLAGS="$TR_CXXFLAGS -falign-loops=2 -falign-jumps=2 -falign-functions=2";; 88 alpha*-*-linux-*) TR_CFLAGS="$TR_CFLAGS -mieee";; 89 esac 90 fi]) 91 92AC_ARG_ENABLE([debug], 93 AS_HELP_STRING([--enable-debug], [enable debug in scourge]), 94 [if test "x${enableval}" = "xyes" ; then 95 TR_CFLAGS="-O0 -ggdb3 -DDEBUG -Wall -Wno-deprecated -fno-inline"; 96 TR_CXXFLAGS="$TR_CFLAGS"; 97 TR_CPPFLAGS="$TR_CFLAGS" 98 fi]) 99 100AC_ARG_ENABLE(profile, 101 [ --enable-profile Produce a profiled executable], 102 [TR_CFLAGS="$TR_CFLAGS -pg"; TR_CXXFLAGS="$TR_CXXFLAGS -pg"]) 103 104 105dnl -------------------------------------------------------------------------- 106dnl Check if compiling for Win32 107dnl -------------------------------------------------------------------------- 108AC_MSG_CHECKING([for Win32 platform]) 109AC_EGREP_CPP(yes, 110[ 111#if defined(WIN32) || defined(__CYGWIN__) 112 yes 113#endif 114], is_win32=yes, is_win32=no ) 115AC_MSG_RESULT([$is_win32]) 116 117AC_MSG_CHECKING([for Mac OSX platform]) 118AC_EGREP_CPP(yes, 119[ 120#if defined(__APPLE__) || defined(__MACH_O__) 121 yes 122#endif 123], is_macosx=yes, is_macosx=no ) 124AC_MSG_RESULT([$is_macosx]) 125 126dnl Add libs required for Windows 127dnl I don't use -mwindows since I like having the console around 128dnl If the console annoys you then remove "-luser32 -lgdi32" and replace 129dnl with "-mwindows" 130if test "x$is_win32" = "xyes" ; then 131 TR_LIBS="$TR_LIBS -luser32 -lgdi32" 132fi 133 134dnl -------------------------------------------------------------------------- 135dnl Check for X 136dnl Note that we only need libs (so that glut links properly on all systems). 137dnl -------------------------------------------------------------------------- 138dnl if test "x$is_win32" = "xno" ; then 139dnl AC_PATH_XTRA 140dnl if test "x$no_x" = "x" ; then 141dnl TR_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXi -lXext -lXmu -lXt $X_EXTRA_LIBS $TR_LIBS" 142dnl fi 143dnl fi 144 145dnl -------------------------------------------------------------------------- 146dnl Check for some common libraries 147dnl -------------------------------------------------------------------------- 148AC_CHECK_LIB( dl, main, TR_LIBS="$TR_LIBS -ldl" ) 149AC_CHECK_LIB( m, main, TR_LIBS="$TR_LIBS -lm" ) 150AC_CHECK_LIB( z, deflate, TR_LIBS="$TR_LIBS -lz", AC_MSG_ERROR([Cannot find libz library]) ) 151 152dnl -------------------------------------------------------------------------- 153dnl Check for SDL 154dnl -------------------------------------------------------------------------- 155AC_ARG_ENABLE(sdl,[ --disable-sdl Disable detction and use of SDL]) 156AC_ARG_ENABLE(sdl,[ --disable-sdl_net Disable detction and use of SDL_net]) 157AC_ARG_ENABLE(sdl,[ --disable-sdl_mixer Disable detction and use of SDL_mixer]) 158 159if test "x$enable_sdl" != "xno" ; then 160 161 SDL_VERSION=1.0.1 162 AM_PATH_SDL($SDL_VERSION, have_SDL=yes, have_SDL=no) 163 164 if test "x$have_SDL" = "xyes" ; then 165 TR_CPPFLAGS="$TR_CPPFLAGS -DHAVE_SDL=1" 166 TR_CFLAGS="$TR_CFLAGS $SDL_CFLAGS" 167 TR_CXXFLAGS="$TR_CXXFLAGS $SDL_CFLAGS" 168 TR_LIBS="$TR_LIBS $SDL_LIBS" 169 170 dnl Check for joystick support in SDL 171 saved_LIBS="$LIBS" 172 LIBS="$saved_LIBS $TR_LIBS" 173 174 AC_CHECK_FUNCS( SDL_JoystickOpen, 175 have_SDL_joystick=yes, have_SDL_joystick=no ) 176 177 if test "x$have_SDL_joystick" = "xno" ; then 178 echo "*** This version of SDL doesn't have joystick support." 179 echo "*** Configuring without joystick support." 180 fi 181 182 if test "x$enable_sdl_mixer" != "xno" ; then 183 dnl Check for SDL_mixer 184 AC_CHECK_LIB( SDL_mixer, Mix_OpenAudio, 185 have_SDL_mixer=yes, have_SDL_mixer=no ) 186 187 if test "x$have_SDL_mixer" = "xyes" ; then 188 TR_CPPFLAGS="$TR_CPPFLAGS -DHAVE_SDL_MIXER=1" 189 TR_LIBS="$TR_LIBS -lSDL_mixer" 190 else 191 echo "*** SDL_mixer not found. Configuring without audio support." 192 fi 193 fi 194 195 if test "x$enable_sdl_net" != "xno" ; then 196 dnl Check for SDL_net 197 AC_CHECK_LIB( SDL_net, SDLNet_Init, 198 have_SDL_net=yes, have_SDL_net=no ) 199 200 if test "x$have_SDL_net" = "xyes" ; then 201 TR_CPPFLAGS="$TR_CPPFLAGS -DHAVE_SDL_NET=1" 202 TR_LIBS="$TR_LIBS -lSDL_net" 203 else 204 echo "*** SDL_net not found. Configuring without network support." 205 fi 206 fi 207 208 dnl Check for SDL_ttf 209 AC_CHECK_LIB( SDL_ttf, TTF_Init, 210 have_SDL_ttf=yes, have_SDL_ttf=no ) 211 212 if test "x$have_SDL_ttf" = "xyes" ; then 213 TR_LIBS="$TR_LIBS -lSDL_ttf" 214 else 215 AC_MSG_ERROR([Cannot find SDL_ttf library]) 216 fi 217 218 dnl Check for SDL_image 219 AC_CHECK_LIB( SDL_image, IMG_Load, 220 have_SDL_image=yes, have_SDL_image=no ) 221 222 if test "x$have_SDL_image" = "xyes" ; then 223 TR_LIBS="$TR_LIBS -lSDL_image" 224 else 225 AC_MSG_ERROR([Cannot find SDL_image library]) 226 fi 227 228 LIBS="$saved_LIBS" 229 else 230 echo "*** SDL not found. Configuring without audio or joystick support." 231 fi 232 233fi 234 235dnl -------------------------------------------------------------------------- 236dnl Check for GL library 237dnl -------------------------------------------------------------------------- 238AC_ARG_WITH(gl-libs, [ --with-gl-libs=DIR GL/MesaGL library location]) 239AC_ARG_WITH(gl-lib-name, [ --with-gl-lib-name=NAME GL library name]) 240 241if test "x$with_gl_libs" = "x" ; then 242 GL_LDOPTS="" 243else 244 GL_LDOPTS="-L$with_gl_libs" 245fi 246 247saved_LIBS="$LIBS" 248 249AC_DEFUN([CHECK_FOR_GL_LIB], [ 250 AC_MSG_CHECKING([for $GL_LIB_NAME library]) 251 LIBS="$saved_LIBS $TR_LIBS $GL_LDOPTS -l$GL_LIB_NAME" 252 AC_TRY_LINK( , , have_GL=yes, have_GL=no) 253 AC_MSG_RESULT([$have_GL]) 254 255 if test "x$have_GL" = "xyes" ; then 256 TR_LIBS="$TR_LIBS $GL_LDOPTS -l$GL_LIB_NAME" 257 258 else 259 dnl Try with -lpthread 260 261 AC_MSG_CHECKING([for $GL_LIB_NAME library (with pthreads)]) 262 LIBS="$saved_LIBS $TR_LIBS $GL_LDOPTS -l$GL_LIB_NAME -lpthread" 263 AC_TRY_LINK( , , have_GL=yes, have_GL=no) 264 AC_MSG_RESULT([$have_GL]) 265 266 if test "x$have_GL" = "xyes" ; then 267 TR_LIBS="$TR_LIBS $GL_LDOPTS -l$GL_LIB_NAME -lpthread" 268 fi 269 fi 270]) 271 272AC_DEFUN([FIND_GL_LIB], [ 273 if test "x$with_gl_lib_name" = "x" ; then 274 GL_LIB_NAME="GL" 275 else 276 GL_LIB_NAME="$with_gl_lib_name" 277 fi 278 279 CHECK_FOR_GL_LIB 280 281 if test "x$have_GL" = "xno" -a "x$with_gl_lib_name" = "x" ; then 282 GL_LIB_LIST=`grep -v -E "^$GL_LIB_NAME\$" <<EOF 283GL 284MesaGL 285opengl32 286EOF 287` 288 289 for GL_LIB_NAME in $GL_LIB_LIST ; do 290 CHECK_FOR_GL_LIB 291 292 if test "x$have_GL" = "xyes" ; then 293 break; 294 fi 295 done 296 fi 297]) 298 299FIND_GL_LIB 300 301if test "x$have_GL" = "xno" -a "x$GL_LDOPTS" = "x" ; then 302 echo "*** Hmm, you don't seem to have OpenGL libraries installed in the standard" 303 echo "*** location (/usr/lib). I'll check in /usr/X11R6/lib, since" 304 echo "*** many distributions (incorrectly) put OpenGL libs there." 305 GL_LDOPTS="-L/usr/X11R6/lib" 306 FIND_GL_LIB 307fi 308 309if test "x$have_GL" = "xno" ; then 310 AC_MSG_ERROR([Cannot find GL library]) 311fi 312 313dnl Check for glXGetProcAddressARB 314AC_CHECK_FUNCS( glXGetProcAddressARB, has_glx_get_proc=yes, 315 has_glx_get_proc=no ) 316 317LIBS="$saved_LIBS" 318 319dnl -------------------------------------------------------------------------- 320dnl Check for GLU library 321dnl -------------------------------------------------------------------------- 322 323AC_ARG_WITH(glu-lib-name, [ --with-glu-lib-name=NAME GLU library name]) 324 325AC_DEFUN([CHECK_FOR_GLU_LIB], [ 326 AC_MSG_CHECKING([for $GLU_LIB_NAME library]) 327 LIBS="$saved_LIBS $TR_LIBS -l$GLU_LIB_NAME" 328 AC_TRY_LINK( , , have_GLU=yes, have_GLU=no) 329 AC_MSG_RESULT([$have_GLU]) 330]) 331 332if test "x$with_glu_lib_name" = "x" ; then 333 GLU_LIB_NAME="GLU" 334else 335 GLU_LIB_NAME="$with_glu_lib_name" 336fi 337 338saved_LIBS="$LIBS" 339 340CHECK_FOR_GLU_LIB 341 342if test "x$have_GLU" = "xno" -a "x$with_glu_lib_name" = "x"; then 343 GLU_LIB_LIST=`grep -v -E "^$GLU_LIB_NAME\$" <<EOF 344GLU 345MesaGLU 346glu32 347EOF 348` 349 350 for GLU_LIB_NAME in $GLU_LIB_LIST ; do 351 CHECK_FOR_GLU_LIB 352 353 if test "x$have_GLU" = "xyes" ; then 354 break 355 fi 356 done 357fi 358 359if test "x$have_GLU" = "xno" ; then 360 AC_MSG_ERROR([Cannot find GLU library]) 361fi 362 363LIBS="$saved_LIBS" 364TR_LIBS="$TR_LIBS -l$GLU_LIB_NAME" 365 366 367dnl -------------------------------------------------------------------------- 368dnl Check for wxWidget library 369dnl -------------------------------------------------------------------------- 370AC_ARG_ENABLE(sdl,[ --enable-editor Enable detection and building of the editor]) 371 372if test "x$enable_editor" = "xyes" ; then 373 374 saved_LIBS="$LIBS" 375 saved_CPPFLAGS="$CPPFLAGS" 376 377 AC_MSG_CHECKING([for wx-config library]) 378 379 AC_PATH_PROG(WXWIDGET, wx-config, no) 380 381 if test "$WXWIDGET" = "no"; then 382 AC_MSG_ERROR(Cannot find wxwidget: Will not build editor) 383 have_WXWIDGET=no 384 else 385 WXWIDGET_CFLAGS=`wx-config --cflags` 386 WXWIDGET_LIBS=`wx-config --libs` 387 have_WXWIDGET=yes 388 fi 389 390 LIBS="$saved_LIBS" 391 TR_LIBS="$TR_LIBS $WXWIDGET_LIBS" 392 CPPFLAGS="$saved_CPPFLAGS" 393 TR_CPPFLAGS="$TR_CPPFLAGS $WXWIDGET_CFLAGS" 394else 395 have_WXWIDGET=no 396fi 397AM_CONDITIONAL(HAVE_WXWIDGET_LIB, test x$have_WXWIDGET = xyes) 398 399dnl -------------------------------------------------------------------------- 400dnl Check for freetype library 401dnl -------------------------------------------------------------------------- 402 403dnl AC_ARG_WITH(freetype-config, [ --with-freetype-config=NAME path to freetype-config]) 404 405saved_LIBS="$LIBS" 406saved_CPPFLAGS="$CPPFLAGS" 407 408if test "x$is_macosx" = "xyes" ; then 409 410 dnl FIXME later: hardcoded mac path using freetype2-dev 411 412 FREETYPE_CFLAGS=`/sw/lib/freetype2/bin/freetype-config --cflags` 413 FREETYPE_LIBS=`/sw/lib/freetype2/bin/freetype-config --libs` 414 have_FREETYPE=yes 415else 416AC_MSG_CHECKING([for freetype-config library]) 417 418AC_PATH_PROG(FREETYPE, freetype-config, no) 419 420if test "$FREETYPE" = "no"; then 421 AC_MSG_ERROR(Cannot find freetype2: Is freetype-config in path?) 422 have_FREETYPE=no 423else 424 FREETYPE_CFLAGS=`pkg-config freetype2 --cflags` 425 FREETYPE_LIBS=`pkg-config freetype2 --libs` 426 have_FREETYPE=yes 427fi 428fi 429 430LIBS="$saved_LIBS" 431TR_LIBS="$TR_LIBS $FREETYPE_LIBS" 432CPPFLAGS="$saved_CPPFLAGS" 433TR_CPPFLAGS="$TR_CPPFLAGS $FREETYPE_CFLAGS" 434 435 436dnl -------------------------------------------------------------------------- 437dnl Check for OpenGL headers 438dnl -------------------------------------------------------------------------- 439 440AC_ARG_WITH(gl-inc, [ --with-gl-inc=DIR OpenGL header file location]) 441 442if test "x$with_gl_inc" = "x" ; then 443 GL_CPPFLAGS="" 444else 445 GL_CPPFLAGS="-I$with_gl_inc" 446fi 447 448dnl check for gl.h 449saved_CPPFLAGS="$CPPFLAGS" 450 451AC_DEFUN([CHECK_FOR_GL_H], [ 452 CPPFLAGS="$saved_CPPFLAGS $GL_CPPFLAGS $TR_CPPFLAGS" 453 454 AC_MSG_CHECKING([for GL/gl.h]) 455 AC_TRY_CPP( [ #include <GL/gl.h> ], have_gl_h=yes, have_gl_h=no ) 456 AC_MSG_RESULT([$have_gl_h]) 457]) 458 459CHECK_FOR_GL_H 460 461if test "x$have_gl_h" = "xno" -a "x$GL_CPPFLAGS" = "x" ; then 462 echo "*** Hmm, you don't seem to have OpenGL headers installed in the standard" 463 echo "*** location (/usr/include). I'll check in /usr/X11R6/include, since" 464 echo "*** many distributions (incorrectly) put OpenGL headers there." 465 GL_CPPFLAGS="-I/usr/X11R6/include" 466 CHECK_FOR_GL_H 467fi 468 469if test "x$have_gl_h" = "xno" ; then 470 AC_MSG_ERROR([Cannot find GL/gl.h]) 471fi 472 473if test "x$has_glx_get_proc" = "xyes" ; then 474 475 dnl Check for glx.h 476 AC_CHECK_HEADERS([GL/glx.h], have_glx_h=yes, have_glx_h=no ) 477 478 if test "x$have_glx_h" = "xno" ; then 479 AC_MSG_ERROR([Cannot find GL/glx.h]) 480 fi 481 482 dnl Check that glXGetProcAddressARB is defined in glx.h 483 dnl AC_MSG_CHECKING([whether glx.h defines glXGetProcAddressARB]); 484 dnl AC_TRY_COMPILE( [#include <GL/glx.h>], [ char *foo = (char*) glXGetProcAddressARB; ], 485 dnl glx_h_up_to_date=yes, glx_h_up_to_date=no ) 486 dnl AC_MSG_RESULT([$glx_h_up_to_date]) 487 488 dnl if test "x$glx_h_up_to_date" = "xno" ; then 489 dnl AC_MSG_ERROR([Your copy of glx.h is out of date. You can get a more recent copy from the latest Mesa distribution (http://mesa3d.sourceforge.net).]) 490 dnl fi 491fi 492 493dnl Check for glext.h 494dnl XXX: which requires GL/gl.h, and autoconf > 2.64 is barfing on this 495dnk XXX: use following check to cover the bases 496dnl AC_CHECK_HEADERS( "GL/glext.h", have_glext_h=yes, have_glext_h=no ) 497have_glext_h=yes 498 499if test "x$have_glext_h" = "xno" ; then 500 AC_MSG_ERROR([ 501***************************************************************** 502You are missing the file glext.h. 503You can get a copy at 504http://oss.sgi.com/projects/ogl-sample/ABI/glext.h 505Place it in the directory /usr/include/GL. 506*****************************************************************]) 507fi 508 509dnl Check that glext.h version is recent enough 510AC_MSG_CHECKING([whether glext.h is recent enough]); 511AC_EGREP_CPP(yes, 512[ 513#include <GL/glext.h> 514#if defined(GL_GLEXT_VERSION) && GL_GLEXT_VERSION >= 6 515 yes 516#endif 517], is_glext_h_recent=yes, is_glext_h_recent=no ) 518AC_MSG_RESULT([$is_glext_h_recent]) 519 520if test "x$is_glext_h_recent" = "xno" ; then 521 AC_MSG_ERROR([ 522***************************************************************** 523Your copy of glext.h is out of date. 524You can get a copy of the latest version at 525http://oss.sgi.com/projects/ogl-sample/ABI/glext.h 526Place it in the directory /usr/include/GL. 527*****************************************************************]) 528fi 529 530CPPFLAGS="$saved_CPPFLAGS" 531TR_CPPFLAGS="$TR_CPPFLAGS $GL_CPPFLAGS" 532 533 534dnl -------------------------------------------------------------------------- 535dnl Borrowed from the Battle for Wesnoth: create the translations directory. 536dnl -------------------------------------------------------------------------- 537AC_CONFIG_COMMANDS([translations], 538[rm -rf translations 539case $srcdir in 540/*) topdir=$srcdir ;; 541*) topdir=`pwd`/$srcdir ;; 542esac 543domain="scourge" 544# Symlinks that allow message catalogs to be used from build tree 545if test -w $srcdir; then 546 pushd po 547 make update-po 548 popd 549 for lang in `cat $srcdir/po/LINGUAS` 550 do 551 mkdir -p $srcdir/../scourge_data/translations/$lang/LC_MESSAGES 552 cp -f $topdir/po/$lang.gmo $srcdir/../scourge_data/translations/$lang/LC_MESSAGES/$domain.mo 553 done 554fi 555]) 556 557 558dnl -------------------------------------------------------------------------- 559dnl Other options 560dnl -------------------------------------------------------------------------- 561 562dnl Turn use of stencil buffer on/off 563AC_ARG_ENABLE(stencil-buffer,[ --enable-stencil-buffer Use if your hardware has a stencil buffer],TR_CPPFLAGS="$TR_CPPFLAGS -DUSE_STENCIL_BUFFER") 564 565dnl Specify data directory 566AC_ARG_WITH(data-dir,[ --with-data-dir=PATH Default scourge data directory],TR_CPPFLAGS="$TR_CPPFLAGS -DDATA_DIR=\\\"$withval\\\"") 567 568 569AC_SUBST(TR_CPPFLAGS) 570AC_SUBST(TR_CFLAGS) 571AC_SUBST(TR_CXXFLAGS) 572AC_SUBST(TR_LIBS) 573 574CPPFLAGS="$CPPFLAGS $TR_CPPFLAGS" 575CFLAGS="$TR_CFLAGS" 576CXXFLAGS="$TR_CXXFLAGS" 577LIBS="$LIBS $TR_LIBS" 578 579AC_OUTPUT(Makefile src/Makefile intl/Makefile po/Makefile.in \ 580src/common/Makefile \ 581src/gui/Makefile \ 582src/test/Makefile \ 583src/rpg/Makefile \ 584src/events/Makefile 585src/freetype/Makefile \ 586src/net/Makefile \ 587src/render/Makefile \ 588src/io/Makefile \ 589src/squirrel/Makefile \ 590src/sqstdlib/Makefile \ 591src/sqbinding/Makefile \ 592autopackage/default.apspec ) 593 594if test "$have_WXWIDGET" = "yes"; then 595 AC_OUTPUT(src/tools/Makefile) 596fi 597 598