]> git.saurik.com Git - apple/xnu.git/blobdiff - makedefs/MakeInc.dir
xnu-2050.7.9.tar.gz
[apple/xnu.git] / makedefs / MakeInc.dir
index 06f191b1f81f09ab6f3043f21ef0e453274f6d5e..12191a3c22ef11a0b8255a62d67115439ea043e3 100644 (file)
@@ -1,16 +1,38 @@
 #
 # Install kernel header files
 #
 #
 # Install kernel header files
 #
-installhdrs: exporthdrs installhdrs_mi installhdrs_md 
-       @echo "[ $(SRCROOT) ] make installhdrs installing Kernel.framework"; \
-       kincpath=$(DSTROOT)/$(KINCDIR);                                 \
+.PHONY: installhdrs
+
+ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
+installhdrs:
+       cd libsyscall ; \
+               sdk="$(SDKROOT)" ;                                                              \
+               if [ $${sdk} = / ] ; then                                               \
+                       sdk="" ;                                                                        \
+               fi;                                                                                             \
+               xcrun -sdk "$(SDKROOT)" xcodebuild installhdrs  \
+                       "SRCROOT=$(SRCROOT)/libsyscall"                                 \
+                       "OBJROOT=$(OBJROOT)"                                            \
+                       "SYMROOT=$(SYMROOT)"                                            \
+                       "DSTROOT=$(DSTROOT)"                                            \
+                       "SDKROOT=$${sdk}"
+else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
+installhdrs:
+       make -C libkern/kxld/ installhdrs
+else ifeq ($(RC_ProjectName),libkmod)
+installhdrs:
+# nothing to do
+else # xnu, xnu_debug, or xnu_headers_Sim
+installhdrs: exporthdrs installhdrs_mi installhdrs_md setup
+       @echo "[ $(SRCROOT) ] make installhdrs installing Kernel.framework"
+       $(_v)kincpath=$(DSTROOT)/$(KINCDIR);                                    \
        krespath=$(DSTROOT)/$(KRESDIR);                                 \
        kframepath=$(DSTROOT)/$(KINCFRAME);                             \
        [ -d $$krespath ] || $(MKDIR) $$krespath;                       \
        [ -d $$kincpath ] || $(MKDIR) $$kincpath;                       \
        cd $(SRCROOT)/EXTERNAL_HEADERS;                                 \
                install $(FILE_INSTALL_FLAGS) Info.plist $$krespath;    \
        krespath=$(DSTROOT)/$(KRESDIR);                                 \
        kframepath=$(DSTROOT)/$(KINCFRAME);                             \
        [ -d $$krespath ] || $(MKDIR) $$krespath;                       \
        [ -d $$kincpath ] || $(MKDIR) $$kincpath;                       \
        cd $(SRCROOT)/EXTERNAL_HEADERS;                                 \
                install $(FILE_INSTALL_FLAGS) Info.plist $$krespath;    \
-               $(SRCROOT)/config/newvers.pl $${krespath}/Info.plist;   \
+               $(NEWVERS) $${krespath}/Info.plist;     \
        cd $$kframepath/Versions;                                       \
            [ -L Current ] || $(LN) $(KINCVERS) Current;                \
        cd $$kframepath;                                                \
        cd $$kframepath/Versions;                                       \
            [ -L Current ] || $(LN) $(KINCVERS) Current;                \
        cd $$kframepath;                                                \
@@ -19,47 +41,96 @@ installhdrs: exporthdrs installhdrs_mi installhdrs_md
        [ -d $(DSTROOT)/$(KPINCDIR) ] || $(MKDIR) $(DSTROOT)/$(KPINCDIR);       \
        cd $$kframepath; [ -L PrivateHeaders ] ||                       \
            $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
        [ -d $(DSTROOT)/$(KPINCDIR) ] || $(MKDIR) $(DSTROOT)/$(KPINCDIR);       \
        cd $$kframepath; [ -L PrivateHeaders ] ||                       \
            $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
+ifeq ($(RC_ProjectName),xnu_headers_Sim)
+       @echo "[ $(SRCROOT) ] make installhdrs installing System.framework"
+       $(_v)spincpath=$(DSTROOT)/$(SPINCDIR);                          \
+       sframepath=$(DSTROOT)/$(SINCFRAME);                             \
+       [ -d $$spincpath ] || $(MKDIR) $$spincpath;                     \
+       cd $$sframepath/Versions;                                       \
+           [ -L Current ] || $(LN) $(SINCVERS) Current;                \
+       cd $$sframepath; [ -L PrivateHeaders ] ||                       \
+           $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
+endif
+ifeq (iPhoneOS,$(PLATFORM))
+       $(_v)$(IPHONEOS_OPTIMIZE) $(DSTROOT)/$(KRESDIR)/Info.plist
+endif
+endif
+
+.PHONY: installhdrs_embedded installhdrs_devicemap
+installhdrs_embedded installhdrs_devicemap: installhdrs
 
 #
 # Install header files order
 #
 .ORDER: installhdrs_mi installhdrs_md
 
 #
 # Install header files order
 #
 .ORDER: installhdrs_mi installhdrs_md
+.PHONY: installhdrs_mi installhdrs_md
 
 #
 # Install machine independent header files
 #
 
 #
 # Install machine independent header files
 #
