diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/Makefile b/Makefile index a4fe8ff..e7429a5 100644 --- a/Makefile +++ b/Makefile | |||
@@ -1,27 +1,40 @@ | |||
1 | SOURCES = mazeoflife.cpp titlestate.cpp htpstate.cpp gamestate.cpp | 1 | PROJECT = mazeoflife |
2 | OBJS = $(SOURCES:.cpp=.cpp.o) | 2 | LTARGET = build/$(PROJECT) |
3 | IMAGES = title.bmp pointer.bmp htp1.bmp htp2.bmp | 3 | WTARGET = build/$(PROJECT).exe |
4 | CIMAGES = $(IMAGES:.bmp=.bmp.o) | ||
5 | CC = g++ | 4 | CC = g++ |
6 | CFLAGS = `pkg-config sdl --cflags` | 5 | WINCC = i586-mingw32msvc-g++ |
7 | LIBS = `pkg-config sdl --libs` | 6 | FILES = $(addprefix build/,$(wildcard *.cpp)) |
7 | MODULES = $(patsubst %.cpp,%,$(FILES)) | ||
8 | SOURCES = $(addsuffix .o,$(MODULES)) | ||
9 | WINSRC = $(addsuffix win,$(SOURCES)) | ||
10 | IMAGES = $(wildcard *.bmp) | ||
11 | CIMAGES = $(addprefix build/,$(IMAGES:.bmp=.bmp.o)) | ||
12 | LINCCFL = `sdl-config --cflags` | ||
13 | LINLDFL = `sdl-config --libs` | ||
14 | WINCCFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --cflags` -DWINDOWS | ||
15 | WINLDFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --libs` | ||
8 | 16 | ||
9 | mazeoflife: $(OBJS) $(CIMAGES) | 17 | all: init $(LTARGET) $(WTARGET) |
10 | $(CC) $(OBJS) $(CIMAGES) $(LIBS) -o mazeoflife | 18 | linux: init $(LTARGET) |
19 | windows: init $(WTARGET) | ||
11 | 20 | ||
12 | %.cpp.o: %.cpp | 21 | init: |
13 | $(CC) -c $< $(CFLAGS) -o $@ | 22 | mkdir -p build |
14 | 23 | ||
15 | %.d: %.cpp | 24 | clean: |
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 | ||
24 | include $(OBJS:.cpp.o=.d) | 30 | $(SOURCES): build/%.o: %.cpp |
31 | $(CC) -c $? -o $@ $(LINCCFL) | ||
25 | 32 | ||
26 | clean: | 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 $? $@ | ||