Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 7714073da8ebcf62d864d16d3919af415b793b39 (plain)
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
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
dnl ----------------------------------------------------------------
dnl append SVN revision to the version number

dnl determine the svn revision number
define([svnversion], esyscmd([sh -c "echo -n 'svn'; svnversion|tr -d '\n'"]))

AC_INIT([osirion], [0.2.6-svnversion])

AC_CONFIG_HEADERS(src/config.h)

AC_LANG_CPLUSPLUS
AC_PROG_CXX
AC_PROG_LIBTOOL

AM_INIT_AUTOMAKE

dnl KDE_FIND_PATH(programm-name, variable-name, list of directories,
dnl     if-not-found, test-parameter)
AC_DEFUN([KDE_FIND_PATH],
[
   AC_MSG_CHECKING([for $1])
   if test -n "$$2"; then
        kde_cv_path="$$2";
   else
        kde_cache=`echo $1 | sed 'y%./+-%__p_%'`

        AC_CACHE_VAL(kde_cv_path_$kde_cache,
        [
        kde_cv_path="NONE"
        dirs="$3"
        kde_save_IFS=$IFS
        IFS=':'
        for dir in $PATH; do
          dirs="$dirs $dir"
        done
        IFS=$kde_save_IFS

        for dir in $dirs; do
          if test -x "$dir/$1"; then
            if test -n "$5"
            then
              evalstr="$dir/$1 $5 2>&1 "
              if eval $evalstr; then
                kde_cv_path="$dir/$1"
                break
              fi
            else
                kde_cv_path="$dir/$1"
                break
            fi
          fi
        done

        eval "kde_cv_path_$kde_cache=$kde_cv_path"

        ])

      eval "kde_cv_path=\"`echo '$kde_cv_path_'$kde_cache`\""

   fi

   if test -z "$kde_cv_path" || test "$kde_cv_path" = NONE; then
      AC_MSG_RESULT(not found)
      $4
   else
      AC_MSG_RESULT($kde_cv_path)
      $2=$kde_cv_path

   fi
])

dnl ----------------------------------------------------------------
dnl HOST dependend variables
dnl 

AC_MSG_CHECKING([host type])
case "$host" in
	*-apple-darwin*)
		HOST_LIBS=""
		HOST_GL_LIBS="-framework OpenGL"
		HOST_AL_LIBS="-framework OpenAL"
		ICON_CLIENT=""
		ICON_SERVER=""
		SDLMAIN="SDLMain.o"
		INSTALLTYPE="application bundle"
		OS=OSX
		AC_MSG_RESULT(OS X)
		AC_DEFINE_UNQUOTED(_OSX, 1, [Define this if you are building for native OS X])

dnl
dnl Do not rely on AC_PROG_OBJC presence (e.g. autoconf 2.59)
dnl http://www.mail-archive.com/xine-cvslog@lists.sourceforge.net/msg01693.html
dnl

		m4_ifdef(
			[AC_PROG_OBJC],
			[AC_PROG_OBJC],
			[AC_CHECK_TOOL([OBJC], [gcc])
			AC_SUBST(OBJC)
			AC_SUBST(OBJCFLAGS)]
		)
		;;

        *-*-mingw*)
		HOST_LIBS="-lws2_32"
		HOST_GL_LIBS="-lopengl32 -lglu32"
		HOST_AL_LIBS="-lopenal32"
		ICON_CLIENT="osirion-res.o"
		ICON_SERVER="osiriond-res.o"
		SDLMAIN=""
		INSTALLTYPE="single directory"
		OS=WIN32
                AC_MSG_RESULT(win32)
                ;;

        *)
                HOST_LIBS=""
                HOST_GL_LIBS="-lGL -lGLU"
		HOST_AL_LIBS="-lopenal"
		ICON_CLIENT=""
		ICON_SERVER=""
		SDLMAIN=""
		INSTALLTYPE="standard"
                AC_MSG_RESULT(generic unix)
		OS=UNIX
                ;;
