From 144cd7031ec3926d1c5c4911b8148ba293de6f1f Mon Sep 17 00:00:00 2001 From: _N0x Date: Wed, 9 Feb 2022 00:35:01 +0100 Subject: [PATCH] Added make file for project and fixed .gitignore --- .gitignore | 5 +++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 7b2e2e2..6f1695e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ +# exclude project binary +f8prog + +# exclude project dirs build/ firmware/ +.ccls-cache/ # ---> C # Prerequisites diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a64b886 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +## Compiler settings +CC = cc +CFLAGS = -Wall +LDFLAGS = + +## Project settings +TARGET = f8prog ## name of the application + +## Paths +SRC = $(wildcard src/*.c) +OFILES = $(patsubst src%, build%, $(patsubst src/%.c, build/%.o, $(SRC))) + + +$(TARGET): ./build $(OFILES) + $(CC) $(CFLAGS) $(OFILES) -o $(TARGET) $(LDFLAGS) + +%.o: ../src/%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +./build: + mkdir -p $@ + +clean: + rm -rf $(OFILES) + rm -f $(TARGET) + rm -rf ./build + +test: $(TARGET) + ./$(TARGET) + +options: + @echo $(TARGET) build options: + @echo "CFLAGS = ${CFLAGS}" + @echo "LDFLAGS = ${LDFLAGS}" + @echo "CC = ${CC}" + +.PHONY: options clean test