-installhdrs_mi:
-       @echo "[ $(SOURCE) ] make installhdrs_mi ";                     \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       kernel_config=$(INSTALL_TYPE);                                  \
-       arch_config=$(INSTALL_ARCH_DEFAULT);                                    \
-       installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};       \
-       [ -d $${installinc_dir} ] ||$(MKDIR) $${installinc_dir};        \
-       ${MAKE} -C $${installinc_dir}                                   \
+installhdrs_mi: setup
+       $(_v)kernel_config=$(INSTALL_TYPE);                             \
+       machine_config=$(MACHINE_CONFIG);                               \
+       arch_config=$(INSTALL_ARCH_DEFAULT);                            \
+       if [ $${arch_config} = ARM ] ; then                             \
+               if [ $${machine_config} = DEFAULT ] ; then              \
+                       machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);   \
+               fi;                                                     \
+       fi;                                                             \
+       if [ $${arch_config} = L4_ARM ] ; then                          \
+               if [ $${machine_config} = DEFAULT ] ; then              \
+                       machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);        \
+               fi;                                                     \
+       fi;                                                             \
+       if [ $${machine_config} = DEFAULT ] ; then                      \
+               installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH};    \
+       else                                                            \
+               installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
+       fi;                                                             \
+       [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir};       \
+       ${MAKE} ${MAKEJOBS} -C $${installinc_dir}                       \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
+               MACHINE_CONFIG=$${machine_config}                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
-               TARGET=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}/       \
+               RELATIVE_SOURCE_PATH=.                                  \
+               TARGET=$${installinc_dir}/                              \
                build_installhdrs_mi;                                   \
 
 #
 # Install machine dependent kernel header files 
                build_installhdrs_mi;                                   \
 
 #
 # Install machine dependent kernel header files 
+# Uses hack for machine_config, which is not threaded through properly.
 #
 #
-installhdrs_md:
-       @echo "[ $(SOURCE) ] make installhdrs_md ";                     \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       kernel_config=$(INSTALL_TYPE);                                  \
+installhdrs_md: setup
+       $(_v)kernel_config=$(INSTALL_TYPE);                             \
+       machine_config=$(MACHINE_CONFIG);                               \
        for arch_config in $(INSTALL_ARCHS);                            \
        do                                                              \
        for arch_config in $(INSTALL_ARCHS);                            \
        do                                                              \
-       [ -d ${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path} ] || \
-       $(MKDIR) ${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};     \
-       ${MAKE} -C ${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}    \
+       if [ $${arch_config} = ARM ] ; then     \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);           \
+               fi;             \
+       fi;             \
+       if [ $${arch_config} = L4_ARM ] ; then  \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);                \
+               fi;             \
+       fi;             \
+       if [ $${machine_config} = DEFAULT ] ; then      \
+               installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH};    \
+       else            \
+               installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
+       fi;             \
+       [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir};       \
+       ${MAKE} ${MAKEJOBS} -C $${installinc_dir}                       \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
+               MACHINE_CONFIG=$${machine_config}                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
-               TARGET=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}/       \
+               RELATIVE_SOURCE_PATH=.                                  \
+               TARGET=$${installinc_dir}/                              \
                build_installhdrs_md;                                   \
        done;
 
                build_installhdrs_md;                                   \
        done;
 
@@ -68,46 +139,57 @@ installhdrs_md:
 #
 do_installhdrs_mi:
 
 #
 do_installhdrs_mi:
 
-build_installhdrs_mi::
-       @echo "[ $(SOURCE) ] make build_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";      \
-       for installinc_subdir in $(INSTINC_SUBDIRS);                    \
-       do                                                              \
-               [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};         \
-               ${MAKE} -C $${installinc_subdir}                        \
-                       MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile       \
-                       SOURCE=$(SOURCE)$${installinc_subdir}/          \
-                       TARGET=$(TARGET)$${installinc_subdir}/          \
-               build_installhdrs_mi;                                   \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} do_installhdrs_mi;
+BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS = $(addprefix build_installhdrs_mi_,$(INSTINC_SUBDIRS))
+
+.PHONY: $(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS)
+
+$(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS):
+       $(_v)installinc_subdir="$(patsubst build_installhdrs_mi_%,%,$@)";       \
+       [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};         \
+       ${MAKE} -C $${installinc_subdir}                                        \
+               MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile               \
+               SOURCE=$(SOURCE)$${installinc_subdir}/                          \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir}      \
+               TARGET=$(TARGET)$${installinc_subdir}/                          \
+               build_installhdrs_mi;
+
+build_installhdrs_mi: $(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS)
+       $(_v)${MAKE} do_installhdrs_mi;
 
 #
 # Install machine dependent kernel header files 
 #
 do_installhdrs_md:
 
 
 #
 # Install machine dependent kernel header files 
 #
 do_installhdrs_md:
 
-build_installhdrs_md::
-       @echo "[ $(SOURCE) ] make installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";    \
-       for installinc_subdir in $($(addprefix INSTINC_SUBDIRS_, $(ARCH_CONFIG)));              \
-       do                                                              \
-               [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};                 \
-               ${MAKE} -C $${installinc_subdir}                        \
-                       MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile       \
-                       SOURCE=$(SOURCE)$${installinc_subdir}/          \
-                       TARGET=$(TARGET)$${installinc_subdir}/          \
-               build_installhdrs_md;                                   \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} do_installhdrs_md;
+BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS = $(addprefix build_installhdrs_md_,$($(addprefix INSTINC_SUBDIRS_, $(ARCH_CONFIG))))
+
+.PHONY: $(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS)
+
+$(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS):
+       $(_v)installinc_subdir="$(patsubst build_installhdrs_md_%,%,$@)";       \
+       [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};         \
+       ${MAKE} -C $${installinc_subdir}                                        \
+               MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile               \
+               SOURCE=$(SOURCE)$${installinc_subdir}/                          \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir}      \
+               TARGET=$(TARGET)$${installinc_subdir}/                          \
+               build_installhdrs_md;
+
+build_installhdrs_md: $(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS)
+       $(_v)${MAKE} do_installhdrs_md;
 
 #
 # Install kernel header files
 #
 
 #
 # Install kernel header files
 #