esac

dnl
dnl Make Objective-C work with automake 1.7.x
dnl http://mlblog.osdir.com/sysutils.automake.general/2003-05/msg00030.shtml
dnl
AM_CONDITIONAL([am__fastdepOBJC], false)

AC_SUBST(OS)
AC_SUBST(HOST_LIBS)
AC_SUBST(ICON_CLIENT)
AC_SUBST(ICON_SERVER)
AC_SUBST(SDLMAIN)

AC_DEFINE(OS, $OS, [Operating System])

dnl ----------------------------------------------------------------
dnl enable compiler warnings or not
dnl

AC_MSG_CHECKING(whether to abort on compiler warnings)
WARN_CFLAGS="$WARN_CLFAGS -Wall"
AC_ARG_ENABLE(error,
        AC_HELP_STRING([--disable-error], [do not abort on compiler warnings]),
        AC_MSG_RESULT(no),
        AC_MSG_RESULT(yes)
        WARN_CFLAGS="$WARN_CFLAGS -Werror"
)
AC_SUBST(WARN_CFLAGS)

dnl ----------------------------------------------------------------
dnl enable DEBUG messages or not
dnl

AC_MSG_CHECKING(whether to include debug messages)
AC_ARG_ENABLE(debug_messages,
	AC_HELP_STRING([--disable-debug-messages], [build without extra debug messages]),
	AC_MSG_RESULT(no),
	AC_MSG_RESULT(yes)
	AC_DEFINE_UNQUOTED(HAVE_DEBUG_MESSAGES, 1, [Define this to enable debug messages])
)

dnl ----------------------------------------------------------------
dnl static link
dnl

AC_ARG_ENABLE(static_libc,
	AC_HELP_STRING([--enable-static-libc], [staticly link with libc and libstdc++]),
	AC_MSG_RESULT(yes)
	STATIC_LDADD="-static-libgcc -static-libstdc++",
	AC_MSG_RESULT(no)
	STATIC_LDADD=""
)

AC_SUBST(STATIC_LDADD)

dnl ----------------------------------------------------------------
dnl curses
dnl

HAVE_CURSES=no

AC_ARG_WITH(curses,
        AC_HELP_STRING([--without-curses],
                [do not include curses support]
        )
)

if test "x${with_curses}" != "xno"; then
        save_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $CURSES_CFLAGS"

	AC_CHECK_HEADER(curses.h,
		HAVE_CURSES="maybe",
		HAVE_CURSES="no"
	)

	if test "x${HAVE_CURSES}" = "xmaybe"; then
		AC_CHECK_LIB(ncurses, initscr,
			HAVE_CURSES="ncurses"
			AC_DEFINE(HAVE_CURSES, ncurses, [Define this if you have the curses library])
			CURSES_LIBS="-lncurses",
			HAVE_CURSES="maybe"
		)
	fi

	if test "x${HAVE_CURSES}" = "xmaybe"; then
		AC_CHECK_LIB(pdcurses, initscr,
			HAVE_CURSES="pdcurses"
			AC_DEFINE(HAVE_CURSES, pdcurses, [Define this if you have the curses library])
			CURSES_LIBS="-lpdcurses",
			HAVE_CURSES="maybe"
		)
	fi

	if test "x${HAVE_CURSES}" = "xmaybe"; then
		AC_CHECK_LIB(curses, initscr,
			HAVE_CURSES="curses"
			AC_DEFINE(HAVE_CURSES, curses, [Define this if you have the curses library])
			CURSES_LIBS="-lcurses",
			HAVE_CURSES="maybe"
		)
	fi


	if test "x${HAVE_CURSES}" = "xmaybe"; then
		HAVE_CURSES=no
	fi

	CPPFLAGS="$save_CPPFLAGS"
