diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-01 14:16:38 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-06-01 14:16:38 +0800 |
commit | c60dba253906a30d3042f1dc4e9b7fe38f053fbe (patch) | |
tree | 57018f05908f0edef30cba255d46688ebfd5cd85 /meowpp.test/GNUmakefile | |
parent | 8bc9f2e8496c0c021b80eb0fb21e828f5900f08d (diff) | |
download | meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar.gz meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar.bz2 meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar.lz meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar.xz meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.tar.zst meow-c60dba253906a30d3042f1dc4e9b7fe38f053fbe.zip |
add test...
Diffstat (limited to 'meowpp.test/GNUmakefile')
-rw-r--r-- | meowpp.test/GNUmakefile | 79 |
1 files changed, 79 insertions, 0 deletions
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 $@ $< |