jacekpoz
97ca8319c3
uses stb to load the image, currently all images have their texture replaced with the texture of the first image gonna try to fix that soon
83 lines
1.6 KiB
Makefile
83 lines
1.6 KiB
Makefile
# Copyright (jacekpoz 2024). Licensed under the EUPL-1.2 or later.
|
|
|
|
CC = clang
|
|
CFLAGS = -std=c11 -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) -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
|