Codebase list cyphesis-cpp / debian/0.6.0-1 configure.ac
debian/0.6.0-1

Tree @debian/0.6.0-1 (Download .tar.gz)

configure.ac @debian/0.6.0-1raw · history · blame

  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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
dnl Initialise autoconf

AC_INIT([cyphesis],[0.6.0],[alriddoch@googlemail.com])
AC_CONFIG_SRCDIR([server/server.cpp])
AC_CONFIG_HEADERS([config.h])

dnl Detect the canonical host environment

AC_CANONICAL_HOST

dnl Initialise automake

AM_INIT_AUTOMAKE([nostdinc dist-bzip2 check-news color-tests parallel-tests no-define silent-rules])
AM_SILENT_RULES([yes])
AM_BINRELOC

dnl Do not need libtool

dnl AC_PROG_LIBTOOL

COMMON_LIBS=
TERRAIN_LIBS=
NETWORK_LIBS=
MATH_LIBS=
MDNS_LIBS=
PGSQL_LIBS=

PYTHON_LINKER_FLAGS=
TAR_PERM_FLAGS=

dnl Test for C++ compiler options

AC_PROG_CXX
AC_PROG_CPP
AC_PROG_RANLIB

AC_PATH_PROG([XMLLINT], [xmllint], [true])

python_prefix=/usr
AC_ARG_WITH(python,
[  --with-python=DIR       Prefix where python is installed in [default=/usr]],
[
    if test $withval != yes; then
        python_prefix=$withval
    fi
])

dnl allow the user to specify that most libraries should be statically linked

STATIC_LIBSTDCPP=
STATIC_LIBGCC=

AC_ARG_ENABLE(static_link,
  [  --enable-static-link    enable static link of some libs [default=no]],
  [
    if test "$enableval" = "yes"; then
      link_static="true"
      STATIC_LIBSTDCPP=`$CXX -print-file-name=libstdc++.a`
      STATIC_LIBGCC=`$CXX -print-file-name=libgcc.a`
    else
      link_static="false"
    fi
  ],[
    link_static="false"
  ]
)
AM_CONDITIONAL(LINK_STATIC, test x"$link_static" = xtrue)

AC_MSG_CHECKING(whether gcc needs -fno-strict-aliasing)
AC_PREPROC_IFELSE([
#ifdef __GNUC__
# if defined(__GNUC_MINOR__) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 3)
#   error -fno-strict-aliasing needed
# elif __GNUC__ > 3
#   error -fno-strict-aliasing needed
# endif
#endif
],[
  GCC_EXTRA_OPT=
  AC_MSG_RESULT(no)
],[
  GCC_EXTRA_OPT=-fno-strict-aliasing
  AC_MSG_RESULT(yes)
])

AC_ARG_ENABLE(debug,
    [  --enable-debug          enable debug information [default=no]],
    [
        if test "$enableval" = "yes"; then
            CXXFLAGS="$CXXFLAGS $GCC_EXTRA_OPT -Wall -DDEBUG"
        else
            CXXFLAGS="$CXXFLAGS $GCC_EXTRA_OPT -Wall -DNDEBUG"
        fi
    ],[
        CXXFLAGS="$CXXFLAGS $GCC_EXTRA_OPT -Wall -DNDEBUG"
    ]
)

dnl allow the user to provide the directory where python is installed in

AC_LANG(C++)

AC_CHECK_FUNCS([sigset sigaction epoll_create poll localtime_r syslog uname])
AC_CHECK_FUNCS([getuid nice fork setsid wait4 getppid kill inet_ntop])
AC_CHECK_FUNCS([unlink usleep Sleep gettimeofday getnameinfo])

AC_SEARCH_LIBS([cos], [m])

AC_MSG_CHECKING([whether we have res_init() available])
AC_LINK_IFELSE(
    [
      AC_LANG_PROGRAM(
      [[
        #include <resolv.h>
      ]],
      [[
        res_init();
      ]]
     )
    ],
    [
        AC_MSG_RESULT([yes])
        AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if you have res_init libs.])
    ],
    [
        AC_MSG_RESULT([no])
    ]
)

AX_BOOST_BASE(
    [1.40],
    [],
    [
        AC_MSG_ERROR([
Cannot find Boost library 1.40 or later.
Please see http://www.boost.org/ for details of how to download and install
Boost.])
    ]
)

