File: configure.in

package info (click to toggle)
dopewars 1.5.12-7
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 5,676 kB
  • ctags: 3,233
  • sloc: ansic: 31,609; sh: 8,833; makefile: 512; yacc: 318
file content (475 lines) | stat: -rw-r--r-- 14,805 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/dopewars.c)

dnl Initialise automake
AM_INIT_AUTOMAKE(dopewars,1.5.12)

dnl Write configuration defines into config.h
AM_CONFIG_HEADER(config.h)

dnl We need this for the Darwin test, plus gettext uses it anyway
AC_CANONICAL_HOST

dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME
AC_STRUCT_TM

dnl Fix Apple's stupid C preprocessor
case "$host_os" in darwin*)
   CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
esac

HAVE_FIXED_GTK="no"

dnl Process client options
AC_ARG_ENABLE(gui-client,
[  --enable-gui-client     include graphical client (GTK+/Win32)],
[ GUI_CLIENT="$enableval" ],[ GUI_CLIENT="probe" ])

AC_ARG_ENABLE(curses-client,
[  --enable-curses-client  include curses client],
[ CURSES_CLIENT="$enableval" ],[ CURSES_CLIENT="probe" ])

AC_ARG_ENABLE(gui-server,
[  --enable-gui-server     use a simple GTK+/Win32 GUI for the server],
[ GUI_SERVER="$enableval" ],[ GUI_SERVER="probe" ])

AC_ARG_ENABLE(glib2,
[  --disable-glib2         use GLib/GTK+ 1.x, even if 2.x is found],
[ USE_GLIB2="$enableval" ],[ USE_GLIB2="yes" ])

AC_ARG_WITH(esd,
[  --without-esd           do not support ESD sound output],
[ USE_ESD="$withval" ], [ USE_ESD="probe" ])

AC_ARG_WITH(sdl,
[  --without-sdl           do not support SDL sound output],
[ USE_SDL="$withval" ], [ USE_SDL="probe" ])

ESD=no
SDL=no

dnl Test for Cygwin environment
AC_CYGWIN
dnl Let the user override this with the --enable-nativewin32 option
AC_ARG_ENABLE(nativewin32,
[  --enable-nativewin32    build a native Win32 binary under Cygwin],
[ CYGWIN="$enableval" ])

if test "$CYGWIN" = "yes" ; then
   AC_MSG_RESULT([Configuring for native Win32 binary under Cygwin])
   AC_DEFINE(CYGWIN, 1, [Define if building under the Cygwin environment])

   dnl This flag allows linking with MSVC-generated DLLs. -fnative-struct was
   dnl used by gcc 2, and -mms-bitfields by gcc 3, so it is tested for here.
   bkp_CFLAGS="$CFLAGS"
   AC_MSG_CHECKING(for compiler MSVC compatibility flag)
   CFLAGS="$CFLAGS -mms-bitfields"
   AC_COMPILE_IFELSE([ AC_LANG_PROGRAM() ], [ mscompat="-mms-bitfields" ],
                     [ mscompat="-fnative-struct" ])
   AC_MSG_RESULT($mscompat)
   CFLAGS="$bkp_CFLAGS"

   dnl Libraries and flags
   dnl N.B. -mno-cygwin is included in CPPFLAGS so the right headers
   dnl are detected (in /usr/include/mingw/ rather than /usr/include)
   dnl later on - e.g. sys/param.h isn't in mingw.
   CFLAGS="$CFLAGS -mwindows $mscompat"
   CPPFLAGS="$CPPFLAGS -mno-cygwin"
   LIBS="$LIBS -lwsock32 -lcomctl32 -lmpr"
   LDFLAGS="$LDFLAGS -mno-cygwin"

   AM_PATH_GLIB_2_0(2.0.0, , [AC_MSG_ERROR(GLib is required)])
   AC_DEFINE(HAVE_GLIB2, 1, [Do we have GLIB 2.0 ?])

   dnl We need to compile and then link in the Windows resources
   WNDRES="dopewars.res"
   AC_SUBST(WNDRES)

   dnl Add support for the Windows multimedia system
   SOUND_LIBS="$SOUND_LIBS -lwinmm"
   PLUGOBJS="$PLUGOBJS plugins/sound_winmm.o"
   AC_DEFINE(HAVE_WINMM, 1, [Do we have the Windows multimedia system?])

   dnl The gtkport implementation works just fine
   dnl for gtk_entry_set_visibility()
   HAVE_FIXED_GTK="yes"

   dnl Use graphical server by default
   if test "$GUI_SERVER" = "probe"; then
     GUI_SERVER="yes"
   fi

   dnl Read high score files, docs and locale files from current directory
   datadir="."
   localstatedir="."
