ptk/Makefile

83 lines
1.6 KiB
Makefile
Raw Normal View History

# Copyright (jacekpoz 2024). Licensed under the EUPL-1.2 or later.
2024-08-08 14:38:43 +02:00
CC = clang
CFLAGS = -std=c11 -Wall -Wextra -Wpedantic
2024-08-13 00:43:49 +02:00
CFLAGS += -fPIC -fstrict-aliasing
2024-08-08 14:38:43 +02:00
CFLAGS += $(shell pkg-config --cflags glfw3 vulkan)
LDFLAGS = $(shell pkg-config --libs glfw3 vulkan)
ifdef DEBUG
CFLAGS += -DDEBUG -g
else
CFLAGS += -O3
endif
GLSLC = glslc
GLSLFLAGS =
NAME = ptk
CFLAGS += -DPTK_ENGINE_NAME=\"ptk\"
CFLAGS += -DPTK_VERSION_MAJOR=0
CFLAGS += -DPTK_VERSION_MINOR=1
CFLAGS += -DPTK_VERSION_PATCH=0
INCLUDE = include
SRC = src
CFLAGS += -I$(INCLUDE) -I$(SRC)
BIN = target
H = $(shell find $(SRC) -type f -name "*.h")
H += $(shell find $(INCLUDE) -type f -name "*.h")
PROG = $(shell find $(SRC) -type f -name "*.c")
OBJ = $(addprefix $(BIN)/, $(PROG:.c=.o))
SHADER = shaders
SHADER_SRC = $(shell find $(SHADER) -type f -name "*.glsl")
SHADER_OBJ = $(addprefix $(BIN)/, $(SHADER_SRC:.glsl=.spv))
.PHONY: all test clean
all: dirs shaders
$(MAKE) $(NAME)
dirs:
mkdir -p $(BIN)
$(NAME): $(OBJ)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -shared -o $(BIN)/lib$@.so
$(BIN)/%.o: %.c $(H)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
shaders: $(SHADER_OBJ)
$(BIN)/%.vert.spv: %.vert.glsl
@mkdir -p $(@D)
$(GLSLC) $(GLSLFLAGS) -fshader-stage=vert $< -o $@
$(BIN)/%.frag.spv: %.frag.glsl
@mkdir -p $(@D)
$(GLSLC) $(GLSLFLAGS) -fshader-stage=frag $< -o $@
clean:
rm -rf $(BIN)
test:
@CC="$(CC)" \
CFLAGS="$(CFLAGS)" \
BIN="$(BIN)" \
INCLUDE="$(INCLUDE)" \
$(MAKE) -f test/Makefile
example:
@CC="$(CC)" \
CFLAGS="$(CFLAGS)" \
BIN="$(BIN)" \
INCLUDE="$(INCLUDE)" \
$(MAKE) -f examples/Makefile