AC_MSG_CHECKING([whether we should link to MacOS-X frameworks])
AC_COMPILE_IFELSE(
    [
      AC_LANG_PROGRAM(
        [[
          #include <CoreFoundation/CFBundle.h>
        ]],
        [[
          CFBundleRef appBundle = CFBundleGetMainBundle();
        ]]
      )
    ],
    [
        AC_MSG_RESULT([yes])
        COMMON_LIBS="$COMMON_LIBS -Wl,-framework,CoreFoundation"
    ],
    [
        AC_MSG_RESULT([no])
    ]
)

dnl General header checks
AC_CHECK_HEADERS(termios.h signal.h syslog.h sys/utsname.h sys/wait.h)
AC_CHECK_HEADERS(winsock.h arpa/inet.h sys/un.h dirent.h io.h sys/ucred.h)
AC_CHECK_HEADERS(windows.h getopt.h)

dnl then check for the header file Python.h and set
dnl python_include_path and python_version
dnl appropriately to what we have found
dnl
dnl if found define HAVE_PYTHON_H
dnl

AC_CHECK_HEADER(python2.7/Python.h,
[
    python_include_path=-I${python_prefix}/include/python2.7
    python_version=2.7
],[
    AC_CHECK_HEADER(python2.6/Python.h,
    [
        python_include_path=-I${python_prefix}/include/python2.6
        python_version=2.6
    ],[
        AC_CHECK_HEADER(python2.5/Python.h,
        [
            python_include_path=-I${python_prefix}/include/python2.5
            python_version=2.5
        ],[
            AC_CHECK_HEADER(python2.4/Python.h,
            [
                python_include_path=-I${python_prefix}/include/python2.4
                python_version=2.4
            ],[
                AC_CHECK_HEADER(python2.3/Python.h,
                [
                    python_include_path=-I${python_prefix}/include/python2.3
                    python_version=2.3
                ],[
                    AC_CHECK_HEADER(python2.2/Python.h,
                    [
                        python_include_path=-I${python_prefix}/include/python2.2
                        python_version=2.2
                    ],[
                        AC_MSG_ERROR([
Cannot find python headers for Python 2.2 or later.
Please see http://www.python.org/ for details of how to download and install
Python. If Python is installed somewhere other than in /usr the please use the
--with-python=DIR option to point to the prefix where Python is installed.])
                    ])
                ])
            ])
        ])
    ])
])

PYTHON_VERSION=${python_version}
PYTHON_INCLUDES=${python_include_path}
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"

dnl build the library path from the found version
python_lib_path=${python_prefix}/lib/python${python_version}/config

PYTHON_UTIL_LIBS=

AC_CHECK_LIB(dl,dlopen,
[
    PYTHON_UTIL_LIBS="$PYTHON_UTIL_LIBS -ldl"
])

AC_CHECK_LIB(util,openpty,
[
    PYTHON_UTIL_LIBS="$PYTHON_UTIL_LIBS -lutil"
])

AC_CHECK_FUNC(pthread_mutex_trylock, ,
[
    ac_save_CXXFLAGS="$CXXFLAGS"
    CXXFLAGS="$CXXFLAGS -pthread"
    AC_CHECK_FUNC(pthread_create, ,
    [
        CXXFLAGS="$ac_save_CXXFLAGS"
        AC_CHECK_LIB(pthread, pthread_create, ,
        [
            AC_MSG_WARN([Cannot find pthread library. Python lib check may fail])
        ])
    ])
])

if test x"$link_static" = "xfalse"; then

