skov-example-projects/helloworld-c-make/Makefile
2024-08-07 10:13:30 +02:00

33 lines
558 B
Makefile

EXECUTABLE = helloworld-c-make
CFLAGS = -std=c17 -Wall -Wextra -pedantic -pedantic-errors -O2
SOURCE_FILES = \
src/main.c
OBJECT_FILES = $(patsubst src/%.c, build/%.o, $(SOURCE_FILES))
HEADER_FILES = $(shell find src/ -name *.h)
all: build/$(EXECUTABLE) build/compile_flags.txt
build/$(EXECUTABLE): $(OBJECT_FILES)
$(CC) -o $@ $(LDFLAGS) $^
build/%.o: src/%.c $(HEADER_FILES) build-folder
$(CC) -c -o $@ $(CFLAGS) $<
build-folder:
mkdir -p build/
clean:
rm -rf build/
build/compile_flags.txt:
echo -xc $(CFLAGS) \
| tr ' ' '\n' \
> $@