1
dnl ======================================
2
dnl GGZ Gaming Zone - Configuration Macros
3
dnl ======================================
5
dnl Copyright (C) 2001 - 2007 Josef Spillner, josef@ggzgamingzone.org
6
dnl This file has heavily been inspired by KDE's acinclude :)
7
dnl It is published under the conditions of the GNU General Public License.
9
dnl ======================================
11
dnl This file is common to most GGZ modules, and should be kept in sync
12
dnl between them all. The master copy resides with libggz.
13
dnl Currently the following modules use it:
14
dnl kde-games, kde-client, gtk-games, gtk-client, utils, grubby,
15
dnl ggz-client-libs, ggzd, gnome-client, txt-client, sdl-games, libggz
16
dnl See /docs/ggz-project/buildsystem for documentation.
18
dnl ======================================
21
dnl See the SVN log for a full history.
23
dnl ------------------------------------------------------------------------
24
dnl Content of this file:
25
dnl ------------------------------------------------------------------------
26
dnl High-level macros:
27
dnl AC_GGZ_CHECK - Checks for presence of GGZ client and server libraries.
28
dnl GGZ users can call this macro to determine at compile
29
dnl time whether to include GGZ support. Server and client
30
dnl are checked separately. GGZ_SERVER and GGZ_CLIENT are
31
dnl defined in config.h, and created as conditionals in
33
dnl AC_GGZ_CHECK_SERVER - The same, but server libs only.
36
dnl AC_GGZ_INIT - initialization and paths/options setup
37
dnl AC_GGZ_VERSION - ensure a minimum version of GGZ
38
dnl AC_GGZ_LIBGGZ - find the libggz headers and libraries
39
dnl AC_GGZ_GGZCORE - find the ggzcore headers and libraries
40
dnl AC_GGZ_CONFIG - find the ggz-config tool and set up configuration
41
dnl AC_GGZ_GGZMOD - find the ggzmod library
42
dnl AC_GGZ_GGZDMOD - find the ggzdmod library
43
dnl AC_GGZ_SERVER - set up game and room path for ggzd game servers
45
dnl Each macro takes two arguments:
46
dnl 1. Action-if-found (or empty for no action).
47
dnl 2. Action-if-not-found (or empty for error, or "ignore" to ignore).
49
dnl Internal functions:
50
dnl AC_GGZ_ERROR - user-friendly error messages
51
dnl AC_GGZ_FIND_FILE - macro for convenience (thanks kde)
52
dnl AC_GGZ_REMOVEDUPS - eliminate duplicate list elements
55
# Version number of this script.
56
# First part is upstream (ggz) version and second Freeciv modifications.
59
dnl ------------------------------------------------------------------------
60
dnl Find a directory containing a single file
61
dnl Synopsis: AC_GGZ_FIND_FILE(file, directorylist, <returnvar>)
62
dnl ------------------------------------------------------------------------
64
AC_DEFUN([AC_GGZ_FIND_FILE],
71
echo "configure: __oline__: $i/$j" >&AC_FD_CC
72
if test -r "$i/$j"; then
73
echo "taking that" >&AC_FD_CC
81
dnl ------------------------------------------------------------------------
82
dnl Remove duplicate entries in a list, and remove all NO's
83
dnl Synopsis: AC_GGZ_REMOVEDUPS(list, <returnlist>)
84
dnl ------------------------------------------------------------------------
86
AC_DEFUN([AC_GGZ_REMOVEDUPS],
92
if test "x$i" = "x$j"; then
96
if test "x$i" = "xNO"; then
99
if test "x$add" = "xyes"; then
106
dnl ------------------------------------------------------------------------
107
dnl User-friendly error messages
108
dnl Synopsis: AC_GGZ_ERROR(libraryname, headerdirlist, libdirlist)
109
dnl ------------------------------------------------------------------------
111
AC_DEFUN([AC_GGZ_ERROR],
114
The library '$1' does not seem to be installed correctly.
115
Headers searched in: $2
116
Libraries searched in: $3
117
Please read QuickStart.GGZ in order to fix this.
122
dnl ------------------------------------------------------------------------
123
dnl Initialization, common values and such
124
dnl Synopsis: AC_GGZ_INIT([export], [defaults])
125
dnl ------------------------------------------------------------------------
127
AC_DEFUN([AC_GGZ_INIT],
129
if test "x$prefix" = "xNONE"; then
130
prefix="${ac_default_prefix}"
132
if test "x$exec_prefix" = "xNONE"; then
133
exec_prefix='${prefix}'
138
AC_HELP_STRING([--with-ggz-dir=DIR], [Path to GGZ Gaming Zone]),
139
[ ac_ggz_prefix="$withval"
142
if test "x$ac_ggz_prefix" != "xno" ; then
143
if test "x${prefix}" = "xNONE"; then
144
ac_ggz_prefix_incdir="${ac_default_prefix}/include"
145
ac_ggz_prefix_libdir="${ac_default_prefix}/lib"
146
ac_ggz_prefix_bindir="${ac_default_prefix}/bin"
147
ac_ggz_prefix_etcdir="${ac_default_prefix}/etc"
149
unq_includedir="${includedir}"
150
unq_libdir="${libdir}"
151
unq_bindir="${bindir}"
152
unq_sysconfdir="${sysconfdir}"
154
eval unq_includedir=`echo $unq_includedir`
155
eval unq_includedir=`echo $unq_includedir`
156
eval unq_libdir=`echo $unq_libdir`
157
eval unq_libdir=`echo $unq_libdir`
158
eval unq_bindir=`echo $unq_bindir`
159
eval unq_bindir=`echo $unq_bindir`
160
eval unq_sysconfdir=`echo $unq_sysconfdir`
161
eval unq_sysconfdir=`echo $unq_sysconfdir`
163
ac_ggz_prefix_incdir="${unq_includedir}"
164
ac_ggz_prefix_libdir="${unq_libdir}"
165
ac_ggz_prefix_bindir="${unq_bindir}"
166
ac_ggz_prefix_etcdir="${unq_sysconfdir}"
168
ac_ggz_stdinc="$ac_ggz_prefix_incdir"
169
ac_ggz_stdlib="$ac_ggz_prefix_libdir"
170
ac_ggz_stdbin="$ac_ggz_prefix_bindir"
171
ac_ggz_stdetc="$ac_ggz_prefix_etcdir/ggzd"
172
if test "x$ac_ggz_prefix" != "x"; then
173
ac_ggz_stdinc="$ac_ggz_stdinc $ac_ggz_prefix/include"
174
ac_ggz_stdlib="$ac_ggz_stdlib $ac_ggz_prefix/lib $ac_ggz_prefix/lib64"
175
ac_ggz_stdbin="$ac_ggz_stdbin $ac_ggz_prefix/bin"
176
ac_ggz_stdetc="$ac_ggz_stdetc $ac_ggz_prefix/etc/ggzd"
178
if test "x$1" = "xdefaults" || test "x$2" = "xdefaults"; then
179
ac_ggz_stdinc="$ac_ggz_stdinc /usr/local/include /usr/include"
180
ac_ggz_stdlib="$ac_ggz_stdlib /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64"
181
ac_ggz_stdbin="$ac_ggz_stdbin /usr/local/bin /usr/bin"
182
ac_ggz_stdetc="$ac_ggz_stdetc /usr/local/etc/ggzd /etc/ggzd"
184
if test "x$1" = "xexport" || test "x$2" = "xexport"; then
185
CPPFLAGS="$CPPFLAGS -I ${ac_ggz_prefix_incdir} -I /usr/local/include"
186
LDFLAGS="$LDFLAGS -L${ac_ggz_prefix_libdir} -L/usr/local/lib"
190
save_cxxflags=$CXXFLAGS
191
if test "x$GCC" = xyes; then
192
CFLAGS="-Wall -Werror"
193
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
194
[[void signedness(void){char c;if(c==-1)c=0;}]])],
196
[save_cflags="$save_cflags -fsigned-char"
197
save_cxxflags="$save_cxxflags -fsigned-char"])
199
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
200
[[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0x550)
202
# include "Error: Only GCC and Sun Studio are supported compilers."
204
[save_cflags="$save_cflags -xchar=signed"
205
save_cxxflags="$save_cxxflags -xchar=signed"],
210
CXXFLAGS=$save_cxxflags
214
dnl ------------------------------------------------------------------------
215
dnl Ensure that a minimum version of GGZ is present
216
dnl Synopsis: AC_GGZ_VERSION(major, minor, micro,
217
dnl action-if-found, action-if-not-found)
218
dnl ------------------------------------------------------------------------
220
AC_DEFUN([AC_GGZ_VERSION],
226
testprologue="#include <ggz.h>"
228
testbody="$testbody if(LIBGGZ_VERSION_MAJOR > $major) return 0;"
229
testbody="$testbody if(LIBGGZ_VERSION_MAJOR < $major) return -1;"
230
testbody="$testbody if(LIBGGZ_VERSION_MINOR > $minor) return 0;"
231
testbody="$testbody if(LIBGGZ_VERSION_MINOR < $minor) return -1;"
232
testbody="$testbody if(LIBGGZ_VERSION_MICRO > $micro) return 0;"
233
testbody="$testbody if(LIBGGZ_VERSION_MICRO < $micro) return -1;"
234
testbody="$testbody return 0;"
237
save_ldflags=$LDFLAGS
238
save_cppflags=$CPPFLAGS
239
save_ldlibrary_path=$LD_LIBRARY_PATH
240
LDFLAGS=$LIBGGZ_LDFLAGS
242
CPPFLAGS=$LIBGGZ_INCLUDES
243
LD_LIBRARY_PATH=$save_ldlibrary_path:$libggz_libraries
244
export LD_LIBRARY_PATH
246
AC_MSG_CHECKING([for GGZ library version: $major.$minor.$micro])
248
[AC_LANG_PROGRAM([[$testprologue]], [[$testbody]])],
249
[ac_ggz_version_check=yes],
250
[ac_ggz_version_check=no],
251
[ac_ggz_version_check="skipped due to cross-compiling"]
253
if test "$ac_ggz_version_check" = "no"; then
255
if test "x$5" = "x"; then
256
AC_MSG_ERROR([The GGZ version is too old. Version $major.$minor.$micro is required.])
260
AC_MSG_RESULT($ac_ggz_version_check)
265
LDFLAGS=$save_ldflags
266
CPPFLAGS=$save_cppflags
267
LD_LIBRARY_PATH=$save_ldlibrary_path
270
dnl ------------------------------------------------------------------------
271
dnl Try to find the libggz headers and libraries.
272
dnl $(LIBGGZ_LDFLAGS) will be -L ... (if needed)
273
dnl and $(LIBGGZ_INCLUDES) will be -I ... (if needed)
274
dnl ------------------------------------------------------------------------
276
AC_DEFUN([AC_GGZ_LIBGGZ],
278
AC_MSG_CHECKING([for GGZ library: libggz])
280
ac_libggz_includes=NO ac_libggz_libraries=NO
284
AC_ARG_WITH(libggz-dir,
285
AC_HELP_STRING([--with-libggz-dir=DIR],[libggz installation prefix]),
286
[ ac_libggz_includes="$withval"/include
287
ac_libggz_libraries="$withval"/lib
289
AC_ARG_WITH(libggz-includes,
290
AC_HELP_STRING([--with-libggz-includes=DIR],
291
[where the libggz includes are]),
292
[ ac_libggz_includes="$withval"
294
AC_ARG_WITH(libggz-libraries,
295
AC_HELP_STRING([--with-libggz-libraries=DIR],[where the libggz libs are]),
296
[ ac_libggz_libraries="$withval"
299
AC_CACHE_VAL(ac_cv_have_libggz,
301
libggz_incdirs="$ac_libggz_includes $ac_ggz_stdinc"
302
AC_GGZ_REMOVEDUPS($libggz_incdirs, libggz_incdirs)
305
AC_GGZ_FIND_FILE($libggz_header, $libggz_incdirs, libggz_incdir)
306
ac_libggz_includes="$libggz_incdir"
308
libggz_libdirs="$ac_libggz_libraries $ac_ggz_stdlib"
309
AC_GGZ_REMOVEDUPS($libggz_libdirs, libggz_libdirs)
312
for dir in $libggz_libdirs; do
313
try="ls -1 $dir/libggz.la $dir/libggz.so"
314
if test -n "`$try 2> /dev/null`"; then libggz_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
317
ac_libggz_libraries="$libggz_libdir"
319
if test "$ac_libggz_includes" = NO || test "$ac_libggz_libraries" = NO; then
320
ac_cv_have_libggz="have_libggz=no"
321
ac_libggz_notfound=""
327
eval "$ac_cv_have_libggz"
329
if test "$have_libggz" != yes; then
330
if test "x$2" = "xignore"; then
331
AC_MSG_RESULT([$have_libggz (ignored)])
333
AC_MSG_RESULT([$have_libggz])
334
if test "x$2" = "x"; then
335
AC_GGZ_ERROR(libggz, $libggz_incdirs, $libggz_libdirs)
338
# perform actions given by argument 2.
342
ac_cv_have_libggz="have_libggz=yes \
343
ac_libggz_includes=$ac_libggz_includes ac_libggz_libraries=$ac_libggz_libraries"
344
AC_MSG_RESULT([$have_libggz (libraries $ac_libggz_libraries, headers $ac_libggz_includes)])
346
libggz_libraries="$ac_libggz_libraries"
347
libggz_includes="$ac_libggz_includes"
349
AC_SUBST(libggz_libraries)
350
AC_SUBST(libggz_includes)
352
LIBGGZ_INCLUDES="-I $libggz_includes"
353
LIBGGZ_LDFLAGS="-L$libggz_libraries"
355
AC_SUBST(LIBGGZ_INCLUDES)
356
AC_SUBST(LIBGGZ_LDFLAGS)
361
# perform actions given by argument 1.
367
dnl ------------------------------------------------------------------------
368
dnl Try to find the ggzcore headers and libraries.
369
dnl $(GGZCORE_LDFLAGS) will be -L ... (if needed)
370
dnl and $(GGZCORE_INCLUDES) will be -I ... (if needed)
371
dnl ------------------------------------------------------------------------
373
AC_DEFUN([AC_GGZ_GGZCORE],
375
AC_MSG_CHECKING([for GGZ library: ggzcore])
377
ac_ggzcore_includes=NO ac_ggzcore_libraries=NO
381
AC_ARG_WITH(ggzcore-dir,
382
AC_HELP_STRING([--with-ggzcore-dir=DIR],[ggzcore installation prefix]),
383
[ ac_ggzcore_includes="$withval"/include
384
ac_ggzcore_libraries="$withval"/lib
386
AC_ARG_WITH(ggzcore-includes,
387
AC_HELP_STRING([--with-ggzcore-includes=DIR],
388
[where the ggzcore includes are]),
389
[ ac_ggzcore_includes="$withval"
391
AC_ARG_WITH(ggzcore-libraries,
392
AC_HELP_STRING([--with-ggzcore-libraries=DIR],
393
[where the ggzcore libs are]),
394
[ ac_ggzcore_libraries="$withval"
397
AC_CACHE_VAL(ac_cv_have_ggzcore,
399
ggzcore_incdirs="$ac_ggzcore_includes $ac_ggz_stdinc"
400
AC_GGZ_REMOVEDUPS($ggzcore_incdirs, ggzcore_incdirs)
401
ggzcore_header=ggzcore.h
403
AC_GGZ_FIND_FILE($ggzcore_header, $ggzcore_incdirs, ggzcore_incdir)
404
ac_ggzcore_includes="$ggzcore_incdir"
406
ggzcore_libdirs="$ac_ggzcore_libraries $ac_ggz_stdlib"
407
AC_GGZ_REMOVEDUPS($ggzcore_libdirs, ggzcore_libdirs)
410
for dir in $ggzcore_libdirs; do
411
try="ls -1 $dir/libggzcore.la $dir/libggzcore.so"
412
if test -n "`$try 2> /dev/null`"; then ggzcore_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
415
ac_ggzcore_libraries="$ggzcore_libdir"
417
if test "$ac_ggzcore_includes" = NO || test "$ac_ggzcore_libraries" = NO; then
418
ac_cv_have_ggzcore="have_ggzcore=no"
419
ac_ggzcore_notfound=""
425
eval "$ac_cv_have_ggzcore"
427
if test "$have_ggzcore" != yes; then
428
if test "x$2" = "xignore"; then
429
AC_MSG_RESULT([$have_ggzcore (intentionally ignored)])
431
AC_MSG_RESULT([$have_ggzcore])
432
if test "x$2" = "x"; then
433
AC_GGZ_ERROR(ggzcore, $ggzcore_incdirs, $ggzcore_libdirs)
436
# Perform actions given by argument 2.
440
ac_cv_have_ggzcore="have_ggzcore=yes \
441
ac_ggzcore_includes=$ac_ggzcore_includes ac_ggzcore_libraries=$ac_ggzcore_libraries"
442
AC_MSG_RESULT([$have_ggzcore (libraries $ac_ggzcore_libraries, headers $ac_ggzcore_includes)])
444
ggzcore_libraries="$ac_ggzcore_libraries"
445
ggzcore_includes="$ac_ggzcore_includes"
447
AC_SUBST(ggzcore_libraries)
448
AC_SUBST(ggzcore_includes)
450
GGZCORE_INCLUDES="-I $ggzcore_includes"
451
GGZCORE_LDFLAGS="-L$ggzcore_libraries"
453
AC_SUBST(GGZCORE_INCLUDES)
454
AC_SUBST(GGZCORE_LDFLAGS)
456
LIB_GGZCORE='-lggzcore'
457
AC_SUBST(LIB_GGZCORE)
459
# Perform actions given by argument 1.
465
dnl ------------------------------------------------------------------------
466
dnl Try to find the ggz-config binary.
467
dnl Sets GGZ_CONFIG to the path/name of the program.
468
dnl Sets also: ggz_gamedir, ggz_datadir etc.
469
dnl ------------------------------------------------------------------------
471
AC_DEFUN([AC_GGZ_CONFIG],
473
AC_MSG_CHECKING([for GGZ configuration tool: ggz-config])
478
AC_ARG_WITH(ggzconfig,
479
AC_HELP_STRING([--with-ggzconfig=DIR],[path to ggz-config]),
480
[ ac_ggz_config="$withval"
483
ac_ggz_config_orig=$ac_ggz_config
485
AC_CACHE_VAL(ac_cv_have_ggzconfig,
487
ggz_config_dirs="$ac_ggz_config $ac_ggz_stdbin"
489
AC_GGZ_FIND_FILE(ggz-config, $ggz_config_dirs, ggz_config_dir)
490
ac_ggz_config="$ggz_config_dir"
492
if test "$ac_ggz_config" = NO; then
493
ac_cv_have_ggzcore="have_ggz_config=no"
494
ac_ggz_config_notfound=""
497
have_ggz_config="yes"
501
eval "$ac_cv_have_ggz_config"
503
if test "$have_ggz_config" != yes; then
504
if test "x$2" = "xignore"; then
505
AC_MSG_RESULT([$have_ggz_config (intentionally ignored)])
507
ggzexecmoddir="\${libdir}/ggz"
508
ggzdatadir="\${datadir}/ggz"
510
AC_SUBST(ggzexecmoddir)
512
AC_DEFINE_UNQUOTED(GAMEDIR, "${libdir}/ggz", [Path where to install the games])
513
AC_DEFINE_UNQUOTED(GGZDATADIR, "${datadir}/ggz", [Path where the games should look for their data files])
515
AC_MSG_RESULT([$have_ggz_config])
516
if test "x$2" = "x"; then
517
AC_MSG_ERROR([ggz-config not found. Please check your installation! ])
520
# Perform actions given by argument 2.
524
pathto_app=`echo $prefix/bin/ | tr -s "/"`
525
pathto_ggz=`echo $ac_ggz_config/ | tr -s "/"`
527
if test "$ac_ggz_config_orig" != "NO"; then
528
pathto_app=$pathto_ggz
531
if test "x$pathto_app" != "x$pathto_ggz"; then
532
AC_MSG_RESULT([$have_ggz_config (dismissed due to different prefix)])
534
ggzexecmoddir="\${libdir}/ggz"
535
ggzdatadir="\${datadir}/ggz"
537
AC_SUBST(ggzexecmoddir)
539
AC_DEFINE_UNQUOTED(GGZMODULECONFDIR, "${prefix}/etc", [Path where the game registry is located])
540
AC_DEFINE_UNQUOTED(GAMEDIR, "${libdir}/ggz", [Path where to install the games])
541
AC_DEFINE_UNQUOTED(GGZDATADIR, "${datadir}/ggz", [Path where the games should look for their data files])
543
ac_cv_have_ggz_config="have_ggz_config=yes \
544
ac_ggz_config=$ac_ggz_config"
545
AC_MSG_RESULT([$ac_ggz_config/ggz-config])
547
ggz_config="$ac_ggz_config"
550
AC_ARG_ENABLE([noregistry],
551
AC_HELP_STRING([--enable-noregistry], [Do not register game modules.]),
552
[enable_noregistry=yes], [enable_noregistry=no])
554
GGZ_CONFIG="${ggz_config}/ggz-config"
555
if test "$enable_noregistry" = yes; then
556
GGZ_CONFIG="$GGZ_CONFIG --noregistry=$enableval"
560
ggzmoduleconfdir=`$GGZ_CONFIG --configdir`
561
AC_DEFINE_UNQUOTED(GGZMODULECONFDIR, "${ggzmoduleconfdir}", [Path where the game registry is located])
562
ggzexecmoddir=`$GGZ_CONFIG --gamedir`
563
AC_DEFINE_UNQUOTED(GAMEDIR, "${ggzexecmoddir}", [Path where to install the games])
564
ggzdatadir=`$GGZ_CONFIG --datadir`
565
AC_DEFINE_UNQUOTED(GGZDATADIR, "${ggzdatadir}", [Path where the games should look for their data files])
566
packagesrcdir=`cd $srcdir && pwd`
567
AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Path where the source is located])
569
if test "$ggzmoduleconfdir" = ""; then
570
AC_MSG_ERROR([ggz-config is unusable. Maybe LD_LIBRARY_PATH needs to be set.])
573
AC_SUBST(ggzmoduleconfdir)
574
AC_SUBST(ggzexecmoddir)
576
AC_SUBST(packagesrcdir)
578
# Perform actions given by argument 1.
585
dnl ------------------------------------------------------------------------
586
dnl Try to find the ggzmod headers and libraries.
587
dnl $(GGZMOD_LDFLAGS) will be -L ... (if needed)
588
dnl and $(GGZMOD_INCLUDES) will be -I ... (if needed)
589
dnl ------------------------------------------------------------------------
591
AC_DEFUN([AC_GGZ_GGZMOD],
593
AC_MSG_CHECKING([for GGZ library: ggzmod])
595
ac_ggzmod_includes=NO ac_ggzmod_libraries=NO
599
AC_ARG_WITH(ggzmod-dir,
600
AC_HELP_STRING([--with-ggzmod-dir=DIR],[ggzmod installation prefix]),
601
[ ac_ggzmod_includes="$withval"/include
602
ac_ggzmod_libraries="$withval"/lib
604
AC_ARG_WITH(ggzmod-includes,
605
AC_HELP_STRING([--with-ggzmod-includes=DIR],
606
[where the ggzmod includes are]),
607
[ ac_ggzmod_includes="$withval"
609
AC_ARG_WITH(ggzmod-libraries,
610
AC_HELP_STRING([--with-ggzmod-libraries=DIR],
611
[where the ggzmod libs are]),
612
[ ac_ggzmod_libraries="$withval"
615
AC_CACHE_VAL(ac_cv_have_ggzmod,
617
ggzmod_incdirs="$ac_ggzmod_includes $ac_ggz_stdinc"
618
AC_GGZ_REMOVEDUPS($ggzmod_incdirs, ggzmod_incdirs)
619
ggzmod_header=ggzmod.h
621
AC_GGZ_FIND_FILE($ggzmod_header, $ggzmod_incdirs, ggzmod_incdir)
622
ac_ggzmod_includes="$ggzmod_incdir"
624
ggzmod_libdirs="$ac_ggzmod_libraries $ac_ggz_stdlib"
625
AC_GGZ_REMOVEDUPS($ggzmod_libdirs, ggzmod_libdirs)
628
for dir in $ggzmod_libdirs; do
629
try="ls -1 $dir/libggzmod.la $dir/libggzmod.so"
630
if test -n "`$try 2> /dev/null`"; then ggzmod_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
633
ac_ggzmod_libraries="$ggzmod_libdir"
635
if test "$ac_ggzmod_includes" = NO || test "$ac_ggzmod_libraries" = NO; then
636
ac_cv_have_ggzmod="have_ggzmod=no"
637
ac_ggzmod_notfound=""
643
eval "$ac_cv_have_ggzmod"
645
if test "$have_ggzmod" != yes; then
646
if test "x$2" = "xignore"; then
647
AC_MSG_RESULT([$have_ggzmod (intentionally ignored)])
649
AC_MSG_RESULT([$have_ggzmod])
650
if test "x$2" = "x"; then
651
AC_GGZ_ERROR(ggzmod, $ggzmod_incdirs, $ggzmod_libdirs)
654
# Perform actions given by argument 2.
658
ac_cv_have_ggzmod="have_ggzmod=yes \
659
ac_ggzmod_includes=$ac_ggzmod_includes ac_ggzmod_libraries=$ac_ggzmod_libraries"
660
AC_MSG_RESULT([$have_ggzmod (libraries $ac_ggzmod_libraries, headers $ac_ggzmod_includes)])
662
ggzmod_libraries="$ac_ggzmod_libraries"
663
ggzmod_includes="$ac_ggzmod_includes"
665
AC_SUBST(ggzmod_libraries)
666
AC_SUBST(ggzmod_includes)
668
GGZMOD_INCLUDES="-I $ggzmod_includes"
669
GGZMOD_LDFLAGS="-L$ggzmod_libraries"
671
AC_SUBST(GGZMOD_INCLUDES)
672
AC_SUBST(GGZMOD_LDFLAGS)
674
LIB_GGZMOD='-lggzmod'
677
# Perform actions given by argument 1.
683
dnl ------------------------------------------------------------------------
684
dnl Try to find the ggzdmod headers and libraries.
685
dnl $(GGZDMOD_LDFLAGS) will be -L ... (if needed)
686
dnl and $(GGZDMOD_INCLUDES) will be -I ... (if needed)
687
dnl ------------------------------------------------------------------------
689
AC_DEFUN([AC_GGZ_GGZDMOD],
691
AC_MSG_CHECKING([for GGZ library: ggzdmod])
693
ac_ggzdmod_includes=NO ac_ggzdmod_libraries=NO
697
AC_ARG_WITH(ggzdmod-dir,
698
AC_HELP_STRING([--with-ggzdmod-dir=DIR], [ggzdmod installation prefix]),
699
[ ac_ggzdmod_includes="$withval"/include
700
ac_ggzdmod_libraries="$withval"/lib
702
AC_ARG_WITH(ggzdmod-includes,
703
AC_HELP_STRING([--with-ggzdmod-includes=DIR],
704
[where the ggzdmod includes are]),
705
[ ac_ggzdmod_includes="$withval"
707
AC_ARG_WITH(ggzdmod-libraries,
708
AC_HELP_STRING([--with-ggzdmod-libraries=DIR],
709
[where the ggzdmod libs are]),
710
[ ac_ggzdmod_libraries="$withval"
713
AC_CACHE_VAL(ac_cv_have_ggzdmod,
715
ggzdmod_incdirs="$ac_ggzdmod_includes $ac_ggz_stdinc"
716
AC_GGZ_REMOVEDUPS($ggzdmod_incdirs, ggzdmod_incdirs)
717
ggzdmod_header=ggzdmod.h
719
AC_GGZ_FIND_FILE($ggzdmod_header, $ggzdmod_incdirs, ggzdmod_incdir)
720
ac_ggzdmod_includes="$ggzdmod_incdir"
722
ggzdmod_libdirs="$ac_ggzdmod_libraries $ac_ggz_stdlib"
723
AC_GGZ_REMOVEDUPS($ggzdmod_libdirs, ggzdmod_libdirs)
726
for dir in $ggzdmod_libdirs; do
727
try="ls -1 $dir/libggzdmod.la $dir/libggzdmod.so"
728
if test -n "`$try 2> /dev/null`"; then ggzdmod_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
731
ac_ggzdmod_libraries="$ggzdmod_libdir"
733
if test "$ac_ggzdmod_includes" = NO || test "$ac_ggzdmod_libraries" = NO; then
734
ac_cv_have_ggzdmod="have_ggzdmod=no"
735
ac_ggzdmod_notfound=""
741
eval "$ac_cv_have_ggzdmod"
743
if test "$have_ggzdmod" != yes; then
744
if test "x$2" = "xignore"; then
745
AC_MSG_RESULT([$have_ggzdmod (intentionally ignored)])
747
AC_MSG_RESULT([$have_ggzdmod])
748
if test "x$2" = "x"; then
749
AC_GGZ_ERROR(ggzdmod, $ggzdmod_incdirs, $ggzdmod_libdirs)
752
# Perform actions given by argument 2.
756
ac_cv_have_ggzdmod="have_ggzdmod=yes \
757
ac_ggzdmod_includes=$ac_ggzdmod_includes ac_ggzdmod_libraries=$ac_ggzdmod_libraries"
758
AC_MSG_RESULT([$have_ggzdmod (libraries $ac_ggzdmod_libraries, headers $ac_ggzdmod_includes)])
760
ggzdmod_libraries="$ac_ggzdmod_libraries"
761
ggzdmod_includes="$ac_ggzdmod_includes"
763
AC_SUBST(ggzdmod_libraries)
764
AC_SUBST(ggzdmod_includes)
766
GGZDMOD_INCLUDES="-I $ggzdmod_includes"
767
GGZDMOD_LDFLAGS="-L$ggzdmod_libraries"
769
AC_SUBST(GGZDMOD_INCLUDES)
770
AC_SUBST(GGZDMOD_LDFLAGS)
772
LIB_GGZDMOD='-lggzdmod'
773
AC_SUBST(LIB_GGZDMOD)
775
# Perform actions given by argument 1.
781
dnl ------------------------------------------------------------------------
782
dnl Try to find the ggz-gtk headers and libraries.
783
dnl $(GGZGTK_LDFLAGS) will be -L ... (if needed)
784
dnl and $(GGZGTK_INCLUDES) will be -I ... (if needed)
785
dnl ------------------------------------------------------------------------
787
AC_DEFUN([AC_GGZ_GTK],
789
AC_MSG_CHECKING([for GGZ library: ggz-gtk])
791
ac_ggz_gtk_includes=NO ac_ggz_gtk_libraries=NO
795
AC_ARG_WITH(ggz-gtk-dir,
796
AC_HELP_STRING([--with-ggz-gtk-dir=DIR], [ggz-gtk installation prefix]),
797
[ ac_ggz_gtk_includes="$withval"/include
798
ac_ggz_gtk_libraries="$withval"/lib
800
AC_ARG_WITH(ggz-gtk-includes,
801
AC_HELP_STRING([--with-ggz-gtk-includes=DIR],
802
[where the ggz-gtk includes are]),
803
[ ac_ggz_gtk_includes="$withval"
805
AC_ARG_WITH(ggz-gtk-libraries,
806
AC_HELP_STRING([--with-ggz-gtk-libraries=DIR],
807
[where the ggz-gtk libs are]),
808
[ ac_ggz_gtk_libraries="$withval"
811
AC_CACHE_VAL(ac_cv_have_ggz_gtk,
813
ggz_gtk_incdirs="$ac_ggz_gtk_includes $ac_ggz_stdinc"
814
AC_GGZ_REMOVEDUPS($ggz_gtk_incdirs, ggz_gtk_incdirs)
815
ggz_gtk_header=ggz-gtk.h
817
AC_GGZ_FIND_FILE($ggz_gtk_header, $ggz_gtk_incdirs, ggz_gtk_incdir)
818
ac_ggz_gtk_includes="$ggz_gtk_incdir"
820
ggz_gtk_libdirs="$ac_ggz_gtk_libraries $ac_ggz_stdlib"
821
AC_GGZ_REMOVEDUPS($ggz_gtk_libdirs, ggz_gtk_libdirs)
824
for dir in $ggz_gtk_libdirs; do
825
try="ls -1 $dir/libggz-gtk.la $dir/libggz-gtk.so"
826
if test -n "`$try 2> /dev/null`"; then ggz_gtk_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
829
ac_ggz_gtk_libraries="$ggz_gtk_libdir"
831
if test "$ac_ggz_gtk_includes" = NO || test "$ac_ggz_gtk_libraries" = NO; then
832
ac_cv_have_ggz_gtk="have_ggz_gtk=no"
833
ac_ggz_gtk_notfound=""
839
eval "$ac_cv_have_ggz_gtk"
841
if test "$have_ggz_gtk" != yes; then
842
if test "x$2" = "xignore"; then
843
AC_MSG_RESULT([$have_ggz_gtk (intentionally ignored)])
845
AC_MSG_RESULT([$have_ggz_gtk])
846
if test "x$2" = "x"; then
847
AC_GGZ_ERROR(ggz-gtk, $ggz_gtk_incdirs, $ggz_gtk_libdirs)
850
# Perform actions given by argument 2.
854
ac_cv_have_ggz_gtk="have_ggz_gtk=yes \
855
ac_ggz_gtk_includes=$ac_ggz_gtk_includes ac_ggz_gtk_libraries=$ac_ggz_gtk_libraries"
856
AC_MSG_RESULT([$have_ggz_gtk (libraries $ac_ggz_gtk_libraries, headers $ac_ggz_gtk_includes)])
858
ggz_gtk_libraries="$ac_ggz_gtk_libraries"
859
ggz_gtk_includes="$ac_ggz_gtk_includes"
861
AC_SUBST(ggz_gtk_libraries)
862
AC_SUBST(ggz_gtk_includes)
864
GGZ_GTK_INCLUDES="-I $ggz_gtk_includes"
865
GGZ_GTK_LDFLAGS="-L$ggz_gtk_libraries"
867
AC_SUBST(GGZ_GTK_INCLUDES)
868
AC_SUBST(GGZ_GTK_LDFLAGS)
870
LIB_GGZ_GTK='-lggz-gtk'
871
AC_SUBST(LIB_GGZ_GTK)
873
# Perform actions given by argument 1.
878
dnl ------------------------------------------------------------------------
879
dnl Setup the game server configuration.
880
dnl Sets ggzdconfdir (ggzd configuration).
881
dnl Sets ggzddatadir (for game server data).
882
dnl ------------------------------------------------------------------------
884
AC_DEFUN([AC_GGZ_SERVER],
886
AC_MSG_CHECKING([for GGZ server: ggzd])
887
AC_ARG_WITH(ggzd-confdir,
888
AC_HELP_STRING([--with-ggzd-confdir=DIR], [directory for room/game data]),
889
[ ac_ggzd_confdir="$withval"
892
AC_CACHE_VAL(ac_cv_have_ggzdconf,
894
if test "x$1" = "xforce"; then
895
if test "x$ac_ggzd_confdir" = "x"; then
896
ggzdconfdirs="$ac_ggz_stdetc"
898
ggzdconfdirs="$ac_ggzd_confdir"
901
ggzdconfdirs="$ac_ggzd_confdir $ac_ggz_stdetc"
905
for dir in $ggzdconfdirs; do
906
if test -n "`ls -d $dir/rooms 2> /dev/null`"; then
907
if test -n "`ls -d $dir/rooms 2> /dev/null`"; then
908
ggzdconfdir=$dir; break;
910
echo "tried $dir" >&AC_FD_CC;
913
echo "tried $dir" >&AC_FD_CC;
917
if test "x$ggzdconfdir" = "xNONE"; then
924
eval "$ac_cv_have_ggzdconf"
926
if test "$have_ggzdconf" != yes; then
927
if test "x$2" = "xignore"; then
928
AC_MSG_RESULT([$have_ggzdconf (intentionally ignored)])
929
elif test "x$2" = "xforce"; then
930
if test "x$ac_ggzd_confdir" = "x"; then
931
ggzdconfdir="\${prefix}/etc/ggzd"
933
ggzdconfdir=$ac_ggzd_confdir
935
AC_MSG_RESULT([$have_ggzdconf (but forced to ${ggzdconfdir})])
937
AC_MSG_RESULT([$have_ggzdconf])
938
if test "x$2" = "x"; then
939
AC_MSG_ERROR([GGZ server configuration not found. Please check your installation! ])
942
# Perform actions given by argument 2.
947
if test "x${prefix}" != "xNONE" && test "x${prefix}" != "x${ac_default_prefix}"; then
948
if test "x$ac_ggzd_confdir" = "x"; then
952
if test "x$ggzdconfdir" != "x${prefix}/etc/ggzd" && test "x$prefixed" = "x1"; then
953
AC_MSG_RESULT([$have_ggzdconf ($ggzdconfdir, but using ${prefix}/etc/ggzd nevertheless)])
954
ggzdconfdir="\${prefix}/etc/ggzd"
956
AC_MSG_RESULT([$have_ggzdconf ($ggzdconfdir)])
960
if test "$have_ggzdconf" = yes || test "x$2" = "xforce"; then
961
AC_SUBST(ggzdconfdir)
963
ggzddatadir=${datadir}/${PACKAGE}
964
AC_DEFINE_UNQUOTED(GGZDDATADIR, "${ggzddatadir}", [Game server data directory])
965
AC_SUBST(ggzddatadir)
967
if test "x${libdir}" = 'x${exec_prefix}/lib'; then
968
if test "x${exec_prefix}" = "xNONE"; then
969
if test "x${prefix}" = "xNONE"; then
970
ggzdexecmoddir="\${ac_default_prefix}/lib/ggzd"
971
ggzdexecmodpath="${ac_default_prefix}/lib/ggzd"
973
ggzdexecmoddir="\${prefix}/lib/ggzd"
974
ggzdexecmodpath="${prefix}/lib/ggzd"
977
ggzdexecmoddir="\${exec_prefix}/lib/ggzd"
978
ggzdexecmodpath="${exec_prefix}/lib/ggzd"
981
ggzdexecmoddir="\${libdir}/ggzd"
982
ggzdexecmodpath="${libdir}/ggzd"
984
AC_SUBST(ggzdexecmoddir)
985
AC_SUBST(ggzdexecmodpath)
987
# Perform actions given by argument 1.
993
dnl ------------------------------------------------------------------------
994
dnl AC_GGZ_CHECK_SERVER
995
dnl Check for presence of GGZ server libraries.
997
dnl Simply call this function in programs that use GGZ. GGZ_SERVER will
998
dnl be #defined in config.h, and created as a conditional
999
dnl in Makefile.am files, if server libraries are present.
1000
dnl ------------------------------------------------------------------------
1002
AC_DEFUN([AC_GGZ_CHECK_SERVER],
1004
AC_GGZ_LIBGGZ([try_ggz="yes"], [try_ggz="no"])
1005
if test "$try_ggz" = "yes"; then
1006
# For now, version 0.0.14 is required. This could be an additional
1008
AC_GGZ_VERSION([0], [99], [4], [], [try_ggz=no])
1012
AC_ARG_WITH(ggz-server,
1013
AC_HELP_STRING([--with-ggz-server], [Force GGZ server support]),
1014
[try_ggz_server=$withval])
1016
if test "x$try_ggz_server" != "xno"; then
1017
if test "$try_ggz" = "yes"; then
1018
# Must pass something as the action-if-failed, or the macro will exit
1019
AC_GGZ_GGZDMOD([ggz_server="yes"], [ggz_server="no"])
1021
if test "$ggz_server" = "yes"; then
1023
AC_DEFINE(GGZ_SERVER, 1, [Server support for GGZ])
1025
if test "$try_ggz_server" = "yes"; then
1026
AC_MSG_ERROR([Could not configure GGZ server support. See above messages.])
1031
AM_CONDITIONAL(GGZ_SERVER, test "$ggz_server" = "yes")
1034
dnl ------------------------------------------------------------------------
1036
dnl Check for presence of GGZ client and server libraries.
1038
dnl Simply call this function in programs that use GGZ. GGZ_SERVER and
1039
dnl GGZ_CLIENT will be #defined in config.h, and created as conditionals
1040
dnl in Makefile.am files.
1042
dnl The only argument accepted gives the frontend for client embedding:
1043
dnl "gtk" => means the libggz-gtk library will be checked
1044
dnl ------------------------------------------------------------------------
1046
AC_DEFUN([AC_GGZ_CHECK],
1048
AC_GGZ_INIT([defaults])
1050
if test x$ac_ggz_prefix != xno ; then
1051
AC_GGZ_LIBGGZ([try_ggz="yes"], [try_ggz="no"])
1056
if test "$try_ggz" = "yes"; then
1057
# For now, version 0.0.14 is required. This could be an additional
1059
AC_GGZ_VERSION([0], [0], [14], [], [try_ggz=no])
1063
AC_ARG_WITH(ggz-client,
1064
AC_HELP_STRING([--with-ggz-client], [Force GGZ client support]),
1065
[try_ggz_client=$withval])
1067
if test "x$try_ggz_client" != "xno"; then
1068
if test "$try_ggz" = "yes"; then
1069
# Must pass something as the action-if-failed, or the macro will exit
1070
AC_GGZ_GGZMOD([AC_GGZ_CONFIG([ggz_client="yes"], [ggz_client="no"])],
1073
if test "$ggz_client" = "yes"; then
1074
AC_DEFINE(GGZ_CLIENT, 1, [Client support for GGZ])
1076
if test "$try_ggz_client" = "yes"; then
1077
AC_MSG_ERROR([Could not configure GGZ client support. See above messages.])
1083
if test "$ggz_client" = "yes"; then
1084
if test "x$1" = "xgtk"; then
1085
AC_GGZ_GTK([ggz_gtk="yes"])
1086
if test $ggz_gtk = "yes"; then
1087
AC_DEFINE(GGZ_GTK, 1, [Support for embedded GGZ through libggz-gtk])
1092
AM_CONDITIONAL(GGZ_CLIENT, test "$ggz_client" = "yes")
1093
AM_CONDITIONAL(GGZ_GTK, test "$ggz_gtk" = "yes")