else
   AC_MSG_RESULT([Configuring for Unix binary])

   dnl On true Unix systems, test for valid curses-like libraries
   if test "$CURSES_CLIENT" != "no" ; then
      AC_CHECK_LIB(ncurses,newterm)
      if test "$ac_cv_lib_ncurses_newterm" = "no" ; then
         AC_CHECK_LIB(curses,newterm)
         if test "$ac_cv_lib_curses_newterm" = "no" ; then
            AC_CHECK_LIB(cur_colr,newterm)
            if test "$ac_cv_lib_cur_colr_newterm" = "no" ; then
               if test "$CURSES_CLIENT" = "yes" ; then
                 AC_MSG_ERROR(Cannot find any curses-type library)
               else
                 AC_MSG_WARN(Cannot find any curses-type library)
                 CURSES_CLIENT="no"
               fi
            fi
         fi
      fi
   fi

   gtk2_found="probe"
   if test "$GUI_CLIENT" != "no" -o "$GUI_SERVER" != "no"; then
      if test "$USE_GLIB2" = "yes" ; then
        AM_PATH_GTK_2_0(2.0.0,gtk2_found="yes",gtk2_found="no")
      fi
      if test "$gtk2_found" = "yes" ; then
        HAVE_FIXED_GTK="yes"
      else
        gtk_found="no"
        AM_PATH_GTK(1.2.0,gtk_found="yes")
        if test "$gtk_found" = "no" ; then
           if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then
             AC_MSG_ERROR(Cannot find GTK+)
           else
             AC_MSG_WARN(Cannot find GTK+)
             GUI_CLIENT="no"
             GUI_SERVER="no"
           fi
        else
           AC_MSG_CHECKING([for non-buggy GTK+ ( >= 1.2.10 )])
           dnl Versions older than 1.2.10 are buggy
           if test "$gtk_config_major_version" -gt 1 ; then
              HAVE_FIXED_GTK="yes"
           elif test "$gtk_config_major_version" -eq 1 ; then
              if test "$gtk_config_minor_version" -gt 2 ; then
                 dnl We assume all 1.3.x releases are OK
                 HAVE_FIXED_GTK="yes"
              elif test "$gtk_config_minor_version" -eq 2 -a \
                        "$gtk_config_micro_version" -ge 10 ; then
                 HAVE_FIXED_GTK="yes"
              fi
           fi
           AC_MSG_RESULT([$HAVE_FIXED_GTK])
        fi
     fi
   fi

   dnl We NEED glib; N.B. don't link against glib2 if we're using GTK+1
   glib2_found="no"
   if test "$USE_GLIB2" = "yes" -a "$gtk2_found" != "no"; then
     AM_PATH_GLIB_2_0(2.0.0, glib2_found="yes")
   fi
   if test "$glib2_found" = "no" ; then
     AM_PATH_GLIB(1.2.0, , [AC_MSG_ERROR(Cannot find glib - aborting)])
   else
     AC_DEFINE(HAVE_GLIB2, 1, [Do we have GLIB 2.0 ?])
   fi

   dnl Add esound support if available
   if test "$USE_ESD" != "no"; then
     AM_PATH_ESD(0.0.20, ESD=yes)
     if test "$ESD" = "yes"; then
       SOUND_CFLAGS="$SOUND_CFLAGS $ESD_CFLAGS"
       SOUND_LIBS="$SOUND_LIBS $ESD_LIBS"
       PLUGOBJS="$PLUGOBJS plugins/sound_esd.o"
       AC_SUBST(ESD_LIBS)
       AC_DEFINE(HAVE_ESD, 1, [Do we have the ESD sound library?])
     elif test "$USE_ESD" = "yes"; then
       AC_MSG_ERROR(Cannot find ESD library)
     fi
   fi

   dnl Add SDL_mixer sound support if available
   if test "$USE_SDL" != "no"; then
     SDL_ALL=no
     AM_PATH_SDL(1.0.0, SDL=yes)
     if test "$SDL" = "yes"; then
       headers=no
       libs=no
       AC_CHECK_HEADER(SDL/SDL_mixer.h, headers=yes)
       AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, libs=yes)
       if test "$libs" = "yes"; then
         if test "$headers" = "yes"; then
           SOUND_CFLAGS="$SOUND_CFLAGS $SDL_CFLAGS"
           SDL_LIBS="$SDL_LIBS -lSDL_mixer"
           SOUND_LIBS="$SOUND_LIBS $SDL_LIBS"
           PLUGOBJS="$PLUGOBJS plugins/sound_sdl.o"
           AC_SUBST(SDL_LIBS)
           AC_DEFINE(HAVE_SDL_MIXER, 1,
                     [Do we have the SDL_mixer sound library?])
           SDL_ALL=yes
         fi
       fi
     fi
     if test "$USE_SDL" = "yes" -a "$SDL_ALL" = "no"; then
       AC_MSG_ERROR(Cannot find SDL library)
     fi
   fi

   dnl Use console server by default
   if test "$GUI_SERVER" = "probe"; then
     GUI_SERVER="no"
   fi

   dnl Some systems use int rather than socklen_t as an argument to getsockopt
   AC_MSG_CHECKING([for socklen_t data type])
   AC_TRY_COMPILE([#include <sys/types.h>
                   #include <sys/socket.h>],[socklen_t val],
                  [AC_MSG_RESULT([yes])
                   AC_DEFINE(HAVE_SOCKLEN_T, 1,
                             [Do we have the socklen_t data type?])],
                  [AC_MSG_RESULT([no])])
fi

AM_CONDITIONAL(ESD, test "$ESD" = "yes")
AM_CONDITIONAL(SDL, test "$SDL" = "yes")

dnl If probing was unsuccessful, these will be set to "no"; therefore,
dnl if still set to "probe" then everything worked, so set to "yes"
if test "$GUI_CLIENT" = "probe"; then
  GUI_CLIENT="yes"
fi
if test "$CURSES_CLIENT" = "probe"; then
  CURSES_CLIENT="yes"
fi

dnl Do i18n stuff
ALL_LINGUAS="de pl pt_BR fr fr_CA nn es es_ES"
AM_GNU_GETTEXT
if test "$gt_cv_func_gettext_libintl" = "yes"; then
    LIBS="-lintl $LIBS"
fi

if test "$GUI_CLIENT" = "yes" ; then
   AC_DEFINE(GUI_CLIENT, 1, [Use the graphical client?])
fi

if test "$CURSES_CLIENT" = "yes" ; then
   AC_DEFINE(CURSES_CLIENT, 1, [Use the (n)curses client?])
fi

if test "$GUI_SERVER" = "yes" ; then
   AC_DEFINE(GUI_SERVER, 1, [Use a graphical server?])
fi

if test "$HAVE_FIXED_GTK" = "yes" ; then
   AC_DEFINE(HAVE_FIXED_GTK, 1,
        [Do we have GTK+ with a non-buggy gtk_entry_set_visibility() ?
   (i.e. >= 1.2.10)])
fi

dnl Can we use a long long datatype for price_t ?
AC_CHECK_SIZEOF(long long)

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(strdup strstr getopt getopt_long fork)

dnl Enable plugins only if we can find the dlopen function, and
dnl the user does not disable them with --disable-plugins or --disable-shared
AC_ARG_ENABLE(plugins,
[  --enable-plugins        use dynamically-loaded sound modules],
[ plugins="$enableval" ],[ plugins="probe" ])

if test "$enable_shared" = "no" ; then
  plugins="no"
fi

if test "$plugins" != "no" ; then
  AC_SEARCH_LIBS(dlopen, dl)
  AC_CHECK_FUNC(dlopen, [plugins="yes"], [plugins="no"])
fi

if test "$plugins" = "yes" ; then
  AC_DEFINE(PLUGINS, 1, [Define if using dynamically-loaded sound modules])
  plugindir="${libdir}/dopewars"
  AC_SUBST(plugindir)
  DP_EXPAND_DIR(PLUGINDIR, '${plugindir}')
  AC_DEFINE_UNQUOTED(PLUGINDIR, "$PLUGINDIR",
                   [The directory containing the plugins])
  PLUGOBJS=""
else
  PLUGLIBS="$SOUND_LIBS"
  AC_SUBST(PLUGLIBS)
fi
AC_SUBST(PLUGOBJS)
AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")

dnl Enable networking by default under Win32, but on Unix systems
dnl make it dependent on the availability of select and socket
network="no"
if test "$CYGWIN" = "yes" ; then
   network="yes"
else
   dnl Check for socket and select even if networking gets manually
   dnl disabled below, since select is used if available for
   dnl millisecond sleeping
   AC_SEARCH_LIBS(socket,socket)
   AC_SEARCH_LIBS(gethostbyname,nsl socket)
   AC_CHECK_FUNCS(socket gethostbyname select)
   if test "$ac_cv_func_select" = "yes" ; then
      if test "$ac_cv_func_socket" = "yes" ; then
         if test "$ac_cv_func_gethostbyname" = "yes" ; then
            network="yes"
         fi
      fi
   fi
fi

dnl Let the user override this with the --enable-networking option
AC_ARG_ENABLE(networking,
[  --enable-networking     dopewars will use TCP/IP to connect to servers],
[ network="$enableval" ])

dnl Inform the user of the status of networking
if test "$network" = "yes" ; then
   AC_DEFINE(NETWORKING, 1,
       [Define if dopewars should use TCP/IP networking to connect to servers])
fi

AC_ARG_ENABLE(strict,
[  --enable-strict         if using gcc, enable extra warnings above -Wall],
[ extrawarnings="$enableval" ])

dnl Enable full warnings if using gcc
if test -n "$GCC"; then
   if test "$extrawarnings" = "yes" ; then
      CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wcast-qual -Wcast-align -Wsign-compare -Waggregate-return -Wredundant-decls -Wnested-externs -Wunused"
   else
      CFLAGS="$CFLAGS -Wall"
   fi
fi

dnl Tell dopewars where the high scores, docs and locale files are
DP_EXPAND_DIR(DPSCOREDIR, '${localstatedir}')
AC_DEFINE_UNQUOTED(DPSCOREDIR, "$DPSCOREDIR",
                   [The directory containing the high score file])
AC_SUBST(DPSCOREDIR)

DP_EXPAND_DIR(DPDATADIR, '${datadir}')
AC_DEFINE_UNQUOTED(DPDATADIR, "$DPDATADIR",
                   [The directory containing the docs and sounds])
AC_SUBST(DPDATADIR)

localedir=${datadir}/locale
AC_SUBST(localedir)
DP_EXPAND_DIR(LOCALEDIR, '${localedir}')
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR",
                   [The directory containing locale files])

