2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Clients fill in the source files to build
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# C_SOURCES := main.c
|
|
|
|
# CXX_SOURCES :=
|
|
|
|
# OBJC_SOURCES :=
|
|
|
|
# OBJCXX_SOURCES :=
|
|
|
|
# DYLIB_C_SOURCES :=
|
2018-01-31 02:29:16 +08:00
|
|
|
# DYLIB_OBJC_SOURCES :=
|
2012-01-11 09:42:58 +08:00
|
|
|
# DYLIB_CXX_SOURCES :=
|
|
|
|
#
|
|
|
|
# Specifying DYLIB_ONLY has the effect of building dylib only, skipping
|
|
|
|
# the building of the a.out executable program. For example,
|
|
|
|
# DYLIB_ONLY := YES
|
|
|
|
#
|
2012-01-17 08:58:08 +08:00
|
|
|
# Also might be of interest:
|
2012-01-11 09:59:55 +08:00
|
|
|
# FRAMEWORK_INCLUDES (Darwin only) :=
|
2015-04-21 02:07:55 +08:00
|
|
|
# CFLAGS_EXTRAS :=
|
2012-01-11 09:59:55 +08:00
|
|
|
# LD_EXTRAS :=
|
2013-07-03 02:13:13 +08:00
|
|
|
# SPLIT_DEBUG_SYMBOLS := YES
|
2015-04-21 02:07:55 +08:00
|
|
|
# CROSS_COMPILE :=
|
2012-01-17 08:58:08 +08:00
|
|
|
#
|
|
|
|
# And test/functionalities/archives/Makefile:
|
|
|
|
# MAKE_DSYM := NO
|
|
|
|
# ARCHIVE_NAME := libfoo.a
|
|
|
|
# ARCHIVE_C_SOURCES := a.c b.c
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
# Uncomment line below for debugging shell commands
|
|
|
|
# SHELL = /bin/sh -x
|
|
|
|
|
2018-01-31 02:29:16 +08:00
|
|
|
SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))/
|
2018-08-21 23:46:15 +08:00
|
|
|
BUILDDIR := $(shell pwd)
|
2018-01-31 02:29:16 +08:00
|
|
|
THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/
|
2015-11-11 05:56:04 +08:00
|
|
|
LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
|
2014-08-14 01:44:53 +08:00
|
|
|
|
2017-03-07 22:57:37 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# If OS is not defined, use 'uname -s' to determine the OS name.
|
|
|
|
#
|
[lit, lldbsuite] Update the lldbsuite to correctly run tests on windows and windows server
Summary:
The new script to run the lldbtests as part of lit invokes each test by calling dotest.py, however, we cannot rely on the system to always correctly interpret the script as python causing the tests to be unresolved on windows (at least). To fix this, we need to make sure that the first parameter in the command line is the python executable itself.
In Makefile.rules, there are a number of windows specific definitions that rely on the HOST_OS being set as Windows_NT but the logic detecting the OS currently does not detect server versions of windows correctly. This change updates the logic to detect windows server as well.
Reviewers: asmith, labath, JDevlieghere, zturner
Reviewed By: JDevlieghere, zturner
Subscribers: zturner, llvm-commits
Differential Revision: https://reviews.llvm.org/D46020
llvm-svn: 330740
2018-04-25 01:08:05 +08:00
|
|
|
# uname on Windows gives "windows32" or "server version windows32", but most
|
|
|
|
# environments standardize on "Windows_NT", so we'll make it consistent here.
|
|
|
|
# When running tests from Visual Studio, the environment variable isn't
|
|
|
|
# inherited all the way down to the process spawned for make.
|
2017-03-07 22:57:37 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
HOST_OS = $(shell uname -s)
|
[lit, lldbsuite] Update the lldbsuite to correctly run tests on windows and windows server
Summary:
The new script to run the lldbtests as part of lit invokes each test by calling dotest.py, however, we cannot rely on the system to always correctly interpret the script as python causing the tests to be unresolved on windows (at least). To fix this, we need to make sure that the first parameter in the command line is the python executable itself.
In Makefile.rules, there are a number of windows specific definitions that rely on the HOST_OS being set as Windows_NT but the logic detecting the OS currently does not detect server versions of windows correctly. This change updates the logic to detect windows server as well.
Reviewers: asmith, labath, JDevlieghere, zturner
Reviewed By: JDevlieghere, zturner
Subscribers: zturner, llvm-commits
Differential Revision: https://reviews.llvm.org/D46020
llvm-svn: 330740
2018-04-25 01:08:05 +08:00
|
|
|
ifneq (,$(findstring windows32,$(HOST_OS)))
|
2017-03-07 22:57:37 +08:00
|
|
|
HOST_OS = Windows_NT
|
|
|
|
endif
|
|
|
|
ifeq "$(OS)" ""
|
|
|
|
OS = $(HOST_OS)
|
|
|
|
endif
|
|
|
|
|
2018-11-16 04:56:44 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# If OS is Windows, force SHELL to be cmd
|
|
|
|
#
|
|
|
|
# Some versions of make on Windows will search for other shells such as
|
|
|
|
# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
|
|
|
|
# so default to using cmd.exe.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifeq "$(OS)" "Windows_NT"
|
|
|
|
SHELL = $(WINDIR)\system32\cmd.exe
|
|
|
|
endif
|
|
|
|
|
2018-11-20 02:41:33 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# If the OS is Windows use double-quotes in commands
|
|
|
|
#
|
|
|
|
# For other operating systems, single-quotes work fine, but on Windows
|
|
|
|
# we strictly required double-quotes
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifeq "$(HOST_OS)" "Windows_NT"
|
|
|
|
JOIN_CMD = &
|
|
|
|
QUOTE = "
|
|
|
|
FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = "
|
|
|
|
else
|
|
|
|
JOIN_CMD = ;
|
|
|
|
QUOTE = '
|
|
|
|
FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = '
|
|
|
|
endif
|
|
|
|
|
2015-06-03 05:38:10 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
|
|
|
|
# from the triple alone
|
|
|
|
#----------------------------------------------------------------------
|
2017-03-03 21:49:34 +08:00
|
|
|
ARCH_CFLAGS :=
|
2015-06-03 05:38:10 +08:00
|
|
|
ifneq "$(TRIPLE)" ""
|
|
|
|
triple_space = $(subst -, ,$(TRIPLE))
|
|
|
|
ARCH =$(word 1, $(triple_space))
|
|
|
|
TRIPLE_VENDOR =$(word 2, $(triple_space))
|
2015-11-05 08:46:25 +08:00
|
|
|
triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/')
|
2015-06-03 05:38:10 +08:00
|
|
|
TRIPLE_OS =$(word 1, $(triple_os_and_version))
|
|
|
|
TRIPLE_VERSION =$(word 2, $(triple_os_and_version))
|
|
|
|
ifeq "$(TRIPLE_VENDOR)" "apple"
|
|
|
|
ifeq "$(TRIPLE_OS)" "ios"
|
2018-11-20 02:41:33 +08:00
|
|
|
CODESIGN := codesign
|
|
|
|
ifeq "$(SDKROOT)" ""
|
2015-06-03 05:38:10 +08:00
|
|
|
# Set SDKROOT if it wasn't set
|
|
|
|
ifneq (,$(findstring arm,$(ARCH)))
|
|
|
|
SDKROOT = $(shell xcrun --sdk iphoneos --show-sdk-path)
|
2015-06-03 05:42:31 +08:00
|
|
|
ifeq "$(TRIPLE_VERSION)" ""
|
|
|
|
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
|
|
|
|
endif
|
2017-03-03 21:49:34 +08:00
|
|
|
ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
|
2015-06-03 05:38:10 +08:00
|
|
|
else
|
|
|
|
SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
|
2015-06-03 05:42:31 +08:00
|
|
|
ifeq "$(TRIPLE_VERSION)" ""
|
|
|
|
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
|
|
|
|
endif
|
2017-03-03 21:49:34 +08:00
|
|
|
ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
|
2015-06-03 05:38:10 +08:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2017-09-26 02:19:39 +08:00
|
|
|
ifeq "$(TRIPLE_OS)" "watchos"
|
2018-11-01 03:42:02 +08:00
|
|
|
CODESIGN := codesign
|
|
|
|
ifeq "$(SDKROOT)" ""
|
2017-09-26 02:19:39 +08:00
|
|
|
# Set SDKROOT if it wasn't set
|
|
|
|
ifneq (,$(findstring arm,$(ARCH)))
|
|
|
|
SDKROOT = $(shell xcrun --sdk watchos --show-sdk-path)
|
|
|
|
ifeq "$(TRIPLE_VERSION)" ""
|
|
|
|
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
|
|
|
|
endif
|
|
|
|
ARCH_CFLAGS :=-mwatchos-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
|
|
|
|
else
|
|
|
|
SDKROOT = $(shell xcrun --sdk watchsimulator --show-sdk-path)
|
|
|
|
ifeq "$(TRIPLE_VERSION)" ""
|
|
|
|
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
|
|
|
|
endif
|
|
|
|
ARCH_CFLAGS :=-mwatchos-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2015-06-03 05:38:10 +08:00
|
|
|
endif
|
|
|
|
endif
|
2017-03-03 21:49:34 +08:00
|
|
|
ifeq "$(OS)" "Android"
|
|
|
|
include $(THIS_FILE_DIR)/Android.rules
|
|
|
|
endif
|
2015-06-03 05:38:10 +08:00
|
|
|
|
2015-04-16 07:38:23 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# If ARCH is not defined, default to x86_64.
|
2010-09-17 04:54:06 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifeq "$(ARCH)" ""
|
2014-12-02 07:13:41 +08:00
|
|
|
ifeq "$(OS)" "Windows_NT"
|
|
|
|
ARCH = x86
|
|
|
|
else
|
2010-09-17 04:54:06 +08:00
|
|
|
ARCH = x86_64
|
|
|
|
endif
|
2014-12-02 07:13:41 +08:00
|
|
|
endif
|
2010-09-17 04:54:06 +08:00
|
|
|
|
2011-01-15 04:46:49 +08:00
|
|
|
#----------------------------------------------------------------------
|
2011-08-24 05:54:10 +08:00
|
|
|
# CC defaults to clang.
|
2011-08-25 02:12:53 +08:00
|
|
|
#
|
|
|
|
# If you change the defaults of CC, be sure to also change it in the file
|
|
|
|
# test/plugins/builder_base.py, which provides a Python way to return the
|
|
|
|
# value of the make variable CC -- getCompiler().
|
|
|
|
#
|
2011-01-15 04:55:13 +08:00
|
|
|
# See also these functions:
|
|
|
|
# o cxx_compiler
|
|
|
|
# o cxx_linker
|
2011-01-15 04:46:49 +08:00
|
|
|
#----------------------------------------------------------------------
|
2011-08-24 05:54:10 +08:00
|
|
|
CC ?= clang
|
2011-01-15 04:46:49 +08:00
|
|
|
ifeq "$(CC)" "cc"
|
2015-05-27 12:42:54 +08:00
|
|
|
ifneq "$(shell which clang)" ""
|
|
|
|
CC = clang
|
|
|
|
else ifneq "$(shell which clang-3.5)" ""
|
|
|
|
CC = clang-3.5
|
|
|
|
else ifneq "$(shell which gcc)" ""
|
|
|
|
CC = gcc
|
|
|
|
endif
|
2011-01-15 04:46:49 +08:00
|
|
|
endif
|
|
|
|
|
2013-01-25 08:31:48 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# ARCHFLAG is the flag used to tell the compiler which architecture
|
|
|
|
# to compile for. The default is the flag that clang accepts.
|
|
|
|
#----------------------------------------------------------------------
|
2015-04-16 09:18:05 +08:00
|
|
|
ARCHFLAG ?= -arch
|
2013-01-25 08:31:48 +08:00
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Change any build/tool options needed
|
|
|
|
#----------------------------------------------------------------------
|
2011-06-21 03:06:04 +08:00
|
|
|
ifeq "$(OS)" "Darwin"
|
2018-04-12 17:25:32 +08:00
|
|
|
DS := $(DSYMUTIL)
|
2011-06-21 03:06:04 +08:00
|
|
|
DSFLAGS =
|
|
|
|
DSYM = $(EXE).dSYM
|
2015-04-21 02:07:55 +08:00
|
|
|
AR := $(CROSS_COMPILE)libtool
|
2012-01-13 07:09:42 +08:00
|
|
|
ARFLAGS := -static -o
|
2013-01-25 08:31:48 +08:00
|
|
|
else
|
2015-04-21 02:07:55 +08:00
|
|
|
AR := $(CROSS_COMPILE)ar
|
2013-01-25 08:31:48 +08:00
|
|
|
# On non-Apple platforms, -arch becomes -m
|
|
|
|
ARCHFLAG := -m
|
|
|
|
|
2014-08-14 01:44:53 +08:00
|
|
|
# i386, i686, x86 -> 32
|
2014-08-01 05:07:41 +08:00
|
|
|
# amd64, x86_64, x64 -> 64
|
2014-02-21 02:40:01 +08:00
|
|
|
ifeq "$(ARCH)" "amd64"
|
2014-08-01 05:07:41 +08:00
|
|
|
override ARCH := $(subst amd64,64,$(ARCH))
|
2014-02-21 02:40:01 +08:00
|
|
|
endif
|
2013-01-25 08:31:48 +08:00
|
|
|
ifeq "$(ARCH)" "x86_64"
|
2014-08-01 05:07:41 +08:00
|
|
|
override ARCH := $(subst x86_64,64,$(ARCH))
|
|
|
|
endif
|
|
|
|
ifeq "$(ARCH)" "x64"
|
|
|
|
override ARCH := $(subst x64,64,$(ARCH))
|
2013-01-25 08:31:48 +08:00
|
|
|
endif
|
2014-08-14 01:44:53 +08:00
|
|
|
ifeq "$(ARCH)" "x86"
|
|
|
|
override ARCH := $(subst x86,32,$(ARCH))
|
|
|
|
endif
|
2013-01-25 08:31:48 +08:00
|
|
|
ifeq "$(ARCH)" "i386"
|
2014-08-01 05:07:41 +08:00
|
|
|
override ARCH := $(subst i386,32,$(ARCH))
|
|
|
|
endif
|
|
|
|
ifeq "$(ARCH)" "i686"
|
|
|
|
override ARCH := $(subst i686,32,$(ARCH))
|
2013-01-25 08:31:48 +08:00
|
|
|
endif
|
2014-11-12 23:13:58 +08:00
|
|
|
ifeq "$(ARCH)" "powerpc"
|
|
|
|
override ARCH := $(subst powerpc,32,$(ARCH))
|
|
|
|
endif
|
|
|
|
ifeq "$(ARCH)" "powerpc64"
|
|
|
|
override ARCH := $(subst powerpc64,64,$(ARCH))
|
|
|
|
endif
|
Add float/vector registers for ppc64le
Summary: Add read and write functions for VSX, VMX and float registers and fix watchpoint size
Reviewers: clayborg
Reviewed By: clayborg
Subscribers: eugene, labath, clayborg, nemanjai, kbarton, JDevlieghere, anajuliapc, gut, lbianc, lldb-commits
Differential Revision: https://reviews.llvm.org/D39487
Patch by: Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>
llvm-svn: 317329
2017-11-03 23:22:36 +08:00
|
|
|
ifeq "$(ARCH)" "powerpc64le"
|
|
|
|
override ARCH := $(subst powerpc64le,64,$(ARCH))
|
|
|
|
endif
|
2015-03-13 19:36:47 +08:00
|
|
|
ifeq "$(ARCH)" "aarch64"
|
|
|
|
override ARCH :=
|
|
|
|
override ARCHFLAG :=
|
|
|
|
endif
|
2015-11-24 18:35:03 +08:00
|
|
|
ifeq "$(ARCH)" "arm"
|
|
|
|
override ARCH :=
|
|
|
|
override ARCHFLAG :=
|
|
|
|
endif
|
2016-04-14 22:28:34 +08:00
|
|
|
ifeq "$(ARCH)" "s390x"
|
|
|
|
override ARCH :=
|
|
|
|
override ARCHFLAG :=
|
|
|
|
endif
|
2015-12-01 13:24:17 +08:00
|
|
|
ifeq "$(findstring mips,$(ARCH))" "mips"
|
|
|
|
override ARCHFLAG := -
|
|
|
|
endif
|
2013-07-03 02:13:13 +08:00
|
|
|
|
|
|
|
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
|
|
|
|
DSYM = $(EXE).debug
|
|
|
|
endif
|
2011-06-21 03:06:04 +08:00
|
|
|
endif
|
|
|
|
|
2015-10-08 06:11:52 +08:00
|
|
|
LIMIT_DEBUG_INFO_FLAGS =
|
2015-12-19 08:52:29 +08:00
|
|
|
NO_LIMIT_DEBUG_INFO_FLAGS =
|
2016-04-20 02:20:11 +08:00
|
|
|
MODULE_DEBUG_INFO_FLAGS =
|
2015-10-08 06:11:52 +08:00
|
|
|
ifneq (,$(findstring clang,$(CC)))
|
|
|
|
LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info
|
2015-12-19 08:52:29 +08:00
|
|
|
NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info
|
2016-04-20 02:20:11 +08:00
|
|
|
MODULE_DEBUG_INFO_FLAGS += -gmodules
|
2015-10-08 06:11:52 +08:00
|
|
|
endif
|
|
|
|
|
2015-12-16 08:22:08 +08:00
|
|
|
DEBUG_INFO_FLAG ?= -g
|
|
|
|
|
|
|
|
CFLAGS ?= $(DEBUG_INFO_FLAG) -O0 -fno-builtin
|
2015-04-16 09:18:05 +08:00
|
|
|
ifeq "$(OS)" "Darwin"
|
2017-10-26 07:56:17 +08:00
|
|
|
CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include
|
2015-04-16 09:18:05 +08:00
|
|
|
else
|
2017-10-26 07:56:17 +08:00
|
|
|
CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include
|
2015-04-16 09:18:05 +08:00
|
|
|
endif
|
2015-11-05 08:46:25 +08:00
|
|
|
|
2018-01-31 02:29:16 +08:00
|
|
|
CFLAGS += -I$(SRCDIR) -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR)
|
2017-12-04 21:31:56 +08:00
|
|
|
CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
|
2013-01-25 08:31:48 +08:00
|
|
|
|
2014-03-13 10:47:14 +08:00
|
|
|
# Use this one if you want to build one part of the result without debug information:
|
2015-04-16 09:18:05 +08:00
|
|
|
ifeq "$(OS)" "Darwin"
|
2017-10-26 07:56:17 +08:00
|
|
|
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
|
2015-04-16 09:18:05 +08:00
|
|
|
else
|
2017-10-26 07:56:17 +08:00
|
|
|
CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)
|
2015-04-16 09:18:05 +08:00
|
|
|
endif
|
2014-03-13 10:47:14 +08:00
|
|
|
|
2015-10-07 18:02:17 +08:00
|
|
|
ifeq "$(MAKE_DWO)" "YES"
|
|
|
|
CFLAGS += -gsplit-dwarf
|
|
|
|
endif
|
|
|
|
|
2018-11-17 00:19:07 +08:00
|
|
|
# Use a shared module cache when building in the default test build directory.
|
2018-11-20 02:41:33 +08:00
|
|
|
CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed $(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE))
|
2018-11-17 00:19:07 +08:00
|
|
|
|
2018-11-17 06:44:57 +08:00
|
|
|
ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
|
|
|
|
CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
|
|
|
|
$(warning failed to set the shared clang module cache dir)
|
2018-11-17 00:19:07 +08:00
|
|
|
endif
|
2018-01-26 02:01:27 +08:00
|
|
|
|
|
|
|
MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
|
|
|
|
|
2016-05-26 21:57:03 +08:00
|
|
|
ifeq "$(MAKE_GMODULES)" "YES"
|
2018-01-26 02:01:27 +08:00
|
|
|
CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)
|
2018-10-02 06:27:42 +08:00
|
|
|
CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)
|
|
|
|
ifeq "$(OS)" "Darwin"
|
|
|
|
CXXFLAGS += -fcxx-modules
|
|
|
|
endif
|
2016-05-26 21:57:03 +08:00
|
|
|
endif
|
|
|
|
|
2018-06-22 21:13:29 +08:00
|
|
|
CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS)
|
2011-08-10 04:07:16 +08:00
|
|
|
LD = $(CC)
|
|
|
|
LDFLAGS ?= $(CFLAGS)
|
2017-03-03 21:49:34 +08:00
|
|
|
LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
|
2017-09-26 02:19:39 +08:00
|
|
|
ifeq (,$(filter $(OS), Windows_NT Android Darwin))
|
2015-12-15 20:11:00 +08:00
|
|
|
ifneq (,$(filter YES,$(ENABLE_THREADS)))
|
2015-05-21 08:19:15 +08:00
|
|
|
LDFLAGS += -pthread
|
2015-04-14 02:21:31 +08:00
|
|
|
endif
|
2014-08-14 01:44:53 +08:00
|
|
|
endif
|
2011-08-10 04:07:16 +08:00
|
|
|
OBJECTS =
|
|
|
|
EXE ?= a.out
|
|
|
|
|
2011-06-21 03:06:04 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
|
|
|
ifeq "$(OS)" "Darwin"
|
|
|
|
DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
|
2015-07-22 01:50:16 +08:00
|
|
|
DYLIB_EXECUTABLE_PATH ?= @executable_path
|
2015-04-14 02:21:31 +08:00
|
|
|
else ifeq "$(OS)" "Windows_NT"
|
|
|
|
DYLIB_FILENAME = $(DYLIB_NAME).dll
|
2011-06-21 03:06:04 +08:00
|
|
|
else
|
|
|
|
DYLIB_FILENAME = lib$(DYLIB_NAME).so
|
|
|
|
endif
|
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
2011-01-15 02:19:53 +08:00
|
|
|
# Function that returns the counterpart C++ compiler, given $(CC) as arg.
|
2016-10-21 02:01:19 +08:00
|
|
|
cxx_compiler_notdir = $(if $(findstring icc,$(1)), \
|
|
|
|
$(subst icc,icpc,$(1)), \
|
|
|
|
$(if $(findstring llvm-gcc,$(1)), \
|
|
|
|
$(subst llvm-gcc,llvm-g++,$(1)), \
|
|
|
|
$(if $(findstring gcc,$(1)), \
|
|
|
|
$(subst gcc,g++,$(1)), \
|
|
|
|
$(subst cc,c++,$(1)))))
|
2013-11-23 05:05:25 +08:00
|
|
|
cxx_compiler = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_compiler_notdir,$(notdir $(1)))),$(call cxx_compiler_notdir,$(1)))
|
2011-01-15 02:19:53 +08:00
|
|
|
|
|
|
|
# Function that returns the C++ linker, given $(CC) as arg.
|
2016-10-21 02:01:19 +08:00
|
|
|
cxx_linker_notdir = $(if $(findstring icc,$(1)), \
|
|
|
|
$(subst icc,icpc,$(1)), \
|
|
|
|
$(if $(findstring llvm-gcc,$(1)), \
|
|
|
|
$(subst llvm-gcc,llvm-g++,$(1)), \
|
|
|
|
$(if $(findstring gcc,$(1)), \
|
|
|
|
$(subst gcc,g++,$(1)), \
|
|
|
|
$(subst cc,c++,$(1)))))
|
2013-11-23 05:05:25 +08:00
|
|
|
cxx_linker = $(if $(findstring /,$(1)),$(join $(dir $(1)), $(call cxx_linker_notdir,$(notdir $(1)))),$(call cxx_linker_notdir,$(1)))
|
2010-09-30 09:22:34 +08:00
|
|
|
|
2016-08-18 00:45:34 +08:00
|
|
|
ifneq "$(OS)" "Darwin"
|
|
|
|
CLANG_OR_GCC := $(strip $(if $(findstring clang,$(CC)), \
|
|
|
|
$(findstring clang,$(CC)), \
|
|
|
|
$(if $(findstring gcc,$(CC)), \
|
|
|
|
$(findstring gcc,$(CC)), \
|
|
|
|
cc)))
|
|
|
|
|
|
|
|
CC_LASTWORD := $(strip $(lastword $(subst -, ,$(CC))))
|
|
|
|
|
|
|
|
replace_with = $(strip $(if $(findstring $(3),$(CC_LASTWORD)), \
|
|
|
|
$(subst $(3),$(1),$(2)), \
|
|
|
|
$(subst $(3),$(1),$(subst -$(CC_LASTWORD),,$(2)))))
|
|
|
|
|
|
|
|
ifeq "$(notdir $(CC))" "$(CC)"
|
|
|
|
replace_cc_with = $(call replace_with,$(1),$(CC),$(CLANG_OR_GCC))
|
|
|
|
else
|
|
|
|
replace_cc_with = $(join $(dir $(CC)),$(call replace_with,$(1),$(notdir $(CC)),$(CLANG_OR_GCC)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
OBJCOPY ?= $(call replace_cc_with,objcopy)
|
|
|
|
ARCHIVER ?= $(call replace_cc_with,ar)
|
|
|
|
override AR = $(ARCHIVER)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef PIE
|
2018-11-20 02:41:33 +08:00
|
|
|
LDFLAGS += -pie
|
2016-08-18 00:45:34 +08:00
|
|
|
endif
|
2016-08-02 21:17:49 +08:00
|
|
|
|
2014-08-14 01:44:53 +08:00
|
|
|
#----------------------------------------------------------------------
|
2014-12-02 07:13:41 +08:00
|
|
|
# Windows specific options
|
2014-08-14 01:44:53 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifeq "$(OS)" "Windows_NT"
|
|
|
|
ifneq (,$(findstring clang,$(CC)))
|
2014-12-02 07:13:41 +08:00
|
|
|
# Clang for Windows doesn't support C++ Exceptions
|
2014-08-14 01:44:53 +08:00
|
|
|
CXXFLAGS += -fno-exceptions
|
|
|
|
CXXFLAGS += -D_HAS_EXCEPTIONS=0
|
2017-03-10 03:54:23 +08:00
|
|
|
|
|
|
|
# MSVC 2015 or higher is required, which depends on c++14, so
|
|
|
|
# append these values unconditionally.
|
|
|
|
CXXFLAGS += -fms-compatibility-version=19.0
|
|
|
|
override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
|
|
|
|
|
2014-12-02 07:13:41 +08:00
|
|
|
# The MSVC linker doesn't understand long section names
|
|
|
|
# generated by the clang compiler.
|
|
|
|
LDFLAGS += -fuse-ld=lld
|
2014-08-14 01:44:53 +08:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-02-25 21:02:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
2013-06-06 03:32:34 +08:00
|
|
|
# C++ standard library options
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifeq (1,$(USE_LIBSTDCPP))
|
|
|
|
# Clang requires an extra flag: -stdlib=libstdc++
|
|
|
|
ifneq (,$(findstring clang,$(CC)))
|
2016-05-13 06:33:02 +08:00
|
|
|
CXXFLAGS += -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP
|
2013-06-06 03:32:34 +08:00
|
|
|
LDFLAGS += -stdlib=libstdc++
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-06-14 05:27:14 +08:00
|
|
|
ifeq (1,$(USE_LIBCPP))
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-30 05:01:14 +08:00
|
|
|
CXXFLAGS += -DLLDB_USING_LIBCPP
|
|
|
|
ifeq "$(OS)" "Linux"
|
|
|
|
ifneq (,$(findstring clang,$(CC)))
|
2017-03-13 20:07:48 +08:00
|
|
|
CXXFLAGS += -stdlib=libc++
|
2015-09-19 06:26:34 +08:00
|
|
|
LDFLAGS += -stdlib=libc++
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-30 05:01:14 +08:00
|
|
|
else
|
|
|
|
CXXFLAGS += -isystem /usr/include/c++/v1
|
|
|
|
LDFLAGS += -lc++
|
2015-09-19 06:26:34 +08:00
|
|
|
endif
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-30 05:01:14 +08:00
|
|
|
else ifeq "$(OS)" "Android"
|
|
|
|
# Nothing to do, this is already handled in
|
|
|
|
# Android.rules.
|
|
|
|
else
|
|
|
|
CXXFLAGS += -stdlib=libc++
|
|
|
|
LDFLAGS += -stdlib=libc++
|
2013-06-14 05:27:14 +08:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# dylib settings
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(DYLIB_C_SOURCES))" ""
|
|
|
|
DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))
|
|
|
|
endif
|
|
|
|
|
2012-02-23 07:57:45 +08:00
|
|
|
ifneq "$(strip $(DYLIB_OBJC_SOURCES))" ""
|
|
|
|
DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o))
|
|
|
|
endif
|
|
|
|
|
2012-01-10 08:00:15 +08:00
|
|
|
ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""
|
2018-11-20 02:41:33 +08:00
|
|
|
DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o))
|
|
|
|
CXX = $(call cxx_compiler,$(CC))
|
|
|
|
LD = $(call cxx_linker,$(CC))
|
2012-01-10 08:00:15 +08:00
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
2016-04-20 02:20:11 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have a precompiled header
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(PCH_CXX_SOURCE))" ""
|
2018-11-20 02:41:33 +08:00
|
|
|
PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch)
|
|
|
|
PCHFLAGS = -include $(PCH_CXX_SOURCE)
|
2016-04-20 02:20:11 +08:00
|
|
|
endif
|
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any C source files
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(C_SOURCES))" ""
|
|
|
|
OBJECTS +=$(strip $(C_SOURCES:.c=.o))
|
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any C++ source files
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(CXX_SOURCES))" ""
|
|
|
|
OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
|
2010-09-30 09:22:34 +08:00
|
|
|
CXX = $(call cxx_compiler,$(CC))
|
2011-01-15 02:19:53 +08:00
|
|
|
LD = $(call cxx_linker,$(CC))
|
2010-08-24 07:56:08 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any ObjC source files
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(OBJC_SOURCES))" ""
|
|
|
|
OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
|
|
|
|
LDFLAGS +=-lobjc
|
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any ObjC++ source files
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(OBJCXX_SOURCES))" ""
|
|
|
|
OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
|
2010-09-30 09:22:34 +08:00
|
|
|
CXX = $(call cxx_compiler,$(CC))
|
2011-01-15 02:19:53 +08:00
|
|
|
LD = $(call cxx_linker,$(CC))
|
2012-04-25 07:05:07 +08:00
|
|
|
ifeq "$(findstring lobjc,$(LDFLAGS))" ""
|
2010-08-24 07:56:08 +08:00
|
|
|
LDFLAGS +=-lobjc
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2012-01-13 07:09:42 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any C source files for archive
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(ARCHIVE_C_SOURCES))" ""
|
|
|
|
ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o))
|
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any C++ source files for archive
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" ""
|
|
|
|
ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o))
|
|
|
|
CXX = $(call cxx_compiler,$(CC))
|
|
|
|
LD = $(call cxx_linker,$(CC))
|
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any ObjC source files for archive
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" ""
|
|
|
|
ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o))
|
|
|
|
LDFLAGS +=-lobjc
|
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we have any ObjC++ source files for archive
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" ""
|
|
|
|
ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o))
|
|
|
|
CXX = $(call cxx_compiler,$(CC))
|
|
|
|
LD = $(call cxx_linker,$(CC))
|
2012-04-25 07:05:07 +08:00
|
|
|
ifeq "$(findstring lobjc,$(LDFLAGS))" ""
|
2012-01-13 07:09:42 +08:00
|
|
|
LDFLAGS +=-lobjc
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-07-25 05:39:24 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Check if we are compiling with gcc 4.6
|
|
|
|
#----------------------------------------------------------------------
|
2015-05-30 03:52:02 +08:00
|
|
|
ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" ""
|
|
|
|
ifneq "$(filter g++,$(CXX))" ""
|
|
|
|
CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3)
|
2013-07-25 05:39:24 +08:00
|
|
|
ifeq "$(CXXVERSION)" "4.6"
|
2018-11-20 02:41:33 +08:00
|
|
|
# GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x
|
|
|
|
# instead. FIXME: remove once GCC version is upgraded.
|
2016-09-07 06:40:11 +08:00
|
|
|
override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS))
|
2013-07-25 05:39:24 +08:00
|
|
|
endif
|
|
|
|
endif
|
2015-05-30 03:52:02 +08:00
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
2016-10-21 02:01:19 +08:00
|
|
|
ifeq ($(findstring clang, $(CXX)), clang)
|
2018-11-20 02:41:33 +08:00
|
|
|
CXXFLAGS += --driver-mode=g++
|
2016-10-21 02:01:19 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq "$(CXX)" ""
|
2018-11-20 02:41:33 +08:00
|
|
|
ifeq ($(findstring clang, $(LD)), clang)
|
|
|
|
LDFLAGS += --driver-mode=g++
|
|
|
|
endif
|
2016-10-21 02:01:19 +08:00
|
|
|
endif
|
|
|
|
|
2012-01-10 08:41:11 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# DYLIB_ONLY variable can be used to skip the building of a.out.
|
|
|
|
# See the sections below regarding dSYM file as well as the building of
|
|
|
|
# EXE from all the objects.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Compile the executable from all the objects.
|
|
|
|
#----------------------------------------------------------------------
|
2012-01-10 08:41:11 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
|
|
|
ifeq "$(DYLIB_ONLY)" ""
|
2012-01-13 07:09:42 +08:00
|
|
|
$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME)
|
2013-10-18 04:09:33 +08:00
|
|
|
$(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
|
2012-01-10 08:41:11 +08:00
|
|
|
else
|
|
|
|
EXE = $(DYLIB_FILENAME)
|
|
|
|
endif
|
|
|
|
else
|
2012-01-13 07:09:42 +08:00
|
|
|
$(EXE) : $(OBJECTS) $(ARCHIVE_NAME)
|
2018-11-19 04:48:25 +08:00
|
|
|
$(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
|
2018-10-17 02:14:30 +08:00
|
|
|
ifneq "$(CODESIGN)" ""
|
|
|
|
$(CODESIGN) -s - "$(EXE)"
|
|
|
|
endif
|
2012-01-13 07:09:42 +08:00
|
|
|
endif
|
|
|
|
|
2018-01-31 02:29:16 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
$(DSYM) : $(EXE)
|
|
|
|
ifeq "$(OS)" "Darwin"
|
|
|
|
ifneq "$(MAKE_DSYM)" "NO"
|
|
|
|
"$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
|
|
|
|
else
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
|
|
|
|
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
|
|
|
|
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2012-01-13 07:09:42 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Make the archive
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ifneq "$(ARCHIVE_NAME)" ""
|
|
|
|
ifeq "$(OS)" "Darwin"
|
|
|
|
$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS)
|
|
|
|
$(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
|
|
|
|
$(RM) $(ARCHIVE_OBJECTS)
|
|
|
|
else
|
|
|
|
$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj)))
|
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Make the dylib
|
|
|
|
#----------------------------------------------------------------------
|
2015-03-14 05:51:11 +08:00
|
|
|
$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL
|
|
|
|
|
2018-02-09 07:10:29 +08:00
|
|
|
ifneq "$(OS)" "Windows_NT"
|
|
|
|
$(DYLIB_OBJECTS) : CFLAGS += -fPIC
|
|
|
|
$(DYLIB_OBJECTS) : CXXFLAGS += -fPIC
|
|
|
|
endif
|
|
|
|
|
2011-06-21 03:06:04 +08:00
|
|
|
$(DYLIB_FILENAME) : $(DYLIB_OBJECTS)
|
|
|
|
ifeq "$(OS)" "Darwin"
|
2015-07-22 01:50:16 +08:00
|
|
|
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)"
|
2018-10-17 02:14:30 +08:00
|
|
|
ifneq "$(CODESIGN)" ""
|
|
|
|
$(CODESIGN) -s - "$(DYLIB_FILENAME)"
|
|
|
|
endif
|
2012-09-21 05:43:11 +08:00
|
|
|
ifneq "$(MAKE_DSYM)" "NO"
|
|
|
|
ifneq "$(DS)" ""
|
2015-01-22 03:30:00 +08:00
|
|
|
"$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"
|
2012-09-21 05:43:11 +08:00
|
|
|
endif
|
|
|
|
endif
|
2011-06-21 03:06:04 +08:00
|
|
|
else
|
2018-11-19 04:48:25 +08:00
|
|
|
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
|
2013-07-03 02:13:13 +08:00
|
|
|
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
|
2015-04-02 19:09:28 +08:00
|
|
|
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
|
|
|
|
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
|
2013-07-03 02:13:13 +08:00
|
|
|
endif
|
2011-06-21 03:06:04 +08:00
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
2016-04-20 02:20:11 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Make the precompiled header and compile C++ sources against it
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifneq "$(PCH_OUTPUT)" ""
|
|
|
|
$(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
|
2018-01-31 02:29:16 +08:00
|
|
|
$(CXX) $(CXXFLAGS) -x c++-header -o $@ $<
|
2016-04-20 02:20:11 +08:00
|
|
|
%.o : %.cpp $(PCH_OUTPUT)
|
2016-05-26 21:57:03 +08:00
|
|
|
$(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $<
|
2016-04-20 02:20:11 +08:00
|
|
|
#endif
|
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Automatic variables based on items already entered. Below we create
|
2015-03-14 05:51:11 +08:00
|
|
|
# an object's lists from the list of sources by replacing all entries
|
2010-08-24 07:56:08 +08:00
|
|
|
# that end with .c with .o, and we also create a list of prerequisite
|
|
|
|
# files by replacing all .c files with .d.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
PREREQS := $(OBJECTS:.o=.d)
|
2015-10-21 20:56:37 +08:00
|
|
|
DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo)
|
2010-08-25 00:35:00 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
|
|
|
DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)
|
2015-09-09 18:20:30 +08:00
|
|
|
DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)
|
2010-08-25 00:35:00 +08:00
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Rule for Generating Prerequisites Automatically using .d files and
|
|
|
|
# the compiler -MM option. The -M option will list all system headers,
|
|
|
|
# and the -MM option will list all non-system dependencies.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
%.d: %.c
|
2015-03-14 05:51:11 +08:00
|
|
|
@rm -f $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
$(CC) -M $(CFLAGS) $< > $@.tmp && \
|
2015-03-14 05:51:11 +08:00
|
|
|
sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
rm -f $@.tmp
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
%.d: %.cpp
|
2015-03-14 05:51:11 +08:00
|
|
|
@rm -f $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
|
2015-03-14 05:51:11 +08:00
|
|
|
sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
rm -f $@.tmp
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
%.d: %.m
|
2015-03-14 05:51:11 +08:00
|
|
|
@rm -f $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
$(CC) -M $(CFLAGS) $< > $@.tmp && \
|
2015-03-14 05:51:11 +08:00
|
|
|
sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
rm -f $@.tmp
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
%.d: %.mm
|
2015-03-14 05:51:11 +08:00
|
|
|
@rm -f $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
|
2015-03-14 05:51:11 +08:00
|
|
|
sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
|
2015-02-05 17:52:42 +08:00
|
|
|
rm -f $@.tmp
|
2010-08-24 07:56:08 +08:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# Include all of the makefiles for each source file so we don't have
|
|
|
|
# to manually track all of the prerequisites for each source file.
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
sinclude $(PREREQS)
|
2010-08-25 00:35:00 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
|
|
|
sinclude $(DYLIB_PREREQS)
|
|
|
|
endif
|
2010-08-24 07:56:08 +08:00
|
|
|
|
2012-04-25 07:05:07 +08:00
|
|
|
# Define a suffix rule for .mm -> .o
|
|
|
|
.SUFFIXES: .mm .o
|
|
|
|
.mm.o:
|
|
|
|
$(CXX) $(CXXFLAGS) -c $<
|
|
|
|
|
2010-08-24 07:56:08 +08:00
|
|
|
.PHONY: clean
|
|
|
|
dsym: $(DSYM)
|
|
|
|
all: $(EXE) $(DSYM)
|
2010-09-28 04:44:46 +08:00
|
|
|
clean::
|
2018-01-26 02:01:27 +08:00
|
|
|
$(RM) -rf $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(CLANG_MODULE_CACHE_DIR)
|
2014-03-08 01:20:50 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
2014-03-08 09:53:27 +08:00
|
|
|
$(RM) -r $(DYLIB_FILENAME).dSYM
|
2015-09-09 18:20:30 +08:00
|
|
|
$(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug
|
2014-03-08 01:20:50 +08:00
|
|
|
endif
|
2016-04-20 02:20:11 +08:00
|
|
|
ifneq "$(PCH_OUTPUT)" ""
|
|
|
|
$(RM) $(PCH_OUTPUT)
|
|
|
|
endif
|
2014-03-08 01:20:50 +08:00
|
|
|
ifneq "$(DSYM)" ""
|
2014-03-08 09:53:27 +08:00
|
|
|
$(RM) -r "$(DSYM)"
|
2010-08-24 07:56:08 +08:00
|
|
|
endif
|
2014-12-17 00:48:19 +08:00
|
|
|
ifeq "$(OS)" "Windows_NT"
|
2015-08-27 03:44:45 +08:00
|
|
|
# http://llvm.org/pr24589
|
|
|
|
IF EXIST "$(EXE)" del "$(EXE)"
|
2015-03-27 00:43:25 +08:00
|
|
|
$(RM) $(wildcard *.manifest *.pdb *.ilk)
|
2015-08-27 03:44:45 +08:00
|
|
|
ifneq "$(DYLIB_NAME)" ""
|
2015-03-27 00:43:25 +08:00
|
|
|
$(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp
|
2015-08-27 03:44:45 +08:00
|
|
|
endif
|
|
|
|
else
|
|
|
|
$(RM) "$(EXE)"
|
2014-12-17 00:48:19 +08:00
|
|
|
endif
|
2011-01-15 05:18:12 +08:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
# From http://blog.melski.net/tag/debugging-makefiles/
|
2018-04-12 17:25:32 +08:00
|
|
|
#
|
2011-01-15 05:18:12 +08:00
|
|
|
# Usage: make print-CC print-CXX print-LD
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
print-%:
|
|
|
|
@echo '$*=$($*)'
|
|
|
|
@echo ' origin = $(origin $*)'
|
|
|
|
@echo ' flavor = $(flavor $*)'
|
|
|
|
@echo ' value = $(value $*)'
|
2011-01-29 01:22:29 +08:00
|
|
|
|
|
|
|
### Local Variables: ###
|
|
|
|
### mode:makefile ###
|
|
|
|
### End: ###
|