aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-09-23 21:11:29 +1000
committerquou <quou@disroot.org>2024-09-23 21:11:29 +1000
commit259237fae792e8f19d9b7920b2354f75bc1789e2 (patch)
treeaf079430f30f7df1b76efc4f96f520b0b6eee0af /Makefile
initial commit, basic platform and rendering code.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile64
1 files changed, 64 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..bf15054
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,64 @@
+compiler = gcc
+tool_compiler = gcc
+linker = gcc
+cflags = -I./ -g -DDEBUG -Dplat_x11 -Dplat_x86 \
+-Dplat_posix -Dallocation_default_alignment=8 \
+-Wall -Wextra -pedantic -std=c90
+lflags = -lX11 -lXi
+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)