+.PHONY: exporthdrs
+
 exporthdrs: exporthdrs_mi exporthdrs_md 
 
 #
 # Install header files order
 #
 .ORDER: exporthdrs_mi exporthdrs_md
 exporthdrs: exporthdrs_mi exporthdrs_md 
 
 #
 # Install header files order
 #
 .ORDER: exporthdrs_mi exporthdrs_md
+.PHONY: exporthdrs_mi exporthdrs_md
 
 #
 # Install machine independent header files
 
 #
 # Install machine independent header files
@@ -115,38 +197,95 @@ exporthdrs: exporthdrs_mi exporthdrs_md
 do_exporthdrs_mi:
 
 exporthdrs_mi:
 do_exporthdrs_mi:
 
 exporthdrs_mi:
-       @echo "[ ${SOURCE} ] make exporthdrs_mi ";                      \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       kernel_config=$(INSTALL_TYPE);                                  \
-       arch_config=$(INSTALL_ARCH_DEFAULT);                                    \
-       exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};        \
-       [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};                                 \
-       ${MAKE} -C $${exportinc_dir}                                    \
+       $(_v)kernel_config=$(INSTALL_TYPE);                             \
+       arch_config=$(INSTALL_ARCH_DEFAULT);                            \
+       machine_config=DEFAULT;                                         \
+       if [ $${arch_config} = ARM ] ; then                             \
+               if [ $${machine_config} = DEFAULT ] ; then              \
+                       machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);   \
+               fi;                                                     \
+       fi;                                                             \
+       if [ $${arch_config} = L4_ARM ] ; then                          \
+               if [ $${machine_config} = DEFAULT ] ; then              \
+                       machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);\
+               fi;                                                     \
+       fi;                                                             \
+       if [ $${machine_config} = DEFAULT ] ; then                      \
+               exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH};     \
+       else                                                            \
+               exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH};  \
+       fi;                                                             \
+       [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};         \
+       ${MAKE} ${MAKEJOBS} -C $${exportinc_dir}                        \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
+               MACHINE_CONFIG=$${machine_config}                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
+               RELATIVE_SOURCE_PATH=.                                  \
                TARGET=$${exportinc_dir}/                               \
                build_exporthdrs_mi;                                    \
 
 #
 # Install machine dependent kernel header files 
 #
                TARGET=$${exportinc_dir}/                               \
                build_exporthdrs_mi;                                    \
 
 #
 # Install machine dependent kernel header files 
 #
+# Note - installation of machine dependent kernel header files only occurs for architecture
+# defined in INSTALL_TYPE.  We use skipit variable to skip over architectures that are not
+# equal to what is in the INSTALL_TYPE variable.
+# TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first item in the
+# set is the kernel configuration.  The second item in the set is the architecture and the 
+# third item is the machine configuration.  There may be multiple sets to build.
 exporthdrs_md:
 exporthdrs_md:
-       @echo "[ $(SOURCE) ] make exporthdrs_md ";                      \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       kernel_config=$(INSTALL_TYPE);                                  \
-       for arch_config in $(ARCH_CONFIGS);                             \
-       do                                                              \
-       exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};        \
-       [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};                                 \
-       ${MAKE} -C $${exportinc_dir}                                    \
-               KERNEL_CONFIG=$${kernel_config}                         \
-               ARCH_CONFIG=$${arch_config}                             \
-               MAKEFILES=${SOURCE}/Makefile                            \
-               SOURCE=${SOURCE}/                                       \
-               TARGET=$${exportinc_dir}/                               \
-               build_exporthdrs_md;                                    \
+       $(_v)my_counter=1;              \
+       for my_config in $(TARGET_CONFIGS_UC);                          \
+       do              \
+       if [ $${my_counter} -eq 1 ] ; then      \
+               skipit=0;                       \
+               my_counter=2;           \
+               kernel_config=$${my_config};            \
+               if [ $${kernel_config} = DEFAULT ] ; then       \
+                       kernel_config=$(DEFAULT_KERNEL_CONFIG);         \
+               fi;             \
+               if [ $${kernel_config} != $(INSTALL_TYPE) ] ; then      \
+                       skipit=1;       \
+               fi;             \
+       elif [ $${my_counter} -eq 2 ] ; then    \
+               my_counter=3;           \
+               arch_config=$${my_config};              \
+               if [ $${arch_config} = DEFAULT ] ; then \
+                       arch_config=`arch | $(TR) a-z A-Z`;             \
+               fi;             \
+       else            \
+               my_counter=1;           \
+               machine_config=$${my_config};           \
+               if [ $${skipit} -eq 0 ] ; then  \
+                       if [ $${arch_config} = ARM ] ; then     \
+                               if [ $${machine_config} = DEFAULT ] ; then      \
+                                       machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);           \
+                               fi;             \
+                       fi;             \
+                       if [ $${arch_config} = L4_ARM ] ; then  \
+                               if [ $${machine_config} = DEFAULT ] ; then      \
+                                       machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);                \
+                               fi;             \
+                       fi;             \
+                       if [ $${machine_config} = DEFAULT ] ; then      \
+                               exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH};     \
+                       else            \
+                               exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH};  \
+                       fi;             \
+                       [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};                                 \
+                       ${MAKE} ${MAKEJOBS} -C $${exportinc_dir}                        \
+                               KERNEL_CONFIG=$${kernel_config}                         \
+                               ARCH_CONFIG=$${arch_config}                             \
+                               MACHINE_CONFIG=$${machine_config}                       \
+                               MAKEFILES=${SOURCE}/Makefile                            \
+                               SOURCE=${SOURCE}/                                       \
+                               RELATIVE_SOURCE_PATH=.                                  \
+                               TARGET=$${exportinc_dir}/                               \
+                               build_exporthdrs_md;                                    \
+               fi;             \
+       fi;             \
        done;
 
 #
        done;
 
 #
