Simplified Makefiles.

This commit is contained in:
LoRd_MuldeR 2022-11-30 21:04:36 +01:00
parent 58fdfcb573
commit 4f2a13217c
8 changed files with 29 additions and 68 deletions

View File

@ -1,19 +1,8 @@
SUBDIRS := libhashset example test
BUILD_ALL := $(patsubst %,build\:%,$(SUBDIRS))
CLEAN_ALL := $(patsubst %,clean\:%,$(SUBDIRS))
.PHONY: all clean test $(SUBDIRS)
.PHONY: all test clean $(BUILD_ALL) $(CLEAN_ALL)
all clean test: $(SUBDIRS)
all: $(BUILD_ALL)
clean: $(CLEAN_ALL)
$(BUILD_ALL):
$(MAKE) -C $(patsubst build:%,%,$@)
$(CLEAN_ALL):
$(MAKE) -C $(patsubst clean:%,%,$@) clean
test: $(BUILD_ALL)
$(MAKE) -C test test
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)

View File

@ -1,16 +1,8 @@
SUBDIRS := hash-set hash-map
BUILD_ALL := $(patsubst %,build\:%,$(SUBDIRS))
CLEAN_ALL := $(patsubst %,clean\:%,$(SUBDIRS))
.PHONY: all clean test $(SUBDIRS)
.PHONY: all clean $(BUILD_ALL) $(CLEAN_ALL)
all clean test: $(SUBDIRS)
all: $(BUILD_ALL)
clean: $(CLEAN_ALL)
$(BUILD_ALL):
$(MAKE) -C $(patsubst build:%,%,$@)
$(CLEAN_ALL):
$(MAKE) -C $(patsubst clean:%,%,$@) clean
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)

View File

@ -10,11 +10,9 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
BIN_FILE := $(BIN_PATH)/example-hash-map$(EXE_SUFFIX)
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
.PHONY: all build clean
.PHONY: all clean test
all: clean build
build: $(ALL_PATH) $(BIN_FILE)
all test: clean $(ALL_PATH) $(BIN_FILE)
$(BIN_FILE): $(SRC_FILE)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

View File

@ -10,11 +10,9 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
BIN_FILE := $(BIN_PATH)/example-hash-set$(EXE_SUFFIX)
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
.PHONY: all build clean
.PHONY: all clean test
all: clean build
build: $(ALL_PATH) $(BIN_FILE)
all test: clean $(ALL_PATH) $(BIN_FILE)
$(BIN_FILE): $(SRC_FILE)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

View File

@ -11,10 +11,12 @@ SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
OBJ_FILE := $(addprefix $(OBJ_PATH)/,$(patsubst %.c,%.o,$(notdir $(SRC_FILE))))
LIB_FILE := $(LIB_PATH)/libhashset-1.a
.PHONY: all build clean
.PHONY: all build clean test
all: clean build
test: build
build: $(ALL_PATH) $(LIB_FILE)
$(LIB_FILE): $(OBJ_FILE)

View File

@ -1,22 +1,8 @@
SUBDIRS := hash-set hash-map
BUILD_ALL := $(patsubst %,build\:%,$(SUBDIRS))
CLEAN_ALL := $(patsubst %,clean\:%,$(SUBDIRS))
TESTS_ALL := $(patsubst %,rtest\:%,$(SUBDIRS))
.PHONY: all clean test $(SUBDIRS)
.PHONY: all clean test $(BUILD_ALL) $(CLEAN_ALL) $(TESTS_ALL)
all clean test: $(SUBDIRS)
all: $(BUILD_ALL)
clean: $(CLEAN_ALL)
test: $(TESTS_ALL)
$(BUILD_ALL):
$(MAKE) -C $(patsubst build:%,%,$@)
$(CLEAN_ALL):
$(MAKE) -C $(patsubst clean:%,%,$@) clean
$(TESTS_ALL):
$(MAKE) -C $(patsubst rtest:%,%,$@) test
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)

View File

@ -10,11 +10,9 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
BIN_FILE := $(BIN_PATH)/test-hash-set$(EXE_SUFFIX)
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
.PHONY: all build clean test
.PHONY: all clean test
all: clean build
build: $(ALL_PATH) $(BIN_FILE)
all: clean $(ALL_PATH) $(BIN_FILE)
$(BIN_FILE): $(SRC_FILE)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
@ -22,8 +20,8 @@ $(BIN_FILE): $(SRC_FILE)
$(ALL_PATH):
mkdir -p $@
test: all
./$(BIN_FILE)
clean:
rm -vf $(BIN_FILE)
test: build
./$(BIN_FILE)

View File

@ -10,11 +10,9 @@ ALL_PATH := $(SRC_PATH) $(BIN_PATH)
BIN_FILE := $(BIN_PATH)/test-hash-set$(EXE_SUFFIX)
SRC_FILE := $(wildcard $(SRC_PATH)/*.c)
.PHONY: all build clean test
.PHONY: all clean test
all: clean build
build: $(ALL_PATH) $(BIN_FILE)
all: clean $(ALL_PATH) $(BIN_FILE)
$(BIN_FILE): $(SRC_FILE)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
@ -22,8 +20,8 @@ $(BIN_FILE): $(SRC_FILE)
$(ALL_PATH):
mkdir -p $@
test: all
./$(BIN_FILE)
clean:
rm -vf $(BIN_FILE)
test: build
./$(BIN_FILE)