init-projects/c/Makefile

32 lines
600 B
Makefile
Raw Normal View History

2024-02-01 15:16:54 +01:00
CC = gcc
RM = rm
2023-09-19 11:47:05 +02:00
SOURCES = $(wildcard src/*.c)
2024-04-03 15:38:54 +02:00
OBJECTS = $(patsubst %.c,%.o,$(notdir $(SOURCES)))
2023-09-19 11:47:05 +02:00
2024-04-20 14:56:15 +02:00
CFLAGS = -std=c17 -pedantic
2023-11-25 21:18:30 +01:00
LDFLAGS =
2023-09-19 11:47:05 +02:00
EXE = example
EXE_EXT = out
2023-09-19 11:47:05 +02:00
%.o: src/%.c
2023-11-12 16:23:10 +01:00
$(CC) -c $< -o $@ $(CFLAGS)
2023-09-19 11:47:05 +02:00
2024-04-03 15:38:54 +02:00
release: CFLAGS += -O3
release: compilation
2024-04-03 15:38:54 +02:00
debug: CFLAGS += -Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes
debug: CFLAGS += -fanalyzer -fsanitize=undefined -g -Og
2024-04-24 00:02:23 +02:00
debug: LDFLAGS += -fsanitize=undefined -fsanitize=leak
2024-04-03 15:38:54 +02:00
debug: compilation
2023-09-19 11:47:05 +02:00
2024-04-03 15:38:54 +02:00
compilation: $(OBJECTS)
$(CC) -o $(EXE).$(EXE_EXT) $(OBJECTS) $(LDFLAGS)
2023-09-19 11:47:05 +02:00
all:
2024-04-03 15:38:54 +02:00
release
2023-09-19 11:47:05 +02:00
clean:
2024-04-03 15:38:54 +02:00
$(RM) $(OBJECTS) $(EXE).$(EXE_EXT)