-do_build_mach_kernel:
- @echo "[ building mach_kernel ]";
- $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/kernel_newvers \
- "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.major`" \
- "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.minor`" \
- "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.variant`"; \
- ${KCC} $(CFLAGS) $(INCLUDES) -c kernel_vers.c; \
- $(LD) $(LDFLAGS_KERNEL) $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST), $(addprefix $(component)/$(firstword $($(addsuffix _KERNEL_CONFIG, $(component))) $(KERNEL_CONFIG))/, $(addsuffix .o, $(component))))) kernel_vers.o -o $(TARGET)/mach_kernel.sys $(LD_KERNEL_LIBS); \
- $(STRIP) $(STRIP_FLAGS) $(TARGET)/mach_kernel.sys -o $(TARGET)/mach_kernel;
+do_build_mach_kernel: $(OBJPATH)/kgmacros
+ $(_v)install $(DATA_INSTALL_FLAGS) $(SRCROOT)/config/version.c $(OBJPATH)/version.c;
+ $(_v)$(SRCROOT)/config/newvers.pl $(OBJPATH)/version.c > /dev/null;
+ @echo CC version.o
+ $(_v)${KCC} -c ${filter-out ${${join $@,_CFLAGS_RM}}, ${CFLAGS}} ${${join $@,_CFLAGS_ADD}} ${INCFLAGS} ${${join $@,_INCFLAGS}} $(OBJPATH)/version.c -o $(OBJPATH)/version.o
+ @echo LD mach_kernel.sys
+ $(_v)$(LD) $(LDFLAGS_KERNEL) $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST), $(addprefix $(component)/$(firstword $($(addsuffix _KERNEL_CONFIG, $(shell printf $(component) | tr a-z A-Z))) $(KERNEL_CONFIG))/, $(addsuffix .o, $(component))))) $(OBJPATH)/version.o -o $(TARGET)/mach_kernel.sys $(LD_KERNEL_LIBS)
+ @echo DSYMUTIL mach_kernel.sys
+ $(_v)if [ $(BUILD_DWARF) -eq 1 ]; then \
+ $(DSYMUTIL) $(DSYMUTIL_FLAGS) $(TARGET)/mach_kernel.sys -o $(TARGET)/mach_kernel.sys.dSYM > /dev/null; \
+ fi;
+ @echo STRIP mach_kernel
+ $(_v)$(STRIP) $(STRIP_FLAGS) $(TARGET)/mach_kernel.sys -o $(TARGET)/mach_kernel
+
+$(OBJPATH)/kgmacros: $(SRCROOT)/kgmacros
+ $(_v)$(CP) $? $@
+
+# Special rules to install machine configuration variants
+
+$(DSTROOT)$(INSTALL_FILE_DIR)mach.$(KERNEL_CONFIG_LC).$(MACHINE_CONFIG_LC): $(TARGET)/mach_kernel force_file_install
+ @echo Installing $< in $@;
+ @if [ ! -e $(DSTROOT)$(INSTALL_FILE_DIR) ]; then \
+ $(MKDIR) $(DSTROOT)$(INSTALL_FILE_DIR); \
+ fi; \
+ if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
+ $(RM) $(RMFLAGS) $@; \
+ install $(FILE_INSTALL_FLAGS) $< $@; \
+ else \
+ if [ ! -e $@ ]; then \
+ echo >empty_file_$(notdir $@); \
+ lipo_arg="$(subst _empty_file, empty_file_$(notdir $@),$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
+ $(LIPO) $${lipo_arg} -create -output $@; \
+ $(RM) $(RMFLAGS) empty_file_$(notdir $@); \
+ fi; \
+ $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
+ fi
+
+$(SYMROOT)$(INSTALL_FILE_DIR)mach.$(KERNEL_CONFIG_LC).$(MACHINE_CONFIG_LC): $(TARGET)/mach_kernel.sys force_file_install
+ @echo Installing $< in $@;
+ @if [ ! -e $(SYMROOT)$(INSTALL_FILE_DIR) ]; then \
+ $(MKDIR) $(SYMROOT)$(INSTALL_FILE_DIR); \
+ fi; \
+ if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
+ $(RM) $(RMFLAGS) $@; \
+ install $(FILE_INSTALL_FLAGS) $< $@; \
+ else \
+ if [ ! -e $@ ]; then \
+ echo >empty_file_$(notdir $@); \
+ lipo_arg="$(subst _empty_file, empty_file_$(notdir $@),$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
+ $(LIPO) $${lipo_arg} -create -output $@; \
+ $(RM) $(RMFLAGS) empty_file_$(notdir $@); \
+ fi; \
+ $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
+ fi
+
+