]> git.saurik.com Git - apple/xnu.git/blobdiff - makedefs/MakeInc.kernel
xnu-3789.21.4.tar.gz
[apple/xnu.git] / makedefs / MakeInc.kernel
index 9c06f04eafa39f2a14d2b8ef136a7eb7a8a2ada0..0885b3fabfbfd44533cd8ee1e680fa229a77d20f 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: makefile;-*-
 #
 # -*- mode: makefile;-*-
 #
-# Copyright (C) 1999-2012 Apple Inc. All rights reserved.
+# Copyright (C) 1999-2016 Apple Inc. All rights reserved.
 #
 # MakeInc.kernel augments the single-architecture
 # recursive build system with rules specific
 #
 # MakeInc.kernel augments the single-architecture
 # recursive build system with rules specific
@@ -28,6 +28,11 @@ endif
 
 STATIC_KMODS =  $(SRCROOT)/kmods.a
 
 
 STATIC_KMODS =  $(SRCROOT)/kmods.a
 
+ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
+do_build_setup::
+       $(_v)$(CAT) > $(OBJPATH)/compile_commands.json < /dev/null
+endif
+
 #
 # Rules for the highly parallel "build" phase, where each build configuration
 # writes into their own $(TARGET) independent of other build configs
 #
 # Rules for the highly parallel "build" phase, where each build configuration
 # writes into their own $(TARGET) independent of other build configs
@@ -51,7 +56,7 @@ endif
 
 .PHONY: do_build_kernel_dSYM
 
 
 .PHONY: do_build_kernel_dSYM
 
-do_build_kernel_dSYM: $(TARGET)/$(KERNEL_FILE_NAME).dSYM 
+do_build_kernel_dSYM: $(TARGET)/$(KERNEL_FILE_NAME).dSYM
        @:
 
 .LDFLAGS: ALWAYS
        @:
 
 .LDFLAGS: ALWAYS
@@ -60,30 +65,30 @@ do_build_kernel_dSYM: $(TARGET)/$(KERNEL_FILE_NAME).dSYM
        $(_v)$(REPLACECONTENTS) $@ $(KCC) $(CFLAGS) $(INCFLAGS)
 
 $(TARGET)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped
        $(_v)$(REPLACECONTENTS) $@ $(KCC) $(CFLAGS) $(INCFLAGS)
 
 $(TARGET)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped
-       @echo STRIP $(@F)
+       @echo "$(ColorH)STRIP$(Color0)      $(ColorLF)$(@F)$(Color0)"
        $(_v)$(STRIP) $(STRIP_FLAGS) $< -o $@
        $(_v)$(RM) $@.ctfdata
 ifeq ($(DO_CTFMERGE),1)
        $(_v)$(STRIP) $(STRIP_FLAGS) $< -o $@
        $(_v)$(RM) $@.ctfdata
 ifeq ($(DO_CTFMERGE),1)
-       @echo CTFMERGE $(@F)
-       $(_v)$(FIND) $(TARGET)/ -name \*.ctf -size +0 |                 \
+       @echo "$(ColorH)CTFMERGE$(Color0)   $(ColorLF)$(@F)$(Color0)"
+       $(_v)$(FIND) $(TARGET)/ -name \*.ctf -size +0 |         \
                $(XARGS) $(CTFMERGE) -l xnu -o $@ -Z $@.ctfdata || true
 endif
        $(_v)if [ -s $@.ctfdata ]; then                                                         \
                $(XARGS) $(CTFMERGE) -l xnu -o $@ -Z $@.ctfdata || true
 endif
        $(_v)if [ -s $@.ctfdata ]; then                                                         \
-               echo CTFINSERT $(@F);                                                           \
-               $(CTFINSERT) $@ $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG))                            \
+               echo "$(ColorH)CTFINSERT$(Color0)  $(ColorLF)$(@F)$(Color0)";                                   \
+               $(CTFINSERT) $@ $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG))                            \
                             $@.ctfdata -o $@;                                                  \
        fi;
        $(_v)$(LN) $(call function_convert_build_config_to_objdir,$(CURRENT_BUILD_CONFIG))/$(KERNEL_FILE_NAME) $(OBJROOT)/$(KERNEL_FILE_NAME)
 
 $(TARGET)/$(KERNEL_FILE_NAME).dSYM: $(TARGET)/$(KERNEL_FILE_NAME).unstripped
                             $@.ctfdata -o $@;                                                  \
        fi;
        $(_v)$(LN) $(call function_convert_build_config_to_objdir,$(CURRENT_BUILD_CONFIG))/$(KERNEL_FILE_NAME) $(OBJROOT)/$(KERNEL_FILE_NAME)
 
 $(TARGET)/$(KERNEL_FILE_NAME).dSYM: $(TARGET)/$(KERNEL_FILE_NAME).unstripped
