自動変数: https://tex2e.github.io/blog/makefile/automatic-variables
依存関係の書き方部:https://www.unixuser.org/~euske/doc/makefile/: https://www.unixuser.org/~euske/doc/makefile/
FrameWork/bin/program
FrameWork/src/.cpp
FrameWork/src/.hpp
FrameWork/src/component/.cpp
FrameWork/src/component/.hpp
FrameWork/Makefile
FrameWork/bin/program
FrameWork/src/*.cpp
FrameWork/src/*.hpp
FrameWork/src/component/*.cpp
FrameWork/src/component/*.hpp
FrameWork/Makefile
$ sh run.sh
make: *** 'bin/libFrameWork.a' に必要なターゲット 'obj/BoxCollider2D.o' を make するルールがありません. 中止.
FrameWork Compile Error
PRG :=bin/libFrameWork.a
SRC_DIR :=src
SRC_COMPONENT_DIR :=src/component
OBJ_DIR :=obj
DEP_DIR :=obj
DEP :=$(wildcard $(DEP_DIR)/*.d)
SRC :=$(wildcard $(SRC_DIR)/*.cpp)
SRC_COMPONENT :=$(wildcard $(SRC_COMPONENT_DIR)/*.cpp)
OBJ_COMPONENT :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC_COMPONENT))))
OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
$(PRG): $(OBJ) $(OBJ_COMPONENT)
# ar rcs $@ $(OBJ) $(OBJ_COMPONENT)
ar rcs $@ $^
$(OBJ_DIR)/%.o: src/%.cpp src/component/%.cpp
# $(CXX) -c -MMD -MP $< -o $@ -I ~/Library -I ~/Library/freetype
$(CXX) -c -MMD -MP $^ -o $@ -I ~/Library -I ~/Library/freetype
-include $(DEP)
clean:
rm -f ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d $(PRG)