ptk/Makefile
jacekpoz 114c8a0c5d
images (kinda) working again
the image example shows :3 but it errors a lot and shit
2024-10-06 13:29:47 +02:00

83 lines
1.6 KiB
Makefile

# Copyright (jacekpoz 2024). Licensed under the EUPL-1.2 or later.
CC = clang
CFLAGS = -std=c23 -Wall -Wextra -Wpedantic
CFLAGS += -Werror -Wfloat-equal -Wshadow
CFLAGS += -fPIC -fstrict-aliasing
CFLAGS += $(shell pkg-config --cflags glfw3 stb vulkan)
LDFLAGS = $(shell pkg-config --libs glfw3 stb 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) -iquote$(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