aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: bc07003ea5d728b9098955daa2cf695b40c87977 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
compiler = gcc
tool_compiler = gcc
linker = gcc
cflags = -I./ -g -DDEBUG -Dplat_x11 -Dplat_x86 \
-Dplat_posix -Dallocation_default_alignment=8 \
-Dplat_pulse \
-Wall -Wextra -pedantic -std=c90
lflags = -lX11 -lXi -lpulse -lpulse-simple -lpthread -lm
target = 1bitjam
int_dir = intermediate
data_dir = data
convimg = convimg
packassets = packassets
pack = pack.h

sources = \
	1bitjam.c \
	asset.c \
	maths.c \
	memory.c \
	plat.c \
	rect.c \
	render.c \

image_sources = \
	$(int_dir)/guy.bmp \
	$(int_dir)/hello.bmp

objects = $(sources:%.c=%.o)
images    = $(image_sources:$(int_dir)/%.bmp=$(data_dir)/%.img)

all: $(target) $(pack)

$(objects): %.o : %.c | $(pack)
	$(compiler) -MMD -MF $(basename $@).d $(cflags) -o $@ -c $<

$(images): $(data_dir)/%.img : $(int_dir)/%.bmp | $(convimg) $(data_dir)
	./$(convimg) $< $@

$(pack): $(packassets) $(images)
	./$(packassets) \
		$(pack) \
		$(data_dir) \
		$(notdir $(images))

$(convimg): convimg.c
	$(tool_compiler) convimg.c $(cflags) -o $@

$(packassets): packassets.c
	$(tool_compiler) packassets.c $(cflags) -o $@

$(target): $(objects)
	$(linker) $(objects) -o $@ $(lflags)

$(data_dir):
	mkdir -p $(data_dir)

clean:
	rm *.d
	rm *.o
	rm $(pack)
	rm -r $(data_dir)
	rm $(target)

-include $(sources:%.c=%.d)