brintos

brintos / llvm-project-archived public Read only

0
0
Text · 22.5 KiB · 55dbd39 Raw
712 lines · plain
1#----------------------------------------------------------------------2# Clients fill in the source files to build3#----------------------------------------------------------------------4# C_SOURCES := main.c5# CXX_SOURCES :=6# OBJC_SOURCES :=7# OBJCXX_SOURCES :=8# DYLIB_C_SOURCES :=9# DYLIB_OBJC_SOURCES :=10# DYLIB_CXX_SOURCES :=11#12# Specifying DYLIB_ONLY has the effect of building dylib only, skipping13# the building of the a.out executable program.  For example,14# DYLIB_ONLY := YES15#16# When specifying one of the DYLIB_*_SOURCES variables, DYLIB_NAME17# controls the (platform-dependent) name of the produced dylib. E.g.,18# on Darwin, if "DYLIB_NAME := foo", the generated dylib will be called19# "libfoo.dylib".20#21# DYLIB_NAME := foo22#23# Specifying FRAMEWORK and its variants has the effect of building a NeXT-style24# framework.25# FRAMEWORK := "Foo"26# FRAMEWORK_HEADERS := "Foo.h"27# FRAMEWORK_MODULES := "module.modulemap"28#29# Also might be of interest:30# FRAMEWORK_INCLUDES (Darwin only) :=31# CFLAGS_EXTRAS :=32# LD_EXTRAS :=33# SPLIT_DEBUG_SYMBOLS := YES34# CROSS_COMPILE :=35# USE_PRIVATE_MODULE_CACHE := YES36 37# Uncomment line below for debugging shell commands38# SHELL = /bin/sh -x39 40# Suppress built-in suffix rules. We explicitly define rules for %.o.41.SUFFIXES:42 43SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))44BUILDDIR := $(shell pwd)45MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))46THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))47LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../48 49# The test harness invokes the test Makefiles with an explicit 'all'50# target, but its handy to be able to recursively call this Makefile51# without specifying a goal. You almost certainly want to build 'all',52# and not only the first target defined in this file (which might vary53# according to variable values).54.DEFAULT_GOAL := all55 56#----------------------------------------------------------------------57# If OS is Windows, force SHELL to be cmd58#59# Some versions of make on Windows will search for other shells such as60# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons61# so default to using cmd.exe.62# Also reset BUILDDIR value because "pwd" returns cygwin or msys path63# which needs to be converted to windows path.64#----------------------------------------------------------------------65ifeq "$(HOST_OS)" "Windows_NT"66	# MinGW make gets $(windir) variable if launched from cmd.exe67	# and $(WINDIR) if launched from MSYS2.68	SHELL := $(or $(windir),$(WINDIR),C:\WINDOWS)\system32\cmd.exe69	BUILDDIR := $(shell echo %cd%)70endif71 72#----------------------------------------------------------------------73# If the OS is Windows use double-quotes in commands74#75# For other operating systems, single-quotes work fine, but on Windows76# we strictly required double-quotes77#----------------------------------------------------------------------78ifeq "$(HOST_OS)" "Windows_NT"79	QUOTE = "80	FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = "81else82	QUOTE = '83	FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = '84endif85 86#----------------------------------------------------------------------87# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more88# from the triple alone89#----------------------------------------------------------------------90ARCH_CFLAGS :=91ifeq "$(OS)" "Android"92	include $(THIS_FILE_DIR)/Android.rules93endif94 95#----------------------------------------------------------------------96# If ARCH is not defined, default to x86_64.97#----------------------------------------------------------------------98ifeq "$(ARCH)" ""99ifeq "$(OS)" "Windows_NT"100	ARCH = x86101else102	ARCH = x86_64103endif104endif105 106#----------------------------------------------------------------------107# CC defaults to clang.108#109# If you change the defaults of CC, be sure to also change it in the file110# test/builders/builder_base.py, which provides a Python way to return the111# value of the make variable CC -- getCompiler().112#----------------------------------------------------------------------113ifeq "$(CC)" ""114$(error "C compiler is not specified. Please run tests through lldb-dotest or lit")115endif116 117# Always override the linker. Assign already normalized CC.118override LD := $(CC)119# A kind of linker. It always gets retrieved from CC.120override LDC := $(CC_TYPE)121 122ifeq "$(HOST_OS)" "Windows_NT"123       # This function enframes the full path with the platform specific quotes. This is necessary to run the c++ executable124       # properly under 'sh' on Windows host (prevent the path breakage because of Windows style path separators).125       override CXX := $(QUOTE)$(CXX)$(QUOTE)126endif127 128#----------------------------------------------------------------------129# Handle SDKROOT for the cross platform builds.130#----------------------------------------------------------------------131 132ifeq "$(OS)" "Darwin"133    ifeq "$(SDKROOT)" ""134	# We haven't otherwise set the SDKROOT, so set it now to macosx135	SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)136    endif137    SYSROOT_FLAGS := -isysroot "$(SDKROOT)"138    GCC_TOOLCHAIN_FLAGS :=139else140    ifneq "$(SDKROOT)" ""141        SYSROOT_FLAGS := --sysroot "$(SDKROOT)"142        GCC_TOOLCHAIN_FLAGS := --gcc-toolchain="$(SDKROOT)/usr"143    else144        # Do not set up these options if SDKROOT was not specified.145        # This is a regular build in that case (or Android).146        SYSROOT_FLAGS :=147        GCC_TOOLCHAIN_FLAGS :=148    endif149endif150 151#----------------------------------------------------------------------152# Use LLD when cross compiling on Darwin.153#----------------------------------------------------------------------154ifeq "$(HOST_OS)" "Darwin"155	ifneq (,$(filter $(OS), Android FreeBSD Linux NetBSD Windows_NT))156		LDFLAGS += -fuse-ld=lld157	endif158endif159 160 161#----------------------------------------------------------------------162# ARCHFLAG is the flag used to tell the compiler which architecture163# to compile for. The default is the flag that clang accepts.164#----------------------------------------------------------------------165ARCHFLAG ?= -arch166 167#----------------------------------------------------------------------168# Change any build/tool options needed169#----------------------------------------------------------------------170ifeq "$(OS)" "Darwin"171	DS := $(DSYMUTIL)172	DSFLAGS := $(DSFLAGS_EXTRAS)173	DSYM = $(EXE).dSYM174	ARFLAGS := -static -o175else176	# On non-Apple platforms, -arch becomes -m177	ARCHFLAG := -m178 179	# i386, i686, x86 -> 32180	# amd64, x86_64, x64 -> 64181	ifeq "$(ARCH)" "amd64"182		override ARCH := $(subst amd64,64,$(ARCH))183	endif184	ifeq "$(ARCH)" "x86_64"185		override ARCH := $(subst x86_64,64,$(ARCH))186	endif187	ifeq "$(ARCH)" "x64"188		override ARCH := $(subst x64,64,$(ARCH))189	endif190	ifeq "$(ARCH)" "x86"191		override ARCH := $(subst x86,32,$(ARCH))192	endif193	ifeq "$(ARCH)" "i386"194		override ARCH := $(subst i386,32,$(ARCH))195	endif196	ifeq "$(ARCH)" "i686"197		override ARCH := $(subst i686,32,$(ARCH))198	endif199	ifeq "$(ARCH)" "powerpc"200		override ARCH := $(subst powerpc,32,$(ARCH))201	endif202	ifeq "$(ARCH)" "powerpc64"203		override ARCH := $(subst powerpc64,64,$(ARCH))204	endif205	ifeq "$(ARCH)" "powerpc64le"206		override ARCH := $(subst powerpc64le,64,$(ARCH))207	endif208	ifeq "$(ARCH)" "aarch64"209		override ARCH :=210		override ARCHFLAG :=211	endif212	ifeq "$(findstring arm,$(ARCH))" "arm"213		override ARCH :=214		override ARCHFLAG :=215	endif216	ifeq "$(ARCH)" "s390x"217		override ARCH :=218		override ARCHFLAG :=219	endif220	ifeq "$(ARCH)" "riscv"221		override ARCH :=222		override ARCHFLAG :=223	endif224	ifeq "$(findstring mips,$(ARCH))" "mips"225		override ARCHFLAG := -226	endif227	ifeq "$(findstring loongarch,$(ARCH))" "loongarch"228		override ARCH :=229		override ARCHFLAG :=230	endif231 232	ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"233		DSYM = $(EXE).debug234	endif235 236	ifeq "$(MAKE_DWP)" "YES"237		MAKE_DWO := YES238		DWP_NAME = $(EXE).dwp239		DYLIB_DWP_NAME = $(DYLIB_NAME).dwp240	endif241endif242 243LIMIT_DEBUG_INFO_FLAGS =244NO_LIMIT_DEBUG_INFO_FLAGS =245MODULE_DEBUG_INFO_FLAGS =246ifeq ($(CC_TYPE), clang)247   LIMIT_DEBUG_INFO_FLAGS += -flimit-debug-info248   NO_LIMIT_DEBUG_INFO_FLAGS += -fno-limit-debug-info249   MODULE_DEBUG_INFO_FLAGS += -gmodules250endif251 252ifeq "$(MAKE_PDB)" "YES"253	DEBUG_INFO_FLAG ?= -g -gcodeview254endif255 256# If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build257# with codeview by default but all the tests rely on dwarf.258ifeq "$(OS)" "Windows_NT"259	DEBUG_INFO_FLAG ?= -gdwarf260endif261 262DEBUG_INFO_FLAG ?= -g263 264CFLAGS ?= $(DEBUG_INFO_FLAG) -O0265CFLAGS += $(SYSROOT_FLAGS)266 267ifeq "$(OS)" "Darwin"268	CFLAGS += $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES)269else270	CFLAGS += $(ARCHFLAG)$(ARCH)271endif272 273CFLAGS += -I$(LLDB_BASE_DIR)/include -I$(LLDB_OBJ_ROOT)/include274CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR)275 276ifndef NO_TEST_COMMON_H277  CFLAGS += -include $(THIS_FILE_DIR)/test_common.h278endif279 280CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)281 282# Use this one if you want to build one part of the result without debug information:283ifeq "$(OS)" "Darwin"284	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)285else286	CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)287endif288 289ifeq "$(MAKE_DWO)" "YES"290	CFLAGS += -gsplit-dwarf291endif292 293ifeq "$(MAKE_DEBUG_NAMES)" "YES"294	CFLAGS += -gpubnames295endif296 297# Enable GNU POSIX extensions (e.g. kill(), usleep(), getpgid(), ...)298ifeq "$(OS)" "Linux"299	CFLAGS += -D_DEFAULT_SOURCE300endif301 302ifeq "$(USE_PRIVATE_MODULE_CACHE)" "YES"303THE_CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/private-module-cache304else305THE_CLANG_MODULE_CACHE_DIR := $(CLANG_MODULE_CACHE_DIR)306endif307 308MODULE_BASE_FLAGS := -fmodules -gmodules -fmodules-cache-path=$(THE_CLANG_MODULE_CACHE_DIR)309MANDATORY_MODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -gmodules310# Build flags for building with C++ modules.311# -glldb is necessary for emitting information about what modules were imported.312MANDATORY_CXXMODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -fcxx-modules -glldb313 314ifeq "$(OS)" "Darwin"315	MANDATORY_MODULE_BUILD_CFLAGS += -fcxx-modules316endif317 318ifeq "$(MAKE_GMODULES)" "YES"319	CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)320	CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS)321endif322 323CFLAGS += $(CFLAGS_EXTRAS)324CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS)325# Copy common options to the linker flags (dwarf, arch. & etc).326# Note: we get some 'garbage' options for linker here (such as -I, --isystem & etc).327LDFLAGS += $(CFLAGS)328LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)329ifeq (,$(filter $(OS), Windows_NT Android Darwin))330	ifneq (,$(filter YES,$(ENABLE_THREADS)))331		LDFLAGS += -pthread332	endif333endif334 335# macOS forbids injecting the ASAN runtime into system processes when336# SIP is enabled. That includes the just-built libLTO that the337# just-built clang injects into the system linker.  Since we don't338# test the compiler here, just use the system (non-asanified) LTO339# library to make ASAN tests work for most users, including the bots.340ifeq "$(OS)" "Darwin"341ifneq "$(ASAN_OPTIONS)" ""342ASAN_LDFLAGS = -Wl,-lto_library -Wl,$(shell dirname $(shell xcrun -find clang))/../lib/libLTO.dylib343endif344endif345LDFLAGS += $(ASAN_LDFLAGS)346 347OBJECTS =348EXE ?= a.out349 350ifneq "$(FRAMEWORK)" ""351	DYLIB_NAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)352	DYLIB_FILENAME ?= $(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)353endif354 355ifneq "$(DYLIB_NAME)" ""356	ifeq "$(OS)" "Darwin"357		ifneq "$(FRAMEWORK)" ""358			DYLIB_INSTALL_NAME ?= @executable_path/$(FRAMEWORK).framework/Versions/A/$(FRAMEWORK)359		else360			DYLIB_FILENAME = lib$(DYLIB_NAME).dylib361			DYLIB_INSTALL_NAME ?= @executable_path/$(DYLIB_FILENAME)362		endif363	else ifeq "$(OS)" "Windows_NT"364		DYLIB_FILENAME = $(DYLIB_NAME).dll365	else366		DYLIB_FILENAME = lib$(DYLIB_NAME).so367	endif368endif369 370ifdef PIE371	LDFLAGS += -pie372endif373 374#----------------------------------------------------------------------375# Windows specific options376#----------------------------------------------------------------------377ifeq "$(OS)" "Windows_NT"378	ifeq ($(CC_TYPE), clang)379		# MSVC 2015 or higher is required, which depends on c++14, so380		# append these values unconditionally.381		CXXFLAGS += -fms-compatibility-version=19.0382		CXXFLAGS += -std=c++14383 384		# The MSVC linker doesn't understand long section names385		# generated by the clang compiler.386		LDFLAGS += -fuse-ld=lld387	endif388endif389 390#----------------------------------------------------------------------391# C++ standard library options392#----------------------------------------------------------------------393ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)394	$(error Libcxx and Libstdc++ cannot be used together)395endif396 397ifeq (1, $(USE_SYSTEM_STDLIB))398	ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)399		$(error Cannot use system's standard library and a custom standard library together)400	endif401endif402 403ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))404  # If no explicit C++ library request was made, but we have paths to a custom libcxx, use405  # them.  Otherwise, use the system library by default.406  ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)407    CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)408    ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""409      CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)410    endif411 412	# If `-nostdlib++` is not passed, clang will link to the system's stdlib.413    LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++414  else415    USE_SYSTEM_STDLIB := 1416  endif417endif418 419ifeq (1,$(USE_LIBSTDCPP))420	# Clang requires an extra flag: -stdlib=libstdc++421	ifeq ($(CC_TYPE), clang)422		# Force clang looking for the gcc's headers at specific rootfs folder.423		CXXFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)424		LDFLAGS += -stdlib=libstdc++ $(GCC_TOOLCHAIN_FLAGS)425	endif426endif427 428ifeq (1,$(USE_LIBCPP))429	ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)430		CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)431		ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""432				CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)433		endif434		# If `-nostdlib++` is not passed, clang will link to the system's stdlib.435		LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++436	else437		ifeq "$(OS)" "Android"438				# Nothing to do, this is already handled in439				# Android.rules.440		else441				CXXFLAGS += -stdlib=libc++442				LDFLAGS += -stdlib=libc++443		endif444		ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))445				ifneq (,$(LLVM_LIBS_DIR))446				LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)447				endif448		endif449	endif450endif451 452ifeq (1, $(USE_SYSTEM_STDLIB))453    ifeq "$(OS)" "Darwin"454        ifeq "$(SDKROOT)" ""455             $(error "SDKROOT must be set on Darwin to use the system libcxx")456        endif457        CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(SDKROOT)/usr/include/c++/v1458        LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++459    else460        ifeq ($(CC_TYPE),clang)461            # Force clang looking for the gcc's headers at specific rootfs folder.462            CXXFLAGS += $(GCC_TOOLCHAIN_FLAGS)463            LDFLAGS += $(GCC_TOOLCHAIN_FLAGS)464        endif465    endif466endif467 468#----------------------------------------------------------------------469# Additional system libraries470#----------------------------------------------------------------------471ifeq (1,$(USE_LIBDL))472	ifeq (,$(filter $(OS), NetBSD Windows_NT))473		LDFLAGS += -ldl474	endif475endif476 477CXXFLAGS += $(CXXFLAGS_EXTRAS)478 479#----------------------------------------------------------------------480# dylib settings481#----------------------------------------------------------------------482 483DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))484DYLIB_OBJECTS +=$(strip $(DYLIB_OBJC_SOURCES:.m=.o))485ifneq "$(strip $(DYLIB_CXX_SOURCES))" ""486	DYLIB_OBJECTS +=$(strip $(patsubst %.mm, %.o, $(DYLIB_CXX_SOURCES:.cpp=.o)))487endif488 489#----------------------------------------------------------------------490# Check if we have a precompiled header491#----------------------------------------------------------------------492ifneq "$(strip $(PCH_CXX_SOURCE))" ""493	PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch)494	PCHFLAGS = -include $(PCH_CXX_SOURCE)495endif496 497#----------------------------------------------------------------------498# Check if we have any C source files499#----------------------------------------------------------------------500ifneq "$(strip $(C_SOURCES))" ""501	OBJECTS +=$(strip $(C_SOURCES:.c=.o))502endif503 504#----------------------------------------------------------------------505# Check if we have any C++ source files506#----------------------------------------------------------------------507ifneq "$(strip $(CXX_SOURCES))" ""508	OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))509endif510 511#----------------------------------------------------------------------512# Check if we have any ObjC source files513#----------------------------------------------------------------------514ifneq "$(strip $(OBJC_SOURCES))" ""515	OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))516	LDFLAGS +=-lobjc517endif518 519#----------------------------------------------------------------------520# Check if we have any ObjC++ source files521#----------------------------------------------------------------------522ifneq "$(strip $(OBJCXX_SOURCES))" ""523	OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))524	ifeq "$(findstring lobjc,$(LDFLAGS))" ""525		LDFLAGS +=-lobjc526	endif527endif528 529ifeq ($(CC_TYPE), clang)530	CXXFLAGS += --driver-mode=g++531endif532 533ifneq "$(CXX)" ""534	# Specify the driver mode parameter if we use clang as the linker.535	ifeq ($(LDC), clang)536		LDFLAGS += --driver-mode=g++537	endif538endif539 540ifeq "$(GEN_GNU_BUILD_ID)" "YES"541	LDFLAGS += -Wl,--build-id542endif543 544#----------------------------------------------------------------------545# DYLIB_ONLY variable can be used to skip the building of a.out.546# See the sections below regarding dSYM file as well as the building of547# EXE from all the objects.548#----------------------------------------------------------------------549 550#----------------------------------------------------------------------551# Compile the executable from all the objects.552#----------------------------------------------------------------------553ifneq "$(DYLIB_NAME)" ""554ifeq "$(DYLIB_ONLY)" ""555$(EXE) : $(OBJECTS) $(DYLIB_FILENAME)556	$(LD) $(OBJECTS) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"557ifneq "$(CODESIGN)" ""558	$(CODESIGN) -s - "$(EXE)"559endif560else561EXE = $(DYLIB_FILENAME)562endif563else564$(EXE) : $(OBJECTS)565	$(LD) $(OBJECTS) $(LDFLAGS) -o "$(EXE)"566ifneq "$(CODESIGN)" ""567	$(CODESIGN) -s - "$(EXE)"568endif569endif570 571#----------------------------------------------------------------------572# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"573#----------------------------------------------------------------------574$(DSYM) : $(EXE)575ifeq "$(OS)" "Darwin"576ifneq "$(MAKE_DSYM)" "NO"577	"$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)"578else579endif580else581ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"582ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"583	cp "$(EXE)" "$(EXE).unstripped"584endif585	$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"586	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"587endif588ifeq "$(MAKE_DWP)" "YES"589	$(DWP) -o "$(DWP_NAME)" $(DWOS)590endif591endif592 593 594#----------------------------------------------------------------------595# Make the dylib596#----------------------------------------------------------------------597$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL598 599ifneq "$(OS)" "Windows_NT"600$(DYLIB_OBJECTS) : CFLAGS += -fPIC601$(DYLIB_OBJECTS) : CXXFLAGS += -fPIC602endif603 604$(DYLIB_FILENAME) : $(DYLIB_OBJECTS)605ifeq "$(OS)" "Darwin"606ifneq "$(FRAMEWORK)" ""607	mkdir -p $(FRAMEWORK).framework/Versions/A/Headers608	mkdir -p $(FRAMEWORK).framework/Versions/A/Modules609	mkdir -p $(FRAMEWORK).framework/Versions/A/Resources610ifneq "$(FRAMEWORK_MODULES)" ""611	cp -r $(FRAMEWORK_MODULES) $(FRAMEWORK).framework/Versions/A/Modules612endif613ifneq "$(FRAMEWORK_HEADERS)" ""614	cp -r $(FRAMEWORK_HEADERS) $(FRAMEWORK).framework/Versions/A/Headers615endif616	(cd $(FRAMEWORK).framework/Versions; ln -sf A Current)617	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Headers Headers)618	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Modules Modules)619	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/Resources Resources)620	(cd $(FRAMEWORK).framework/; ln -sf Versions/A/$(FRAMEWORK) $(FRAMEWORK))621endif622	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_INSTALL_NAME)" -dynamiclib -o "$(DYLIB_FILENAME)"623ifneq "$(CODESIGN)" ""624	$(CODESIGN) -s - "$(DYLIB_FILENAME)"625endif626ifneq "$(MAKE_DSYM)" "NO"627ifneq "$(DS)" ""628	"$(DS)" $(DSFLAGS) "$(DYLIB_FILENAME)"629endif630endif631else632	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"633ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"634ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"635	cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).unstripped"636endif637	$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"638	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"639endif640ifeq "$(MAKE_DWP)" "YES"641	$(DWP) -o $(DYLIB_DWP_FILE) $(DYLIB_DWOS)642endif643endif644 645#----------------------------------------------------------------------646# Make the precompiled header and compile C++ sources against it647#----------------------------------------------------------------------648 649ifneq "$(PCH_OUTPUT)" ""650$(PCH_OUTPUT) : $(PCH_CXX_SOURCE)651	$(CXX) $(CXXFLAGS) -x c++-header -o $@ $<652endif653 654%.o: %.c %.d655	$(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<656 657%.o: %.cpp %.d $(PCH_OUTPUT)658	$(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<659 660%.o: %.m %.d661	$(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<662 663%.o: %.mm %.d664	$(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<665 666#----------------------------------------------------------------------667# Automatic variables based on items already entered. Below we create668# an object's lists from the list of sources by replacing all entries669# that end with .c with .o, and we also create a list of prerequisite670# files by replacing all .c files with .d.671#----------------------------------------------------------------------672PREREQS := $(OBJECTS:.o=.d)673DWOS := $(OBJECTS:.o=.dwo)674ifneq "$(DYLIB_NAME)" ""675	DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)676	DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)677endif678 679# Don't error if a .d file is deleted.680$(PREREQS) $(DYLIB_PREREQS): ;681 682#----------------------------------------------------------------------683# Include all of the makefiles for each source file so we don't have684# to manually track all of the prerequisites for each source file.685#----------------------------------------------------------------------686include $(wildcard $(PREREQS) $(DYLIB_PREREQS))687 688.PHONY: clean689dsym:	$(DSYM)690all:	$(EXE) $(DSYM)691clean::692ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""693	$(error Trying to invoke the clean rule, but not using the default build tree layout)694else695	$(RM) -r $(wildcard $(BUILDDIR)/*)696endif697 698#----------------------------------------------------------------------699# From http://blog.melski.net/tag/debugging-makefiles/700#701# Usage: make print-CC print-CXX print-LD702#----------------------------------------------------------------------703print-%:704	@echo '$*=$($*)'705	@echo '  origin = $(origin $*)'706	@echo '  flavor = $(flavor $*)'707	@echo '   value = $(value  $*)'708 709### Local Variables: ###710### mode:makefile ###711### End: ###712