[英]makefile to take dependency of all file in particular directory
我有一個C ++項目。 在我的Project文件夾中,我有三個子項目文件夾。
Proj_Folder
Include
head1.h
head2.h
....
Sub_Proj1
proj1.cpp
makefile
Sub_Proj2
proj2.cpp
makefile
Sub_Proj3
proj3.cpp
makefile
ShareAll.cpp
makefile
這是“ Proj_Folder”文件夾中的makefile。
OBJS = ../ShareAll.o proj1.o
proj1: ${OBJS}
${CXX} ${CFLAGS} -o $@ $+
proj1.o : proj1.cpp
${CXX} ${CFLAGS} -c $< -o $@
../ShareAll.o : ../ShareAll.cpp
${CXX} ${CFLAGS} -c $< -o $@
我需要包括位於目錄“包含”中的所有頭文件作為整個項目的依賴項。
我嘗試下面的代碼。
C_HEADER_FILES := $(patsubst Include/*.h)
# The dependency file names.
DEPS := $(C_HEADER_FILES:.h=.d)
# Let make read the dependency files and handle them.
-include $(DEPS)
但是它說
makefile:30: *** insufficient number of arguments (1) to function `patsubst'. Stop.
如何將所有頭文件作為依賴項包含在此項目的makefile中?
您使用錯誤的功能來收集.h文件集。 您需要使用:
C_HEADER_FILES := $(wildcard Include/*.h)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.