vc3/Makefile
2025-03-31 16:20:10 +02:00

54 lines
897 B
Makefile

MAKEFLAGS += -j $(shell nproc)
CC = gcc
C_FLAGS = \
-std=c17 \
-Wall -Wextra -Wpedantic -Wconversion \
-pedantic -pedantic-errors \
-Wno-unused-variable \
-Wno-unused-parameter \
-I. \
L_FLAGS = -pthread
C_FLAGS += $(shell pkg-config sdl2 --cflags)
L_FLAGS += $(shell pkg-config sdl2 --libs)
F_FLAGS =
OPTIMIZATION =
RELEASE=0
ifeq ($(RELEASE),1)
C_FLAGS += -Werror
F_FLAGS += -flto=auto
OPTIMIZATION += -O3
else
C_FLAGS += -g
F_FLAGS += -fsanitize=address,undefined,leak
OPTIMIZATION += -Og
endif
HEADERS = $(shell find . -name *.h)
VM_SOURCES = $(shell find vm/ -name *.c)
VM_OBJECTS = $(patsubst %.c,build/%.o,$(VM_SOURCES))
all: bin/vm
bin/vm: $(VM_OBJECTS)
@mkdir -p $(dir $@)
$(CC) $^ -o $@ $(F_FLAGS) $(OPTIMIZATION) $(L_FLAGS)
build/%.o: %.c $(HEADERS)
@mkdir -p $(dir $@)
$(CC) $< -c -o $@ $(C_FLAGS) $(OPTIMIZATION) $(F_FLAGS)
clean:
rm -rf build/ bin/