@@ -154,122 +293,214 @@ exporthdrs_md:
 #
 do_exporthdrs_mi:
 
 #
 do_exporthdrs_mi:
 
-build_exporthdrs_mi:
-       @echo "[ $(SOURCE) ] make build_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";       \
-       _TMP_EXPINC_SUBDIRS="$(EXPINC_SUBDIRS)";                        \
-       for exportinc_subdir in $${_TMP_EXPINC_SUBDIRS};                \
-       do                                                              \
-               [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};                           \
-               ${MAKE} -C $${exportinc_subdir}                         \
-                       MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile        \
-                       SOURCE=$(SOURCE)$${exportinc_subdir}/           \
-                       TARGET=$(TARGET)$${exportinc_subdir}/           \
-               build_exporthdrs_mi;                                    \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} do_exporthdrs_mi;
+BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS = $(addprefix build_exporthdrs_mi_,$(EXPINC_SUBDIRS))
+
+.PHONY: $(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS)
+
+$(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS):
+       $(_v)exportinc_subdir="$(patsubst build_exporthdrs_mi_%,%,$@)";         \
+       [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};           \
+       ${MAKE} -C $${exportinc_subdir}                                         \
+               MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile                \
+               SOURCE=$(SOURCE)$${exportinc_subdir}/                           \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir}       \
+               TARGET=$(TARGET)$${exportinc_subdir}/                           \
+               build_exporthdrs_mi;
+
+build_exporthdrs_mi: $(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS)
+       $(_v)${MAKE} do_exporthdrs_mi;
 
 #
 # Install machine dependent kernel header files 
 #
 do_exporthdrs_md:
 
 
 #
 # Install machine dependent kernel header files 
 #
 do_exporthdrs_md:
 
-build_exporthdrs_md:
-       @echo "[ $(SOURCE) ] make exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";     \
-       _TMP_exportinc_subdir="$($(addprefix EXPINC_SUBDIRS_, $(ARCH_CONFIG)))";        \
-       for exportinc_subdir in $${_TMP_exportinc_subdir};                      \
-       do                                                              \
-               [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};                           \
-               ${MAKE} -C $${exportinc_subdir}                         \
-                       MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile        \
-                       SOURCE=$(SOURCE)$${exportinc_subdir}/           \
-                       TARGET=$(TARGET)$${exportinc_subdir}/           \
-               build_exporthdrs_md;                                    \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} do_exporthdrs_md;
+BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS = $(addprefix build_exporthdrs_md_,$($(addprefix EXPINC_SUBDIRS_, $(ARCH_CONFIG))))
+
+.PHONY: $(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS)
+
+$(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS):
+       $(_v)exportinc_subdir="$(patsubst build_exporthdrs_md_%,%,$@)";         \
+       [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};           \
+       ${MAKE} -C $${exportinc_subdir}                                         \
+               MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile                \
+               SOURCE=$(SOURCE)$${exportinc_subdir}/                           \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir}       \
+               TARGET=$(TARGET)$${exportinc_subdir}/                           \
+               build_exporthdrs_md;
+
+build_exporthdrs_md: $(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS)
+       $(_v)${MAKE} do_exporthdrs_md;
 
 #
 # Setup pass for  all architectures for all Configuration/Architecture options
 #
 
 #
 # Setup pass for  all architectures for all Configuration/Architecture options
 #
+.PHONY: setup
+
 setup:
 setup:
-       @echo "[ $(SOURCE) ] make setup";                                       \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       for kernel_config in $(KERNEL_CONFIGS);                         \
-       do                                                              \
-       for arch_config in $(ARCH_CONFIGS);                             \
-       do                                                              \
-       setup_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}; \
-       [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};                                   \
-       ${MAKE} -C $${setup_subdir}                                     \
+       $(_v)kernel_config=$(INSTALL_TYPE);                             \
+       arch_config=$(INSTALL_ARCH_DEFAULT);                            \
+       setup_subdir=${OBJROOT}/$${RELATIVE_SOURCE_PATH};               \
+       [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};           \
+       ${MAKE} ${MAKEJOBS} -C $${setup_subdir}                         \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
+               MACHINE_CONFIG=$${machine_config}                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
+               RELATIVE_SOURCE_PATH=.                                  \
                TARGET=$${setup_subdir}/                                \
                TARGET=$${setup_subdir}/                                \
-       build_setup;                                                    \
-       done;                                                           \
-       done;
+       build_setup;
 
 do_build_setup:
 
 
 do_build_setup:
 
-build_setup:
-       @echo "[ $(SOURCE) ] make build_setup $(COMPONENT) $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";  \
-       _TMP_setup_subdir="$(SETUP_SUBDIRS) $($(addprefix SETUP_SUBDIRS_, $(ARCH_CONFIG)))";    \
-       for setup_subdir in $${_TMP_setup_subdir};              \
-       do                                                      \
-       [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};                           \
+BUILD_SETUP_SUBDIRS_TARGETS = $(addprefix build_setup_,$(SETUP_SUBDIRS) $($(addprefix SETUP_SUBDIRS_, $(ARCH_CONFIG))))
+
+.PHONY: $(BUILD_SETUP_SUBDIRS_TARGETS)
+
+$(BUILD_SETUP_SUBDIRS_TARGETS):
+       $(_v)setup_subdir="$(patsubst build_setup_%,%,$@)";     \
+       [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};   \
        ${MAKE} -C $${setup_subdir}                             \
                MAKEFILES=${SOURCE}/$${setup_subdir}/Makefile   \
                SOURCE=${SOURCE}/$${setup_subdir}/              \
        ${MAKE} -C $${setup_subdir}                             \
                MAKEFILES=${SOURCE}/$${setup_subdir}/Makefile   \
                SOURCE=${SOURCE}/$${setup_subdir}/              \
