2024-08-02 15:07:55 +01:00
|
|
|
|
|
|
|
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)
|
2024-08-07 09:10:18 +01:00
|
|
|
$(CC) -o $@ $(LDFLAGS) $^
|
2024-08-02 15:07:55 +01:00
|
|
|
|
|
|
|
build/%.o: src/%.c $(HEADER_FILES) build-folder
|
|
|
|
$(CC) -c -o $@ $(CFLAGS) $<
|
|
|
|
|
|
|
|
build-folder:
|
|
|
|
mkdir -p build/
|
|
|
|
|
|
|
|
clean:
|
2024-08-07 09:10:18 +01:00
|
|
|
rm -rf build/
|
2024-08-02 15:07:55 +01:00
|
|
|
|
|
|
|
build/compile_flags.txt:
|
|
|
|
echo -xc $(CFLAGS) \
|
|
|
|
| tr ' ' '\n' \
|
|
|
|
> $@
|
|
|
|
|
|
|
|
|