AC_CHECK_LIB(python${python_version}, Py_Initialize,
[
    python_libs="-lpython${python_version}"
    PYTHON_UTIL_LIBS=
],
[
    AC_CHECK_LIB(python${python_version}, Py_Initialize,
    [
        python_libs="-L${python_lib_path} -lpython${python_version}"
        PYTHON_LINKER_FLAGS="-export-dynamic"
    ],AC_MSG_ERROR([
Cannot find python libraries. Do you have python development installed? Please
see http://www.python.org/ for details of how to download and install Python.]),
    [-L${python_lib_path} ${PYTHON_UTIL_LIBS}])
])

else

AC_CHECK_LIB(python${python_version}, Py_Initialize,
[
    python_libs="-L${python_lib_path} -lpython${python_version}"
    PYTHON_LINKER_FLAGS="-export-dynamic"
],AC_MSG_ERROR([
Cannot find python libraries. Do you have python development installed?
Please see http://www.python.org/ for details of how to download and install
Python.]),
[-L${python_lib_path} ${PYTHON_UTIL_LIBS}])

fi

PYTHON_LIBS=${python_libs}

AM_PATH_LIBGCRYPT(1.2.0,
[
    CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
    COMMON_LIBS="$COMMON_LIBS $LIBGCRYPT_LIBS"
],
[
    AC_MSG_ERROR([
Cannot find libgcrypt for encrypted passwords. Please see
http://directory.fsf.org/security/libgcrypt.html for details of how to
download and install libgcrypt development libraries. If it is installed
please ensure libgcrypt-config is on the PATH.])
])

PKG_PROG_PKG_CONFIG

dnl PKG_CHECK_MODULES(MONO, mono,
dnl     [
dnl         CPPFLAGS="$CPPFLAGS $MONO_CFLAGS"
dnl         COMMON_LIBS="$COMMON_LIBS $MONO_LIBS"
dnl     ])

PKG_CHECK_MODULES(DEPS, atlascpp-0.6 varconf-1.0 >= 0.6.4,
    [
        CPPFLAGS="$CPPFLAGS $DEPS_CFLAGS"
        COMMON_LIBS="$COMMON_LIBS $DEPS_LIBS"
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([
Cannot find valid versions of required WorldForge libraries:
$DEPS_PKG_ERRORS
Perhaps you should add the directory containing the missing libraries to the
PKG_CONFIG_PATH environment variable.
Please see http://worldforge.org/dev/eng/servers/cyphesis for details of the
libraries required and where to obtain them.])
    ])

PKG_CHECK_MODULES(WFMATH, wfmath-1.0 >= 1.0.0,
    [
        MATH_LIBS="$MATH_LIBS $WFMATH_LIBS"
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([
Cannot find valid versions of required WorldForge maths library, wfmath:
$WFMATH_PKG_ERRORS
Perhaps you should add the directory containing the missing libraries to the
PKG_CONFIG_PATH environment variable.
Please see http://worldforge.org/dev/eng/servers/cyphesis for details of the
libraries required and where to obtain them.])
    ])

PKG_CHECK_MODULES(MERCATOR, mercator-0.3 >= 0.3.0,
    [
        CPPFLAGS="$CPPFLAGS $MERCATOR_CFLAGS"
        TERRAIN_LIBS="$TERRAIN_LIBS $MERCATOR_LIBS"
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([
Cannot find valid versions of required WorldForge terrain library, mercator:
$MERCATOR_PKG_ERRORS
Perhaps you should add the directory containing the missing libraries to the
PKG_CONFIG_PATH environment variable.
Please see http://worldforge.org/dev/eng/servers/cyphesis for details of the
libraries required and where to obtain them.])
    ])

PKG_CHECK_MODULES(BULLET, bullet >= 2.77,
    [
        CPPFLAGS="$CPPFLAGS $BULLET_CFLAGS"
        TERRAIN_LIBS="$TERRAIN_LIBS $BULLET_LIBS"
        AC_DEFINE([HAVE_BULLET], [1], [Define to 1 if using bullet])
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_WARN([
Cannot find valid versions of required physics library, bullet:
$BULLET_PKG_ERRORS
Perhaps you should add the directory containing the missing libraries to the
PKG_CONFIG_PATH environment variable.
Please see http://worldforge.org/dev/eng/servers/cyphesis for details of the
libraries required and where to obtain them.])
    ])

PKG_CHECK_MODULES(SKSTREAM, skstream-0.3 >= 0.3.6,
    [
        CPPFLAGS="$CPPFLAGS $SKSTREAM_CFLAGS"
        NETWORK_LIBS="$NETWORK_LIBS $SKSTREAM_LIBS"
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([
Cannot find valid versions of required WorldForge network library, skstream:
$SKSTREAM_PKG_ERRORS
Perhaps you should add the directory containing the missing libraries to the
PKG_CONFIG_PATH environment variable.
Please see http://worldforge.org/dev/eng/servers/cyphesis for details of the
libraries required and where to obtain them.])
    ])

PKG_CHECK_MODULES(AVAHI, avahi-client,
    [
        CPPFLAGS="$CPPFLAGS $AVAHI_CFLAGS"
        MDNS_LIBS="$MDNS_LIBS $AVAHI_LIBS"
        AC_DEFINE(HAVE_AVAHI, 1, [Define to 1 if you have avahi libs.])
    ],
    [
        AC_MSG_RESULT([no])
        AC_MSG_NOTICE([Ommiting DNS-SD functionality.])
    ])

AM_PATH_PSQL(7.1.0,
    [
        if test "$PG_CFLAGS" != "-I/usr/include"; then
            CPPFLAGS="$CPPFLAGS $PG_CFLAGS"
        fi
        if test "$PG_LIBS" != "-L/usr/lib"; then
            PGSQL_LIBS="$PGSQL_LIBS $PG_LIBS"
        fi
    ],
    AC_MSG_ERROR([
Cannot find PostgreSQL config or config failed. Please install PostgreSQL and
ensure than pg_config is on the PATH. See http://www.postgresql.org/ for
details of how to download the software.])
)

ac_save_LIBS="$LIBS"
LIBS="$LIBS $PG_LIBS"
AC_CHECK_LIB(pq,PQconnectdb,
[
    PGSQL_LIBS="$PGSQL_LIBS -lpq"
],
[
    AC_CHECK_LIB(pq,PQconnectStart,
    [
        PGSQL_LIBS="$PGSQL_LIBS -lpq -lws2_32 -lwsock32 -lsecur32"
    ],
    [
        AC_MSG_ERROR([
Cannot find PostgreSQL bindings! Have you installed the PostgreSQL development
software?])
    ],[-lws2_32 -lwsock32 -lsecur32])
])
LIBS="$ac_save_LIBS"

READLINE_LIBS=

AC_CHECK_LIB(termcap,tgetent, 
    [READLINE_LIBS="$READLINE_LIBS -ltermcap"],
    AC_CHECK_LIB(ncurses, tgetent, 
        [READLINE_LIBS="$READLINE_LIBS -lncurses"],
        AC_MSG_WARN([
Cannot find tgetent in termcap or ncurses libraries!
This may be a problem for readline.])
    )
)

AC_CHECK_LIB(readline,readline,
    [
        READLINE_LIBS="$READLINE_LIBS -lreadline"
        AC_COMPILE_IFELSE(
          [
            AC_LANG_PROGRAM(
              [[
                #include <stdio.h>
                #include <readline/readline.h>
              ]],
              [[
                readline("test > ")
              ]]
            )
          ],
          [
            AC_DEFINE(READLINE_CXX_SANE, 1, Define if readline headers are C++ aware)
          ],
          [
            AC_MSG_WARN(Readline C++ workaround enabled)
          ]
        )
    ],
    [
        AC_MSG_WARN([
Cannot find readline! Please see http://directory.fsf.org/readline.html for
details of how to download and install the missing library.])
    ],[ $READLINE_LIBS ]
)

AC_MSG_CHECKING([whether tar allows permissions to be overriden])
if tar cf /dev/null --mode o+rX /dev/null 2> /dev/null ; then
    TAR_PERM_FLAGS="--mode o+rX"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi

AC_SUBST(VARCONF_LIBS)
AC_SUBST(READLINE_LIBS)
AC_SUBST(COMMON_LIBS)
AC_SUBST(TERRAIN_LIBS)
AC_SUBST(NETWORK_LIBS)
AC_SUBST(MATH_LIBS)
AC_SUBST(MDNS_LIBS)
AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_UTIL_LIBS)
AC_SUBST(python_version)
AC_SUBST(PGSQL_LIBS)

AC_SUBST(STATIC_LIBSTDCPP)
AC_SUBST(STATIC_LIBGCC)

AC_SUBST(PYTHON_LINKER_FLAGS)
AC_SUBST(TAR_PERM_FLAGS)

dnl Generate files
AC_CONFIG_FILES([
    cyphesis.spec
    cyphesis.iss
    Makefile
    libraries/Makefile
    physics/Makefile
    common/Makefile
    modules/Makefile
    rulesets/Makefile
    server/Makefile
    client/Makefile
    tools/Makefile
    data/Makefile
    data/minimal/Makefile
    data/mars/Makefile
    tests/Makefile
    man/Makefile
    dox/Makefile
    autopackage/default.apspec
])
AC_OUTPUT