+               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${setup_subdir}   \
                TARGET=${TARGET}/$${setup_subdir}/              \
                TARGET=${TARGET}/$${setup_subdir}/              \
-               build_setup;                                    \
-       done;                                                   \
-       ${MAKE} do_build_setup;
+               build_setup;
+
+build_setup: $(BUILD_SETUP_SUBDIRS_TARGETS)
+       $(_v)${MAKE} do_build_setup;
 
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
 
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
-ifeq ($(COMPONENT), .)
+# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first 
+# item in the set is the kernel configuration.  The second item in the set is the architecture  
+# and the third item is the machine configuration.  There may be multiple sets to build.
+#
+.PHONY: all
+
+ifeq ($(RC_ProjectName),Libsyscall)
+all:
+       cd libsyscall ; \
+               sdk="$(SDKROOT)" ;                                                      \
+               if [ $${sdk} = / ] ; then                                               \
+                       sdk="" ;                                                        \
+               fi;                                                                     \
+               xcrun -sdk "$(SDKROOT)" xcodebuild install                              \
+                       "SRCROOT=$(SRCROOT)/libsyscall"                                 \
+                       "OBJROOT=$(OBJROOT)"                                            \
+                       "SYMROOT=$(SYMROOT)"                                            \
+                       "DSTROOT=$(DSTROOT)"                                            \
+                       "SDKROOT=$${sdk}"
+else ifeq ($(RC_ProjectName),libkxld)
+all:
+       make -C libkern/kxld/ install
+else ifeq ($(RC_ProjectName),libkxld_host)
+all:
+       make -C libkern/kxld/ install PRODUCT_TYPE=ARCHIVE
+else ifeq ($(RC_ProjectName),libkmod)
+all:
+       cd libkern/kmod ; \
+               sdk="$(SDKROOT)" ;                                                      \
+               if [ $${sdk} = / ] ; then                                               \
+                       sdk="" ;                                                        \
+               fi;                                                                     \
+               xcrun -sdk "$(SDKROOT)" xcodebuild install                              \
+                       "SRCROOT=$(SRCROOT)/libkern/kmod"                               \
+                       "OBJROOT=$(OBJROOT)"                                            \
+                       "SYMROOT=$(SYMROOT)"                                            \
+                       "DSTROOT=$(DSTROOT)"                                            \
+                       "SDKROOT=$${sdk}"
+else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim) # Libsyscall/xnu _headers_Sim
 all: exporthdrs
 all: exporthdrs
+else # xnu or xnu_debug
+ifeq ($(COMPONENT), .)
+all: exporthdrs setup
 else
 all:
 endif
 else
 all:
 endif
-       @echo "[ $(SOURCE) ] make all";                                 \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
-       for kernel_config in $(KERNEL_CONFIGS);                         \
-       do                                                              \
-       for arch_config in $(ARCH_CONFIGS);                             \
-       do                                                              \
-       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}; \
-       [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};                                   \
-       ${MAKE} -C $${build_subdir}                                     \
-               KERNEL_CONFIG=$${kernel_config}                         \
-               ARCH_CONFIG=$${arch_config}                             \
-               MAKEFILES=${SOURCE}/Makefile                            \
-               SOURCE=${SOURCE}/                                       \
-               build_all;                                              \
-       done;                                                           \
+       $(_v)my_counter=1;              \
+       for my_config in $(TARGET_CONFIGS_UC);                          \
+       do              \
+       if [ $${my_counter} -eq 1 ] ; then      \
+               my_counter=2;           \
+               kernel_config=$${my_config};            \
+               if [ $${kernel_config} = DEFAULT ] ; then       \
+                       kernel_config=$(DEFAULT_KERNEL_CONFIG);         \
+               fi;             \
+       elif [ $${my_counter} -eq 2 ] ; then    \
+               my_counter=3;           \
+               arch_config=$${my_config};              \
+               if [ $${arch_config} = DEFAULT ] ; then \
+                       arch_config=`arch | $(TR) a-z A-Z`;             \
+               fi;             \
+       else            \
+               my_counter=1;           \
+               machine_config=$${my_config};           \
+               if [ $${arch_config} = ARM ] ; then     \
+                       if [ $${machine_config} = DEFAULT ] ; then      \
+                               machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);           \
+                       fi;             \
+               fi;             \
+               if [ $${arch_config} = L4_ARM ] ; then  \
+                       if [ $${machine_config} = DEFAULT ] ; then      \
+                               machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);                \
+                       fi;             \
+               fi;             \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
+               else            \
+                       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
+               fi;             \
+               [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};                                   \
+                       ${MAKE} ${MAKEJOBS} -C $${build_subdir}                         \
+                               KERNEL_CONFIG=$${kernel_config}                         \
+                               ARCH_CONFIG=$${arch_config}                             \
+                               MACHINE_CONFIG=$${machine_config}                       \
+                               MAKEFILES=${SOURCE}/Makefile                            \
+                               SOURCE=${SOURCE}/                                       \
+                               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}            \
+                               build_all;                                              \
+       fi;             \
        done;
        done;
+endif
+
+.PHONY: all_embedded all_devicemap
+all_embedded all_devicemap: all
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
 do_build_all:
 
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
 do_build_all:
 