dnl Add in the required clients
AM_CONDITIONAL(GUI_CLIENT, test "$GUI_CLIENT" = "yes")
if test "$GUI_CLIENT" = "yes" ; then
  GUILIB="gui_client/libguiclient.a"
  AC_SUBST(GUILIB)
fi
AM_CONDITIONAL(CURSES_CLIENT, test "$CURSES_CLIENT" = "yes")
if test "$CURSES_CLIENT" = "yes" ; then
  CURSESLIB="curses_client/libcursesclient.a"
  AC_SUBST(CURSESLIB)
fi

dnl Compile in the gtkport stuff for any kind of GUI
AM_CONDITIONAL(GTKPORT, test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes")
if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then
  GTKPORTLIB="gtkport/libgtkport.a"
  AC_SUBST(GTKPORTLIB)
fi

dnl Compile in the cursesport stuff for the curses client only
AM_CONDITIONAL(CURSESPORT, test "$CURSES_CLIENT" = "yes")
if test "$CURSES_CLIENT" = "yes" ; then
  CURSESPORTLIB="cursesport/libcursesport.a"
  AC_SUBST(CURSESPORTLIB)
fi

AC_SUBST(SOUND_CFLAGS)
AC_SUBST(SOUND_LIBS)

AC_OUTPUT([
Makefile
src/Makefile
src/gui_client/Makefile
src/curses_client/Makefile
src/gtkport/Makefile
src/cursesport/Makefile
src/plugins/Makefile
sounds/Makefile
sounds/19.5degs/Makefile
doc/Makefile
doc/help/Makefile
intl/Makefile
dopewars.spec
doc/dopewars.6
po/Makefile.in],
[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])

echo
echo "dopewars has been configured as follows:"
echo
if test "$CYGWIN" = "yes" ; then
   echo "Building native Windows (Win32) version"
else
   echo "Building Unix version"
fi
echo
echo "CLIENTS"
if test "$CURSES_CLIENT" = "no" -a "$GUI_CLIENT" = "no" ; then
   echo " - No clients will be compiled (binary will be server/AI only)"
else
   if test "$CURSES_CLIENT" = "yes" ; then
      echo " - Text-mode (curses) client"
   fi
   if test "$GUI_CLIENT" = "yes" ; then
      echo " - Graphical (GTK+ or Win32) client"
   fi
fi

echo
if test "$network" = "yes" ; then
   echo "TCP/IP networking support enabled for multi-player games"
   echo
   echo "SERVER"
   if test "$GUI_SERVER" = "yes" ; then
      echo " - Graphical server"
   else
      echo " - Text-mode server"
   fi
else
   echo "Networking support DISABLED; single-player mode only"
fi

if test "$GUI_SERVER" = "yes" -o "$GUI_CLIENT" = "yes" ; then
   if test "$HAVE_FIXED_GTK" = "no" ; then
     cat <<FGTKEND

WARNING: You have an old version of GTK+, which has bugs in the
gtk_entry_set_visibility function (used for password-entry boxes). Thus, for
stability reasons, this function will not be used, and all passwords entered
will be visible. To fix this, upgrade GTK+ to version 1.2.10 or later.
FGTKEND
   fi
fi
echo