0
我目前工作的一個大項目,比我過去,所以我組織在一棵樹上我的文件(見下文)的Makefile遞歸
Project
| |-----Components|------folderb|-----asdf.cpp
| | | |-----fdsa.cpp
| | |
|----- Source| |------afolder|-----qwerty.cpp
| |
| |-----Include|-----bar.h
| |-----foo.h
|----- Bin
|
|----- Build
|
|----- Makefile
我還在學習如何make makefile,但我仍然在最後幾行得到「與目標模式不匹配」。任何幫助將非常感激!
##########################################
# Editable options #
##########################################
# Title
EXECUTABLE_NAME=net
# Compiler options
CC=g++
CFLAGS= -Wall
LDFLAGS= -Wall
# Folders
SRC_DIR=Source
BLD_DIR=Build
BIN_DIR=Bin
HDR_DIR=$(SRC_DIR)/Include
#########################################################
# Do Not Touch This #
#########################################################
SOURCE_FILES := $(shell find $(SRC_DIR)/ -type f -name '*.cpp')
SOURCE_FILE_NAMES := $(shell find $(SRC_DIR)/ -type f -name '*.cpp' -printf "%f\n")
HEADER_FILES := $(wildcard $(HDR_DIR)*.h)
OBJECT_FILES := $(SOURCE_FILE_NAMES:.cpp=.o)
EXECUTABLE_FILES = $(EXECUTABLE_NAME:%=$(BLD_DIR)/%)
build: $(EXECUTABLE_FILES)
clean:
rm -r -f $(BIN_DIR)
.PHONY: build clean
$(EXECUTABLE_FILES): $(OBJECT_FILES)
@$(CC) $(LDFLAGS) -o [email protected] $^
@echo "Build successful!"
$(OBJECT_FILES): $(BIN_DIR)/%.o: $(SRC_DIR)/**/%.cpp
@echo Compiling $^
@$(CC) $(CFLAGS) -o -c [email protected] $^