-build_all: 
-       @TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT);        \
-       echo "[ $(SOURCE) ] make build_all $(COMPONENT) $(KERNEL_CONFIG) $(ARCH_CONFIG) $${TARGET}";    \
-       _TMP_comp_subdir="$(COMP_SUBDIRS) $($(addprefix COMP_SUBDIRS_, $(ARCH_CONFIG)))";       \
-       for comp_subdir in $${_TMP_comp_subdir};                        \
-       do                                                              \
-               [ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir};                             \
-               ${MAKE} -C $${comp_subdir}                              \
-                       MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile    \
-                       SOURCE=${SOURCE}$${comp_subdir}/                \
-                       TARGET=$${TARGET}                               \
-               build_all;                                              \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} INCL_MAKEDEP=TRUE TARGET=$${TARGET} do_build_all;   \
+BUILD_ALL_SUBDIRS_TARGETS = $(addprefix build_all_,$(COMP_SUBDIRS) $($(addprefix COMP_SUBDIRS_, $(ARCH_CONFIG))))
+
+.PHONY: $(BUILD_ALL_SUBDIRS_TARGETS)
+
+$(BUILD_ALL_SUBDIRS_TARGETS):
+       $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
+               TARGET=$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
+       else            \
+               TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";     \
+       fi;             \
+       comp_subdir="$(patsubst build_all_%,%,$@)";             \
+       [ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir};     \
+       ${MAKE} -C $${comp_subdir}                              \
+               MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile    \
+               SOURCE=${SOURCE}$${comp_subdir}/                \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir}    \
+               TARGET=$${TARGET}                               \
+               build_all;
+
+build_all: $(BUILD_ALL_SUBDIRS_TARGETS)
+       $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
+               TARGET=$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
+       else            \
+               TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";     \
+       fi;             \
+       ${MAKE} INCL_MAKEDEP=TRUE TARGET=$${TARGET} do_build_all;       \
        _TMP_comp_subdir="$(CONFIG_SUBDIRS) $($(addprefix CONFIG_SUBDIRS_, $(ARCH_CONFIG)))";   \
        for comp_subdir in $${_TMP_comp_subdir};                        \
        do                                                              \
        _TMP_comp_subdir="$(CONFIG_SUBDIRS) $($(addprefix CONFIG_SUBDIRS_, $(ARCH_CONFIG)))";   \
        for comp_subdir in $${_TMP_comp_subdir};                        \
        do                                                              \
@@ -277,30 +508,63 @@ build_all:
                ${MAKE} -C $${comp_subdir}                              \
                        MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile    \
                        SOURCE=${SOURCE}$${comp_subdir}/                \
                ${MAKE} -C $${comp_subdir}                              \
                        MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile    \
                        SOURCE=${SOURCE}$${comp_subdir}/                \
+                       RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir}    \
                        TARGET=$${TARGET}                               \
                build_all;                                              \
                        TARGET=$${TARGET}                               \
                build_all;                                              \
-       done;                                                           \
+       done;                                                           
        
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
        
 
 #
 # Build all architectures for all Configuration/Architecture options
 #
+# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first 
+# item in the set is the kernel configuration.  The second item is the architecture  
+# and the third item is the machine configuration.  There may be multiple sets to build.
+#
 mach_kernel:
 mach_kernel:
-       @echo "[ $(SOURCE) ] make mach_kernel";                         \
-       for kernel_config in $(KERNEL_CONFIGS);                         \
-       do                                                              \
-       for arch_config in $(ARCH_CONFIGS);                             \
-       do                                                              \
-       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config};      \
-       [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};                                   \
-       ${MAKE} -C $${build_subdir}                                     \
-               KERNEL_CONFIG=$${kernel_config}                         \
-               ARCH_CONFIG=$${arch_config}                             \
-               MAKEFILES=${SOURCE}/Makefile                            \
-               SOURCE=${SOURCE}/                                       \
-               TARGET=$${build_subdir}/                                \
-               build_mach_kernel;                                      \
-       done;                                                           \
+       $(_v)my_counter=1;              \
+       for my_config in $(TARGET_CONFIGS_UC);                          \
+       do              \
+       if [ $${my_counter} -eq 1 ] ; then      \
+               my_counter=2;           \
+               kernel_config=$${my_config};            \
+               if [ $${kernel_config} = DEFAULT ] ; then       \
+                       kernel_config=$(DEFAULT_KERNEL_CONFIG);         \
+               fi;             \
+       elif [ $${my_counter} -eq 2 ] ; then    \
+               my_counter=3;           \
+               arch_config=$${my_config};              \
+               if [ $${arch_config} = DEFAULT ] ; then \
+                       arch_config=`arch | $(TR) a-z A-Z`;             \
+               fi;             \
+       else            \
+               my_counter=1;           \
+               machine_config=$${my_config};           \
+               if [ $${arch_config} = ARM ] ; then     \
+                       if [ $${machine_config} = DEFAULT ] ; then      \
+                               machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);           \
+                       fi;             \
+               fi;             \
+               if [ $${arch_config} = L4_ARM ] ; then  \
+                       if [ $${machine_config} = DEFAULT ] ; then      \
+                               machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);                \
+                       fi;             \
+               fi;             \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config};      \
+               else            \
+                       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config};   \
+               fi;             \
+               [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};                                   \
+               ${MAKE} ${MAKEJOBS} -C $${build_subdir}                                 \
+                       KERNEL_CONFIG=$${kernel_config}                         \
+                       ARCH_CONFIG=$${arch_config}                             \
+                       MACHINE_CONFIG=$${machine_config}                       \
+                       MAKEFILES=${SOURCE}/Makefile                            \
+                       SOURCE=${SOURCE}/                                       \
+                       TARGET=$${build_subdir}/                                \
+                       build_mach_kernel;                                      \
+       fi;             \
        done;
 
 #
        done;
 
 #
@@ -309,8 +573,7 @@ mach_kernel:
 do_build_mach_kernel:
 
 build_mach_kernel: 
 do_build_mach_kernel:
 
 build_mach_kernel: 
-       @echo "[ $(SOURCE) ] make build_mach_kernel $(COMPONENT) $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)";    \
-       ${MAKE} ${MAKEJOBS} do_build_mach_kernel;
+       $(_v)${MAKE} do_build_mach_kernel;
 
 
 #
 
 
 #
