summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2009-06-22 09:35:52 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2009-06-22 09:35:52 -0400
commitbca5121051383933e5fdf15f6bcb04ddb797ac45 (patch)
tree185673e034fa4602f6d042812ea46156b81272e0
parentd80a5cbd3dc888a17dadf134d0a6031b313b3dc9 (diff)
downloadmazeoflife-bca5121051383933e5fdf15f6bcb04ddb797ac45.tar.gz
mazeoflife-bca5121051383933e5fdf15f6bcb04ddb797ac45.tar.bz2
mazeoflife-bca5121051383933e5fdf15f6bcb04ddb797ac45.zip
Added cross compiliation
-rw-r--r--.hgignore1
-rw-r--r--Makefile53
-rw-r--r--htpstate.cpp11
-rw-r--r--resources.h25
-rw-r--r--titlestate.cpp7
5 files changed, 50 insertions, 47 deletions
diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.hgignore
@@ -0,0 +1 @@
build
diff --git a/Makefile b/Makefile index a4fe8ff..e7429a5 100644 --- a/Makefile +++ b/Makefile
@@ -1,27 +1,40 @@
1SOURCES = mazeoflife.cpp titlestate.cpp htpstate.cpp gamestate.cpp 1PROJECT = mazeoflife
2OBJS = $(SOURCES:.cpp=.cpp.o) 2LTARGET = build/$(PROJECT)
3IMAGES = title.bmp pointer.bmp htp1.bmp htp2.bmp 3WTARGET = build/$(PROJECT).exe
4CIMAGES = $(IMAGES:.bmp=.bmp.o)
5CC = g++ 4CC = g++
6CFLAGS = `pkg-config sdl --cflags` 5WINCC = i586-mingw32msvc-g++
7LIBS = `pkg-config sdl --libs` 6FILES = $(addprefix build/,$(wildcard *.cpp))
7MODULES = $(patsubst %.cpp,%,$(FILES))
8SOURCES = $(addsuffix .o,$(MODULES))
9WINSRC = $(addsuffix win,$(SOURCES))
10IMAGES = $(wildcard *.bmp)
11CIMAGES = $(addprefix build/,$(IMAGES:.bmp=.bmp.o))
12LINCCFL = `sdl-config --cflags`
13LINLDFL = `sdl-config --libs`
14WINCCFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --cflags` -DWINDOWS
15WINLDFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --libs`
8 16
9mazeoflife: $(OBJS) $(CIMAGES) 17all: init $(LTARGET) $(WTARGET)
10 $(CC) $(OBJS) $(CIMAGES) $(LIBS) -o mazeoflife 18linux: init $(LTARGET)
19windows: init $(WTARGET)
11 20
12%.cpp.o: %.cpp 21init:
13 $(CC) -c $< $(CFLAGS) -o $@ 22 mkdir -p build
14 23
15%.d: %.cpp 24clean:
16 @set -e; rm -f $@; \ 25 rm -rdfv build
17 $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
18 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
19 rm -f $@.$$$$
20 26
21%.bmp.o: %.bmp 27$(LTARGET): $(SOURCES) $(CIMAGES)
22 objcopy --input binary --output elf32-i386 -B i386 $< $@ 28 $(CC) $(SOURCES) $(CIMAGES) -o $(LTARGET) $(LINLDFL)
23 29
24include $(OBJS:.cpp.o=.d) 30$(SOURCES): build/%.o: %.cpp
31 $(CC) -c $? -o $@ $(LINCCFL)
25 32
26clean: 33$(WTARGET): $(WINSRC) $(CIMAGES)
27 rm -rdfv $(OBJS) $(OBJS:.cpp.o=.d) $(CIMAGES) mazeoflife 34 $(WINCC) $(WINSRC) $(CIMAGES) -o $(WTARGET) $(WINLDFL)
35
36$(WINSRC): build/%.owin: %.cpp
37 $(WINCC) -c $? -o $@ $(WINCCFL)
38
39$(CIMAGES): build/%.bmp.o: %.bmp
40 objcopy --input binary --output elf32-i386 -B i386 $? $@
diff --git a/htpstate.cpp b/htpstate.cpp index 30d58a2..8de884f 100644 --- a/htpstate.cpp +++ b/htpstate.cpp
@@ -2,14 +2,9 @@
2 2
3HowToPlayState::HowToPlayState() 3HowToPlayState::HowToPlayState()
4{ 4{
5 SDL_RWops *rw = SDL_RWFromMem(&_binary_htp1_bmp_start, (int) &_binary_htp1_bmp_size); 5 LOADIMAGE(background1,htp1)
6 background1 = SDL_LoadBMP_RW(rw, 1); 6 LOADIMAGE(background2,htp2)
7 7 LOADIMAGE(pointer,pointer)
8 rw = SDL_RWFromMem(&_binary_htp2_bmp_start, (int) &_binary_htp2_bmp_size);
9 background2 = SDL_LoadBMP_RW(rw, 1);
10
11 rw = SDL_RWFromMem(&_binary_pointer_bmp_start, (int) &_binary_pointer_bmp_size);
12 pointer = SDL_LoadBMP_RW(rw, 1);
13 8
14 secondPage = false; 9 secondPage = false;
15 selection = 0; 10 selection = 0;
diff --git a/resources.h b/resources.h index 4e01a90..457fbec 100644 --- a/resources.h +++ b/resources.h
@@ -1,20 +1,17 @@
1#ifndef RESOURCES_H 1#ifndef RESOURCES_H
2#define RESOURCES_H 2#define RESOURCES_H
3 3
4// title.bmp 4#ifdef WINDOWS
5extern int* _binary_title_bmp_start; 5#define LOADIMAGE(var,title) SDL_RWops * title ## _rw = SDL_RWFromMem(&binary_ ## title ## _bmp_start, (int) &binary_ ## title ## _bmp_size); var = SDL_LoadBMP_RW( title ## _rw, 1);
6extern int* _binary_title_bmp_size; 6#define DEFIMAGE(title) extern int* binary_ ## title ## _bmp_start; extern int* binary_ ## title ## _bmp_size;
7 7#else
8// pointer.bmp 8#define LOADIMAGE(var,title) SDL_RWops * title ## _rw = SDL_RWFromMem(&_binary_ ## title ## _bmp_start, (int) &_binary_ ## title ## _bmp_size); var = SDL_LoadBMP_RW( title ## _rw, 1);
9extern int* _binary_pointer_bmp_start; 9#define DEFIMAGE(title) extern int* _binary_ ## title ## _bmp_start; extern int* _binary_ ## title ## _bmp_size;
10extern int* _binary_pointer_bmp_size; 10#endif
11
12// htp1.bmp
13extern int* _binary_htp1_bmp_start;
14extern int* _binary_htp1_bmp_size;
15 11
16// htp2.bmp 12DEFIMAGE(title)
17extern int* _binary_htp2_bmp_start; 13DEFIMAGE(pointer)
18extern int* _binary_htp2_bmp_size; 14DEFIMAGE(htp1)
15DEFIMAGE(htp2)
19 16
20#endif 17#endif
diff --git a/titlestate.cpp b/titlestate.cpp index c011480..6c4401d 100644 --- a/titlestate.cpp +++ b/titlestate.cpp
@@ -2,11 +2,8 @@
2 2
3TitleState::TitleState() 3TitleState::TitleState()
4{ 4{
5 SDL_RWops *rw = SDL_RWFromMem(&_binary_title_bmp_start, (int) &_binary_title_bmp_size); 5 LOADIMAGE(background,title)
6 background = SDL_LoadBMP_RW(rw, 1); 6 LOADIMAGE(pointer,pointer)
7
8 rw = SDL_RWFromMem(&_binary_pointer_bmp_start, (int) &_binary_pointer_bmp_size);
9 pointer = SDL_LoadBMP_RW(rw, 1);
10 7
11 selection = 0; 8 selection = 0;
12 9