endif
endif
-ifndef INCR_INSTALLHDRS
-ifeq ($(shell test -d $$DSTROOT/$INCDIR;echo $$?),0)
-export INCR_INSTALLHDRS = TRUE
-else
-export INCR_INSTALLHDRS = FALSE
-endif
-endif
-
#
# Component List
#
ifndef COMPONENT_LIST
export COMPONENT_LIST = osfmk bsd iokit pexpert libkern libsa
-export COMPONENT_LIST_UC := $(shell echo -n $(COMPONENT_LIST) | $(TR) a-z A-Z)
+export COMPONENT_LIST_UC := $(shell printf "%s" "$(COMPONENT_LIST)" | $(TR) a-z A-Z)
endif
ifndef COMPONENT
export COMPONENT := $(firstword $(subst /, ,$(shell $(RELPATH) $(SRCROOT) $(SOURCE))))
#
ifndef ARCH_CONFIGS
ifdef RC_ARCHS
-export ARCH_CONFIGS := $(shell echo -n $(RC_ARCHS) | $(TR) a-z A-Z)
+export ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z)
else
export ARCH_CONFIGS := $(shell arch | $(TR) a-z A-Z)
endif
endif
ifdef ARCH_CONFIG
ifndef ARCH_CONFIG_LC
-export ARCH_CONFIG_LC := $(shell echo -n $(ARCH_CONFIG) | $(TR) A-Z a-z)
+export ARCH_CONFIG_LC := $(shell printf "%s" "$(ARCH_CONFIG)" | $(TR) A-Z a-z)
endif
endif
# Kernel Configuration options
#
# supported configurations : RELEASE DEBUG PROFILE
-#
+# By default, make wll build RELEASE, otherwise the value of KERNEL_CONFIG
+# will be used as kernel configuration. If KERNEL_CONFIGS (plural) is set
+# it will override KERNEL_CONFIG. Make sure to set KERNEL_CONFIGS because
+# build_all rule loops over it when building.
+
ifndef KERNEL_CONFIGS
+ifndef KERNEL_CONFIG
export KERNEL_CONFIGS = RELEASE
+else
+export KERNEL_CONFIGS = $(KERNEL_CONFIG)
+endif
endif
+
ifndef KERNEL_CONFIG
export KERNEL_CONFIG = $(firstword $(KERNEL_CONFIGS))
endif
else
export INSTALL_ARCHS = $(ARCH_CONFIGS)
endif
-export INSTALL_ARCHS_LC := $(shell echo -n $(ARCH_CONFIGS) | $(TR) A-Z a-z)
+export INSTALL_ARCHS_LC := $(shell printf "%s" "$(ARCH_CONFIGS)" | $(TR) A-Z a-z)
endif
export INSTALL_ARCH_DEFAULT = PPC
#
# Standard defines list
#
-export DEFINES = -DAPPLE -DNeXT -DKERNEL_PRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT)
+export DEFINES = -DAPPLE -DNeXT -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT)
#
# Compiler command
#
-KCC = /usr/bin/cc
-KC++ = /usr/bin/c++
-CC = $(KCC)
+KCC := $(CC)
+KC++ := $(CXX)
+
+#
+# Compiler warning flags
+#
+
+CWARNFLAGS_STD = \
+ -Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
+ -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
+ -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \
+ -Wnested-externs -Wredundant-decls
+
+export CWARNFLAGS ?= $(CWARNFLAGS_STD)
+
+MWARNFLAGS_STD = \
+ -Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes \
+ -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
+ -Wshadow -Wcast-align -Wbad-function-cast -Wchar-subscripts -Winline \
+ -Wnested-externs -Wredundant-decls
+
+export MWARNFLAGS ?= $(MWARNFLAGS_STD)
+
+CXXWARNFLAGS_STD = \
+ -Wall -Wno-format-y2k -W \
+ -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch \
+ -Wshadow -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls
+
+export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
#
export CFLAGS_GEN = -static -g -nostdinc -nostdlib -no-cpp-precomp \
-fno-builtin -finline -fno-keep-inline-functions -msoft-float \
- -fsigned-bitfields -Wpointer-arith $(OTHER_CFLAGS)
+ -fsigned-bitfields $(OTHER_CFLAGS) -force_cpusubtype_ALL
export CFLAGS_RELEASE =
export CFLAGS_DEBUG =
export CFLAGS_PROFILE = -pg
export CFLAGS_PPC = -arch ppc -Dppc -DPPC -D__PPC__ -DPAGE_SIZE_FIXED
-export CFLAGS_I386 = -arch i386 -Di386 -DI386 -D__I386__ \
- -march=i686 -mpreferred-stack-boundary=2 -falign-functions=4 -mcpu=pentium4
+export CFLAGS_I386 = -arch i386 -Di386 -DI386 -D__I386__ -DPAGE_SIZE_FIXED
export CFLAGS_RELEASEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
export CFLAGS_RELEASE_TRACEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
export CFLAGS_DEBUGPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
export CFLAGS_PROFILEPPC = -O2 -mcpu=750 -mmultiple -fschedule-insns
-export CFLAGS_RELEASEI386 = -O2
-export CFLAGS_DEBUGI386 = -O2
-export CFLAGS_PROFILEI386 = -O2
+export CFLAGS_RELEASEI386 = -Os
+export CFLAGS_DEBUGI386 = -Os
+export CFLAGS_PROFILEI386 = -Os
export CFLAGS = $(CFLAGS_GEN) \
$($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \
$($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),CFLAGS_))) \
$(DEFINES)
+export MIGCC = $(CC)
+
# Default C++ flags
#
-CXXFLAGS_GEN = -fno-rtti -fno-exceptions -fcheck-new -fapple-kext -fpermissive
+CXXFLAGS_GEN = -fno-rtti -fno-exceptions -fcheck-new -fapple-kext
CXXFLAGS = $(CXXFLAGS_GEN) \
$($(addsuffix $(ARCH_CONFIG),CXXFLAGS_)) \
#
# Assembler command
#
-AS = /usr/bin/cc
-S_KCC = /usr/bin/cc
+AS = $(CC)
+S_KCC = $(CC)
#
# Default SFLAGS
#
# Linker command
#
-LD = /usr/bin/ld
+LD = $(KC++) -nostdlib
#
# Default LDFLAGS
$($(addsuffix $(ARCH_CONFIG),LDFLAGS_COMPONENT_)) \
$($(addsuffix $(KERNEL_CONFIG),LDFLAGS_COMPONENT_))
-export LDFLAGS_KERNEL_GEN = -static -force_cpusubtype_ALL -segalign 0x1000
+export LDFLAGS_KERNEL_GEN = \
+ -static \
+ -fapple-kext \
+ -force_cpusubtype_ALL \
+ -Wl,-e,__start \
+ -Wl,-segalign,0x1000 \
+ -Wl,-sectalign,__TEXT,__text,0x1000 \
+ -Wl,-sectalign,__DATA,__common,0x1000 \
+ -Wl,-sectalign,__DATA,__bss,0x1000 \
+ -Wl,-sectcreate,__PRELINK,__text,/dev/null \
+ -Wl,-sectcreate,__PRELINK,__symtab,/dev/null \
+ -Wl,-sectcreate,__PRELINK,__info,/dev/null
export LDFLAGS_KERNEL_RELEASE =
# -noseglinkedit
export LDFLAGS_KERNEL_DEBUG =
export LDFLAGS_KERNEL_PROFILE =
-export LDFLAGS_KERNEL_PPC = -arch ppc -segaddr __VECTORS 0x0 -segaddr __TEXT 0x7000 -e __start -sectalign __TEXT __text 0x1000 -sectalign __DATA __common 0x1000 -sectalign __DATA __bss 0x1000 -sectcreate __PRELINK __text /dev/null -sectcreate __PRELINK __symtab /dev/null -sectcreate __PRELINK __info /dev/null
-export LDFLAGS_KERNEL_I386 = -arch i386 -segaddr __TEXT 0x100000 -e _pstart -sectcreate __PRELINK __text /dev/null -sectcreate __PRELINK __symtab /dev/null -sectcreate __PRELINK __info /dev/null
+export LDFLAGS_KERNEL_PPC = \
+ -arch ppc \
+ -Wl,-segaddr,__VECTORS,0x0 \
+ -Wl,-segaddr,__HIB,0x7000 \
+ -Wl,-segaddr,__TEXT,0xe000
+
+export LDFLAGS_KERNEL_I386 = \
+ -arch i386 \
+ -Wl,-segaddr,__HIB,0x100000 \
+ -Wl,-segaddr,__TEXT,0x111000
export LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
$($(addsuffix $(ARCH_CONFIG),LDFLAGS_KERNEL_)) \
#
export INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
export INCFLAGS_EXTERN = -I$(OBJROOT)/EXTERN_HDRS -I$(SRCROOT)/EXTERNAL_HEADERS -I$(SRCROOT)/EXTERNAL_HEADERS/bsd
-export INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT)
+export INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
export INCFLAGS_POSIX = -I$(OBJROOT)/EXPORT_HDRS/bsd
export INCFLAGS_LOCAL = -I.
KINCFRAME = $(FRAMEDIR)/Kernel.framework
KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers
KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders
+KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources
+
+XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE
+
+SPINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE
+SINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE
+KPINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL
+KINCFRAME_UNIFDEF = $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL
#
# Compononent Header file destinations