@@ -323,23 +586,99 @@ build_mach_kernel:
 # Install kernel based on RC_ARCHS for all INSTALL_TYPES
 # Install kernel header files based on RC_ARCHS
 #
 # Install kernel based on RC_ARCHS for all INSTALL_TYPES
 # Install kernel header files based on RC_ARCHS
 #
-install: installhdrs all installman
-       @echo "[ $(SOURCE) ] make install";                             \
-       rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));                      \
+install: installhdrs all installman installmachinekernels
+ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
+# nothing to do
+else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
+# nothing to do, work performed in "all" action
+else ifeq ($(RC_ProjectName),libkmod)
+# nothing to do, work performed in "all" action
+else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim)
+# nothing to do
+else # xnu or xnu_debug
+# A bit of a hack for machine_config: machine configs aren't really threaded through properly.
+       $(_v)machine_config=$(MACHINE_CONFIG);          \
        for kernel_config in $(INSTALL_TYPE);                           \
        do                                                              \
        for arch_config in $(INSTALL_ARCHS);                            \
        do                                                              \
        for kernel_config in $(INSTALL_TYPE);                           \
        do                                                              \
        for arch_config in $(INSTALL_ARCHS);                            \
        do                                                              \
-       install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};       \
+       if [ $${arch_config} = ARM ] ; then     \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);           \
+               fi;             \
+       fi;             \
+       if [ $${arch_config} = L4_ARM ] ; then  \
+               if [ $${machine_config} = DEFAULT ] ; then      \
+                       machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);                \
+               fi;             \
+       fi;             \
+       if [ $${machine_config} = DEFAULT ] ; then      \
+               install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH};    \
+       else            \
+               install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
+       fi;             \
        [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};                                       \
        [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};                                       \
-       ${MAKE} -C $${install_subdir}                                   \
+       ${MAKE} ${MAKEJOBS} -C $${install_subdir}                       \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
                KERNEL_CONFIG=$${kernel_config}                         \
                ARCH_CONFIG=$${arch_config}                             \
+               MACHINE_CONFIG=$${machine_config}                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
                MAKEFILES=${SOURCE}/Makefile                            \
                SOURCE=${SOURCE}/                                       \
+               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}            \
                build_install;                                          \
        done;                                                           \
        done;
                build_install;                                          \
        done;                                                           \
        done;
+ifeq ($(RC_ProjectName),xnu_debug)
+       $(_v)$(MKDIR) $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(MV) $(DSTROOT)/mach_kernel* $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(CP) $(SYMROOT)/kgmacros $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(CP) -r $(SYMROOT)/System.kext $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(CP) -r $(SYMROOT)/mach_kernel.dSYM $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(CP) $(SRCROOT)/config/README.DEBUG-kernel.txt $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
+       $(_v)$(MV) $(DSTROOT)/System $(DSTROOT)/usr $(OBJROOT)/
+endif
+endif
+
+.PHONY: install_embedded install_devicemap
+install_embedded install_devicemap: install
+
+installmachinekernels:
+       @echo "[ $(SOURCE) ] make installmachinekernels";                               \
+       my_counter=1;           \
+       for my_config in $(TARGET_CONFIGS_UC);                          \
+       do              \
+       if [ $${my_counter} -eq 1 ] ; then      \
+               my_counter=2;           \
+               kernel_config=$${my_config};            \
+               if [ $${kernel_config} = DEFAULT ] ; then       \
+                       kernel_config=$(DEFAULT_KERNEL_CONFIG);         \
+               fi;             \
+       elif [ $${my_counter} -eq 2 ] ; then    \
+               my_counter=3;           \
+               arch_config=$${my_config};              \
+               if [ $${arch_config} = DEFAULT ] ; then \
+                       arch_config=`arch | $(TR) a-z A-Z`;             \
+               fi;             \
+       else            \
+               my_counter=1;           \
+               machine_config=$${my_config};           \
+               if [ $${machine_config} != DEFAULT ] ; then     \
+                       build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config};   \
+                       install_kernel_file=mach.`printf "%s" "$${kernel_config}" | $(TR) A-Z a-z`.`printf "%s" "$${machine_config}" | $(TR) A-Z a-z`;  \
+                       [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};                                   \
+                       ${MAKE} ${MAKEJOBS} -C $${build_subdir}                                 \
+                               INSTALL_KERNEL_FILE=$${install_kernel_file}             \
+                               KERNEL_CONFIG=$${kernel_config}                         \
+                               ARCH_CONFIG=$${arch_config}                             \
+                               MACHINE_CONFIG=$${machine_config}                       \
+                               MAKEFILES=${SOURCE}/Makefile                            \
+                               SOURCE=${SOURCE}/                                       \
+                               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}            \
+                               TARGET=$${build_subdir}/                                \
+                               do_build_install;                                       \
+               fi;             \
+       fi;             \
+       done;
 
 #
 # Install for all architectures for all Configuration/Architecture options
 
 #
 # Install for all architectures for all Configuration/Architecture options
@@ -348,35 +687,51 @@ setup_build_install:
 
 do_build_install:
 
 
 do_build_install:
 
