init-projects/c/Makefile
2024-04-20 14:56:15 +02:00

31 lines
584 B
Makefile

CC = gcc
RM = rm
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst %.c,%.o,$(notdir $(SOURCES)))
CFLAGS = -std=c17 -pedantic
LDFLAGS =
EXE = example
EXE_EXT = out
%.o: src/%.c
$(CC) -c $< -o $@ $(CFLAGS)
release: CFLAGS += -O3
release: compilation
debug: CFLAGS += -Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes
debug: CFLAGS += -fanalyzer -fsanitize=undefined -g -Og
debug: LDFLAGS += -fsanitize=undefined
debug: compilation
compilation: $(OBJECTS)
$(CC) -o $(EXE).$(EXE_EXT) $(OBJECTS) $(LDFLAGS)
all:
release
clean:
$(RM) $(OBJECTS) $(EXE).$(EXE_EXT)