fi
AC_SUBST(CURSES_CFLAGS)
AC_SUBST(CURSES_LIBS)

dnl ----------------------------------------------------------------
dnl bullet
dnl

HAVE_BULLET=no

AC_ARG_ENABLE(static_bullet,
	AC_HELP_STRING([--enable-static-bullet], [staticly link with bullet physics libraries]),
	AC_MSG_RESULT(yes),
	AC_MSG_RESULT(no)
)

AC_ARG_WITH(bullet,
        AC_HELP_STRING([--with-bullet=PREFIX],
                [link with bullet physics library installed in PREFIX]
        )
)

LDFLAGS_save="$LDFLAGS"
CPPFLAGS_save="$CPPFLAGS"

BULLET_DIR="/usr"
if test "x${with_bullet}" != "x"; then
	BULLET_DIR="${with_bullet}"
fi

CPPFLAGS="-I${BULLET_DIR}/include/bullet"

AC_CHECK_HEADER(btBulletDynamicsCommon.h,
	[],
	AC_MSG_ERROR([bullet physics library not found in ${BULLET_DIR}])
)

AC_MSG_CHECKING([if static linking of the bullet libraries is requested])
if test "x${enable_static_bullet}" = "xyes"; then
	BULLET_CPPFLAGS="-I${BULLET_DIR}/include/bullet"
	BULLET_LIBS="${BULLET_DIR}/lib/libBulletDynamics.a $BULLET_DIR/lib/libBulletCollision.a $BULLET_DIR/lib/libLinearMath.a"
	AC_MSG_RESULT([yes])
else
	BULLET_CPPFLAGS="-I${BULLET_DIR}/include/bullet"
	BULLET_LIBS="-lBulletDynamics -lBulletCollision -lLinearMath"
	AC_MSG_RESULT([no])
fi

CPPFLAGS="$CPPFLAGS_save $BULLET_CPPFLAGS"
LDFLAGS="$LDFLAGS_save $BULLET_LIBS"

CPPFLAGS="$CPPFLAGS_save"
LDFLAGS="$LDFLAGS_save"

AC_SUBST(BULLET_CPPFLAGS)
AC_SUBST(BULLET_LIBS)

dnl ----------------------------------------------------------------
dnl zlib
dnl

LIBS_save="$LIBS"
LDFLAGS_save="$LDFLAGS"

AC_CHECK_HEADER(zlib.h, 
	[],
	AC_MSG_ERROR([zlib.h not found])
)

AC_CHECK_LIB(z, compress,
	[],
	AC_MSG_ERROR([zlib not found])
)

LDFLAGS="$LDFLAGS_save"
LIBS="$LIBS_save"

LIBZ_LIBS="-lz"
AC_SUBST(LIBZ_LIBS)


dnl ----------------------------------------------------------------
dnl build client and server or dedicated server only
dnl
BUILD_CLIENT=no

AC_ARG_WITH(client,
	AC_HELP_STRING([--without-client], [do not build the client application])
)

AC_MSG_CHECKING(whether to build client)

if test "x${with_client}" = xno; then

	AC_MSG_RESULT(no)

