From c60dba253906a30d3042f1dc4e9b7fe38f053fbe Mon Sep 17 00:00:00 2001 From: cathook Date: Sun, 1 Jun 2014 14:16:38 +0800 Subject: add test... --- meowpp.test/GNUmakefile | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 meowpp.test/GNUmakefile (limited to 'meowpp.test/GNUmakefile') diff --git a/meowpp.test/GNUmakefile b/meowpp.test/GNUmakefile new file mode 100644 index 0000000..2e503b8 --- /dev/null +++ b/meowpp.test/GNUmakefile @@ -0,0 +1,79 @@ +INC := inc +SRC := src +OBJ := obj +BIN := bin +DEP := dep + +LIB_INCS := +CXX := g++ +CXXFLAGS := -Wall -I$(INC) $(LIB_INCS) -g -pedantic -lstdc++ -lm +CXX_OBJ := $(CXX) -c +CXX_DEP := $(CXX) -MM + +DEPENDENCY_CREATER := ./GNUmakefile.dependency.sh + +OBJECTS := $(patsubst $(SRC)/%.cpp,$(OBJ)/%.o,$(wildcard $(SRC)/*.cpp)) +DEPENDENCYS := $(patsubst $(SRC)/%.cpp,$(DEP)/%.d,$(wildcard $(SRC)/*.cpp)) + +TARGET_FILE := GNUmakefile.targets +TARGETS := + +NAME := empty + +.PHONY: all all2 dep clean init new del add sub + +all: all2 + +-include $(TARGET_FILE) + +all2: $(TARGETS) + +init: + -@mkdir -p $(BIN) + -@mkdir -p $(SRC) + -@mkdir -p $(INC) + -@mkdir -p $(OBJ) + -@mkdir -p $(DEP) + -@echo '' > $(TARGET_FILE) + +new: + @set -e; echo "Add target '$(NAME)'"; \ + echo 'TARGETS := $$(TARGETS) $$(BIN)/$(NAME)' >> $(TARGET_FILE); \ + echo '$(NAME)_OBJS := $(foreach n,$(OBJS),$$(OBJ)/$(n).o)' >> $(TARGET_FILE); \ + echo '$(NAME)_LIBS := $(LIBS)' >> $(TARGET_FILE); \ + echo '$$(BIN)/$(NAME): $$(OBJ)/$(NAME).o $$($(NAME)_OBJS)' >> $(TARGET_FILE); \ + echo '\t@echo Target: $$@...' >> $(TARGET_FILE); \ + echo '\t@$$(CXX) $$^ $$(CXXFLAGS) `pkg-config --cflags --libs $$($(NAME)_LIBS) 2>/dev/null` -o $$@' >> $(TARGET_FILE); \ + echo '' >> $(TARGET_FILE) + +add: + @set -e; echo "Add Objects $(OBJS) to Target '$(NAME)'"; \ + sed '/^$(NAME)_OBJS :=/s/$$/& $(foreach n,$(OBJS),\$$(OBJ)\/$(n).o)/' $(TARGET_FILE) >$(TARGET_FILE).$$$$; \ + mv -f $(TARGET_FILE).$$$$ $(TARGET_FILE) + @set -e; echo "Add Libraries $(LIBS) to Target '$(NAME)'"; \ + sed '/^$(NAME)_LIBS :=/s/$$/& $(subst /,\/,$(LIBS))/' $(TARGET_FILE) >$(TARGET_FILE).$$$$; \ + mv -f $(TARGET_FILE).$$$$ $(TARGET_FILE) + +sub: + @set -e; echo "Remove Objects $(OBJS) from Target '$(NAME)'"; \ + sed '/^$(NAME)_OBJS :=/s/$(subst \ ,|,$(foreach n,$(OBJS),\$$(OBJ)\/$(n).o))//' $(TARGET_FILE) >$(TARGET_FILE).$$$$; \ + mv -f $(TARGET_FILE).$$$$ $(TARGET_FILE) + @set -e; echo "Remove Libraries $(LIBS) from Target '$(NAME)'"; \ + sed '/^$(NAME)_OBJS :=/s/$(subst \ ,|,$(foreach n,$(LIBS),\$$(OBJ)\/$(n).o))//' $(TARGET_FILE) >$(TARGET_FILE).$$$$; \ + mv -f $(TARGET_FILE).$$$$ $(TARGET_FILE) + +clean: + -rm -f $(BIN)/* + -rm -f $(OBJ)/* 2>/dev/null + -rm -f $(DEP)/* + +dep: $(DEPENDENCY); + +-include $(DEPENDENCYS) + +$(DEPENDENCYS):: $(DEP)/%.d: $(SRC)/%.cpp + $(DEPENDENCY_CREATER) "`$(CXX_DEP) $(CXXFLAGS) $<`" $@ + +$(OBJECTS): $(OBJ)/%.o: $(SRC)/%.cpp $(DEP)/%.d $(DEP)/%.d + @echo 'Objects: $@...' + @$(CXX_OBJ) $(CXXFLAGS) -o $@ $< -- cgit v1.2.3