File: gengameng.m4

package info (click to toggle)
gengameng 4.1-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,468 kB
  • ctags: 177
  • sloc: sh: 8,342; cpp: 935; makefile: 110
file content (106 lines) | stat: -rw-r--r-- 2,680 bytes parent folder | download | duplicates (2)
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
dnl AM_PATH_GENGAMENG(MIN-VERSION)
dnl
dnl Tests for gengameng, and defines GENGAMENG_PREFIX, GENGAMENG_CFLAGS
dnl and GENGAMENG_LIBS, as well as GENGAMENG_CONFIG, which is the full name
dnl of the gengameng-config script.
dnl All of these variables are submitted to AC_SUBST().
dnl Also tries to link a test program with gengameng.
dnl Calls AC_MSG_ERROR() on failure.
dnl Offers the option --with-gengameng-config=X.  Default is to search $PATH.
dnl
dnl Receives minimal version number to require as the argument.
dnl Example: AM_PATH_GENGAMENG(4.0)
dnl

AC_DEFUN([AM_PATH_GENGAMENG],
[
	MIN_GENGAMENG_VERSION="$1"

	AC_MSG_CHECKING(for gengameng - version >= $MIN_GENGAMENG_VERSION)

	AC_ARG_WITH(gengameng-config,
[  --with-gengameng-config=X    Full pathname of gengameng-config script
                               (Default is to search $PATH)],
	[
		GENGAMENG_CONFIG="$withval"
	],
	[
		GENGAMENG_CONFIG=`which gengameng-config` ||
		{ AC_MSG_ERROR([Could not find gengameng-config in path]); }
			# the semi-colon is necessary
	])


	GENGAMENG_VERSION=`$GENGAMENG_CONFIG --version`
	actual=`echo $GENGAMENG_VERSION | awk -F. '{ printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
	minver=`echo "$MIN_GENGAMENG_VERSION" | awk -F. '{ printf "%d", ([$]1 * 1000 + [$]2) * 1000 + [$]3;}'`
	if test "$actual" -ge "$minver"; then
		AC_MSG_RESULT([found $GENGAMENG_VERSION])
	else
		AC_MSG_ERROR([gengameng >= $MIN_GENGAMENG_VERSION is required; found $GENGAMENG_VERSION])
	fi

	unset minver
	unset actual
	unset GENGAMENG_VERSION

	GENGAMENG_PREFIX=`$GENGAMENG_CONFIG --prefix`
	GENGAMENG_CFLAGS=`$GENGAMENG_CONFIG --cflags`
	GENGAMENG_LIBS=`$GENGAMENG_CONFIG --libs`

	AC_SUBST(GENGAMENG_CONFIG)
	AC_SUBST(GENGAMENG_PREFIX)
	AC_SUBST(GENGAMENG_CFLAGS)
	AC_SUBST(GENGAMENG_LIBS)


	# Try to link with gengameng:
	old_CFLAGS="$CXXFLAGS"
	CXXFLAGS="$GENGAMENG_CFLAGS"
	old_LIBS="$LIBS"
	LIBS="$GENGAMENG_LIBS"

	AC_TRY_LINK(
	[
		#include <gengameng/GameEngine.h>
	],
	[
		class TestEngine : GameEngine
		{
		public:
		    TestEngine() throw(string)
		    : GameEngine(Couple(1, 1), "", false) {}

		    virtual void processKey(SDLKey keysym, bool pressed) {}
		    virtual bool tick() { return false; }
		};

		try
		{
		    TestEngine theTestEngine;
		}
		catch (const string &s)
		{
		    fprintf(stderr, "Engine init error: %s\n", s.c_str());
		    return 1;
		}
		catch (int e)
		{
		    fprintf(stderr, "init error # %d\n", e);
		    return 1;
		}
		return 0;
	],
	[
		true
	],
	[
		AC_MSG_ERROR([could not link with gengameng.
You can get it on the BurgerSpace Home Page on the Web.])
	])

	CXXFLAGS="$old_CXXFLAGS"
	unset old_CXXFLAGS
	LIBS="$old_LIBS"
	unset old_LIBS
])