summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile42
1 files changed, 40 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 8b774cd..55499da 100644
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,37 @@
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
+int_dir = intermediate
+data_dir = data
target = 3de
+convmesh = convmesh
+packassets = packassets
+pack = pack
sources = \
3de.c \
+ asset.c \
maths.c \
memory.c \
plat.c \
rect.c \
- render.c
+ render.c \
+ standard.c
objects = $(sources:%.c=%.o)
-all: $(target)
+mesh_sources = \
+ $(int_dir)/monkey.obj \
+ $(int_dir)/cube.obj
+
+meshes = $(mesh_sources:$(int_dir)/%.obj=$(data_dir)/%.msh)
+assets = $(meshes)
+
+all: $(target) $(pack)
$(objects): %.o : %.c
$(compiler) -MMD -MF $(basename $@).d $(cflags) -o $@ -c $<
@@ -24,7 +39,30 @@ $(objects): %.o : %.c
$(target): $(objects)
$(linker) $(objects) -o $@ $(lflags)
+$(meshes): $(data_dir)/%.msh : $(int_dir)/%.obj | $(convmesh) $(data_dir)
+ ./$(convmesh) $< $@
+
+$(convassets): convassets.c
+ $(tool_compiler) $(cflags) -o $@ $<
+
+$(convmesh): convmesh.c
+ $(tool_compiler) $(cflags) -o $@ $<
+
+$(packassets): packassets.c
+ $(tool_compiler) packassets.c $(cflags) -o $@
+
+$(pack): $(packassets) $(meshes)
+ ./$(packassets) \
+ $(data_dir) \
+ $(notdir $(meshes))
+
+$(data_dir):
+ mkdir -p $(data_dir)
+
clean:
+ rm -f $(packassets)
+ rm -f $(convmesh)
+ rm -rf data
rm *.d
rm *.o
rm $(target)