我有一个项目目录结构如下:
Source-----------------
---Project1------------
-----------Project1_vA-
-----------Project1_vB-
---Project2------------
-----------Project2_vA-
-----------Project2_vB-
---Project3------------
-----------Project3_vA-
我正在尝试在所有子目录中为递归构建lib编写makefile:
DIRS := $(dir $(wildcard $(LOCAL_PATH)/*/));
$(info $(DIRS))
for item in $(DIRS); do \
$(info sublib) \
$(info $(item)) \
if [[ "$item" == "$LOCAL_PATH/glm/" || \
"$item" == "$LOCAL_PATH/common/" ]] \
then \
continue; \
fi \
SUBDIRS := $(dir $(wildcard $(item)/*/)) \
$(info $(SUBDIRS)) \
for subitem in $(SUBDIRS); do \
include $(CLEAR_VARS) \
$(info $(subitem)) \
LOCAL_MODULE := $(subitem) \ \
LOCAL_CFLAGS := -g -fexceptions \
LOCAL_ARM_MODE := arm \
LOCAL_SRC_FILES := $(subitem)/*.cpp \
$(subitem)/main.cpp \
LOCAL_SHARED_LIBRARIES := common \
LOCAL_LDLIBS := -llog -lGLESv2 \
include $(BUILD_SHARED_LIBRARY) \
done; \
done;
但是,循环块中的错误 - $(info $(item))
- 显示空格。
$(info $(DIRS))
- 显示"Source/Project1/ Source/Project2/ Source/Project3/;"
请帮助。
答案 0 :(得分:1)
使用find怎么样?
DIRS := `find . -type d`
PROJECT_DIRS := $(filter ...,$(DIRS))
NON_PROJECT_DIRS := $(filter-out ...,$(DIRS))
.PHONY: $(DIRS)
$(PROJECT_DIRS): $(NON_PROJECT_DIRS)
... rules for making projects ...
$(NON_PROJECT_DIRS):
... rules for making sub dirs ...