-build_install: 
-       @TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT);        \
-       echo "[ $(SOURCE) ] make build_install $(COMPONENT) $(KERNEL_CONFIG) $(ARCH_CONFIG) $${TARGET}";        \
+BUILD_INSTALL_SUBDIRS_TARGETS = $(addprefix build_install_,$(INST_SUBDIRS))
+
+.PHONY: $(BUILD_INSTALL_SUBDIRS_TARGETS)
+
+$(BUILD_INSTALL_SUBDIRS_TARGETS):
+       $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
+               TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
+       else            \
+               TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";     \
+       fi;             \
        ${MAKE} TARGET=$${TARGET} setup_build_install;                  \
        kernel_config=$(KERNEL_CONFIG);                                 \
        ${MAKE} TARGET=$${TARGET} setup_build_install;                  \
        kernel_config=$(KERNEL_CONFIG);                                 \
-       for install_subdir in $(INST_SUBDIRS);                          \
-       do                                                              \
-               [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};                               \
-               ${MAKE} -C $${install_subdir}                           \
-                       KERNEL_CONFIG=$${kernel_config}                 \
-                       MAKEFILES=${SOURCE}/$${install_subdir}/Makefile \
-                       SOURCE=${SOURCE}$${install_subdir}/             \
-                       TARGET=$${TARGET}                               \
-               build_install;                                          \
-       done;                                                           \
-       ${MAKE} ${MAKEJOBS} TARGET=$${TARGET} do_build_install;
+       install_subdir="$(patsubst build_install_%,%,$@)";              \
+       [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};                               \
+       ${MAKE} -C $${install_subdir}                           \
+               KERNEL_CONFIG=$${kernel_config}                 \
+               MAKEFILES=${SOURCE}/$${install_subdir}/Makefile \
+               SOURCE=${SOURCE}$${install_subdir}/             \
+               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${install_subdir}         \
+               TARGET=$${TARGET}                               \
+               build_install;
+
+build_install: $(BUILD_INSTALL_SUBDIRS_TARGETS)
+       $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
+               TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
+       else            \
+               TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";     \
+       fi;             \
+       ${MAKE} TARGET=$${TARGET} do_build_install;
 
 
 #
 # Install source tree
 #
 
 
 #
 # Install source tree
 #
-installsrc:
-       pax -rw . ${SRCROOT}
+.PHONY: installsrc
 
 
+installsrc:
+       $(_v)($(TAR) -c --mode go=r,+X --no-ignore-case --exclude .svn --exclude .git --exclude cscope.\* --exclude BUILD --exclude \*~ -f - .) | (cd $(SRCROOT) && $(TAR) --no-same-owner -xf -)
 
 
 #
 # Clean up source tree
 #
 
 
 #
 # Clean up source tree
 #
+.PHONY: clean
+
 clean:
 
 #
 clean:
 
 #
@@ -407,36 +762,59 @@ cscope: cscope.files
 
 tags: cscope.files
        @echo "Building ctags"
 
 tags: cscope.files
        @echo "Building ctags"
-       @-xargs ctags -dtw < cscope.files 2> /dev/null || \
+       @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
                echo "Phantom files detected!" 2>&1 > /dev/null
                echo "Phantom files detected!" 2>&1 > /dev/null
+       @-[ -f TAGS ] || ${MAKE} TAGS
+
+TAGS: cscope.files
        @echo "Building etags"
        @-cat cscope.files | etags -l auto -S - 2> /dev/null
 
 #
 # Install Man Pages
 #
        @echo "Building etags"
        @-cat cscope.files | etags -l auto -S - 2> /dev/null
 
 #
 # Install Man Pages
 #
+.PHONY: installman
+
 installman:
 installman:
-       @echo "[ $(SRCROOT) ] Installing man pages"; \
-       manpath=$(DSTROOT)/$(MANDIR);   \
+ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
+# nothing to do
+else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
+# nothing to do
+else ifeq ($(RC_ProjectName),libkmod)
+# nothing to do
+else ifeq ($(findstring xnu_,$(RC_ProjectName)),xnu_)
+installman:
+# nothing to do
+else # xnu
+       @echo "[ $(SRCROOT) ] Installing man pages"
+       $(_v)manpath=$(DSTROOT)/$(MANDIR);   \
        [ -d $$manpath ] || $(MKDIR) $$manpath;             \
        [ -d $$manpath ] || $(MKDIR) $$manpath;             \
-       ${MAKE} MAKEFILES=${SOURCE}/Makefile \
+       ${MAKE} ${MAKEJOBS} MAKEFILES=${SOURCE}/Makefile \
                SOURCE=${SOURCE}/ \
                SOURCE=${SOURCE}/ \
+               RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
                TARGET=${DSTROOT}/ \
                build_installman
                TARGET=${DSTROOT}/ \
                build_installman
+       ${SRCROOT}/config/compress-man-pages.pl ${DSTROOT}/${MANDIR}
+endif
 
 do_installman:
 
 
 do_installman:
 
-build_installman:
-       @echo "[ $(SOURCE) ] make build_installman";    \
-       if [ -n "$(strip $(INSTMAN_SUBDIRS))" ]; then \
-               for installman_subdir in $(INSTMAN_SUBDIRS); do \
-                       ${MAKE} -C $${installman_subdir} -r \
-                               MAKEFILES=$(SOURCE)$${installman_subdir}/Makefile \
-                               SOURCE=$(SOURCE)$${installman_subdir}/ \
-                               TARGET=$(TARGET)$${installman_subdir}/ \
-                               build_installman; \
-               done; \
-       fi; \
-       if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
-               ${MAKE} ${MAKEJOBS} do_installman; \
+BUILD_INSTALLMAN_SUBDIRS_TARGETS = $(addprefix build_installman_,$(INSTMAN_SUBDIRS))
+
+.PHONY: $(BUILD_INSTALLMAN_SUBDIRS_TARGETS)
+
+$(BUILD_INSTALLMAN_SUBDIRS_TARGETS):
+       $(_v)installman_subdir="$(patsubst build_installman_%,%,$@)";   \
+       ${MAKE} -C $${installman_subdir} -r                                     \
+               MAKEFILES=$(SOURCE)$${installman_subdir}/Makefile               \
+               SOURCE=$(SOURCE)$${installman_subdir}/                          \
+               RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installman_subdir}      \
+               TARGET=$(TARGET)$${installman_subdir}/                          \
+               build_installman; 
+
+build_installman: $(BUILD_INSTALLMAN_SUBDIRS_TARGETS)
+       $(_v)if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
+               ${MAKE} do_installman; \
        fi
        fi
+
+# vim: set ft=make: