]> git.saurik.com Git - apple/xnu.git/blobdiff - makedefs/MakeInc.def
xnu-2422.110.17.tar.gz
[apple/xnu.git] / makedefs / MakeInc.def
index 4e49fe6a71320f217dd09f6f5d44c3d144ea392f..910cc0e4623a09b46a6717c33569ec51aa199961 100644 (file)
-export SOURCE=$(shell /bin/pwd)
-export RELATIVE_SOURCE_PATH ?= .
-
-#
-# gnumake 3.77 support
+# -*- mode: makefile;-*-
 #
-export USE_APPLE_PB_SUPPORT = all
-
+# Copyright (C) 1999-2012 Apple Inc. All rights reserved.
 #
-# Incremental Build option
-#
-ifndef INCR_EXPORTHDRS
-ifeq ($(shell test -d $$OBJROOT/EXPORT_HDRS;echo $$?),0)
-export INCR_EXPORTHDRS = TRUE
-else
-export INCR_EXPORTHDRS = FALSE
-endif
-endif
-
-
-#
-# Component List
-#
-ifndef COMPONENT_LIST 
-export COMPONENT_LIST  = osfmk bsd libkern iokit pexpert libsa security
-export COMPONENT_LIST_UC := $(shell printf "%s" "$(COMPONENT_LIST)" | $(TR) a-z A-Z)
-endif
-ifndef COMPONENT
-export COMPONENT       := $(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))
-export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST)) 
-else
-ifeq   ($(COMPONENT), .)
-export COMPONENT       := $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH))))
-export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST)) 
-endif
-endif
-
-# Architecture options
+# MakeInc.def contains global definitions for building,
+# linking, and installing files.
 #
-ifndef SUPPORTED_ARCH_CONFIGS
-export SUPPORTED_ARCH_CONFIGS = I386 X86_64
-endif
-
-ifndef ARCH_CONFIGS
-ifdef RC_ARCHS
-export ARCH_CONFIGS    := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | sed -E 's/ARMV[0-9][A-Z]?/ARM/g')
-else
-ifeq ($(PLATFORM),iPhoneOS)
-       export ARCH_CONFIGS     := ARM
-else
-       export ARCH_CONFIGS     := $(shell arch | $(TR) a-z A-Z | sed -E 's/ARMV[0-9][A-Z]?/ARM/g')
-endif
-endif
-endif
-ifdef  ARCH_CONFIG
-ifndef ARCH_CONFIG_LC
-export ARCH_CONFIG_LC  := $(shell printf "%s" "$(ARCH_CONFIG)" | $(TR) A-Z a-z)
-endif
-endif
 
 #
-# Platform options
+# Architecture Configuration options
 #
-ifndef SUPPORTED_PLATFORMS
-export SUPPORTED_PLATFORMS = MacOSX iPhoneOS iPhoneSimulator
-endif
-
-# PLATFORM is set earlier in MakeInc.cmd, closer to where decisions about
-# platform tools are made
+SUPPORTED_ARCH_CONFIGS := X86_64
 
 #
 # Kernel Configuration options  
 #
-ifndef SUPPORTED_KERNEL_CONFIGS
-export SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE
-endif
-
-ifndef DEFAULT_KERNEL_CONFIG
-ifeq ($(RC_ProjectName),xnu_debug)
-export DEFAULT_KERNEL_CONFIG = DEBUG
-else
-export DEFAULT_KERNEL_CONFIG = RELEASE
-endif
-endif
-
-# If KERNEL_CONFIGS is specified it should override KERNEL_CONFIG.
-# If KERNEL_CONFIG is specified it will override the default. Will quit with
-# error if more than one config is specified.
-# If DEFAULT_KERNEL_CONFIG is not specified then it will be built RELEASE.
-ifndef KERNEL_CONFIGS
-       ifndef KERNEL_CONFIG
-       export KERNEL_CONFIGS   = $(DEFAULT_KERNEL_CONFIG)
-       else
-       export KERNEL_CONFIGS   = $(KERNEL_CONFIG)
-       endif
-endif
-
-ifndef KERNEL_CONFIG
-export KERNEL_CONFIG   = $(firstword $(KERNEL_CONFIGS))
-endif
-
-ifneq ($(words $(KERNEL_CONFIG)), 1)
-$(error There were $(words $(KERNEL_CONFIG)) parameters passed to KERNEL_CONFIG = $(KERNEL_CONFG). \
-               Are you sure? To specify multiple configurations please use KERNEL_CONFIGS)
-endif
-
-ifndef MACHINE_CONFIG
-export MACHINE_CONFIG  = DEFAULT
-endif
-
+SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE
 
 #
 # Machine Configuration options  
 #
-export SUPPORTED_I386_MACHINE_CONFIGS := DEFAULT
-export SUPPORTED_X86_64_MACHINE_CONFIGS := DEFAULT
+
+SUPPORTED_X86_64_MACHINE_CONFIGS = NONE
 
 
 #
-# Target configuration options.  NOTE - target configurations will 
-# override ARCH_CONFIGS and KERNEL_CONFIGS.
-#
-# Target configs come in groups of three parameters.  The first is the 
-# kernel configuration, the second is the architecture configuration,
-# and the third is the machine configuration.  You may pass in as
-# many groups of configurations as you wish.  Each item passed in is
-# separated by whitespace.
-#
-# Example:
-#      TARGET_CONFIGS="release x86_64 default debug i386 default release arm S5l8920X"
-# Parameters may be in upper or lower case (they are converted to upper).
-#
-# "default" parameter is a special case.  It means use the default value for 
-# that parameter.  Here are the default values for each configuration:
-#
-# default kernel configuration = DEFAULT_KERNEL_CONFIG
-# default architecture configuration = system architecture where you are running make.
-# default machine configuration for i386 = none at this time.
-# default machine configuration for x86_64 = none at this time.
-# default machine configuration for arm = "S5L8920X".
+# Platform options
 #
-ifndef TARGET_CONFIGS_UC
-ifdef TARGET_CONFIGS
-       export TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
-       export MACHINE_CONFIG   = $(word 3, $(TARGET_CONFIGS_UC))
-       export DEFAULT_KERNEL_CONFIG = $(word 1, $(TARGET_CONFIGS_UC))
-else
-
-       ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
-# generate set of standard embedded configs
-               export TARGET_CONFIGS = $(TARGET_CONFIGS_EMBEDDED)
-       else ifneq ($(filter %_devicemap,$(MAKECMDGOALS)),)
-               DEVICEMAP_PLATFORMS = $(shell $(EMBEDDED_DEVICE_MAP) -query SELECT DISTINCT Platform FROM Targets | $(TR) [:lower:] [:upper:])
-               export TARGET_CONFIGS = $(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(foreach my_arch,$(ARCH_CONFIGS),$(foreach my_machine_config,$(filter $(DEVICEMAP_PLATFORMS),$(SUPPORTED_$(my_arch)_MACHINE_CONFIGS)),$(my_kernel_config) $(my_arch) $(my_machine_config) )))
-       else
-# generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIG (which defaults to "DEFAULT")
-               export TARGET_CONFIGS = $(strip $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_kern_config, $(KERNEL_CONFIGS), $(my_kern_config) $(my_arch_config) $(MACHINE_CONFIG))))
-       endif
-       export TARGET_CONFIGS_UC := $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z)
-       export MACHINE_CONFIG   = $(word 3, $(TARGET_CONFIGS_UC))
-       export DEFAULT_KERNEL_CONFIG = $(word 1, $(TARGET_CONFIGS_UC))
-endif
-endif
-
-export MACHINE_CONFIG_LC := $(shell printf "%s" "$(MACHINE_CONFIG)" | $(TR) A-Z a-z)
-export KERNEL_CONFIG_LC := $(shell printf "%s" "$(KERNEL_CONFIG)" | $(TR) A-Z a-z)
+SUPPORTED_PLATFORMS = MacOSX iPhoneOS iPhoneSimulator
 
 #
-# Validate configuration options
+# Setup up *_LC variables during recursive invocations
 #
-ifneq ($(ARCH_CONFIG),)
-ifeq ($(filter $(ARCH_CONFIG),$(SUPPORTED_ARCH_CONFIGS)),)
-$(error Unsupported ARCH_CONFIG $(ARCH_CONFIG))
-endif
-endif
 
-ifneq ($(KERNEL_CONFIG),)
-ifeq ($(filter $(KERNEL_CONFIG),$(SUPPORTED_KERNEL_CONFIGS)),)
-$(error Unsupported KERNEL_CONFIG $(KERNEL_CONFIG))
-endif
+ifndef CURRENT_ARCH_CONFIG_LC
+       export CURRENT_ARCH_CONFIG_LC   := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z)
 endif
 
-ifneq ($(MACHINE_CONFIG),)
-ifneq ($(ARCH_CONFIG),)
-ifeq ($(filter $(MACHINE_CONFIG),$(SUPPORTED_$(ARCH_CONFIG)_MACHINE_CONFIGS)),)
-$(error Unsupported MACHINE_CONFIG $(MACHINE_CONFIG))
-endif
-endif
+ifndef CURRENT_KERNEL_CONFIG_LC
+       export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z)
 endif
 
-ifneq ($(PLATFORM),)
-ifeq ($(filter $(PLATFORM),$(SUPPORTED_PLATFORMS)),)
-$(error Unsupported PLATFORM $(PLATFORM))
-endif
+ifndef CURRENT_MACHINE_CONFIG_LC
+       export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z)
 endif
 
+
 #
-# Kernel Configuration to install
-#
-#  supported install architecture : I386 X86_64 
+# Component List
 #
-export INSTALL_TYPE    = $(DEFAULT_KERNEL_CONFIG)
-
-ifndef INSTALL_ARCHS
-export INSTALL_ARCHS   = $(strip $(foreach my_config, $(SUPPORTED_ARCH_CONFIGS), $(filter $(TARGET_CONFIGS_UC),$(my_config))))
-export INSTALL_ARCHS_LC := $(shell printf "%s" "$(INSTALL_ARCHS)" | $(TR) A-Z a-z)
-endif
+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)) 
 
-export INSTALL_ARCH_DEFAULT    = $(firstword $(INSTALL_ARCHS))
-ifeq ($(INSTALL_ARCH_DEFAULT),)
-$(error Could not determine INSTALL_ARCH_DEFAULT)
-endif
 
 #
 # Deployment target flag
 #
-ifndef DEPLOYMENT_TARGET_FLAGS
-SDKVERSION=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
 ifeq ($(PLATFORM),MacOSX)
-    export DEPLOYMENT_TARGET_FLAGS := -mmacosx-version-min=$(SDKVERSION)
+    DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
 else ifeq ($(PLATFORM),iPhoneOS)
-    export DEPLOYMENT_TARGET_FLAGS := -miphoneos-version-min=$(SDKVERSION)
+    DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
 else ifeq ($(PLATFORM),iPhoneSimulator)
-    export DEPLOYMENT_TARGET_FLAGS := 
+    DEPLOYMENT_TARGET_FLAGS =
 else
-    export DEPLOYMENT_TARGET_FLAGS := 
-endif
+    DEPLOYMENT_TARGET_FLAGS =
 endif
 
+
 #
 # Standard defines list
 #
-export DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \
-       -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT)
+DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \
+       -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT) \
+       $(SEED_DEFINES)
 
 #
 # Compiler command
 #
-KCC  := $(CC)
-KC++ := $(CXX)
+KCC  = $(CC)
+KC++ = $(CXX)
 
 #
 # Compiler warning flags
@@ -249,9 +90,6 @@ CWARNFLAGS_STD = \
        -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wchar-subscripts \
        -Winline -Wnested-externs -Wredundant-decls -Wextra-tokens
 
-# Certain warnings are non-fatal (8474835)
-CWARNFLAGS_STD += -Wno-error=cast-align
-
 # Can be overridden in Makefile.template or Makefile.$arch
 export CWARNFLAGS ?= $(CWARNFLAGS_STD)
 
@@ -264,8 +102,8 @@ CXXWARNFLAGS_STD = \
        -Wcast-qual -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts \
        -Wredundant-decls -Wextra-tokens
 
-# Certain warnings are non-fatal (8474835, 9000888)
-CXXWARNFLAGS_STD += -Wno-error=cast-align -Wno-error=overloaded-virtual
+# overloaded-virtual warnings are non-fatal (9000888)
+CXXWARNFLAGS_STD += -Wno-error=overloaded-virtual
 
 # Can be overridden in Makefile.template or Makefile.$arch
 export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
@@ -274,17 +112,9 @@ define add_perfile_cxxflags
 $(1)_CXXWARNFLAGS_ADD += $2
 endef
 
-#
-# Setup for parallel sub-makes based on 2 times number of logical CPUs
-#
-ifndef MAKEJOBS
-export MAKEJOBS = --jobs=$(shell expr `/usr/sbin//sysctl -n hw.logicalcpu` \* 2)
-endif
-
 #
 # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers
 
-ARCH_FLAGS_I386                  = -arch i386
 ARCH_FLAGS_X86_64        = -arch x86_64
 
 
@@ -292,73 +122,56 @@ ARCH_FLAGS_X86_64   = -arch x86_64
 # Default CFLAGS
 #
 ifdef RC_CFLAGS
-export OTHER_CFLAGS    = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS))
+OTHER_CFLAGS   = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS))
 endif
 
-export DSYMRESDIR   = ./Contents/Resources/
-export DSYMBUILDDIR = ./Contents/Resources/DWARF/
+#
+# Debug info
+#
+DSYMKERNELSYSDIR = mach_kernel.sys.dSYM
+DSYMINFODIR    = Contents
+DSYMKGMACROSDIR        = Contents/Resources
+DSYMLLDBMACROSDIR = Contents/Resources/Python
+DSYMDWARFDIR   = Contents/Resources/DWARF
+
+DEBUG_CFLAGS := -gdwarf-2
+BUILD_DSYM := 1
 
 #
 # We must not use -fno-keep-inline-functions, or it will remove the dtrace
 # probes from the kernel.
 #
-export CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
+CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
        -freorder-blocks -fno-builtin -fno-common \
        -fsigned-bitfields $(OTHER_CFLAGS)
 
-ifeq ($(BUILD_STABS),1)
-export CFLAGS_GEN += -gstabs+
-export BUILD_DWARF = 0
-export BUILD_STABS = 1
-else
-export CFLAGS_GEN += -gdwarf-2
-export BUILD_DWARF = 1
-export BUILD_STABS = 0
-endif
-
-export CFLAGS_RELEASE  = 
-export CFLAGS_DEVELOPMENT      =
-export CFLAGS_DEBUG    = -fstack-protector-all
-export CFLAGS_PROFILE  = -pg
+CFLAGS_RELEASE         = 
+CFLAGS_DEVELOPMENT     =
+CFLAGS_DEBUG   = 
+CFLAGS_PROFILE         =  -pg
 
-export CFLAGS_I386     = -static -Di386 -DI386 -D__I386__ \
-                               -DPAGE_SIZE_FIXED -msoft-float \
-                               -integrated-as
-export CFLAGS_X86_64   = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
+CFLAGS_X86_64  = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
                                -DPAGE_SIZE_FIXED -mkernel -msoft-float \
-                               -integrated-as
-
-
-ifeq (-arch armv7,$(ARCH_FLAGS_ARM))
-CFLAGS_ARM             += -mthumb
-endif
-ifeq (-arch armv6,$(ARCH_FLAGS_ARM))
-CFLAGS_ARM             += -mthumb
-endif
+                               -fno-limit-debug-info # Workaround for 11076603
 
 
-export CFLAGS_RELEASEI386 = -O2
-export CFLAGS_DEVELOPMENTI386 = -O2
-export CFLAGS_DEBUGI386 = -O0
-export CFLAGS_PROFILEI386 = -O2
-
-export CFLAGS_RELEASEX86_64 = -O2
-export CFLAGS_DEVELOPMENTX86_64 = -O2
+CFLAGS_RELEASEX86_64 = -O2
+CFLAGS_DEVELOPMENTX86_64 = -O2
 # No space optimization for the DEBUG kernel for the benefit of gdb:
-export CFLAGS_DEBUGX86_64 = -O0
-export CFLAGS_PROFILEX86_64 = -O2
-
-export CFLAGS_RELEASEARM = -O2
-export CFLAGS_DEVELOPMENTARM = -O2
-export CFLAGS_DEBUGARM = -O0
-export CFLAGS_PROFILEARM = -O2
-
-export CFLAGS  = $(CFLAGS_GEN) \
-                 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \
-                 $($(addsuffix $(KERNEL_CONFIG),CFLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),CFLAGS_))) \
+CFLAGS_DEBUGX86_64 = -O0
+CFLAGS_PROFILEX86_64 = -O2
+
+CFLAGS_RELEASEARM = -O2
+CFLAGS_DEVELOPMENTARM = -O2
+CFLAGS_DEBUGARM = -O0
+CFLAGS_PROFILEARM = -O2
+
+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) \
                  $(DEFINES)
 
@@ -370,9 +183,13 @@ OTHER_CXXFLAGS     =
 
 CXXFLAGS_GEN  = -fapple-kext $(OTHER_CXXFLAGS)
 
+# For the moment, do not use gnu++11
+#CXXFLAGS_ARM = -std=gnu++11
+
 CXXFLAGS      = $(CXXFLAGS_GEN) \
-                 $($(addsuffix $(ARCH_CONFIG),CXXFLAGS_)) \
-                 $($(addsuffix $(KERNEL_CONFIG),CXXFLAGS_))
+                 $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \
+                 $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_))
+
 
 #
 # Assembler command
@@ -383,26 +200,23 @@ S_KCC     = $(CC)
 #
 # Default SFLAGS
 #
-export SFLAGS_GEN = -D__ASSEMBLER__ $(OTHER_CFLAGS)
+SFLAGS_GEN = -D__ASSEMBLER__ $(OTHER_CFLAGS)
 
-export SFLAGS_RELEASE  = 
-export SFLAGS_DEVELOPMENT      = 
-export SFLAGS_DEBUG    = 
-export SFLAGS_PROFILE  = 
+SFLAGS_RELEASE         = 
+SFLAGS_DEVELOPMENT     = 
+SFLAGS_DEBUG   = 
+SFLAGS_PROFILE         = 
 
-export SFLAGS_I386     = $(CFLAGS_I386)
-export SFLAGS_X86_64   = $(CFLAGS_X86_64)
+SFLAGS_X86_64  = $(CFLAGS_X86_64)
 
-
-export SFLAGS  = $(SFLAGS_GEN) \
-                 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),SFLAGS_)) \
-                 $($(addsuffix $(KERNEL_CONFIG),SFLAGS_)) \
+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) \
                  $(DEFINES)
 
-
 #
 # Linker command
 #
@@ -411,12 +225,15 @@ LD        = $(KC++) -nostdlib
 #
 # Default LDFLAGS
 #
-export LDFLAGS_KERNEL_GEN = \
+# Availability of DWARF allows DTrace CTF (compressed type format) to be constructed.
+# ctf_insert creates the CTF section.  It needs reserved padding in the
+# headers for the load command segment and the CTF section structures.
+#
+LDFLAGS_KERNEL_GEN = \
        -nostdlib \
        -fapple-kext \
        -Wl,-e,__start \
        -Wl,-sectalign,__TEXT,__text,0x1000 \
-       -Wl,-sectalign,__TEXT,initcode,0x1000 \
        -Wl,-sectalign,__DATA,__common,0x1000 \
        -Wl,-sectalign,__DATA,__bss,0x1000 \
        -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
@@ -426,49 +243,30 @@ export LDFLAGS_KERNEL_GEN = \
        -Wl,-new_linker \
        -Wl,-pagezero_size,0x0 \
        -Wl,-version_load_command \
-       -Wl,-function_starts
+       -Wl,-function_starts \
+       -Wl,-headerpad,152
 
-# Availability of DWARF allows DTrace CTF (compressed type format) to be constructed.
-# ctf_insert creates the CTF section.  It needs reserved padding in the
-# headers for the load command segment and the CTF section structures.
-ifeq ($(BUILD_DWARF),1)
-export LDFLAGS_KERNEL_GEN += \
-    -Wl,-headerpad,152
-endif
-
-export LDFLAGS_KERNEL_RELEASE  =
-export LDFLAGS_KERNEL_DEVELOPMENT      =
-export LDFLAGS_KERNEL_DEBUG    = 
-export LDFLAGS_KERNEL_PROFILE  = 
-
-export LDFLAGS_KERNEL_RELEASEI386     = \
-       -Wl,-segaddr,__INITPT,0x00100000 \
-       -Wl,-segaddr,__INITGDT,0x00106000 \
-       -Wl,-segaddr,__SLEEP,0x00107000 \
-       -Wl,-segaddr,__HIB,0x00108000 \
-       -Wl,-image_base,0x200000 \
-       -Wl,-seg_page_size,__TEXT,0x200000
-
-export LDFLAGS_KERNEL_DEBUGI386 = $(LDFLAGS_KERNEL_RELEASEI386)
-export LDFLAGS_KERNEL_DEVELOPMENTI386 = $(LDFLAGS_KERNEL_RELEASEI386)
-export LDFLAGS_KERNEL_PROFILEI386 = $(LDFLAGS_KERNEL_RELEASEI386)
+LDFLAGS_KERNEL_RELEASE         =
+LDFLAGS_KERNEL_DEVELOPMENT     =
+LDFLAGS_KERNEL_DEBUG   = 
+LDFLAGS_KERNEL_PROFILE         = 
 
 # KASLR static slide config:
 ifndef SLIDE
 SLIDE=0x00
 endif
-KERNEL_MIN_ADDRESS      := 0xffffff8000000000
-KERNEL_BASE_OFFSET      := 0x100000
-KERNEL_STATIC_SLIDE     := $(shell printf "0x%016x" \
-                          $$[ $(SLIDE) << 21 ])
-KERNEL_STATIC_BASE      := $(shell printf "0x%016x" \
-                          $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ])
-KERNEL_HIB_SECTION_BASE := $(shell printf "0x%016x" \
-                          $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ])
-KERNEL_TEXT_BASE        := $(shell printf "0x%016x" \
-                          $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ])
-
-export LDFLAGS_KERNEL_RELEASEX86_64 = \
+KERNEL_MIN_ADDRESS      = 0xffffff8000000000
+KERNEL_BASE_OFFSET      = 0x100000
+KERNEL_STATIC_SLIDE     = $(shell printf "0x%016x" \
+                         $$[ $(SLIDE) << 21 ])
+KERNEL_STATIC_BASE      = $(shell printf "0x%016x" \
+                         $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ])
+KERNEL_HIB_SECTION_BASE = $(shell printf "0x%016x" \
+                         $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ])
+KERNEL_TEXT_BASE        = $(shell printf "0x%016x" \
+                         $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ])
+
+LDFLAGS_KERNEL_RELEASEX86_64 = \
        -Wl,-pie \
        -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
        -Wl,-image_base,$(KERNEL_TEXT_BASE) \
@@ -482,112 +280,103 @@ export LDFLAGS_KERNEL_RELEASEX86_64 = \
        -Wl,-sectalign,__HIB,__const,0x1000 \
        -Wl,-sectalign,__HIB,__bss,0x1000 \
        -Wl,-sectalign,__HIB,__common,0x1000 \
+       $(LDFLAGS_NOSTRIP_FLAG)
 
 # Define KERNEL_BASE_OFFSET so known at compile time:
-export CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
-
-export LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
-export LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
-export LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
 
-export LDFLAGS_KERNEL_RELEASEARM     = \
-       -Wl,-pie \
-       -Wl,-static \
-       -Wl,-image_base,0x80001000 \
-       -Wl,-exported_symbols_list,$(TARGET)/kernel-kpi.exp
-
-export LDFLAGS_KERNEL_DEVELOPMENTARM     = \
-       -Wl,-pie \
-       -Wl,-static \
-       -Wl,-image_base,0x80001000
+LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
 
-export LDFLAGS_KERNEL_DEBUGARM = $(LDFLAGS_KERNEL_DEVELOPMENTARM)
 
-# Offset image base by page to have iBoot load kernel TEXT correctly.
-# First page is used for various purposes : sleep token, reset vector.
-
-export LDFLAGS_KERNEL  = $(LDFLAGS_KERNEL_GEN) \
-                 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
-                 $($(addsuffix $(ARCH_CONFIG),LDFLAGS_KERNEL_)) \
-                 $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
-                 $($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_))) \
+LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
+                 $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
+                 $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \
+                 $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
+                 $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \
                  $(DEPLOYMENT_TARGET_FLAGS)
 
 #
 # Default runtime libraries to be linked with the kernel
 #
-export LD_KERNEL_LIBS  = -lcc_kext
+LD_KERNEL_LIBS = -lcc_kext
 
+#
+# DTrace support
+#
+ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE)
+ifneq ($(filter ARM%,$(CURRENT_ARCH_CONFIG)),)
+DO_CTFCONVERT = 0
+DO_CTFMERGE   = 0
+DO_CTFMACHO   = 0
+else
+DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT)
+DO_CTFMERGE   = 1
+DO_CTFMACHO   = $(NEEDS_CTF_MACHOS)
+endif
+else
+DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT)
+DO_CTFMERGE   = 1
+DO_CTFMACHO   = $(NEEDS_CTF_MACHOS)
+endif
 
 #
 # Default INCFLAGS
 #
-export INCFLAGS_IMPORT         = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
-export INCFLAGS_EXTERN         = -I$(OBJROOT)/EXTERN_HDRS -I$(SRCROOT)/EXTERNAL_HEADERS -I$(SRCROOT)/EXTERNAL_HEADERS/bsd
-export INCFLAGS_GEN    = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
-export INCFLAGS_POSIX  = -I$(OBJROOT)/EXPORT_HDRS/bsd
-export INCFLAGS_LOCAL  = -I.
+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.
 
-export INCFLAGS        = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE)
+INCFLAGS       = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE)
 
 #
 # Default MIGFLAGS
 #
-export MIGFLAGS        = $(DEFINES) $(INCFLAGS) $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \
-                         $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
-                         $(DEPLOYMENT_TARGET_FLAGS)
+MIGFLAGS       = $(DEFINES) $(INCFLAGS) $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
+               $(DEPLOYMENT_TARGET_FLAGS)
 
 #
 # Support for LLVM Link Time Optimization (LTO)
 #
+# CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files
+# that deal poorly with LTO, or files that must be machine
+# code *.o files for xnu to build (i.e, setsegname runs on
+# them).
+#
+# LDFLAGS_NOSTRIP_FLAG is used to support configurations that
+# do not utilize an export list.  For these configs to build,
+# we need to prevent the LTO logic from dead stripping them.
 
 ifeq ($(BUILD_LTO),1)
-export CFLAGS_GEN      += -flto
-export CXXFLAGS_GEN    += -flto
-export LDFLAGS_KERNEL_GEN      += -Wl,-object_path_lto,$(TARGET)/lto.o
-export CFLAGS_NOLTO_FLAG = -fno-lto
-export BUILD_MACHO_OBJ = 0
-export BUILD_LTO       = 1
-else
-export CFLAGS_NOLTO_FLAG =
-export BUILD_MACHO_OBJ = 1
-export BUILD_LTO       = 0
-endif
-
-#
-# Support for LLVM Integrated Assembler with clang driver
-#
-ifeq ($(BUILD_INTEGRATED_ASSEMBLER),1)
-export SFLAGS_GEN      += -integrated-as
-export CFLAGS_GEN      += -integrated-as
-export CXXFLAGS_GEN    += -integrated-as
-export SFLAGS_NOINTEGRATEDAS_FLAGS     = -no-integrated-as
-export CFLAGS_NOINTEGRATEDAS_FLAGS     = -no-integrated-as
+CFLAGS_GEN     += -flto
+CXXFLAGS_GEN   += -flto
+LDFLAGS_KERNEL_GEN     += -Wl,-mllvm,-disable-simplify-libcalls -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
-export SFLAGS_NOINTEGRATEDAS_FLAGS     =
-export CFLAGS_NOINTEGRATEDAS_FLAGS     =
+LDFLAGS_NOSTRIP_FLAG =
+CFLAGS_NOLTO_FLAG =
+SUPPORTS_CTFCONVERT    = 1
+NEEDS_CTF_MACHOS       = 0
 endif
 
 #
 # Default VPATH
 #
-empty:=
-space:= $(empty) $(empty)
-export VPATH_IMPORT    = $(subst $(space),:,$(patsubst %,$(OBJROOT)/EXPORT_HDRS/%,$(strip $(COMPONENT_IMPORT_LIST)))):
-export VPATH_EXTERN    = $(OBJROOT)/EXTERN_HDRS:
-export VPATH_GEN       = .:$(SOURCE):
-
-export VPATH           = $(VPATH_GEN)$(VPATH_IMPORT)$(VPATH_EXTERN)$(VPATH_MAKEFILE)
+export VPATH = .:$(SOURCE)
 
 #
 # Macros that control installation of kernel and its header files
 #
 # install flags for header files
 # 
-INSTALL_FLAGS = -c -m 0444
-FILE_INSTALL_FLAGS = -c -m 0644
-DATA_INSTALL_FLAGS = -c -m 0644
+INSTALL_FLAGS = -c -S -m 0444
+DATA_INSTALL_FLAGS = -c -S -m 0644
+EXEC_INSTALL_FLAGS = -c -S -m 0755
 
 #
 # Header file destinations
@@ -621,54 +410,83 @@ KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources
 
 XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE
 
-PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x),-UPLATFORM_$(x)))
 
-SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -U_OPEN_SOURCE_
-SINCFRAME_UNIFDEF  = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -D_OPEN_SOURCE_
-KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL -U_OPEN_SOURCE_
-KINCFRAME_UNIFDEF  = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL -D_OPEN_SOURCE_
+PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UPLATFORM_$(x)))
+
+SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__
+SINCFRAME_UNIFDEF  = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__
+KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL -U_OPEN_SOURCE_ -U__OPEN_SOURCE__
+KINCFRAME_UNIFDEF  = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL -D_OPEN_SOURCE_ -D__OPEN_SOURCE__
 
 
 #
-# Component Header file destinations
+# Compononent Header file destinations
 #
 EXPDIR = EXPORT_HDRS/$(COMPONENT)
 
 #
 # Strip Flags
 #
-export STRIP_FLAGS_RELEASE     = -S -x 
-export STRIP_FLAGS_DEVELOPMENT = -S -x 
-export STRIP_FLAGS_DEBUG       = -S 
-export STRIP_FLAGS_PROFILE     = -S -x
+STRIP_FLAGS_RELEASE    = -S -x 
+STRIP_FLAGS_DEVELOPMENT        = -S -x 
+STRIP_FLAGS_DEBUG      = -S 
+STRIP_FLAGS_PROFILE    = -S -x
 
-export STRIP_FLAGS     = $($(addsuffix $(KERNEL_CONFIG),STRIP_FLAGS_)) 
+STRIP_FLAGS    = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_)) 
 
 #
 # dsymutil flags
 #
-export DSYMUTIL_FLAGS_I386 = --arch=i386
-export DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
+DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
 
-export DSYMUTIL_FLAGS = $($(addsuffix $(ARCH_CONFIG),DSYMUTIL_FLAGS_))
+DSYMUTIL_FLAGS = $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_))
 
 #
 # Man Page destination
 #
-MANDIR = usr/share/man
+MANDIR = /usr/share/man
 
 #
 # DEBUG alias location
 #
-DEVELOPER_EXTRAS_DIR = AppleInternal/Developer/Extras
+DEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_debug
 
 #
-#  This must be here before any rules are possibly defined by the
-#  machine dependent makefile fragment so that a plain "make" command
-#  always works.  The config program will emit an appropriate rule to
-#  cause "all" to depend on every kernel configuration it generates.
+# mach_kernel install location
 #
+INSTALL_KERNEL_DIR = /
 
-default: all
+#
+# System.kext pseudo-kext install location
+#
+INSTALL_EXTENSIONS_DIR = /System/Library/Extensions
+
+#
+# KDK location for iOS
+#
+INSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK
+
+#
+# Misc. Etc.
+#
+INSTALL_SHARE_MISC_DIR = /usr/share/misc
+INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace
+
+#
+# Overrides for XBS build aliases
+#
+ifeq ($(RC_ProjectName),xnu_debug)
+INSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR)
+DELETE_KERNEL_FRAMEWORK_AND_MISC = 1
+INSTALL_XNU_DEBUG_FILES = 1
+endif
+ifeq ($(PLATFORM),iPhoneOS)
+INSTALL_PRIMARY_KERNEL_LIKE_NON_PRIMARY = 1
+INSTALL_KERNEL_SYM_TO_KDK = 1
+USE_BINARY_PLIST = 1
+else ifeq ($(PLATFORM),iPhoneSimulator)
+INSTALL_SYSTEM_FRAMEWORK_SYMLINKS = 1
+USE_BINARY_PLIST = 1
+endif
 
 # vim: set ft=make: