init-projects/c/Makefile
2024-04-03 15:38:54 +02:00

31 lines
584 B
Makefile

CC = gcc
RM = rm
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst %.c,%.o,$(notdir $(SOURCES)))
CFLAGS = -std=c11 -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)