Skip to content

Commit 961f43c

Browse files
committed
c-cpp: refactor makefiles
1 parent 2866c14 commit 961f43c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

c-cpp/makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ run: $(TARGETS)
5757
.PHONY: r
5858
r: run
5959

60-
$(BUILD_DIR)/%.o: src/%.cpp
60+
$(BUILD_DIR)/%.o: %.cpp
6161
@mkdir --parents $(shell dirname $@)
6262
$(CXX) $(CXXFLAGS) -MMD -MF $(@:.o=.d) -c -o $@ $<
6363

64-
$(BUILD_DIR)/%.o: src/%.c
64+
$(BUILD_DIR)/%.o: %.c
6565
@mkdir --parents $(shell dirname $@)
6666
$(CC) $(CFLAGS) -MMD -MF $(@:.o=.d) -c -o $@ $<
6767

c-cpp/targets.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ TARGETS = \
33
$(TARGET_DIR)/cpp-example
44

55
DEPS := src/c-example.c src/example.c
6-
DEPS := $(DEPS:src/%.c=$(BUILD_DIR)/%.o)
7-
$(TARGET_DIR)/c-example: $(DEPS)
6+
$(TARGET_DIR)/c-example: $(DEPS:%.c=$(BUILD_DIR)/%.o)
87
@mkdir --parents $(shell dirname $@)
98
$(CC) -o $@ $^ $(LDFLAGS)
109

1110
DEPS := src/cpp-example.cpp
12-
DEPS := $(DEPS:src/%.cpp=$(BUILD_DIR)/%.o)
13-
$(TARGET_DIR)/cpp-example: $(DEPS)
11+
$(TARGET_DIR)/cpp-example: $(DEPS:%.cpp=$(BUILD_DIR)/%.o)
1412
@mkdir --parents $(shell dirname $@)
1513
$(CXX) -o $@ $^ $(LDFLAGS)

0 commit comments

Comments
 (0)