llvm-project/lldb/gtest/make/Makefile.rules

91 lines
2.9 KiB
Makefile

# Retrieve this Makefile's location.
THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
# Set default target to be test
.DEFAULT_GOAL := test
# Set up GTEST for canonical Linux and MacOSX source trees.
ifneq ($(wildcard $(THIS_FILE_DIR)../../llvm/utils/unittest/googletest),)
# Assume lldb/llvm (MacOSX Xcode) directory form.
LLVM_BASE_DIR := $(realpath $(THIS_FILE_DIR)../../llvm)
else
# Assume llvm/tools/lldb (Non-MacOSX) directory form.
LLVM_BASE_DIR := $(realpath $(THIS_FILE_DIR)../../../..)
endif
ifeq ($(GTEST_DIR),)
GTEST_DIR := $(LLVM_BASE_DIR)/utils/unittest/googletest
endif
GTEST_INCLUDE_DIR := $(GTEST_DIR)/include
ifeq ($(LLVM_BUILD_DIR),)
ifneq ($(wildcard $(THIS_FILE_DIR)../../llvm-build/Release+Asserts/x86_64/Release+Asserts),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../llvm-build/Release+Asserts/x86_64/Release+Asserts)
else ifneq ($(wildcard $(THIS_FILE_DIR)../../../../../build-debug/lib),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../../../../build-debug)
endif
endif
ifeq ($(LLVM_BUILD_DIR),)
$(error Could not find LLVM build output dir, please set it with LLVM_BUILD_DIR)
endif
GTEST_STATIC_LIB_DIR := $(LLVM_BUILD_DIR)/lib
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
ifneq ($(wildcard $(LLVM_BUILD_DIR)/../include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/../include)
else ifneq ($(wildcard $(LLVM_BUILD_DIR)/include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/include)
endif
endif
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
$(error Could not find LLVM build directory include dir, please set it with LLVM_BUILD_INCLUDE_DIR)
endif
# $(info LLVM_BASE_DIR = $(LLVM_BASE_DIR))
# $(info LLVM_BUILD_DIR = $(LLVM_BUILD_DIR))
# $(info GTEST_DIR = $(GTEST_DIR))
# $(info GTEST_INCLUDE_DIR = $(GTEST_INCLUDE_DIR))
# $(info GTEST_STATIC_LIB_DIR = $(GTEST_STATIC_LIB_DIR))
# Note lldb/include is already added for us by test/make/Makefile.rules
LLDB_HEADER_DIRS += \
-I $(realpath $(THIS_FILE_DIR)../../source/)
# -I $(realpath $(THIS_FILE_DIR)../../include)
CFLAGS_EXTRAS += -I $(GTEST_INCLUDE_DIR) -I $(LLVM_BASE_DIR)/include -I $(LLVM_BUILD_INCLUDE_DIR) $(LLDB_HEADER_DIRS)
LD_EXTRAS += $(GTEST_STATIC_LIB_DIR)/libgtest.a $(GTEST_STATIC_LIB_DIR)/libgtest_main.a $(GTEST_STATIC_LIB_DIR)/libLLVMSupport.a
.PHONY: clean test
# Handle subdirs
ifneq ($(SUBDIRS),)
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
test:: subdirs
clean:: subdirs
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
endif
# Skip pulling in build rules when we don't have an CXX_SOURCES defined.
# If this is the case, then we're just recursing directories.
# Consider doing directory handling/makefile running via a python script
# like test/dotest.py.
ifneq ($(CXX_SOURCES),)
include $(realpath $(THIS_FILE_DIR)../../test/make/Makefile.rules)
test:: $(EXE)
$(realpath $(EXE))
endif