ifneq ($(MakefileCommonIn),)
PreConditions += $(MakefileCommon)
endif
ifneq ($(MakefileCommonIn),)
PreConditions += $(MakefileCommon)
endif
ifneq ($(MakefileConfigIn),)
PreConditions += $(MakefileConfig)
endif
ifneq ($(MakefileConfigIn),)
PreConditions += $(MakefileConfig)
endif
ifndef GCCLD
GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
endif
ifndef GCCLD
GCCLD := $(LLVMToolDir)/gccld$(EXEEXT)
endif
LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
endif
ifndef LLI
LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT)
endif
ifndef LLI
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
endif
LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs))
endif
-ifneq ($(strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
+ifeq ($(strip $(filter clean clean-local dist-clean,$(MAKECMDGOALS))),)
-ProjLibsOptions := $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
-ProjLibsPaths := $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
+
+# If LLVM_CONFIG doesn't exist, build it. This can happen if you do a make
+# clean in tools, then do a make in tools (instead of at the top level).
+$(LLVM_CONFIG):
+ @echo "*** llvm-config doesn't exist - rebuilding it."
+ @$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
+
+$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
+
+ProjLibsOptions = $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS))
+ProjLibsPaths = $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
endif
ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
endif
-#---------------------------------------------------------
-# Tell make that we need to rebuild subdirectories before
-# we can link the tool. This affects things like LLI which
-# has library subdirectories.
-#---------------------------------------------------------
-$(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS))
-
#---------------------------------------------------------
# Provide targets for building the tools
#---------------------------------------------------------
#---------------------------------------------------------
# Provide targets for building the tools
#---------------------------------------------------------
$(ToolBuildPath): $(ToolDir)/.dir
endif
$(ToolBuildPath): $(ToolDir)/.dir
endif
-$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
+$(ToolBuildPath): $(ObjectsO) $(LLVM_CONFIG) $(ProjLibsPaths) $(LLVMLibsPaths)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
$(Verb) $(LTLink) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
ifndef DISABLE_AUTO_DEPENDENCIES
# If its not one of the cleaning targets
ifndef DISABLE_AUTO_DEPENDENCIES
# If its not one of the cleaning targets
-ifneq ($(strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
+ifneq ($(strip $(filter-out clean clean-local dist-clean,$(MAKECMDGOALS)))),)
# Get the list of dependency files
DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))
# Get the list of dependency files
DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources)))