else
	AC_MSG_RESULT(yes)

	LDFLAGS_save="$LDFLAGS"

	dnl ---------------------------------------------------------------
	dnl OpenGL
	dnl
	
	if test "x${OS}" = "xOSX"; then
		AC_CHECK_HEADER(OpenGL/gl.h,
			[],
			[AC_MSG_ERROR([OpenGL/gl.h not found])]
		)
		AC_CHECK_HEADER(OpenGL/glu.h,
			[],
			[AC_MSG_ERROR([OpenGL/glu.h not found])]
		)
	else
		AC_CHECK_HEADER(GL/gl.h,
			[],
			[AC_MSG_ERROR([GL/gl.h not found])]
		)
		AC_CHECK_HEADER(GL/glu.h,
			[],
			[AC_MSG_ERROR([GL/glu.h not found])]
		)
	fi
	
	LDFLAGS="$LDFLAGS_save"
	GL_LIBS="$HOST_GL_LIBS"
	AC_SUBST(GL_LIBS)
	AC_SUBST(GL_CFLAGS)

	dnl ---------------------------------------------------------------
	dnl OpenAL
	
	if test "x${OS}" = "xOSX"; then
		AC_CHECK_HEADER(OpenAL/al.h,
			[],
			[AC_MSG_ERROR([OpenAL/al.h not found])]
		)
	else
		AC_CHECK_HEADER(AL/al.h,
			[],
			[AC_MSG_ERROR([AL/al.h not found])]
		)
	fi
	
	LDFLAGS="$LDFLAGS_save"
	AL_LIBS="$HOST_AL_LIBS"
	AC_SUBST(AL_LIBS)
	AC_SUBST(AL_CFLAGS)
	
	dnl ---------------------------------------------------------------
	dnl libpng
	dnl
	
	LIBS_save="$LIBS"
	LIBS="$LIBZ_LIBS"

	AC_CHECK_HEADER(png.h, 
		[],
		[AC_MSG_ERROR([png.h not found])]
	)
	AC_CHECK_LIB(png, png_create_info_struct,
		HAVE_LIBPNG=yes,
		[AC_MSG_ERROR([libpng not found])]
	)
	
	LIBS="$LIBS_save"
	LIBPNG_LIBS="-lpng"
	AC_SUBST(LIBPNG_LIBS)

	dnl ---------------------------------------------------------------
	dnl libjpeg
	dnl
	
	AC_CHECK_HEADER(jpeglib.h,
			[],
			[AC_MSG_ERROR([jpeglib.h not found])]
	)
	AC_CHECK_LIB(jpeg, jpeg_start_decompress,
		HAVE_LIBJPEG=yes
		AC_DEFINE_UNQUOTED(HAVE_LIBJPEG, 1, [Define this if you have libjpeg]),
		AC_MSG_ERROR([libjpeg not found])
	)
	LIBJPG_LIBS="-ljpeg"
	AC_SUBST(LIBJPG_LIBS)

	dnl ---------------------------------------------------------------
	dnl Ogg Vorbis
	dnl

	LIBS_save="$LIBS"
	LIBS="$LIBS -lvorbis -l ogg"

	AC_CHECK_HEADER(vorbis/vorbisfile.h,
			[],
			[AC_MSG_ERROR([vorbis/vorbisfile.h not found])]
	)
	AC_CHECK_HEADER(vorbis/codec.h,
			[],
			[AC_MSG_ERROR([vorbis/codec.h not found])]
	)

	AC_CHECK_LIB(vorbisfile, ov_fopen,
		HAVE_VORBISFILE=yes
		AC_DEFINE_UNQUOTED(HAVE_VORBISFILE, 1, [Define this if you have libvorbisfile]),
		AC_MSG_ERROR([libvorbisfile not found])
	)
	
	LIBS="$LIBS_SAVE"
	LIBVORBISFILE_LIBS="-lvorbisfile -lvorbis -logg"
	AC_SUBST(LIBVORBISFILE_LIBS)

	dnl ---------------------------------------------------------------
	dnl SDL
	dnl

	AC_MSG_CHECKING([looking for SDL])
	KDE_FIND_PATH(sdl-config, LIBSDL_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [
			AC_MSG_ERROR([SDL not found])
	])
		
	if test -n "$LIBSDL_CONFIG"; then
		LIBSDL_LIBS="`$LIBSDL_CONFIG --libs`"
		LIBSDL_RPATH=
		for args in $LIBSDL_LIBS; do
		case $args in
			-L*)
			LIBSDL_RPATH="$LIBSDL_RPATH $args"
			;;
		esac
		done
		
		LIBSDL_RPATH=`echo $LIBSDL_RPATH | sed -e "s/-L/-R/g"`
		LIBSDL_CFLAGS="`$LIBSDL_CONFIG --cflags`"
	fi
		
	AC_MSG_RESULT($HAVE_LIBSDL)
		
	AC_SUBST(LIBSDL_LIBS)
	AC_SUBST(LIBSDL_CFLAGS)
	AC_SUBST(LIBSDL_RPATH)

	BUILD_CLIENT=yes
	AC_DEFINE_UNQUOTED(BUILD_CLIENT, 1, [Define this to build the client])
fi

CXXFLAGS="-pipe $DEBUG_CFLAGS $WARN_CFLAGS $CXXFLAGS"
AC_SUBST(CXXFLAGS)

CPPFLAGS="$CPPFLAGS $BULLET_CPPFLAGS"
AC_SUBST(CPPFLAGS)

dnl ---------------------------------------------------------------
dnl   Installation paths

AC_MSG_CHECKING(installation type)
AC_ARG_ENABLE(single_directory,
        AC_HELP_STRING(
                [--enable-single-directory], [install everything in a single directory]
        ),
        AC_MSG_RESULT(single directory)
	INSTALLTYPE="single directory",
        AC_MSG_RESULT(standard)
	INSTALLTYPE="standard"
)

if test "x${INSTALLTYPE}" = xstandard; then
	test "$prefix" = "NONE" && prefix="/usr/local"
	bindir="$prefix/bin"
	pkgdatadir="$prefix/share/${PACKAGE}"
	docdir="$pkgdatadir/doc"
else
	test "$prefix" = "NONE" && prefix="/opt/games/$PACKAGE"
	bindir="$prefix"
	pkgdatadir="$prefix"
	docdir="$prefix/doc"
fi

PACKAGE_DATADIR="$pkgdatadir/data"

AC_DEFINE(PACKAGE_DATADIR, "$PACKAGE_DATADIR",
	[Define this to the path containing the game data.]
)

dnl ---------------------------------------------------------------
dnl    Write makefiles and config.h

AM_CONDITIONAL(BUILD_CLIENT, test "x$BUILD_CLIENT" = xyes)
AM_CONDITIONAL(BUILD_DEDICATED, test "x$BUILD_CLIENT" = xno)

AC_CONFIG_FILES([ \
	src/auxiliary/Makefile \
	src/math/Makefile \
	src/sys/Makefile \
	src/filesystem/Makefile \
	src/model/Makefile \
	src/core/Makefile \
	src/dedicated/Makefile \
	src/audio/Makefile \
	src/render/Makefile \
	src/ui/Makefile\
	src/client/Makefile \
	src/game/base/Makefile \
	src/game/example/Makefile \
	src/game/intro/Makefile \
	src/game/Makefile \
	src/Makefile \
	Makefile])

AC_OUTPUT

dnl ---------------------------------------------------------------
dnl   Configuration summary

AC_MSG_RESULT([
Project::OSiRiON $VERSION

Configuration summary:

platform ........... $host
flags .............. $CPPFLAGS $CXXFLAGS
libraries .......... $HOST_LIBS $LIBJPG_LIBS $LIBPNG_LIBS $LIBZ_LIBS $CURSES_LIBS $STATIC_LDADD
bullet ............. $BULLET_LIBS
curses ............. $HAVE_CURSES
build client ....... $BUILD_CLIENT])

if test "x$BUILD_CLIENT" = xyes; then
AC_MSG_RESULT([SDL ................ $LIBSDL_LIBS
opengl ............. $GL_LIBS
openal ............. $AL_LIBS]
vorbisfile ......... $LIBVORBISFILE_LIBS)
fi

AC_MSG_RESULT([
Installation directories:

installation type .. $INSTALLTYPE
prefix ............. $prefix
binaries ........... $bindir
documentation ...... $docdir
game data .......... $PACKAGE_DATADIR
])