fileformatsproject-legacy/Makefile

33 lines
982 B
Makefile
Executable File

CC = gcc
CC_FLAGS = -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c17 -pedantic -pedantic-errors -O3 -I./
CC_SANITIZER_FLAGS = -fsanitize=address -fsanitize=undefined
LIB_SOURCES = $(wildcard lib/*.c)
LIB_OBJECTS = $(patsubst %.c, %.o, $(LIB_SOURCES))
HEADER_FILES = $(wildcard lib/*.h)
MAIN_EXECUTABLE = bin/main
LIBCPROJECT_PATH = ./libcproject/build/libcproject.a
LIBCPROJECT_CC_FLAGS = -L. -l:${LIBCPROJECT_PATH}
${MAIN_EXECUTABLE}: ./main.c ${HEADER_FILES} $(addprefix build/, ${LIB_OBJECTS}) ${LIBCPROJECT_PATH}
mkdir --parents ./bin
mkdir --parents ./assets
${CC} ${CC_FLAGS} ${CC_SANITIZER_FLAGS} $^ -o $@ ${LIBCPROJECT_CC_FLAGS}
.PHONY: run
run: ${MAIN_EXECUTABLE}
./$< ${ARGS}
build/lib:
mkdir --parents ./build/lib
build/lib/%.o: lib/%.c ${HEADER_FILES} | build/lib
${CC} ${CC_FLAGS} -c $< -o $@
.PHONY: lint
lint:
clang-format --Werror --dry-run ${LIB_SOURCES} ${HEADER_FILES} ./main.c
.PHONY: clean
clean:
rm --recursive --force ./bin ./build ./assets