diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-07-13 13:18:57 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-07-13 13:18:57 +0200 |
commit | 6801029214469b0d94a134220fa2fdacf26ee747 (patch) | |
tree | 8705a30d9b06f3a5e933fcdcf3c1bf002cae5102 | |
parent | fix(README): Remove the `.md` suffix (diff) | |
download | flake-templates-6801029214469b0d94a134220fa2fdacf26ee747.tar.gz flake-templates-6801029214469b0d94a134220fa2fdacf26ee747.zip |
fix(templates/c): Support multiple input files in makefile
-rw-r--r-- | templates/c/makefile | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/templates/c/makefile b/templates/c/makefile index 63ca24c..6128f06 100644 --- a/templates/c/makefile +++ b/templates/c/makefile @@ -12,8 +12,8 @@ BIN_PATH := $(BUILD_DIR)$(BIN_NAME) SRC := $(wildcard src/*.c) -OBJ := $(SRC:.c=.o) -DEP := $(OBJ:.o=.d) +OBJ := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.o))) +DEP := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.d))) LIBS := @@ -25,11 +25,11 @@ default: all all: $(BIN_NAME) $(BIN_NAME): $(OBJ) - $(CC) $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) + $(CC) $^ -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OBJ): $(SRC) - mkdir --parents $(BUILD_DIR) - $(CC) -c $< -o $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) $(ALL_CFLAGS) + @mkdir --parents $(BUILD_DIR) + $(CC) -c -o $@ $(addprefix ./src/,$(patsubst %.o,%.c,$(notdir $@))) $(ALL_CFLAGS) manual: mkdir --parents $(BUILD_DIR)docs |