From 8dac3405ec3d83fcc6b14c3e08e1fbc8e0d584f6 Mon Sep 17 00:00:00 2001 From: tylen Date: Wed, 25 Sep 2024 10:55:54 +0000 Subject: [PATCH] use makefile instead simple build.sh #7 --- .github/workflows/build.yml | 2 +- Makefile | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00bf9aa..984aa31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,4 +13,4 @@ jobs: uses: actions/checkout@v3 - name: Run build script run: | - ./build.sh + make diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d66bf1c --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +CC = gcc +CFLAGS = -Wall -ggdb +SRCS = $(shell find ./src -type f -name "*.c") +BUILD_DIR = $(shell git rev-parse --show-toplevel)/build +OBJS = $(SRCS:.c=.o) + +all: $(BUILD_DIR)/cdo + +$(BUILD_DIR)/cdo: $(OBJS) + @mkdir -p $(BUILD_DIR) + $(CC) $(CFLAGS) -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + rm -rf $(BUILD_DIR) $(OBJS) + +.PHONY: all