-       $(_v)echo DSYMUTIL $(@F)
+       $(_v)echo "$(ColorH)DSYMUTIL$(Color0)   $(ColorLF)$(@F)$(Color0)"
        $(_v)$(DSYMUTIL) $(DSYMUTIL_FLAGS) $< -o $@
        $(_v)$(MV) $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME).unstripped $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME)
        $(_v)$(TOUCH) $@
 
        $(_v)$(DSYMUTIL) $(DSYMUTIL_FLAGS) $< -o $@
        $(_v)$(MV) $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME).unstripped $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME)
        $(_v)$(TOUCH) $@
 
-$(TARGET)/$(KERNEL_FILE_NAME).unstripped: $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST),$(component)/$(CURRENT_KERNEL_CONFIG)/$(component).filelist)) lastkernelconstructor.o $(SRCROOT)/config/version.c $(SRCROOT)/config/MasterVersion .LDFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
+$(TARGET)/$(KERNEL_FILE_NAME).unstripped: $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST),$(component)/$(CURRENT_KERNEL_CONFIG)/$(component).filelist)) lastkerneldataconst.o lastkernelconstructor.o $(SRCROOT)/config/version.c $(SRCROOT)/config/MasterVersion .LDFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
        $(_v)${MAKE} -f $(firstword $(MAKEFILE_LIST)) version.o
        $(_v)${MAKE} -f $(firstword $(MAKEFILE_LIST)) version.o
-       @echo LD $(@F)
+       @echo "$(ColorL)LD$(Color0)  $(ColorLF)$(@F)$(Color0)"
        $(_v)$(CAT) $(filter %.filelist,$+) < /dev/null > link.filelist
        $(_v)$(LD) $(LDFLAGS_KERNEL) -filelist link.filelist version.o $(filter %.o,$+) -o $@ $(LD_KERNEL_LIBS)
 
        $(_v)$(CAT) $(filter %.filelist,$+) < /dev/null > link.filelist
        $(_v)$(LD) $(LDFLAGS_KERNEL) -filelist link.filelist version.o $(filter %.o,$+) -o $@ $(LD_KERNEL_LIBS)
 
@@ -100,6 +105,21 @@ $(OBJPATH)/version.c: $(SRCROOT)/config/version.c $(NEWVERS) $(SRCROOT)/config/M
        $(_v)$(CP) $< $@
        $(_v)$(NEWVERS) $(OBJPATH)/version.c > /dev/null;
 
        $(_v)$(CP) $< $@
        $(_v)$(NEWVERS) $(OBJPATH)/version.c > /dev/null;
 
+-include lastkerneldataconst.d
+lastkerneldataconst.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
+lastkerneldataconst.o: $(SRCROOT)/libsa/lastkerneldataconst.c
+       ${C_RULE_0}
+       ${C_RULE_1A}$<
+       ${C_RULE_2}
+
+
+lastkernelconstructor.o_CFLAGS_RM = -fprofile-instr-generate
+# the LAST segment is mapped read-only on arm, so if we include llvm profiling
+# here it will segfault the kernel.  (see arm_vm_init.c) We don't currently have
+# a way of retrieving these counters from LAST anyway, so there's no harm in just
+# disabling them.
+
+LAST_FILES=lastkernelconstructor.o
 -include lastkernelconstructor.d
 lastkernelconstructor.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
 lastkernelconstructor.o: $(SRCROOT)/libsa/lastkernelconstructor.c
 -include lastkernelconstructor.d
 lastkernelconstructor.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
 lastkernelconstructor.o: $(SRCROOT)/libsa/lastkernelconstructor.c
@@ -108,8 +128,11 @@ lastkernelconstructor.o: $(SRCROOT)/libsa/lastkernelconstructor.c
        ${C_RULE_2}
        ${C_RULE_3}
        ${C_RULE_4}
        ${C_RULE_2}
        ${C_RULE_3}
        ${C_RULE_4}
-       $(_v)$(SEG_HACK) -s __DATA -n __LAST -o $@__ $@
-       $(_v)$(MV) $@__ $@
+       $(_v)for last_file in ${LAST_FILES};                            \
+        do                                                     \
+               $(SEG_HACK) -s __DATA -n __LAST -o $${last_file}__ $${last_file} || exit 1; \
+                mv $${last_file}__ $${last_file} || exit 1;            \
+        done
 
 #
 # Install rules. Each build config is classified as "primary" (the first
 
 #
 # Install rules. Each build config is classified as "primary" (the first
@@ -161,11 +184,11 @@ do_install_xnu_debug_files:       $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)/README.DEBUG-kern
 $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME) ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then      \
 $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME) ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then      \
-               echo INSTALL $(@F) "($(CURRENT_ARCH_CONFIG_LC) $(CURRENT_MACHINE_CONFIG_LC))"; \
+               echo "$(ColorH)INSTALL$(Color0)    $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_MACHINE_CONFIG_LC)$(Color0))\""; \
                $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                 \
                cmdstatus=$$?;                                          \
        else                                                            \
                $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                 \
                cmdstatus=$$?;                                          \
        else                                                            \
-               echo INSTALL $(@F) "($(CURRENT_ARCH_CONFIG_LC) $(CURRENT_MACHINE_CONFIG_LC))"; \
+               echo "$(ColorH)INSTALL$(Color0)    $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_MACHINE_CONFIG_LC)$(Color0))\""; \
                $(LIPO) -create $@ $< -output $@;                       \
                cmdstatus=$$?;                                          \
        fi;                                                             \
                $(LIPO) -create $@ $< -output $@;                       \
                cmdstatus=$$?;                                          \
        fi;                                                             \
