oglc/makefile

47 lines
1.0 KiB
Makefile
Raw Normal View History

2021-07-04 03:53:37 +02:00
SRC_DIR = src
BIN_DIR = bin
RES_DIR = res
2021-07-24 02:31:35 +02:00
SHADER_DIR = $(SRC_DIR)/_shader
SHADER_ROOT_DIR = $(SHADER_DIR)/root
SHADER_INCLUDE_DIR = $(SHADER_DIR)/common
2021-07-04 03:53:37 +02:00
TARGET = $(BIN_DIR)/oglc
CC = gcc
LIBS = `pkg-config --static --libs glew sdl2`
CFLAGS = -I$(SRC_DIR) -Wall
SRC = $(shell find $(SRC_DIR) -name *.c)
OBJ = $(SRC:%.c=%.o)
2021-07-24 02:31:35 +02:00
# find files in SHADER_ROOT_DIR
# top level compute shader programs
SHADERS = $(shell find $(SHADER_ROOT_DIR) -name *.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)
2021-07-04 03:53:37 +02:00
# create dirs if they dont exist
_dummy := $(shell mkdir -p $(BIN_DIR))
$(TARGET): $(OBJ)
2021-07-24 02:31:35 +02:00
# preprocess shaders and store results in bin/res/shader/ under root name
foreach root,$(SHADER_ROOT_DIR),$(echo $(root))
2021-07-04 03:53:37 +02:00
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
cp -r $(RES_DIR) $(BIN_DIR)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
-rm -r $(BIN_DIR)
-rm */*.o
run: $(TARGET)
$(TARGET)
.PHONY: run clean