summary refs log tree commit diff stats
path: root/Makefile
blob: 4face93d7deeadc5acbf66e70dc118f9bde68b8a (plain) (blame)
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
PROJECT = mazeoflife
LTARGET = build/$(PROJECT)
WTARGET = build/$(PROJECT).exe
CC = g++
WINCC = i586-mingw32msvc-g++
WINDRES = i586-mingw32msvc-windres
FILES 	= $(addprefix build/,$(wildcard *.cpp))
MODULES = $(patsubst %.cpp,%,$(FILES))
SOURCES = $(addsuffix .o,$(MODULES))
WINSRC 	= $(addsuffix win,$(SOURCES))
IMAGES = $(wildcard *.bmp)
CIMAGES = $(addprefix build/,$(IMAGES:.bmp=.bmp.o))
LINCCFL = `sdl-config --cflags`
LINLDFL = `sdl-config --libs`
WINCCFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --cflags` -DWINDOWS
WINLDFL = `/opt/SDL-1.2.9/bin/i386-mingw32msvc-sdl-config --libs`

all: init $(LTARGET) $(WTARGET)
linux: init $(LTARGET)
windows: init $(WTARGET)

init:
	mkdir -p build

clean:
	rm -rdfv build

$(LTARGET): $(SOURCES) $(CIMAGES)
	$(CC) $(SOURCES) $(CIMAGES) -o $(LTARGET) $(LINLDFL)

$(SOURCES): build/%.o: %.cpp
	$(CC) -c $? -o $@ $(LINCCFL)

$(WTARGET): $(WINSRC) $(CIMAGES) build/winres.o
	$(WINCC) $(WINSRC) $(CIMAGES) build/winres.o -o $(WTARGET) $(WINLDFL)

$(WINSRC): build/%.owin: %.cpp
	$(WINCC) -c $? -o $@ $(WINCCFL)

build/winres.o: winres.rc
	$(WINDRES) $? $@

$(CIMAGES): build/%.bmp.o: %.bmp
	objcopy --input binary --output elf32-i386 -B i386 $? $@