2021-07-04 03:53:37 +02:00
|
|
|
SRC_DIR = src
|
|
|
|
BIN_DIR = bin
|
|
|
|
RES_DIR = res
|
|
|
|
|
2021-07-30 00:39:04 +02:00
|
|
|
SHADER_DIR = $(RES_DIR)/shader
|
|
|
|
SHADER_QUAD_DIR = $(SHADER_DIR)/quad
|
|
|
|
SHADER_ROOT_DIR = $(SHADER_DIR)/root
|
|
|
|
SHADER_INCLUDE_DIR = $(SHADER_DIR)/include
|
|
|
|
SHADER_TARGET_DIR = $(BIN_DIR)/$(RES_DIR)
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
run: $(TARGET)
|
2021-07-31 19:59:41 +02:00
|
|
|
$(LAUNCH) $(TARGET)
|
2021-07-04 03:53:37 +02:00
|
|
|
|
|
|
|
.PHONY: run clean
|