init-projects/c/Makefile
2024-04-24 00:02:23 +02:00

31 lines
600 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 -fsanitize=leak
debug: compilation
compilation: $(OBJECTS)
$(CC) -o $(EXE).$(EXE_EXT) $(OBJECTS) $(LDFLAGS)
all:
release
clean:
$(RM) $(OBJECTS) $(EXE).$(EXE_EXT)