我试图通过使用一个通用的 makefile 来整合一些构建信息。我的问题是我想使用来自不同子目录级别的 makefile,这使得工作目录值 ( pwd
) 不可预测。例如:
# Makefile.common
TOP := $(shell pwd)
COMPONENT_DIR := $(TOP)/component
COMPONENT_INC := $(COMPONENT_DIR)/include
COMPONENT_LIB := $(COMPONENT_DIR)/libcomponent.a
如果我Makefile.common
从子目录中包含,像这样,$(TOP)
目录不正确,其他一切都遵循:
# other_component/Makefile
include ../Makefile.common
# $(COMPONENT_LIB) is incorrectly other_component/component
Makefile.common
使用自己的目录路径而不是更善变的最佳方法是什么pwd
?