oglc/makefile

57 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

2021-07-04 03:53:37 +02:00
SRC_DIR = src
BIN_DIR = bin
2021-08-02 20:43:05 +02:00
SHADER_DIR = shader
2021-07-04 03:53:37 +02:00
2021-07-30 00:39:04 +02:00
SHADER_QUAD_DIR = $(SHADER_DIR)/quad
SHADER_ROOT_DIR = $(SHADER_DIR)/root
SHADER_INCLUDE_DIR = $(SHADER_DIR)/include
2021-08-02 20:43:05 +02:00
SHADER_TARGET_DIR = $(BIN_DIR)
2021-07-30 00:39:04 +02:00
# find files in SHADER_ROOT_DIR
# top level compute shader programs
SHADERS = $(shell find $(SHADER_ROOT_DIR) -wholename "$(SHADER_ROOT_DIR)*.glsl")
# find files in SHADER_INCLUDE_DIR
# small chunks of shader code, included repeatedly in the top-level programs
SHADER_INCLUDES = $(shell find $(SHADER_INCLUDE_DIR) -name *.glsl)
SHADER_TARGETS = $(SHADERS:$(SHADER_ROOT_DIR)/%.glsl=$(SHADER_TARGET_DIR)/%.compute)
2021-07-24 02:31:35 +02:00
2021-07-04 03:53:37 +02:00
TARGET = $(BIN_DIR)/oglc
2021-07-31 19:59:41 +02:00
LAUNCH = "./launch"
2021-07-30 00:39:04 +02:00
2021-07-04 03:53:37 +02:00
CC = gcc
2021-07-30 03:06:59 +02:00
LIBS = `pkg-config --static --libs glew sdl2 cglm`
2021-07-04 03:53:37 +02:00
CFLAGS = -I$(SRC_DIR) -Wall
SRC = $(shell find $(SRC_DIR) -name *.c)
OBJ = $(SRC:%.c=%.o)
# create dirs if they dont exist
_dummy := $(shell mkdir -p $(BIN_DIR))
2021-07-30 00:39:04 +02:00
$(TARGET): $(OBJ) $(SHADER_TARGETS)
mkdir -p $(BIN_DIR)
mkdir -p $(SHADER_TARGET_DIR)
cp $(shell find $(SHADER_QUAD_DIR) -wholename "$(SHADER_QUAD_DIR)/*") $(SHADER_TARGET_DIR)
$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS)
2021-07-24 02:31:35 +02:00
2021-07-30 00:39:04 +02:00
$(SHADER_TARGET_DIR)/%.compute: $(SHADER_ROOT_DIR)/%.glsl $(SHADER_INCLUDES)
mkdir -p $(SHADER_TARGET_DIR)
python ppp.py $< $(SHADER_INCLUDES) > $@
2021-07-04 03:53:37 +02:00
2021-07-30 00:39:04 +02:00
# how to make a .o out of a .c
2021-07-04 03:53:37 +02:00
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
-rm -r $(BIN_DIR)
-rm */*.o
2022-06-21 01:41:52 +02:00
# TODO: extract run-* out to like, python scripts? arguments can be implemented with argparse to
# manage simple interface with C binary
2021-07-04 03:53:37 +02:00
run: $(TARGET)
2022-06-21 01:41:52 +02:00
$(LAUNCH) $(TARGET) 1.0
run-converge: $(TARGET)
$(LAUNCH) $(TARGET) 0.0
2021-07-04 03:53:37 +02:00
.PHONY: run clean