summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2013-08-25 17:07:35 -0400
committerStarla Insigna <starla4444@gmail.com>2013-08-25 17:07:35 -0400
commitd47da18958b5214def5127e201f60668c566d9bb (patch)
tree00751c11ff7d44c9e8bd56e0f4c670bb337095aa
parent387685d34e6c4ebee776a700a01fed4df05446be (diff)
downloadmazeoflife-d47da18958b5214def5127e201f60668c566d9bb.tar.gz
mazeoflife-d47da18958b5214def5127e201f60668c566d9bb.tar.bz2
mazeoflife-d47da18958b5214def5127e201f60668c566d9bb.zip
Moved to an autoconf-based build system
-rw-r--r--.hgignore13
-rw-r--r--Makefile45
-rw-r--r--Makefile.am7
-rw-r--r--acinclude.m4185
-rw-r--r--chlstate.cpp4
-rw-r--r--configure.ac44
-rw-r--r--hsglobal.cpp4
-rw-r--r--hslocal.cpp6
-rw-r--r--hsnew.cpp4
-rw-r--r--hssubmit.cpp6
-rw-r--r--htpstate.cpp6
-rw-r--r--includes.h4
-rw-r--r--mazeoflife.cpp4
-rw-r--r--titlestate.cpp4
14 files changed, 269 insertions, 67 deletions
diff --git a/.hgignore b/.hgignore index d76b74e..85018a3 100644 --- a/.hgignore +++ b/.hgignore
@@ -1,2 +1,13 @@
1build
2.DS_Store 1.DS_Store
2(.*)\.o
3Makefile.in
4aclocal.m4
5autom4te.cache
6configure
7.deps
8config.log
9config.status
10missing
11install-sh
12depcomp
13mazeoflife
diff --git a/Makefile b/Makefile deleted file mode 100644 index 8a9d3b5..0000000 --- a/Makefile +++ /dev/null
@@ -1,45 +0,0 @@
1PROJECT = mazeoflife
2LTARGET = build/$(PROJECT)
3WTARGET = build/$(PROJECT).exe
4CC = g++
5WINCC = i586-mingw32msvc-g++
6WINDRES = i586-mingw32msvc-windres
7FILES = $(addprefix build/,$(wildcard *.cpp))
8HEADERS = $(wildcard *.h)
9MODULES = $(patsubst %.cpp,%,$(FILES))
10SOURCES = $(addsuffix .o,$(MODULES))
11WINSRC = $(addsuffix win,$(SOURCES))
12RES = $(wildcard resources/*)
13CRES = $(patsubst resources/%,build/%,$(RES))
14LINCCFL = `sdl-config --cflags` -I/usr/local/Cellar/sdl_net/1.2.8/include/SDL/ -I/usr/local/Cellar/sdl_ttf/2.0.11/include/SDL/
15LINLDFL = `sdl-config --libs` -lSDL_ttf -lSDL_net
16WINCCFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --cflags` -DWINDOWS
17WINLDFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --libs` -lSDL_ttf -lSDL_net
18
19all: init $(LTARGET) $(WTARGET)
20linux: init $(LTARGET)
21windows: init $(WTARGET)
22
23init:
24 mkdir -p build
25
26clean:
27 rm -rdfv build
28
29$(LTARGET): $(SOURCES) $(CRES)
30 $(CC) $(SOURCES) -o $(LTARGET) $(LINLDFL)
31
32$(SOURCES): build/%.o: %.cpp $(HEADERS)
33 $(CC) -c $< -o $@ $(LINCCFL)
34
35$(WTARGET): $(WINSRC) $(CRES) build/winres.o
36 $(WINCC) $(WINSRC) build/winres.o -o $(WTARGET) $(WINLDFL)
37
38$(WINSRC): build/%.owin: %.cpp $(HEADERS)
39 $(WINCC) -c $< -o $@ $(WINCCFL)
40
41build/winres.o: winres.rc
42 $(WINDRES) $? $@
43
44$(CRES): build/%: resources/%
45 cp $? $@
diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..f1b00a1 --- /dev/null +++ b/Makefile.am
@@ -0,0 +1,7 @@
1AUTOMAKE_OPTIONS = subdir-objects
2ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
3
4bin_PROGRAMS = mazeoflife
5mazeoflife_SOURCES = chlstate.cpp gamestate.cpp highscore.cpp hsglobal.cpp hslist.cpp hslocal.cpp hsnew.cpp hssubmit.cpp htpstate.cpp mazeoflife.cpp titlestate.cpp
6AM_CXXFLAGS = $(SDLTTF_CXXFLAGS) $(SDLNET_CXXFLAGS)
7mazeoflife_LDADD = $(SDLTTF_LIBS) $(SDLNET_LIBS)
diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..0d44c45 --- /dev/null +++ b/acinclude.m4
@@ -0,0 +1,185 @@
1# Configure paths for SDL
2# Sam Lantinga 9/21/99
3# stolen from Manish Singh
4# stolen back from Frank Belew
5# stolen from Manish Singh
6# Shamelessly stolen from Owen Taylor
7
8# serial 1
9
10dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
11dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
12dnl
13AC_DEFUN([AM_PATH_SDL],
14[dnl
15dnl Get the cflags and libraries from the sdl-config script
16dnl
17AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
18 sdl_prefix="$withval", sdl_prefix="")
19AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
20 sdl_exec_prefix="$withval", sdl_exec_prefix="")
21AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
22 , enable_sdltest=yes)
23
24 if test x$sdl_exec_prefix != x ; then
25 sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
26 if test x${SDL_CONFIG+set} != xset ; then
27 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
28 fi
29 fi
30 if test x$sdl_prefix != x ; then
31 sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
32 if test x${SDL_CONFIG+set} != xset ; then
33 SDL_CONFIG=$sdl_prefix/bin/sdl-config
34 fi
35 fi
36
37 as_save_PATH="$PATH"
38 if test "x$prefix" != xNONE; then
39 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
40 fi
41 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
42 PATH="$as_save_PATH"
43 min_sdl_version=ifelse([$1], ,0.11.0,$1)
44 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
45 no_sdl=""
46 if test "$SDL_CONFIG" = "no" ; then
47 no_sdl=yes
48 else
49 SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
50 SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
51
52 sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
53 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
54 sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
55 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
56 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
57 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
58 if test "x$enable_sdltest" = "xyes" ; then
59 ac_save_CFLAGS="$CFLAGS"
60 ac_save_CXXFLAGS="$CXXFLAGS"
61 ac_save_LIBS="$LIBS"
62 CFLAGS="$CFLAGS $SDL_CFLAGS"
63 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
64 LIBS="$LIBS $SDL_LIBS"
65dnl
66dnl Now check if the installed SDL is sufficiently new. (Also sanity
67dnl checks the results of sdl-config to some extent
68dnl
69 rm -f conf.sdltest
70 AC_TRY_RUN([
71#include <stdio.h>
72#include <stdlib.h>
73#include <string.h>
74#include "SDL.h"
75
76char*
77my_strdup (char *str)
78{
79 char *new_str;
80
81 if (str)
82 {
83 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
84 strcpy (new_str, str);
85 }
86 else
87 new_str = NULL;
88
89 return new_str;
90}
91
92int main (int argc, char *argv[])
93{
94 int major, minor, micro;
95 char *tmp_version;
96
97 /* This hangs on some systems (?)
98 system ("touch conf.sdltest");
99 */
100 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
101
102 /* HP/UX 9 (%@#!) writes to sscanf strings */
103 tmp_version = my_strdup("$min_sdl_version");
104 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
105 printf("%s, bad version string\n", "$min_sdl_version");
106 exit(1);
107 }
108
109 if (($sdl_major_version > major) ||
110 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
111 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
112 {
113 return 0;
114 }
115 else
116 {
117 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
118 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
119 printf("*** best to upgrade to the required version.\n");
120 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
121 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
122 printf("*** config.cache before re-running configure\n");
123 return 1;
124 }
125}
126
127],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
128 CFLAGS="$ac_save_CFLAGS"
129 CXXFLAGS="$ac_save_CXXFLAGS"
130 LIBS="$ac_save_LIBS"
131 fi
132 fi
133 if test "x$no_sdl" = x ; then
134 AC_MSG_RESULT(yes)
135 ifelse([$2], , :, [$2])
136 else
137 AC_MSG_RESULT(no)
138 if test "$SDL_CONFIG" = "no" ; then
139 echo "*** The sdl-config script installed by SDL could not be found"
140 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
141 echo "*** your path, or set the SDL_CONFIG environment variable to the"
142 echo "*** full path to sdl-config."
143 else
144 if test -f conf.sdltest ; then
145 :
146 else
147 echo "*** Could not run SDL test program, checking why..."
148 CFLAGS="$CFLAGS $SDL_CFLAGS"
149 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
150 LIBS="$LIBS $SDL_LIBS"
151 AC_TRY_LINK([
152#include <stdio.h>
153#include "SDL.h"
154
155int main(int argc, char *argv[])
156{ return 0; }
157#undef main
158#define main K_and_R_C_main
159], [ return 0; ],
160 [ echo "*** The test program compiled, but did not run. This usually means"
161 echo "*** that the run-time linker is not finding SDL or finding the wrong"
162 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
163 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
164 echo "*** to the installed location Also, make sure you have run ldconfig if that"
165 echo "*** is required on your system"
166 echo "***"
167 echo "*** If you have an old version installed, it is best to remove it, although"
168 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
169 [ echo "*** The test program failed to compile or link. See the file config.log for the"
170 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
171 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
172 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
173 CFLAGS="$ac_save_CFLAGS"
174 CXXFLAGS="$ac_save_CXXFLAGS"
175 LIBS="$ac_save_LIBS"
176 fi
177 fi
178 SDL_CFLAGS=""
179 SDL_LIBS=""
180 ifelse([$3], , :, [$3])
181 fi
182 AC_SUBST(SDL_CFLAGS)
183 AC_SUBST(SDL_LIBS)
184 rm -f conf.sdltest
185]) \ No newline at end of file
diff --git a/chlstate.cpp b/chlstate.cpp index 48bf8c2..5c9f488 100644 --- a/chlstate.cpp +++ b/chlstate.cpp
@@ -2,8 +2,8 @@
2 2
3ChooseHighscoreListState::ChooseHighscoreListState() 3ChooseHighscoreListState::ChooseHighscoreListState()
4{ 4{
5 background = SDL_LoadBMP("chl.bmp"); 5 background = SDL_LoadBMP("resources/chl.bmp");
6 pointer = SDL_LoadBMP("pointer.bmp"); 6 pointer = SDL_LoadBMP("resources/pointer.bmp");
7 7
8 selection = 0; 8 selection = 0;
9} 9}
diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..f311aa6 --- /dev/null +++ b/configure.ac
@@ -0,0 +1,44 @@
1AC_INIT(mazeoflife, version-2.0)
2AC_PREREQ([2.59])
3AM_INIT_AUTOMAKE([1.10 no-define foreign])
4AC_PROG_CXX
5AC_CONFIG_FILES([Makefile])
6
7dnl Check for SDL
8SDL_VERSION=1.2.0
9AM_PATH_SDL($SDL_VERSION,
10 :,
11 AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
12)
13CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
14LIBS="$LIBS $SDL_LIBS"
15
16dnl Check for SDL_ttf
17AC_ARG_WITH([sdl-ttf-include-path],
18 [AS_HELP_STRING([--with-sdl-ttf-include-path],
19 [location of the SDL_ttf headers, defaults to /usr/include/SDL])],
20 [SDLTTF_CXXFLAGS="-I$withval"],
21 [SDLTTF_CXXFLAGS="-I/usr/include/SDL"])
22AC_SUBST([SDLTTF_CXXFLAGS])
23
24AC_ARG_WITH([sdl-ttf-lib-path],
25 [AS_HELP_STRING([--with-sdl-ttf-lib-path], [location of the SDL_ttf library])],
26 [SDLTTF_LIBS="-L$withval -lsdl_ttf"],
27 [SDLTTF_LIBS="-lsdl_ttf"])
28AC_SUBST([SDLTTF_LIBS])
29
30dnl Check for SDL_net
31AC_ARG_WITH([sdl-net-include-path],
32 [AS_HELP_STRING([--with-sdl-net-include-path],
33 [location of the SDL_net headers, defaults to /usr/include/SDL])],
34 [SDLNET_CXXFLAGS="-I$withval"],
35 [SDLNET_CXXFLAGS="-I/usr/include/SDL"])
36AC_SUBST([SDLNET_CXXFLAGS])
37
38AC_ARG_WITH([sdl-net-lib-path],
39 [AS_HELP_STRING([--with-sdl-net-lib-path], [location of the SDL_net library])],
40 [SDLNET_LIBS="-L$withval -lsdl_net"],
41 [SDLNET_LIBS="-lsdl_net"])
42AC_SUBST([SDLNET_LIBS])
43
44AC_OUTPUT \ No newline at end of file
diff --git a/hsglobal.cpp b/hsglobal.cpp index c21d314..3076403 100644 --- a/hsglobal.cpp +++ b/hsglobal.cpp
@@ -2,8 +2,8 @@
2 2
3GlobalHighscoreListState::GlobalHighscoreListState() 3GlobalHighscoreListState::GlobalHighscoreListState()
4{ 4{
5 options = SDL_LoadBMP("hlo_rtm.bmp"); 5 options = SDL_LoadBMP("resources/hlo_rtm.bmp");
6 pointer = SDL_LoadBMP("pointer.bmp"); 6 pointer = SDL_LoadBMP("resources/pointer.bmp");
7 7
8 list = SDL_CreateRGBSurface(SDL_SWSURFACE || SDL_SRCCOLORKEY, 480, 480, 32, 0,0,0,0); 8 list = SDL_CreateRGBSurface(SDL_SWSURFACE || SDL_SRCCOLORKEY, 480, 480, 32, 0,0,0,0);
9 Uint32 bgColor = SDL_MapRGB(list->format, 255, 255, 255); 9 Uint32 bgColor = SDL_MapRGB(list->format, 255, 255, 255);
diff --git a/hslocal.cpp b/hslocal.cpp index b33a094..eec87e2 100644 --- a/hslocal.cpp +++ b/hslocal.cpp
@@ -6,12 +6,12 @@ LocalHighscoreListState::LocalHighscoreListState(bool fromGame)
6 6
7 if (fromGame) 7 if (fromGame)
8 { 8 {
9 options = SDL_LoadBMP("hlo_paartm.bmp"); 9 options = SDL_LoadBMP("resources/hlo_paartm.bmp");
10 } else { 10 } else {
11 options = SDL_LoadBMP("hlo_rtm.bmp"); 11 options = SDL_LoadBMP("resources/hlo_rtm.bmp");
12 } 12 }
13 13
14 pointer = SDL_LoadBMP("pointer.bmp"); 14 pointer = SDL_LoadBMP("resources/pointer.bmp");
15 15
16 LocalHighscoreList* lhl = new LocalHighscoreList(); 16 LocalHighscoreList* lhl = new LocalHighscoreList();
17 list = lhl->render(); 17 list = lhl->render();
diff --git a/hsnew.cpp b/hsnew.cpp index 2f3e0a2..b4894c2 100644 --- a/hsnew.cpp +++ b/hsnew.cpp
@@ -4,8 +4,8 @@ NewHighscoreState::NewHighscoreState(int level)
4{ 4{
5 this->level = level; 5 this->level = level;
6 6
7 options = SDL_LoadBMP("hlo_passartm.bmp"); 7 options = SDL_LoadBMP("resources/hlo_passartm.bmp");
8 pointer = SDL_LoadBMP("pointer.bmp"); 8 pointer = SDL_LoadBMP("resources/pointer.bmp");
9 9
10 lhl = new NewHighscoreList(level); 10 lhl = new NewHighscoreList(level);
11 newpos = lhl->getNewPos(); 11 newpos = lhl->getNewPos();
diff --git a/hssubmit.cpp b/hssubmit.cpp index 7d4c551..eaacb88 100644 --- a/hssubmit.cpp +++ b/hssubmit.cpp
@@ -2,7 +2,7 @@
2 2
3SubmitHighscoreListState::SubmitHighscoreListState(char* hsname, int level) 3SubmitHighscoreListState::SubmitHighscoreListState(char* hsname, int level)
4{ 4{
5 pointer = SDL_LoadBMP("pointer.bmp"); 5 pointer = SDL_LoadBMP("resources/pointer.bmp");
6 6
7 this->hsname = hsname; 7 this->hsname = hsname;
8 this->level = level; 8 this->level = level;
@@ -38,9 +38,9 @@ int SubmitHighscoreListState::LoadHighscoreList(void* pParam)
38 38
39 if (lhl->hasFailed()) 39 if (lhl->hasFailed())
40 { 40 {
41 ((SubmitHighscoreListState*)pParam)->options = SDL_LoadBMP("hlo_passartm.bmp"); 41 ((SubmitHighscoreListState*)pParam)->options = SDL_LoadBMP("resources/hlo_passartm.bmp");
42 } else { 42 } else {
43 ((SubmitHighscoreListState*)pParam)->options = SDL_LoadBMP("hlo_paartm.bmp"); 43 ((SubmitHighscoreListState*)pParam)->options = SDL_LoadBMP("resources/hlo_paartm.bmp");
44 } 44 }
45 45
46 SDL_Rect oSpace = {0, 440, ((SubmitHighscoreListState*)pParam)->options->w, ((SubmitHighscoreListState*)pParam)->options->h}; 46 SDL_Rect oSpace = {0, 440, ((SubmitHighscoreListState*)pParam)->options->w, ((SubmitHighscoreListState*)pParam)->options->h};
diff --git a/htpstate.cpp b/htpstate.cpp index fbf6b71..0771290 100644 --- a/htpstate.cpp +++ b/htpstate.cpp
@@ -2,9 +2,9 @@
2 2
3HowToPlayState::HowToPlayState() 3HowToPlayState::HowToPlayState()
4{ 4{
5 background1 = SDL_LoadBMP("htp1.bmp"); 5 background1 = SDL_LoadBMP("resources/htp1.bmp");
6 background2 = SDL_LoadBMP("htp2.bmp"); 6 background2 = SDL_LoadBMP("resources/htp2.bmp");
7 pointer = SDL_LoadBMP("pointer.bmp"); 7 pointer = SDL_LoadBMP("resources/pointer.bmp");
8 8
9 secondPage = false; 9 secondPage = false;
10 selection = 0; 10 selection = 0;
diff --git a/includes.h b/includes.h index 6023709..38523b7 100644 --- a/includes.h +++ b/includes.h
@@ -1,6 +1,6 @@
1#include <SDL.h> 1#include <SDL.h>
2#include <SDL_ttf.h> 2#include <SDL/SDL_ttf.h>
3#include <SDL_net.h> 3#include <SDL/SDL_net.h>
4#include <SDL_thread.h> 4#include <SDL_thread.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <time.h> 6#include <time.h>
diff --git a/mazeoflife.cpp b/mazeoflife.cpp index 9033526..107a640 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
33 SDL_WM_SetCaption("Maze Of Life", NULL); 33 SDL_WM_SetCaption("Maze Of Life", NULL);
34 34
35 SDL_Surface* icon; 35 SDL_Surface* icon;
36 icon = SDL_LoadBMP("icon.bmp"); 36 icon = SDL_LoadBMP("resources/icon.bmp");
37 SDL_WM_SetIcon(icon, NULL); 37 SDL_WM_SetIcon(icon, NULL);
38 38
39 /* 39 /*
@@ -118,7 +118,7 @@ Uint32 tick(Uint32 interval, void *param)
118 118
119TTF_Font* loadFont(int size) 119TTF_Font* loadFont(int size)
120{ 120{
121 TTF_Font* tmpfont = TTF_OpenFont("mono.ttf", size); 121 TTF_Font* tmpfont = TTF_OpenFont("resources/mono.ttf", size);
122 122
123 if (tmpfont == NULL) 123 if (tmpfont == NULL)
124 { 124 {
diff --git a/titlestate.cpp b/titlestate.cpp index 95023e5..5a9b91e 100644 --- a/titlestate.cpp +++ b/titlestate.cpp
@@ -2,8 +2,8 @@
2 2
3TitleState::TitleState() 3TitleState::TitleState()
4{ 4{
5 background = SDL_LoadBMP("title.bmp"); 5 background = SDL_LoadBMP("resources/title.bmp");
6 pointer = SDL_LoadBMP("pointer.bmp"); 6 pointer = SDL_LoadBMP("resources/pointer.bmp");
7 7
8 selection = 0; 8 selection = 0;
9} 9}