@@ -174,11 +197,11 @@ $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NA
 $(SYMROOT)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then              \
 $(SYMROOT)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then              \
-               echo INSTALLSYM $(@F) "($(CURRENT_ARCH_CONFIG_LC))";    \
+               echo "$(ColorH)INSTALLSYM$(Color0) $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""; \
                $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                         \
                cmdstatus=$$?;                                                  \
        else                                                                    \
                $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                         \
                cmdstatus=$$?;                                                  \
        else                                                                    \
-               echo INSTALLSYM $(@F) "($(CURRENT_ARCH_CONFIG_LC))";    \
+               echo "$(ColorH)INSTALLSYM$(Color0) $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""; \
                $(LIPO) -create $@ $< -output $@;                               \
                cmdstatus=$$?;                                                  \
        fi;                                                                     \
                $(LIPO) -create $@ $< -output $@;                               \
                cmdstatus=$$?;                                                  \
        fi;                                                                     \
@@ -186,35 +209,35 @@ $(SYMROOT)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped ALWAYS
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros: $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros
        $(_v)$(MKDIR) $(dir $@)
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros: $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros
        $(_v)$(MKDIR) $(dir $@)
-       @echo INSTALLMACROS $(@F) "($(CURRENT_ARCH_CONFIG_LC))"
+       @echo "$(ColorH)INSTALLMACROS$(Color0) $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
        $(_v)$(CP) -r $< $(dir $@)
        $(_v)$(TOUCH) $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME) $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME): $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)
        $(_v)$(MKDIR) $(dir $@)
        $(_v)$(CP) -r $< $(dir $@)
        $(_v)$(TOUCH) $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME) $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME): $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)
        $(_v)$(MKDIR) $(dir $@)
-       @echo INSTALLMACROS $(@F) "($(CURRENT_ARCH_CONFIG_LC))"
+       @echo "$(ColorH)INSTALLMACROS$(Color0) $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)/README.DEBUG-kernel.txt: $(SRCROOT)/config/README.DEBUG-kernel.txt
        $(_v)$(MKDIR) $(dir $@)
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)/README.DEBUG-kernel.txt: $(SRCROOT)/config/README.DEBUG-kernel.txt
        $(_v)$(MKDIR) $(dir $@)
-       @echo INSTALL $(@F)
+       @echo "$(ColorH)INSTALL$(Color0)       $(ColorF)$(@F)$(Color0)"
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist: $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist
        $(_v)$(MKDIR) $(dir $@)
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist: $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist
        $(_v)$(MKDIR) $(dir $@)
-       @echo INSTALLSYM dSYM $(@F) "($(CURRENT_ARCH_CONFIG_LC))"
+       @echo "$(ColorH)INSTALLSYM$(Color0) $(ColorL)dSYM$(Color0) $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then                      \
        $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
 
 $(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) ALWAYS
        $(_v)$(MKDIR) $(dir $@)
        $(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ ]; then                      \
-               echo INSTALLSYM dSYM $(@F).dSYM "($(CURRENT_ARCH_CONFIG_LC))";  \
-               $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                                 \
-               cmdstatus=$$?;                                                          \
+               echo "$(ColorH)INSTALLSYM$(Color0) $(ColorL)dSYM$(Color0) $(ColorF)$(@F).dSYM$(ColorF) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\"";     \
+               $(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;                                 \
+               cmdstatus=$$?;                                                          \
        else                                                                            \
        else                                                                            \
-               echo INSTALLSYM dSYM $(@F).dSYM "($(CURRENT_ARCH_CONFIG_LC))";  \
-               $(LIPO) -create $@ $< -output $@;                                       \
-               cmdstatus=$$?;                                                          \
+               echo "$(ColorH)INSTALLSYM$(Color0) $(ColorL)dSYM$(Color0) $(ColorF)$(@F).dSYM$(ColorF) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\"";     \
+               $(LIPO) -create $@ $< -output $@;                                       \
+               cmdstatus=$$?;                                                          \
        fi;                                                                             \
        exit $$cmdstatus
 
        fi;                                                                             \
        exit $$cmdstatus
 
@@ -267,5 +290,11 @@ ifeq ($(USE_BINARY_PLIST),1)
        $(_v)$(PLUTIL) -convert binary1 -o $@ $@
 endif
 
        $(_v)$(PLUTIL) -convert binary1 -o $@ $@
 endif
 
+$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(ALIAS_FILE_NAME): ALWAYS
+       $(_v)echo "$(ColorH)ALIAS$(Color0)      $(ColorF)$(@F)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_MACHINE_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_ALIAS_MACHINE_CONFIG_LC)$(Color0))\""
+       $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME) $@
+
+install_alias: $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(ALIAS_FILE_NAME)
+
 print_exports:
        $(_v)printenv | sort
 print_exports:
        $(_v)printenv | sort