# -*- mode: makefile;-*-
#
-# Copyright (C) 1999-2013 Apple Inc. All rights reserved.
+# Copyright (C) 1999-2016 Apple Inc. All rights reserved.
#
# MakeInc.def contains global definitions for building,
# linking, and installing files.
SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H
#
-# Kernel Configuration options
+# Kernel Configuration options
#
SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE
#
-# Machine Configuration options
+# Machine Configuration options
#
SUPPORTED_X86_64_MACHINE_CONFIGS = NONE
SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE
-#
-# Platform options
-#
-SUPPORTED_PLATFORMS = MacOSX iPhoneOS iPhoneSimulator iPhoneOSNano iPhoneNanoSimulator
-
#
# Setup up *_LC variables during recursive invocations
#
ifndef CURRENT_ARCH_CONFIG_LC
- export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z)
+ export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z)
endif
ifndef CURRENT_KERNEL_CONFIG_LC
export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z)
endif
-
#
# Component List
#
-COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security
-COMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH))))
-COMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST))
+COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security
+COMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH))))
+COMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST))
#
#
ifeq ($(PLATFORM),MacOSX)
DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
-else ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
+else ifeq ($(PLATFORM),WatchOS)
+ DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
+else ifeq ($(PLATFORM),tvOS)
+ DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
+else ifeq ($(PLATFORM),AppleTVOS)
+ DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
+else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
-else ifneq ($(filter iPhoneSimulator iPhoneNanoSimulator,$(PLATFORM)),)
+else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
DEPLOYMENT_TARGET_FLAGS =
else
DEPLOYMENT_TARGET_FLAGS =
endif
+DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
+
#
# Standard defines list
KCC = $(CC)
KC++ = $(CXX)
+GENASSYM_KCC = $(CC)
+
#
# Compiler warning flags
#
CWARNFLAGS_STD = \
- -Wall -Werror -Wno-format-y2k -Wextra -Wstrict-prototypes \
+ -Weverything -Werror -Wextra -Wstrict-prototypes \
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
-Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wchar-subscripts \
-Winline -Wnested-externs -Wredundant-decls -Wextra-tokens \
- -Wunreachable-code
+ -Wunreachable-code \
+ -Wno-assign-enum \
+ -Wno-bad-function-cast \
+ -Wno-c++98-compat \
+ -Wno-c++-compat \
+ -Wno-conditional-uninitialized \
+ -Wno-conversion \
+ -Wno-covered-switch-default \
+ -Wno-disabled-macro-expansion \
+ -Wno-documentation-unknown-command \
+ -Wno-format-non-iso \
+ -Wno-format-nonliteral \
+ -Wno-reserved-id-macro \
+ -Wno-language-extension-token \
+ -Wno-missing-variable-declarations \
+ -Wno-packed \
+ -Wno-padded \
+ -Wno-partial-availability \
+ -Wno-pedantic \
+ -Wno-shift-sign-overflow \
+ -Wno-switch-enum \
+ -Wno-undef \
+ -Wno-unused-macros \
+ -Wno-used-but-marked-unused \
+ -Wno-variadic-macros \
+ -Wno-vla \
+ -Wno-zero-length-array
# Can be overridden in Makefile.template or Makefile.$arch
export CWARNFLAGS ?= $(CWARNFLAGS_STD)
endef
CXXWARNFLAGS_STD = \
- -Wall -Werror -Wno-format-y2k -Wextra -Wpointer-arith -Wreturn-type \
+ -Weverything -Werror -Wextra -Wpointer-arith -Wreturn-type \
-Wcast-qual -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts \
-Wredundant-decls -Wextra-tokens \
- -Wunreachable-code
+ -Wunreachable-code \
+ -Wno-assign-enum \
+ -Wno-bad-function-cast \
+ -Wno-c++98-compat \
+ -Wno-c++98-compat-pedantic \
+ -Wno-c++-compat \
+ -Wno-conditional-uninitialized \
+ -Wno-conversion \
+ -Wno-covered-switch-default \
+ -Wno-disabled-macro-expansion \
+ -Wno-documentation-unknown-command \
+ -Wno-exit-time-destructors \
+ -Wno-format-non-iso \
+ -Wno-format-nonliteral \
+ -Wno-global-constructors \
+ -Wno-reserved-id-macro \
+ -Wno-language-extension-token \
+ -Wno-missing-variable-declarations \
+ -Wno-old-style-cast \
+ -Wno-packed \
+ -Wno-padded \
+ -Wno-partial-availability \
+ -Wno-pedantic \
+ -Wno-shift-sign-overflow \
+ -Wno-switch-enum \
+ -Wno-undef \
+ -Wno-unused-macros \
+ -Wno-used-but-marked-unused \
+ -Wno-variadic-macros \
+ -Wno-vla \
+ -Wno-zero-length-array
# overloaded-virtual warnings are non-fatal (9000888)
CXXWARNFLAGS_STD += -Wno-error=overloaded-virtual
ARCH_FLAGS_X86_64H = -arch x86_64h
+
#
# Default CFLAGS
#
# probes from the kernel.
#
CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
- -freorder-blocks -fno-builtin -fno-common \
+ -fno-builtin -fno-common \
-fsigned-bitfields $(OTHER_CFLAGS)
-CFLAGS_RELEASE =
-CFLAGS_DEVELOPMENT =
-CFLAGS_DEBUG =
-CFLAGS_PROFILE = -pg
+CFLAGS_RELEASE =
+CFLAGS_DEVELOPMENT =
+CFLAGS_DEBUG =
+CFLAGS_PROFILE = -pg
CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
- -DPAGE_SIZE_FIXED -mkernel -msoft-float
+ -DPAGE_SIZE_FIXED -mkernel -msoft-float
CFLAGS_X86_64H = $(CFLAGS_X86_64)
CFLAGS_PROFILEARM = -O2
-CFLAGS = $(CFLAGS_GEN) \
+CFLAGS = $(CFLAGS_GEN) \
$($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \
$($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \
$(DEPLOYMENT_TARGET_FLAGS) \
+ $(DEPLOYMENT_TARGET_DEFINES) \
$(DEFINES)
#
OTHER_CXXFLAGS =
-CXXFLAGS_GEN = -fapple-kext $(OTHER_CXXFLAGS)
-
-# For the moment, do not use gnu++11
-#CXXFLAGS_ARM = -std=gnu++11
-
+CXXFLAGS_GEN = -std=gnu++11 -fapple-kext $(OTHER_CXXFLAGS)
CXXFLAGS = $(CXXFLAGS_GEN) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \
$($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_))
-
#
# Assembler command
#
#
SFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS)
-SFLAGS_RELEASE =
-SFLAGS_DEVELOPMENT =
-SFLAGS_DEBUG =
-SFLAGS_PROFILE =
+SFLAGS_RELEASE =
+SFLAGS_DEVELOPMENT =
+SFLAGS_DEBUG =
+SFLAGS_PROFILE =
-SFLAGS_X86_64 = $(CFLAGS_X86_64)
-SFLAGS_X86_64H = $(CFLAGS_X86_64H)
+SFLAGS_X86_64 = $(CFLAGS_X86_64)
+SFLAGS_X86_64H = $(CFLAGS_X86_64H)
-SFLAGS = $(SFLAGS_GEN) \
+SFLAGS = $(SFLAGS_GEN) \
$($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \
$($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \
$(DEPLOYMENT_TARGET_FLAGS) \
+ $(DEPLOYMENT_TARGET_DEFINES) \
$(DEFINES)
#
-Wl,-sectalign,__TEXT,__text,0x1000 \
-Wl,-sectalign,__DATA,__common,0x1000 \
-Wl,-sectalign,__DATA,__bss,0x1000 \
- -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
- -Wl,-sectcreate,__PRELINK_STATE,__kernel,/dev/null \
- -Wl,-sectcreate,__PRELINK_STATE,__kexts,/dev/null \
+ -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
+ -Wl,-sectcreate,"__PLK_TEXT_EXEC",__text,/dev/null \
+ -Wl,-sectcreate,__PRELINK_DATA,__data,/dev/null \
+ -Wl,-sectcreate,"__PLK_DATA_CONST",__data,/dev/null \
+ -Wl,-sectcreate,"__PLK_LINKEDIT",__data,/dev/null \
-Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \
-Wl,-new_linker \
-Wl,-pagezero_size,0x0 \
-Wl,-function_starts \
-Wl,-headerpad,152
-LDFLAGS_KERNEL_RELEASE =
-LDFLAGS_KERNEL_DEVELOPMENT =
-LDFLAGS_KERNEL_DEBUG =
-LDFLAGS_KERNEL_PROFILE =
+LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel
+
+LDFLAGS_KERNEL_RELEASE =
+LDFLAGS_KERNEL_DEVELOPMENT =
+LDFLAGS_KERNEL_DEBUG =
+LDFLAGS_KERNEL_PROFILE =
# KASLR static slide config:
ifndef SLIDE
-Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
-Wl,-image_base,$(KERNEL_TEXT_BASE) \
-Wl,-seg_page_size,__TEXT,0x200000 \
- -Wl,-sectalign,__DATA,__const,0x1000 \
- -Wl,-sectalign,__DATA,__sysctl_set,0x1000 \
-Wl,-sectalign,__HIB,__bootPT,0x1000 \
-Wl,-sectalign,__HIB,__desc,0x1000 \
-Wl,-sectalign,__HIB,__data,0x1000 \
-Wl,-sectalign,__HIB,__const,0x1000 \
-Wl,-sectalign,__HIB,__bss,0x1000 \
-Wl,-sectalign,__HIB,__common,0x1000 \
+ -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \
+ -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \
+ -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \
+ -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \
+ -Wl,-rename_section,__DATA,__const,__CONST,__constdata \
+ -Wl,-no_zero_fill_sections \
$(LDFLAGS_NOSTRIP_FLAG)
# Define KERNEL_BASE_OFFSET so known at compile time:
LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
+ $(LDFLAGS_KERNEL_SDK) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \
$($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
#
# Default INCFLAGS
#
-INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
-INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS
+INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
+INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS
INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
INCFLAGS_LOCAL = -I.
+INCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel
-INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE)
+INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK)
#
# Default MIGFLAGS
MIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
$(DEPLOYMENT_TARGET_FLAGS)
+# Support for LLVM Profile Guided Optimization (PGO)
+
+ifeq ($(BUILD_PROFILE),1)
+CFLAGS_GEN += -fprofile-instr-generate -DPROFILE
+CXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE
+endif
+
+ifdef USE_PROFILE
+CFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE)
+CXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE)
+LDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE)
+
+CFLAGS_GEN += -Wno-error=profile-instr-out-of-date
+endif
+
#
# Support for LLVM Link Time Optimization (LTO)
#
USE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG))
endif
+SUPPORTS_CTFCONVERT = 0
ifeq ($(USE_LTO),1)
CFLAGS_GEN += -flto
CXXFLAGS_GEN += -flto
-LDFLAGS_KERNEL_GEN += -Wl,-mllvm,-inline-threshold=125 -Wl,-object_path_lto,$(TARGET)/lto.o # -Wl,-mllvm -Wl,-disable-fp-elim
+LDFLAGS_KERNEL_GEN += -Wl,-mllvm,-inline-threshold=125 -Wl,-object_path_lto,$(TARGET)/lto.o # -Wl,-mllvm -Wl,-disable-fp-elim
LDFLAGS_NOSTRIP_FLAG = -rdynamic
CFLAGS_NOLTO_FLAG = -fno-lto
-SUPPORTS_CTFCONVERT = 0
NEEDS_CTF_MACHOS = 1
else
LDFLAGS_NOSTRIP_FLAG =
CFLAGS_NOLTO_FLAG =
+ifneq ($(CTFCONVERT),)
SUPPORTS_CTFCONVERT = 1
+endif
NEEDS_CTF_MACHOS = 0
endif
+ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
+BUILD_DSYM := 0
+DO_CTFCONVERT := 0
+DO_CTFMERGE := 0
+DO_CTFMACHO := 0
+KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC)
+KC++ = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CXX)
+S_KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC)
+STRIP = true
+endif
+
#
# Default VPATH
#
# Macros that control installation of kernel and its header files
#
# install flags for header files
-#
+#
INSTALL_FLAGS = -c -S -m 0444
DATA_INSTALL_FLAGS = -c -S -m 0644
EXEC_INSTALL_FLAGS = -c -S -m 0755
#
# Header file destinations
#
-ifeq ($(RC_ProjectName),xnu_headers_Sim)
- include $(MAKEFILEPATH)/../AppleInternal/Makefiles/Makefile.indigo_prefix
- HEADER_INSTALL_PREFIX = $(INDIGO_PREFIX)
-else
- HEADER_INSTALL_PREFIX =
-endif
-
-FRAMEDIR = $(HEADER_INSTALL_PREFIX)/System/Library/Frameworks
+FRAMEDIR = /System/Library/Frameworks
SINCVERS = B
SINCFRAME = $(FRAMEDIR)/System.framework
SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources
ifndef INCDIR
- INCDIR = $(HEADER_INSTALL_PREFIX)/usr/include
+ INCDIR = /usr/include
endif
ifndef LCLDIR
LCLDIR = $(SPINCDIR)
#
# Strip Flags
#
-STRIP_FLAGS_RELEASE = -S -x
-STRIP_FLAGS_DEVELOPMENT = -S
-STRIP_FLAGS_DEBUG = -S
+STRIP_FLAGS_RELEASE = -S -x
+STRIP_FLAGS_DEVELOPMENT = -S
+STRIP_FLAGS_DEBUG = -S
STRIP_FLAGS_PROFILE = -S -x
-STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_))
+STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_))
#
# dsymutil flags
KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py
endif
+CURRENT_ALIAS_MACHINE_CONFIG = $(word 4,$(subst ^, ,$(CURRENT_BUILD_CONFIG)))
+CURRENT_ALIAS_MACHINE_CONFIG_LC = $(shell printf "%s" "$(CURRENT_ALIAS_MACHINE_CONFIG)" | $(TR) A-Z a-z)
+ifneq ($(CURRENT_ALIAS_MACHINE_CONFIG),)
+ALIAS_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_ALIAS_MACHINE_CONFIG_LC)
+endif
+
#
# System.kext pseudo-kext install location
#
#
INSTALL_SHARE_MISC_DIR = /usr/share/misc
INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace
+INSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace
#
# Overrides for XBS build aliases
INSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR)
INSTALL_KERNEL_SYM_TO_KDK = 1
INSTALL_XNU_DEBUG_FILES = 1
-else ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
+else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
INSTALL_KERNEL_SYM_TO_KDK = 1
USE_BINARY_PLIST = 1
-else ifneq ($(filter iPhoneSimulator iPhoneNanoSimulator,$(PLATFORM)),)
+else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
USE_BINARY_PLIST = 1
else ifeq ($(PLATFORM),MacOSX)
INSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR)