]> git.saurik.com Git - apple/xnu.git/blobdiff - makedefs/MakeInc.cmd
xnu-6153.121.1.tar.gz
[apple/xnu.git] / makedefs / MakeInc.cmd
index e69b52e0cf631f544ab80d5cfbf0d609e156739e..0c8420d13b839aeecfe77d222ac1ed3a6e42aeaf 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: makefile;-*-
 #
-# Copyright (C) 1999-2012 Apple Inc. All rights reserved.
+# Copyright (C) 1999-2016 Apple Inc. All rights reserved.
 #
 # MakeInc.cmd contains command paths for use during
 # the build, as well as make fragments and text
 #
 # Commands for the build environment
 #
+
 ##
 # Verbosity
 ##
+
 ifeq ($(RC_XBS),YES)
-VERBOSE = YES
+       VERBOSE = YES
 else
-VERBOSE = NO
+       VERBOSE = NO
 endif
-ifeq ($(VERBOSE),YES)
-_v =
-_vstdout =
-else
-_v = @
-_vstdout = > /dev/null
+
+ECHO = echo
+
+LOG = echo
+makelog = $(info $1)
+ERR = $(ECHO) > /dev/stderr
+
+QUIET ?= 0
+ifneq ($(QUIET),0)
+       LOG = :
+       makelog =
+       ifeq ($(VERBOSE),YES)
+               override VERBOSE = NO
+       endif
 endif
 
 ifeq ($(VERBOSE),YES)
+       _v =
+       _vstdout =
        XCRUN = /usr/bin/xcrun -verbose
 else
+       _v = @
+       _vstdout = > /dev/null
        XCRUN = /usr/bin/xcrun
 endif
 
-SDKROOT ?= /
+VERBOSE_GENERATED_MAKE_FRAGMENTS = NO
+
+SDKROOT ?= macosx
 HOST_SDKROOT ?= macosx
-HOST_SPARSE_SDKROOT ?= /
 
 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
 # must resolve these to a full path and override SDKROOT.
@@ -49,6 +64,9 @@ override SDKROOT = $(SDKROOT_RESOLVED)
 
 ifeq ($(HOST_SDKROOT_RESOLVED),)
 export HOST_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -show-sdk-path)
+ifeq ($(strip $(HOST_SDKROOT_RESOLVED)),)
+export HOST_SDKROOT_RESOLVED := /
+endif
 endif
 override HOST_SDKROOT = $(HOST_SDKROOT_RESOLVED)
 
@@ -57,17 +75,22 @@ ifeq ($(PLATFORM),)
        export PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
        ifeq ($(PLATFORM),)
                export PLATFORM := MacOSX
+       else ifeq ($(shell echo $(PLATFORM) | tr A-Z a-z),watchos)
+               export PLATFORM := WatchOS
        endif
 endif
 
-ifeq ($(SDKVERSION),)
-     export SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
+ifeq ($(PLATFORM),MacOSX)
+       ifeq (DriverKit,$(shell echo $(SDKROOT_RESOLVED) | sed 's,^.*/\([^/1-9]*\)[1-9][^/]*\.sdk$$,\1,'))
+               export PLATFORM := DriverKit
+               export DRIVERKIT ?= 1
+               export DRIVERKITROOT ?= /System/DriverKit
+               export DRIVERKITRUNTIMEROOT = $(DRIVERKITROOT)/Runtime
+       endif
 endif
 
-ifeq ($(PLATFORM),iPhoneOS)
-       ifeq ($(HOST_SPARSE_SDKROOT),/)
-               export HOST_SPARSE_SDKROOT := $(shell $(XCRUN) -sdk iphonehost.internal -show-sdk-path)
-       endif
+ifeq ($(SDKVERSION),)
+     export SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
 endif
 
 # CC/CXX get defined by make(1) by default, so we can't check them
@@ -87,6 +110,9 @@ endif
 ifeq ($(MIGCC),)
        export MIGCC := $(CC)
 endif
+ifeq ($(IIG),)
+       export IIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find iig)
+endif
 ifeq ($(STRIP),)
        export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip)
 endif
@@ -118,20 +144,38 @@ ifeq ($(NMEDIT),)
        export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit)
 endif
 
+#
+# Platform options
+#
+SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS
+SUPPORTED_SIMULATOR_PLATFORMS := iPhoneSimulator iPhoneNanoSimulator tvSimulator AppleTVSimulator WatchSimulator
+SUPPORTED_PLATFORMS := MacOSX DriverKit $(SUPPORTED_SIMULATOR_PLATFORMS) $(SUPPORTED_EMBEDDED_PLATFORMS)
+
 # Platform-specific tools
-ifeq (iPhoneOS,$(PLATFORM))
+ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
 ifeq ($(EMBEDDED_DEVICE_MAP),)
        export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map)
 endif
-EDM_DBPATH = $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
+EDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
 endif
 
 # Scripts or tools we build ourselves
+#
+# setsegname - Rename segments in a Mach-O object file
+# kextsymboltool - Create kext pseudo-kext Mach-O kexts binaries
+# decomment - Strip out comments to detect whether a file is comments-only
+# installfile - Atomically copy files, esp. when multiple architectures
+#               are trying to install the same target header
+# replacecontents - Write contents to a file and update modtime *only* if
+#               contents differ
+#
 SEG_HACK = $(OBJROOT)/SETUP/setsegname/setsegname
 KEXT_CREATE_SYMBOL_SET = $(OBJROOT)/SETUP/kextsymboltool/kextsymboltool
 DECOMMENT = $(OBJROOT)/SETUP/decomment/decomment
 NEWVERS = $(SRCROOT)/config/newvers.pl
 INSTALL = $(OBJROOT)/SETUP/installfile/installfile
+REPLACECONTENTS = $(OBJROOT)/SETUP/replacecontents/replacecontents
+JSONCOMPILATIONDB = $(OBJROOT)/SETUP/json_compilation_db/json_compilation_db
 
 # Standard BSD tools
 RM = /bin/rm -f
@@ -141,16 +185,17 @@ MV = /bin/mv
 LN = /bin/ln -fs
 CAT = /bin/cat
 MKDIR = /bin/mkdir -p
+CHMOD = /bin/chmod
 FIND = /usr/bin/find
 XARGS = /usr/bin/xargs
-TAR = /usr/bin/gnutar
+PAX = /bin/pax
 BASENAME = /usr/bin/basename
 DIRNAME = /usr/bin/dirname
 TR = /usr/bin/tr
 TOUCH = /usr/bin/touch
+SLEEP = /bin/sleep
 AWK = /usr/bin/awk
 SED = /usr/bin/sed
-ECHO = /bin/echo
 PLUTIL = /usr/bin/plutil
 
 #
@@ -194,18 +239,18 @@ _function_create_build_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3))
 # $(3) is an un-expanded machine config from a TARGET_CONFIGS_UC tuple
 _function_create_build_configs_do_expand =          $(call _function_create_build_configs_join, \
                                                           $(if $(filter DEFAULT,$(1)), \
-                                                               $(DEFAULT_KERNEL_CONFIG), \
+                                                               $(DEFAULT_KERNEL_CONFIG), \
                                                                $(1) \
                                                            ), \
                                                           $(if $(filter DEFAULT,$(2)), \
-                                                               $(DEFAULT_ARCH_CONFIG), \
+                                                               $(DEFAULT_ARCH_CONFIG), \
                                                                $(2) \
                                                            ), \
                                                           $(if $(filter DEFAULT,$(3)), \
-                                                               $(if $(filter DEFAULT,$(2)), \
-                                                                    $(DEFAULT_$(DEFAULT_ARCH_CONFIG)_MACHINE_CONFIG), \
+                                                               $(if $(filter DEFAULT,$(2)), \
+                                                                    $(DEFAULT_$(DEFAULT_ARCH_CONFIG)_MACHINE_CONFIG), \
                                                                     $(DEFAULT_$(strip $(2))_MACHINE_CONFIG) \
-                                                               ), \
+                                                               ), \
                                                                $(3) \
                                                            ) \
                                                     )
@@ -214,20 +259,57 @@ _function_create_build_configs_do_expand =          $(call _function_create_buil
 #      3 elements at a time
 function_create_build_configs = $(sort \
                                        $(strip \
-                                                $(call _function_create_build_configs_do_expand, \
-                                                       $(word 1,$(1)), \
-                                                       $(word 2,$(1)), \
-                                                       $(word 3,$(1)), \
+                                                $(call _function_create_build_configs_do_expand, \
+                                                       $(word 1,$(1)), \
+                                                       $(word 2,$(1)), \
+                                                       $(word 3,$(1)), \
                                                  ) \
                                                 $(if $(word 4,$(1)), \
                                                      $(call function_create_build_configs, \
                                                             $(wordlist 4,$(words $(1)),$(1)) \
                                                       ), \
-                                                      \
                                                  ) \
                                          ) \
                                   )
 
+# Similar to build configs, but alias configs are a 4-tuple
+
+# $(1) is an expanded kernel config from a TARGET_CONFIGS_ALIASES_UC tuple
+# $(2) is an expanded arch config from a TARGET_CONFIGS_ALIASES_UC tuple
+# $(3) is an expanded kernel machine config from a TARGET_CONFIGS_ALIASES_UC tuple
+# $(4) is an expanded SoC platform config from a TARGET_CONFIGS_ALIASES_UC tuple,
+#      which should be an alias of $(3)
+_function_create_alias_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3))^$(strip $(4))
+
+_function_create_alias_configs_do_expand =         $(call _function_create_alias_configs_join, \
+                                                          $(if $(filter DEFAULT,$(1)), \
+                                                               $(DEFAULT_KERNEL_CONFIG), \
+                                                               $(1) \
+                                                           ), \
+                                                          $(if $(filter DEFAULT,$(2)), \
+                                                               $(DEFAULT_ARCH_CONFIG), \
+                                                               $(2) \
+                                                           ), \
+                                                          $(3), \
+                                                          $(4) \
+                                                    )
+
+function_create_alias_configs = $(sort \
+                                       $(strip \
+                                                $(call _function_create_alias_configs_do_expand, \
+                                                       $(word 1,$(1)), \
+                                                       $(word 2,$(1)), \
+                                                       $(word 3,$(1)), \
+                                                       $(word 4,$(1)), \
+                                                 ) \
+                                                $(if $(word 5,$(1)), \
+                                                     $(call function_create_alias_configs, \
+                                                            $(wordlist 5,$(words $(1)),$(1)) \
+                                                      ), \
+                                                 ) \
+                                        ) \
+                                )
+
 # $(1) is a fully-expanded kernel config
 # $(2) is a fully-expanded arch config
 # $(3) is a fully-expanded machine config. "NONE" is not represented in the objdir path
@@ -235,7 +317,7 @@ function_convert_target_config_uc_to_objdir = $(if $(filter NONE,$(3)),$(strip $
 
 # $(1) is a fully-expanded build config (like "RELEASE^X86_64^NONE")
 function_convert_build_config_to_objdir = $(call function_convert_target_config_uc_to_objdir, \
-                                                $(word 1,$(subst ^, ,$(1))), \
+                                                $(word 1,$(subst ^, ,$(1))), \
                                                 $(word 2,$(subst ^, ,$(1))), \
                                                 $(word 3,$(subst ^, ,$(1))) \
                                           )
@@ -263,7 +345,15 @@ space := $(empty) $(empty)
 
 # Arithmetic
 # $(1) is the number to increment
-NUM16 = x x x x x x x x x x x x x x x x 
-increment = $(words x $(wordlist 1,$(1),$(NUM16)))
+NUM32 = x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
+increment = $(words x $(wordlist 1,$(1),$(NUM32)))
+decrement = $(words $(wordlist 2,$(1),$(NUM32)))
+
+# Create a sequence from 1 to $(1)
+# F(N) = if N > 0: return F(N-1) + "N" else: return ""
+sequence = $(if $(wordlist 1,$(1),$(NUM32)),$(call sequence,$(call decrement,$(1))) $(1),)
+
+# Reverse a list of words in $(1)
+reverse = $(if $(word 2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(word 1,$(1))
 
 # vim: set ft=make: