From b8b66778a28263da6fdddf99572a7ad9a1487f5a Mon Sep 17 00:00:00 2001 From: Charles Mita Date: Wed, 28 Mar 2018 14:04:57 +0100 Subject: [PATCH] Improve Makefile to stop unnecessary rebuilds --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 674cee8..2aa9983 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,24 @@ INC_DIR = $(SRC_DIR) CC=h5cc CFLAGS=-Wall -g -O2 -fpic -I$(INC_DIR) +.PHONY: all +all: plugin example + +.PHONY: plugin +plugin: $(BUILD_DIR)/plugin.so + +.PHONY: example +example: $(BUILD_DIR)/example + $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c mkdir -p $(BUILD_DIR) $(CC) $(CFLAGS) -c $< -o $@ -plugin: $(BUILD_DIR)/plugin.o $(BUILD_DIR)/file.o $(BUILD_DIR)/err.o +$(BUILD_DIR)/plugin.so: $(BUILD_DIR)/plugin.o $(BUILD_DIR)/file.o $(BUILD_DIR)/err.o mkdir -p $(BUILD_DIR) $(CC) $(CFLAGS) -shared $^ -o $(BUILD_DIR)/plugin.so -example: $(BUILD_DIR)/test.o $(BUILD_DIR)/file.o $(BUILD_DIR)/err.o +$(BUILD_DIR)/example: $(BUILD_DIR)/test.o $(BUILD_DIR)/file.o $(BUILD_DIR)/err.o mkdir -p $(BUILD_DIR) $(CC) $(CFLAGS) $^ -o $(BUILD_DIR)/example