first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,186 @@
|
||||
# Copyright (C) 2008, 2009-2011, 2013-2015 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
# Rules for building objects.
|
||||
#
|
||||
|
||||
_INCLUDES := $(addprefix -I,$(GLOBAL_INCLUDES)) $(addprefix -I,$(EXTERNAL_INCLUDES))
|
||||
|
||||
# flags always passed to the C compiler
|
||||
_CFLAGS := $(GLOBAL_CFLAGS) $(CEXTRAFLAGS) $(CWARNFLAGS)
|
||||
|
||||
# flags always passed to the C++ compiler
|
||||
_CPPFLAGS := $(GLOBAL_CFLAGS) $(CPPEXTRAFLAGS) $(CPPWARNFLAGS)
|
||||
|
||||
# extra flags to bring in the compiler runtime, since we turn it off via -nodefaultlibs
|
||||
_RUNTIME_FLAGS := -L$(SDKROOT)/usr/local/lib -lcompiler_rt-static $(LIBBUILTIN_BUILD)
|
||||
|
||||
# produce coverage info, but don't add profiling into the built binaries
|
||||
# this lets us compare coverage from unit tests to the lines built for real targets
|
||||
ifeq ($(COVERAGE),YES)
|
||||
_CFLAGS += -ftest-coverage
|
||||
_CPPFLAGS += -ftest-coverage
|
||||
endif
|
||||
|
||||
ALL_OBJS := $(call TOBUILDDIR,$(ALL_OBJS))
|
||||
|
||||
ALL_DEPS += $(ALL_OBJS:%o=%d)
|
||||
|
||||
ALL_STATICLIBS += $(PREBUILT_STATICLIBS)
|
||||
|
||||
# Make everything depend on the contents of makefiles, as they are sneaky
|
||||
GLOBAL_SRCDEPS += $(MAKEFILE_LIST)
|
||||
|
||||
# Avoid invoking the C++ compiler to link with unless we need it
|
||||
ifeq ($(WITH_CPLUSPLUS),true)
|
||||
_LD := $(CPP)
|
||||
else
|
||||
_LD := $(CC)
|
||||
endif
|
||||
|
||||
#
|
||||
# If the build has defined an info symbol file, we can process it to locate TEXT_BASE rather than
|
||||
# depending on makefiles to generate it.
|
||||
#
|
||||
# Note that this must be lazily resolved, as at the time we run this the file probably doesn't exist.
|
||||
# Note also the hokey '0x' prefix to the value; nm prints as hex.
|
||||
#
|
||||
# XXX For now, don't do this unless TEXT_BASE was never defined at the Makefile level. Later
|
||||
# we can relax this as platforms stop doing it.
|
||||
#
|
||||
ifeq ($(TEXT_BASE),)
|
||||
ifneq ($(INFO_SYMBOL_FILE),)
|
||||
SEG1ADDR = -seg1addr 0x$(shell nm $(INFO_SYMBOL_FILE) | grep TEXT_BASE | cut -d ' ' -f 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Dump all the interesting variables used to build things with
|
||||
ifeq (0,1)
|
||||
$(warning _INCLUDES = $(_INCLUDES))
|
||||
$(warning _CFLAGS = $(_CFLAGS))
|
||||
$(warning _CPPFLAGS = $(_CPPFLAGS))
|
||||
$(warning _RUNTIME_FLAGS = $(_RUNTIME_FLAGS))
|
||||
$(warning LIBRARY_ALLFLAGS = $(LIBRARY_ALLFLAGS))
|
||||
$(warning PRODUCT_ALLFLAGS = $(PRODUCT_ALLFLAGS))
|
||||
$(warning GLOBAL_ALLFLAGS = $(GLOBAL_ALLFLAGS))
|
||||
$(warning ALL_OBJS = $(ALL_OBJS))
|
||||
$(warning ALL_DEPS = $(ALL_DEPS))
|
||||
$(warning ALL_OBJS = $(ALL_OBJS))
|
||||
endif
|
||||
|
||||
# rules for linked binaries
|
||||
$(PRODUCT_MACHO): $(LINKER_SCRIPT) $(ALL_OBJS) $(ALL_STATICLIBS) ./tools/macho_post_process.py ./tools/macho.py
|
||||
@$(MKDIR)
|
||||
@echo LD $@ using $(_RUNTIME_FLAGS)
|
||||
$(_v)$(_LD) $(SEG1ADDR) $(GLOBAL_LDFLAGS) $(ALL_OBJS) $(ALL_STATICLIBS) $(ALL_STATICLIBS) $(_RUNTIME_FLAGS) -exported_symbols_list $(LINKER_EXPORTS) -o $@ -Wl,-map,$@.map $(addprefix -Wl,-force_load,$(GLOBAL_LDFORCELIBS))
|
||||
ifneq ($(TEXT_FOOTPRINT),)
|
||||
@total_size=`$(SIZE) -m $@|sed -n 's/^total \([0-9][0-9]*\)/\1/p'`; if [[ $$total_size -gt $$(($(TEXT_FOOTPRINT))) ]]; then \
|
||||
echo "ERROR: total size is $$(( $$total_size - $(TEXT_FOOTPRINT) )) bytes larger than TEXT_FOOTPRINT, $(TEXT_FOOTPRINT) bytes, for this platform"; \
|
||||
mv $@ $@.OVERSIZED; \
|
||||
exit 1; \
|
||||
fi
|
||||
endif
|
||||
$(_v)./tools/macho_post_process.py --build-tag $(XBS_BUILD_TAG) $@
|
||||
|
||||
# rules for objects going into the product build directory
|
||||
$(BUILDDIR)/%.o: %.c $(PRODUCT_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo CC $@
|
||||
$(_v)$(CC) $(PRODUCT_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
ifeq ($(ANALYZE),YES)
|
||||
@echo ANALYZE $@
|
||||
$(_v)$(ANALYZER) $(PRODUCT_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) $(ANALYZERFLAGS) $<
|
||||
endif
|
||||
|
||||
$(BUILDDIR)/%.o: %.cpp $(PRODUCT_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo C++ $@
|
||||
$(_v)$(CPP) $(PRODUCT_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CPPFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
|
||||
$(BUILDDIR)/%.o: %.S $(PRODUCT_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo ASM $@
|
||||
$(_v)$(CC) $(PRODUCT_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(GLOBAL_ASFLAGS) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
|
||||
# rules for source files in the builddir
|
||||
$(BUILDDIR)/%.o: $(BUILDDIR)/%.c $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo CC $@
|
||||
$(_v)$(CC) $(GLOBAL_ALLFLAGS) $(_CFLAGS) -DDEBUG_FILE_HASH=0xbaddadcabadULL $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
ifeq ($(ANALYZE),YES)
|
||||
@echo ANALYZE $@
|
||||
$(_v)$(ANALYZER) $(GLOBAL_ALLFLAGS) $(_CFLAGS) -DDEBUG_FILE_HASH=0xbaddadcabadULL $(_INCLUDES) $(ANALYZERFLAGS) $<
|
||||
endif
|
||||
|
||||
$(BUILDDIR)/%.o: $(BUILDDIR)/%.S $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo ASM $@
|
||||
$(_v)$(CC) $(GLOBAL_ALLFLAGS) $(GLOBAL_ASFLAGS) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
|
||||
# a rule for copying precompiled object files to somewhere they can be found at link time
|
||||
$(BUILDDIR)/%.o: %.o
|
||||
@$(MKDIR)
|
||||
@echo CP $@
|
||||
$(_v)$(CP) $< $@
|
||||
|
||||
#
|
||||
# Rules for objects going into the libdir
|
||||
#
|
||||
# Note that these rules should not be exposed in any other phase, to avoid problems with library
|
||||
# objects being spuriously rebuilt.
|
||||
#
|
||||
ifeq ($(MAKEPHASE),libraries)
|
||||
$(LIBOBJDIR)/%.o: %.c $(LIBRARY_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo LIBCC $@
|
||||
$(_v)$(CC) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
ifeq ($(ANALYZE),YES)
|
||||
@echo ANALYZE $@
|
||||
$(_v)$(ANALYZER) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) $(ANALYZERFLAGS) $<
|
||||
endif
|
||||
|
||||
$(LIBOBJDIR)/%.o: %.cpp $(LIBRARY_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo LIBC++ $@
|
||||
$(_v)$(CPP) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CPPFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
ifeq ($(ANALYZE),YES)
|
||||
@echo ANALYZE++ $@
|
||||
$(_v)$(ANALYZERPP) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CPPFLAGS) $(DEBUG_FILE_HASH) $(_INCLUDES) $(ANALYZERFLAGS) $<
|
||||
endif
|
||||
|
||||
$(LIBOBJDIR)/%.o: %.S $(LIBRARY_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo LIBASM $@
|
||||
$(_v)$(CC) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(GLOBAL_ASFLAGS) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
|
||||
# rules for source files in the libdir
|
||||
$(LIBOBJDIR)/%.o: $(LIBOBJDIR)/%.c $(LIBRARY_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo LIBCC $@
|
||||
$(_v)$(CC) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) -DDEBUG_FILE_HASH=0xbaddadcabadULL $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
ifeq ($(ANALYZE),YES)
|
||||
@echo ANALYZE $@
|
||||
$(_v)$(ANALYZER) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(_CFLAGS) -DDEBUG_FILE_HASH=0xbaddadcabadULL $(_INCLUDES) $(ANALYZERFLAGS) $<
|
||||
endif
|
||||
|
||||
$(LIBOBJDIR)/%.o: $(LIBOBJDIR)/%.S $(LIBRARY_SRCDEPS) $(GLOBAL_SRCDEPS)
|
||||
@$(MKDIR)
|
||||
@echo LIBASM $@
|
||||
$(_v)$(CC) $(LIBRARY_ALLFLAGS) $(GLOBAL_ALLFLAGS) $(GLOBAL_ASFLAGS) $(_INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
|
||||
|
||||
# a rule for copying precompiled object files to somewhere they can be found at link time
|
||||
$(LIBOBJDIR)/%.o: %.o
|
||||
@$(MKDIR)
|
||||
@echo CP $@
|
||||
$(_v)$(CP) $< $@
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# Copyright (C) 2007-2015 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Configuration common to all makefiles
|
||||
#
|
||||
|
||||
# Note that use of '=' assignment is intentional for COPTFLAGS and DEPLOYMENT_TARGET_FLAGS,
|
||||
# allowing either to be overridden at make invocation for local development purposes.
|
||||
|
||||
# Clang has the concept of "smaller even if it's slightly slower". Use it.
|
||||
COPTFLAGS = -Oz
|
||||
# Use these flags to get almost useable stack traces
|
||||
#COPTFLAGS = -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||
|
||||
# Use latest compiler runtime.
|
||||
ifneq ($(RC_XBS), YES)
|
||||
ifeq ($(SDK_PRODUCT_NAME),Watch OS)
|
||||
DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
|
||||
else
|
||||
ifeq ($(SDK_PRODUCT_NAME),Apple TVOS)
|
||||
DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
|
||||
else
|
||||
ifeq ($(SDK_PRODUCT_NAME),iPhone OS)
|
||||
DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
GLOBAL_INCLUDES := include include/posix include/gcc include/c++ $(OBJROOT)/build/include
|
||||
EXTERNAL_INCLUDES := $(SDKROOT)/usr/local/include/
|
||||
|
||||
GLOBAL_CFLAGS := -static $(COPTFLAGS) -mno-implicit-float
|
||||
GLOBAL_CFLAGS += -ffreestanding
|
||||
GLOBAL_CFLAGS += -fno-common # catches multiple declarations of global variables
|
||||
GLOBAL_CFLAGS += -funsigned-char -fno-strict-aliasing
|
||||
GLOBAL_CFLAGS += -fstack-protector-strong
|
||||
|
||||
CEXTRAFLAGS := -nostdinc -std=gnu11
|
||||
CPPEXTRAFLAGS := -nostdinc++ -fno-exceptions -fno-rtti -std=gnu++98
|
||||
|
||||
CWARNFLAGS := -Werror -W -Wall -Wbuiltin-memcpy-chk-size -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-int-to-void-pointer-cast -Wno-tautological-constant-out-of-range-compare
|
||||
CPPWARNFLAGS := -Werror -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function
|
||||
|
||||
# Allow GNU-isms.
|
||||
CWARNFLAGS += -Wno-gnu
|
||||
CPPWARNFLAGS += -Wno-gnu
|
||||
|
||||
GLOBAL_ASFLAGS := -D__ASSEMBLY__ -Dglobal=globl -Dword=long
|
||||
GLOBAL_ASFLAGS += -integrated-as
|
||||
|
||||
GLOBAL_ALLFLAGS := -g -DIBOOT=1 $(DEPLOYMENT_TARGET_FLAGS)
|
||||
|
||||
GLOBAL_LDFLAGS := -Wl,-new_linker -Wl,-preload -Wl,-merge_zero_fill_sections
|
||||
GLOBAL_LDFLAGS += -static -nostartfiles -dead_strip -e _start -nodefaultlibs
|
||||
GLOBAL_LDFLAGS += $(DEPLOYMENT_TARGET_FLAGS)
|
||||
GLOBAL_LDFLAGS += -Wl,-sectalign,__TEXT,__cstring,40
|
||||
GLOBAL_LDFLAGS += -Wl,-sectalign,__DATA,__data,40
|
||||
GLOBAL_LDFLAGS += -Wl,-sectalign,__DATA,__zerofill,40
|
||||
#// Hack while waiting for <rdar://problem/16136513> No const variables should end up in __DATA
|
||||
GLOBAL_LDFLAGS += -Wl,-rename_section,__DATA,__const,__TEXT,__const2
|
||||
|
||||
|
||||
GLOBAL_LDFORCELIBS :=
|
||||
|
||||
LIBRARY_LDFLAGS := -Wl,-new_linker -static -nostartfiles -nodefaultlibs -r
|
||||
|
||||
ANALYZERFLAGS = --analyze -D__clang_analyzer__
|
||||
ifneq ($(ANALYZE_FORMAT),text)
|
||||
ANALYZERFLAGS += -Xanalyzer -analyzer-output=html
|
||||
ANALYZERFLAGS += -o $(OBJROOT)/build/analyzer-html
|
||||
else
|
||||
ANALYZERFLAGS += -Xanalyzer -analyzer-output=text
|
||||
endif
|
||||
ifneq ($(ANALYZE_VERBOSE),YES)
|
||||
ANALYZERFLAGS += -Xclang -analyzer-disable-checker -Xclang deadcode.DeadStores
|
||||
endif
|
||||
|
||||
ifeq ($(SANITIZE),YES)
|
||||
SANITIZE_CFLAGS := -fsanitize=address
|
||||
SANITIZE_LDFLAGS := -fsanitize=address
|
||||
endif
|
||||
|
||||
# Build host platform-specfic stuff here
|
||||
ifeq ($(BUILD_OS),linux)
|
||||
|
||||
# uint64_t is long on Linux, long long on Darwin
|
||||
# so just disable format string warnings on Linux
|
||||
CWARNFLAGS += -Wno-format
|
||||
endif
|
||||
@@ -0,0 +1,218 @@
|
||||
# Copyright (C) 2010-2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
|
||||
################################################################################
|
||||
# Macros for interacting with the device map database.
|
||||
#
|
||||
|
||||
ifeq ($(DEVICEMAP),)
|
||||
$(error Cannot locate embedded_device_map - device map queries will fail.)
|
||||
endif
|
||||
|
||||
# Oh, makefile! This is the only way to escape a comma in some cases.
|
||||
COMMA := ,
|
||||
|
||||
# Transform a whitespace separated list to a comma separated list of
|
||||
# double-quoted items.
|
||||
# Example input: iBoot iBSS iBEC iBoot
|
||||
# Example output: "iBoot", "iBSS", "iBEC", "iBoot"
|
||||
# Method:
|
||||
# 1) Enclose each item in <"item",>
|
||||
# 2) Terminate with <X>
|
||||
# 3) Remove trailing <,X>
|
||||
MAKE_SQL_LIST = \
|
||||
$(subst $(COMMA)X,,$(foreach i,$(1),\"$(i)\"$(COMMA))X)
|
||||
|
||||
#
|
||||
# Locate the device map database; this prevents EDM having to locate the
|
||||
# platform every time it runs.
|
||||
#
|
||||
DEVICEMAP_DATABASE ?= $(PLATFORMROOT)/usr/local/standalone/firmware/device_map.db
|
||||
DEVICEMAP_DBOPT := -db $(DEVICEMAP_DATABASE)
|
||||
|
||||
#
|
||||
# Returns the set of TARGET values known to the map.
|
||||
#
|
||||
DEVICEMAP_TARGETS = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT TargetType \
|
||||
FROM Targets \
|
||||
GROUP BY TargetType)
|
||||
|
||||
#
|
||||
# Returns the set of PLATFORM values associated with at least one TARGET.
|
||||
#
|
||||
DEVICEMAP_PLATFORMS = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT Platform \
|
||||
FROM Targets)
|
||||
|
||||
#
|
||||
# Returns the set of PRODUCT values defined for the TARGET passed in $1
|
||||
#
|
||||
# Note that this may include product types that we can't generate, so it
|
||||
# needs to be post-filtered to remove unknown products.
|
||||
#
|
||||
DEVICEMAP_PRODUCTS_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT FileType \
|
||||
FROM Files \
|
||||
INNER JOIN Manifests USING \(manifestID\) \
|
||||
INNER JOIN Targets USING \(Target\) \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
GROUP BY FileType)
|
||||
|
||||
#
|
||||
# Returns the chip ID value defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_CHIPID_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT ChipID \
|
||||
FROM Targets \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
GROUP BY ChipID)
|
||||
|
||||
#
|
||||
# Returns the epoch value defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_EPOCH_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT SecurityEpoch \
|
||||
FROM Targets \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
GROUP BY SecurityEpoch)
|
||||
|
||||
#
|
||||
# Returns the crypto hash method defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_CRYPTO_HASH_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT CryptoHashMethod \
|
||||
FROM Targets \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
GROUP BY CryptoHashMethod)
|
||||
|
||||
#
|
||||
# Returns the epoch value defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_EPOCH_FOR_PLATFORM = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT SecurityEpoch \
|
||||
FROM Targets \
|
||||
WHERE Platform == \"$(1)\" \
|
||||
GROUP BY SecurityEpoch)
|
||||
|
||||
#
|
||||
# Returns the crypto hash method defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_CRYPTO_HASH_FOR_PLATFORM = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT CryptoHashMethod \
|
||||
FROM Targets \
|
||||
WHERE Platform == \"$(1)\" \
|
||||
GROUP BY CryptoHashMethod)
|
||||
|
||||
#
|
||||
# Returns the product id value defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_PRODUCTID_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT ProductID \
|
||||
FROM Targets \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
GROUP BY ProductID)
|
||||
|
||||
#
|
||||
# Returns the image format defined for the PLATFORM passed in $1
|
||||
#
|
||||
DEVICEMAP_IMGFMT_FOR_PLATFORM = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT ImageFormat \
|
||||
FROM Targets \
|
||||
WHERE Platform == \"$(1)\" \
|
||||
)
|
||||
|
||||
#
|
||||
# Returns the image format defined for the TARGET passed in $1
|
||||
#
|
||||
DEVICEMAP_IMGFMT_FOR_TARGET = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT ImageFormat \
|
||||
FROM Targets \
|
||||
WHERE TargetType == \"$(1)\" \
|
||||
)
|
||||
|
||||
#
|
||||
# Returns a series for target:imageformat:epoch:productid sequences for
|
||||
# all targets, use the macros below to look up keys in the result
|
||||
#
|
||||
DEVICEMAP_TGT_DICT = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-separator : \
|
||||
-query SELECT DISTINCT \
|
||||
TargetType, ImageFormat, SecurityEpoch, ProductID, CryptoHashMethod \
|
||||
FROM Targets \
|
||||
)
|
||||
|
||||
DEVICEMAP_TGT_DICT_IMGFMT = $(word 2,$(subst :, ,$(filter $(2):%,$(1))))
|
||||
DEVICEMAP_TGT_DICT_EPOCH = $(word 3,$(subst :, ,$(filter $(2):%,$(1))))
|
||||
DEVICEMAP_TGT_DICT_PRODUCTID = $(word 4,$(subst :, ,$(filter $(2):%,$(1))))
|
||||
DEVICEMAP_TGT_DICT_CRYPTOHASH = $(word 5,$(subst :, ,$(filter $(2):%,$(1))))
|
||||
|
||||
#
|
||||
# Returns a series for target:product:payloadtype tuples for
|
||||
# all target/product pairs, use the macro below to look up keys in the result
|
||||
#
|
||||
DEVICEMAP_TGT_PRODUCT_DICT = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-separator : \
|
||||
-query SELECT DISTINCT \
|
||||
TargetType, fileType, PayloadType \
|
||||
FROM Files \
|
||||
INNER JOIN Manifests USING \(manifestID\) \
|
||||
INNER JOIN Targets USING \(Target\) \
|
||||
WHERE fileType IN \($(call MAKE_SQL_LIST,$(1))\) \
|
||||
)
|
||||
|
||||
DEVICEMAP_TGT_PRODUCT_DICT_PAYLOADTYPE = $(word 3,$(subst :, ,$(filter $(2):$(3):%,$(1))))
|
||||
|
||||
#
|
||||
# Returns the PayloadType value defined for object specified by
|
||||
# PRODUCT passed in $1
|
||||
# TARGET passed in $2
|
||||
#
|
||||
DEVICEMAP_PAYLOADTYPE_FOR_OBJECT = $(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) \
|
||||
-query SELECT DISTINCT PayloadType \
|
||||
FROM Files \
|
||||
INNER JOIN Manifests USING \(manifestID\) \
|
||||
INNER JOIN Targets USING \(Target\) \
|
||||
WHERE fileType == \"$(1)\" \
|
||||
AND TargetType == \"$(2)\" \
|
||||
GROUP BY PayloadType \
|
||||
)
|
||||
|
||||
#
|
||||
# Returns the set of TARGET values which have at least one firmware file.
|
||||
# This can be used to elide targets with no firmware.
|
||||
#
|
||||
# PRODUCT list is passed in $1, e.g iBoot iBSS iBEC iBoot
|
||||
#
|
||||
DEVICEMAP_TARGETS_FOR_PRODUCTS = \
|
||||
$(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) -query \
|
||||
SELECT DISTINCT TargetType \
|
||||
FROM Files \
|
||||
INNER JOIN Manifests USING \(manifestID\) \
|
||||
INNER JOIN Targets USING \(Target\) \
|
||||
WHERE fileType IN \($(call MAKE_SQL_LIST,$(1))\))
|
||||
|
||||
#
|
||||
# Returns all TARGET-PRODUCT-BUILD tuples where:
|
||||
#
|
||||
# TargetType is in list $1 (TARGETS)
|
||||
# FileType is in list $2 (PRODUCTS)
|
||||
# BuildStyle is in list $3 (BUILDS)
|
||||
#
|
||||
DEVICE_MAP_TPB_FILTERED = \
|
||||
$(shell $(DEVICEMAP) $(DEVICEMAP_DBOPT) -query \
|
||||
SELECT DISTINCT TargetType, FileType, BuildStyle \
|
||||
FROM Files \
|
||||
INNER JOIN Manifests USING \(manifestID\) \
|
||||
INNER JOIN Targets USING \(Target\) \
|
||||
WHERE \
|
||||
TargetType IN \($(call MAKE_SQL_LIST,$(1))\) AND \
|
||||
FileType IN \($(call MAKE_SQL_LIST,$(2))\) AND \
|
||||
BuildStyle IN \($(call MAKE_SQL_LIST,$(3))\) \
|
||||
| sed "s/|/-/g")
|
||||
@@ -0,0 +1,73 @@
|
||||
# Copyright (c) 2007 Apple Inc. All Rights Reserved
|
||||
#
|
||||
# Customise the protocol header file to reflect a specific build of the firmware.
|
||||
#
|
||||
# The following environment variables are expected:
|
||||
#
|
||||
# OBJFILE Firmware object file
|
||||
# BINFILE Binary ROM data file
|
||||
# NM An 'nm' suitable for the object file
|
||||
#
|
||||
|
||||
BEGIN { FS = ":" }
|
||||
|
||||
# eat lines that ask for it
|
||||
/EATLINE/ {
|
||||
next
|
||||
}
|
||||
|
||||
# by default, copy input to output
|
||||
$1!="/*SUBST" {
|
||||
print $0
|
||||
next
|
||||
}
|
||||
|
||||
# read a string value from the environment
|
||||
$1=="/*SUBST" && $2=="ENVSTR" {
|
||||
if (ENVIRON[$4] != "") {
|
||||
printf "%s\"%s\"%s\n", $3, ENVIRON[$4], $5
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# read a variable from the environment
|
||||
$1=="/*SUBST" && $2=="ENV" {
|
||||
if (ENVIRON[$4] != "") {
|
||||
printf "%s%s%s\n", $3, ENVIRON[$4], $5
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# look up a variable in the object file
|
||||
$1=="/*SUBST" && $2=="VAR" {
|
||||
cmd = sprintf("%s %s | grep \" %s\" | cut -f 1 -d ' '", ENVIRON["NM"], ENVIRON["OBJFILE"], $4)
|
||||
if (cmd | getline value == 0) {
|
||||
value = "ffffffff"
|
||||
}
|
||||
printf "%s0x%s%s\n", $3, value, $5
|
||||
next
|
||||
}
|
||||
|
||||
# format the binary file as hex and insert it
|
||||
$1=="/*SUBST" && $2=="FILE" {
|
||||
format = "cat %s | dd obs=16 conv=osync 2>/dev/null | hexdump -v -e '~\t~ 16/1 ~0x%%02x,~ ~\n~'"
|
||||
gsub(/~/, "\"", format)
|
||||
cmd = sprintf(format, ENVIRON["BINFILE"])
|
||||
system(cmd)
|
||||
next
|
||||
}
|
||||
|
||||
# insert the file named via the environment
|
||||
$1=="/*SUBST" && $2=="INSERT" {
|
||||
if (ENVIRON[$3] != "") {
|
||||
cmd = sprintf("cat %s", ENVIRON[$3])
|
||||
system(cmd)
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# eat the next line
|
||||
$1=="/*SUBST" && $2=="EATLINE" {
|
||||
next
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Copyright (C) 2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Makefile to build global headers common to multiple build targets in the iBoot tree
|
||||
#
|
||||
# The list of libraries to build is derived from the contents of the file named
|
||||
# in HDRLIST, which encodes the global and local path to the header in the format:
|
||||
#
|
||||
# <global header path>@<module header path>
|
||||
#
|
||||
|
||||
ifeq ($(MAKEPHASE),headers)
|
||||
|
||||
HEADER_SPECS := $(shell touch $(HDRLIST) && cat $(HDRLIST))
|
||||
HEADER_LIST := $(subst ~,/,$(HEADER_SPECS))
|
||||
|
||||
BUILD_ACTIONS := $(addprefix build@,$(HEADER_SPECS))
|
||||
CLEAN_ACTIONS := $(addprefix clean@,$(HEADER_SPECS))
|
||||
|
||||
ACTIONS := $(BUILD_ACTIONS) $(CLEAN_ACTIONS)
|
||||
|
||||
$(ACTIONS): $(MAKEFILE_LIST) $(HDRLIST)
|
||||
$(ACTIONS): spec = $(subst @, ,$@)
|
||||
$(ACTIONS): action = $(word 1,$(spec))
|
||||
$(ACTIONS): header = $(word 3,$(spec))
|
||||
$(ACTIONS): module = $(dir $(header))
|
||||
$(ACTIONS):
|
||||
@echo "%%%% $(action) $(header)"
|
||||
$(_v)$(MAKE) -f $(module)header.mk \
|
||||
HEADER=$(header) \
|
||||
$(action)
|
||||
|
||||
build: $(BUILD_ACTIONS)
|
||||
|
||||
clean:
|
||||
$(_v)rm -f $(HEADER_LIST)
|
||||
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# Copyright (C) 2008-2011 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Makefile to build a library common to multiple build targets in the iBoot tree
|
||||
#
|
||||
# We expect the following to be set:
|
||||
#
|
||||
# MODULE
|
||||
# Path to a directory containing a library.mk Makefile for the library
|
||||
# we are going to build.
|
||||
#
|
||||
# TAG
|
||||
# A unique identifier for the library we are going to build.
|
||||
#
|
||||
# OPTIONS
|
||||
#
|
||||
# Options to pass to the compiler when building the library.
|
||||
#
|
||||
|
||||
include makefiles/macros.mk
|
||||
include makefiles/config.mk
|
||||
|
||||
LIBDIR := $(OBJROOT)/build/lib-$(TAG)
|
||||
LIBOBJDIR := $(addprefix $(LIBDIR)/,$(MODULE))
|
||||
GLOBAL_ALLFLAGS += $(OPTIONS)
|
||||
LIBRARY_LDFLAGS += $(OPTIONS)
|
||||
|
||||
# XXX HACK ALERT
|
||||
# It would be nice to have both makefile options and compile options encoded in the
|
||||
# library spec. Currently the only one we need is ARCH, so just hack it for now.
|
||||
ifneq ($(findstring arm64,$(TAG)),)
|
||||
ARCH := arm64
|
||||
else
|
||||
ifneq ($(findstring arm,$(TAG)),)
|
||||
ARCH := arm
|
||||
endif
|
||||
endif
|
||||
|
||||
# XXX HACK ALERT
|
||||
# Libraries don't process options the same way as non-library files. In order
|
||||
# to get the build flavor in the same format that everything else expects
|
||||
# we have to play some games.
|
||||
BUILD := $(lastword $(subst -, ,$(TAG)))
|
||||
GLOBAL_ALLFLAGS += -D$(BUILD)_BUILD=1
|
||||
|
||||
# For ROMRELEASE builds, define RELEASE_BUILD so that everything that uses
|
||||
# BUILD_RELEASE doesn't have to be touched to use ROMRELEASE also. Also,
|
||||
# libraries must be completely silent and not emit any debug or panic strings
|
||||
# for ROMRELEASE builds.
|
||||
ifeq ($(BUILD),ROMRELEASE)
|
||||
GLOBAL_ALLFLAGS += -DRELEASE_BUILD=1 -DDEBUG_LEVEL=DEBUG_SILENT -DNO_PANIC_STRINGS=1
|
||||
endif
|
||||
ifeq ($(BUILD),RELEASE)
|
||||
GLOBAL_ALLFLAGS += -DTERSE_PANIC_STRINGS=1
|
||||
endif
|
||||
|
||||
# Read the module makefile
|
||||
#
|
||||
# The module makefile defines COMMONLIBS containing the names of libraries
|
||||
# to build. For each entry in COMMONLIBS there is:
|
||||
#
|
||||
# o an <entry>_BUILD variable which gives the name of the output library.
|
||||
# o an <entry>_OBJS variable which gives the name of the objects to be built into the library.
|
||||
|
||||
include $(MODULE)/library.mk
|
||||
|
||||
TARGETVARS := $(addsuffix _BUILD,$(COMMONLIBS))
|
||||
MAKELIBS := $(foreach i,$(TARGETVARS),$(value $i))
|
||||
|
||||
$(MAKELIBS): objs = $(value $(addsuffix _OBJS,$(basename $(notdir $@))))
|
||||
$(MAKELIBS):
|
||||
@$(MKDIR)
|
||||
@echo AR $@
|
||||
$(_v)$(AR) -crS $@ $(objs)
|
||||
$(_v)$(RANLIB) $@
|
||||
|
||||
# Now we can define object build rules
|
||||
include makefiles/build.mk
|
||||
|
||||
build: $(MAKELIBS)
|
||||
|
||||
clean:
|
||||
$(_v)rm -rf $(LIBDIR)
|
||||
|
||||
# Empty rule for .d files
|
||||
%.d:
|
||||
%.Td:
|
||||
|
||||
ifeq ($(filter $(MAKECMDGOALS), clean), )
|
||||
-include $(ALL_DEPS)
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Copyright (C) 2008 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Makefile to build libraries common to multiple build targets in the iBoot tree
|
||||
#
|
||||
# The list of libraries to build is derived from the contents of the file named in LIBLIST, which
|
||||
# encodes the library module path, library uniquing tag and build options for the library in the
|
||||
# format:
|
||||
#
|
||||
# <module path>~<uniquing tag>[~<build option>[~<build option>[~...]]]
|
||||
#
|
||||
# It is assumed that the contents of the LIBLIST file have been uniqued and thus
|
||||
# every library target is unique.
|
||||
#
|
||||
|
||||
LIBRARY_SPECS := $(shell touch $(LIBLIST) && cat $(LIBLIST))
|
||||
|
||||
BUILD_ACTIONS := $(addprefix build~,$(LIBRARY_SPECS))
|
||||
CLEAN_ACTIONS := $(addprefix clean~,$(LIBRARY_SPECS))
|
||||
|
||||
ACTIONS := $(BUILD_ACTIONS) $(CLEAN_ACTIONS)
|
||||
|
||||
$(ACTIONS): $(MAKEFILE_LIST) $(LIBLIST)
|
||||
$(ACTIONS): spec = $(subst ~, ,$@)
|
||||
$(ACTIONS): action = $(word 1,$(spec))
|
||||
$(ACTIONS): module = $(word 2,$(spec))
|
||||
$(ACTIONS): tag = $(word 3,$(spec))
|
||||
$(ACTIONS): options = $(wordlist 4,$(words $(spec)),$(spec))
|
||||
$(ACTIONS):
|
||||
@echo "%%%% $(action) $(module) as $(tag)"
|
||||
$(_v)$(MAKE) -f makefiles/lib.mk \
|
||||
MODULE=$(module) \
|
||||
TAG=$(tag) \
|
||||
OPTIONS="$(options)" \
|
||||
$(action)
|
||||
|
||||
build: $(BUILD_ACTIONS)
|
||||
|
||||
clean: $(CLEAN_ACTIONS)
|
||||
@@ -0,0 +1,50 @@
|
||||
# Copyright (C) 2009-2011, 2014 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
TOBUILDDIR = $(addprefix $(BUILDDIR)/,$(1))
|
||||
TOHDRDIR = $(addprefix $(HDRDIR)/,$(1))
|
||||
TOLIBDIR = $(addprefix $(LIBDIR)/,$(1))
|
||||
TOLIBOBJDIR = $(addprefix $(LIBOBJDIR)/,$(1))
|
||||
TOSYMDIR = $(addprefix $(SYMDIR)/,$(1))
|
||||
TOTOOLSDIR = $(addprefix $(TOOLS_BIN)/,$(1))
|
||||
TOTESTDIR = $(addprefix $(TESTDIR)/,$(1))
|
||||
|
||||
# build the target directory in a rule
|
||||
MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
|
||||
|
||||
# gets the local directory of the makefile. Requires GNU make 3.81
|
||||
GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
# returns a variable's numeric value or zero if empty
|
||||
NUMBER = $(or $(1),0)
|
||||
|
||||
# evaluate arithmetic using the bash $(()) construct
|
||||
EVALUATE = $(shell echo $$(( $(1) )))
|
||||
|
||||
# add two variables (empty variables count as zero)
|
||||
ADD = $(call EVALUATE, $(call NUMBER,$(1)) + $(call NUMBER,$(2)))
|
||||
|
||||
# safe case transformations
|
||||
UPCASE = $(shell echo $(1) | tr a-z A-Z)
|
||||
DOWNCASE = $(shell echo $(1) | tr A-Z a-z)
|
||||
|
||||
# test whether OPTIONS mentions the argument
|
||||
OPTION_ISSET = $(patsubst %,true,$(filter $(1),$(OPTIONS)) $(filter $(1)=%,$(OPTIONS)))
|
||||
|
||||
# fetch the value that OPTIONS defines for the argument
|
||||
OPTION_VALUE = $(patsubst $(1)=%,%,$(filter $(1)=%,$(OPTIONS)))
|
||||
|
||||
# evil hack to get a space as the first argument to $(subst ...)
|
||||
empty :=
|
||||
|
||||
# for generating definition of obfuscated logging ID from filename
|
||||
HASH_FOR_FILE = $(or $(word 2,$(subst :, ,$(filter $<:%,$(DEBUG_FILENAME_HASHES)))),$(error Error: debug hash not found for source file $< needed for $@))
|
||||
DEBUG_FILE_HASH = -DDEBUG_FILE_HASH=0x$(HASH_FOR_FILE)ULL
|
||||
@@ -0,0 +1,52 @@
|
||||
# Copyright (C) 2008 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
#
|
||||
# Handle one iteration of the nested module include logic for main.mk
|
||||
#
|
||||
# The caller is expected to set:
|
||||
#
|
||||
# MODULES_VAR
|
||||
# The name of the variable containing modules to include, and
|
||||
# which will be set by included module makefiles.
|
||||
#
|
||||
# MODULE_MAKEFILE
|
||||
# The name of the makefile in the module directory
|
||||
#
|
||||
# LIBDIR
|
||||
# If the modules being processed are library modules, the root
|
||||
# of the current library object tree.
|
||||
#
|
||||
|
||||
# strip modules that the configuration insists we cannot have
|
||||
# strip modules that we have already included
|
||||
# use $(sort ...) to remove duplicates in the list
|
||||
MODULES_TO_INCLUDE := $(sort $(filter-out $(MODULES_ALREADY_INCLUDED),$(filter-out $(MODULES_ELIDE),$($(MODULES_VAR)))))
|
||||
|
||||
# clear the modules variable so that included modules can request dependencies
|
||||
$(MODULES_VAR) :=
|
||||
|
||||
# template for each module we are including
|
||||
define include_template
|
||||
LIBOBJDIR := $$(addprefix $$(LIBDIR)/,$$(MODULE))
|
||||
MODULE_RULES_FILE := $$(addprefix $$(MODULE)/,$$(MODULE_MAKEFILE))
|
||||
include $$(MODULE_RULES_FILE)
|
||||
endef
|
||||
|
||||
# expand the template and execute
|
||||
$(foreach MODULE,$(MODULES_TO_INCLUDE),$(eval $(include_template)))
|
||||
|
||||
# remember what we have included
|
||||
MODULES_ALREADY_INCLUDED+= $(MODULES_TO_INCLUDE)
|
||||
|
||||
# recursively invoke ourself if there are still modules to include
|
||||
ifneq ($($(MODULES_VAR)),)
|
||||
include makefiles/main-nested-module.mk
|
||||
endif
|
||||
@@ -0,0 +1,537 @@
|
||||
# Copyright (C) 2007-2014 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
# Makefile to build/install a specific executable from the iBoot source tree
|
||||
#
|
||||
# The following must be set by the caller:
|
||||
#
|
||||
# CONFIG
|
||||
# PRODUCT
|
||||
# BUILD
|
||||
# XBS_BUILD_TAG
|
||||
# OBJROOT
|
||||
# SYMROOT
|
||||
#
|
||||
# The following may be set by the caller:
|
||||
#
|
||||
# APPLICATION_OPTIONS
|
||||
# List of options from application to be added to OPTIONS
|
||||
#
|
||||
# IMAGE_TYPE
|
||||
# Installation will generate an image component of the
|
||||
# specified type.
|
||||
#
|
||||
# IMAGE_FORMAT
|
||||
# Installation will generate images of the format(s) listed.
|
||||
# Valid formats are 2 and 3 (Image2, Image3 respectively).
|
||||
#
|
||||
# DFU_IMAGE
|
||||
# The generated image will also be installed into the DFU
|
||||
# install location.
|
||||
#
|
||||
# ROM_IMAGE
|
||||
# Installation will generate a raw binary.
|
||||
#
|
||||
# INTEL_HEX
|
||||
# Installation will generate an Intel Hex format version
|
||||
# of the binary. ROM_IMAGE_SIZE must be set to a value
|
||||
# of the form XXk where XX is your average power of 2
|
||||
# and larger than the binary image (this causes the
|
||||
# image to be padded correspondingly).
|
||||
#
|
||||
# Environment:
|
||||
# TOOLCHAIN_PREFIX
|
||||
# Locate tools somewhere other than on the path.
|
||||
#
|
||||
# XXX need something to cause the mach-o to be installed
|
||||
|
||||
include makefiles/macros.mk
|
||||
include makefiles/config.mk
|
||||
|
||||
#$(warning Building $(SUB_TARGET)-$(PRODUCT) $(CONFIG) $(BUILD) config)
|
||||
|
||||
# Directories
|
||||
BUILDDIR := $(OBJROOT)/build/$(SUB_TARGET)$(CONFIG)-$(PRODUCT)-$(BUILD)
|
||||
HDRDIR := $(OBJROOT)/build/include
|
||||
SYMDIR := $(SYMROOT)/build/$(SUB_TARGET)$(CONFIG)-$(PRODUCT)-$(BUILD)
|
||||
APPDIR := apps/$(APPLICATION)
|
||||
LIBDIR := /BAD
|
||||
|
||||
# Built products
|
||||
PRODUCT_BUILD := $(call TOSYMDIR,$(PRODUCT))
|
||||
PRODUCT_MACHO := $(PRODUCT_BUILD).sys
|
||||
PRODUCT_DSYM := $(PRODUCT_MACHO).dSYM
|
||||
PRODUCT_BIN := $(PRODUCT_BUILD).bin
|
||||
PRODUCT_LIBLIST := $(call TOBUILDDIR,$(PRODUCT)).library_list
|
||||
PRODUCT_HDRLIST := $(call TOBUILDDIR,$(PRODUCT)).header_list
|
||||
|
||||
# Local tools
|
||||
BHC := $(call TOTOOLSDIR,bhc)
|
||||
MACHO2BIN := $(call TOTOOLSDIR,Macho2Bin)
|
||||
|
||||
# All sources depend on these
|
||||
GLOBAL_SRCDEPS :=
|
||||
PRODUCT_SRCDEPS :=
|
||||
|
||||
# Global headers live here:
|
||||
GLOBAL_INCLUDES += $(HDRDIR)
|
||||
|
||||
# Product-related compilation flags
|
||||
PRODUCT_ALLFLAGS :=
|
||||
|
||||
# Object files to build, added to by included rules.mk files.
|
||||
ALL_OBJS :=
|
||||
|
||||
# Deps for object files, computed locally (except for libraries, XXX probably a bug)
|
||||
ALL_DEPS :=
|
||||
|
||||
# Static libraries we build locally.
|
||||
LOCALLIBS :=
|
||||
|
||||
# Static libraries built for us by libraries.mk.
|
||||
COMMONLIBS :=
|
||||
|
||||
# Static libraries someone else already built.
|
||||
PREBUILT_STATICLIBS :=
|
||||
|
||||
# Static libraries imported externally.
|
||||
EXTERNAL_STATICLIBS :=
|
||||
|
||||
# All static libraries.
|
||||
ALL_STATICLIBS :=
|
||||
|
||||
# Additional dependencies for the product.
|
||||
EXTRA_PRODUCTDEPS :=
|
||||
|
||||
# Dependencies for cleaning
|
||||
CLEAN :=
|
||||
|
||||
# Source modules list, added to by included rules.mk files.
|
||||
MODULES :=
|
||||
|
||||
# Module opt-out list, added to by included rules.mk files.
|
||||
MODULES_ELIDE :=
|
||||
|
||||
# Common library module dependency list, added to by included rules.mk files.
|
||||
LIBRARY_MODULES :=
|
||||
|
||||
# Options to be passed to all compiled sources in the form <NAME>=<value>. -D will be added
|
||||
# automatically.
|
||||
OPTIONS :=
|
||||
|
||||
# Tag that identifies libraries used/generated by this build
|
||||
# This is appended by other rules to uniquely identify library builds.
|
||||
LIBRARY_TAG :=
|
||||
|
||||
# Options passed to the library build
|
||||
LIBRARY_OPTIONS := BUILD=$(BUILD)
|
||||
|
||||
# Compiler options for the library build
|
||||
LIBRARY_ALLFLAGS :=
|
||||
|
||||
# Default is no synch AES
|
||||
AES_SYNCH_FIXUP := false
|
||||
|
||||
# Expose what we are building to the compiler
|
||||
# APPLICATION_$(APPLICATION)
|
||||
# PRODUCT_$(PRODUCT)
|
||||
# SUB_TARGET_$(SUB_TARGET)
|
||||
# SUB_TARGET_$(SUB_TARGET)_CONFIG_$(CONFIG)
|
||||
# CONFIG_$(CONFIG)
|
||||
APPLICATION_UPPER := $(call UPCASE, $(APPLICATION))
|
||||
PRODUCT_UPPER := $(call UPCASE, $(PRODUCT))
|
||||
SUB_TARGET_UPPER := $(call UPCASE, $(SUB_TARGET))
|
||||
CONFIG_UPPER := $(call UPCASE, $(CONFIG))
|
||||
OPTIONS += APPLICATION_$(APPLICATION_UPPER)=1
|
||||
# 8208311
|
||||
OPTIONS += $(APPLICATION_OPTIONS)
|
||||
OPTIONS += PRODUCT_$(PRODUCT_UPPER)=1
|
||||
OPTIONS += SUB_TARGET_$(SUB_TARGET_UPPER)=1
|
||||
OPTIONS += SUB_TARGET_STRING=\"$(SUB_TARGET)\"
|
||||
OPTIONS += SUB_TARGET_UPPER_STRING=\"$(SUB_TARGET_UPPER)\"
|
||||
ifneq ($(CONFIG),)
|
||||
OPTIONS += SUB_TARGET_$(SUB_TARGET_UPPER)_CONFIG_$(CONFIG_UPPER)=1
|
||||
OPTIONS += CONFIG_$(CONFIG_UPPER)=1
|
||||
endif
|
||||
OPTIONS += $(BUILD)_BUILD=1
|
||||
ifneq ($(CRYPTO_HASH),sha1)
|
||||
CRYPTO_HASH_UPPER := $(call UPCASE, $(subst -,_,$(CRYPTO_HASH)))
|
||||
OPTIONS += WITH_$(CRYPTO_HASH_UPPER)=1
|
||||
endif
|
||||
|
||||
# Also define RELEASE_BUILD for the ROMRELEASE build flavor so that everything
|
||||
# uses BUILD_RELEASE doesn't have to be touched to use ROMRELEASE also.
|
||||
ifeq ($(BUILD),ROMRELEASE)
|
||||
OPTIONS += RELEASE_BUILD=1
|
||||
endif
|
||||
|
||||
# export hacks as options
|
||||
OPTIONS += $(addprefix HACK_,$(HACKS))
|
||||
|
||||
# Identifying strings
|
||||
OPTIONS += BUILD_STYLE=\"$(BUILD)\"
|
||||
OPTIONS += CONFIG_PROGNAME_STRING=\"$(PRODUCT)\"
|
||||
OPTIONS += CONFIG_BOARD_STRING=\"$(SUB_TARGET)$(CONFIG)\"
|
||||
|
||||
# can't OPTIONS this as it changes for every non-XBS build
|
||||
GLOBAL_CFLAGS += -DXBS_BUILD_TAG=\"$(XBS_BUILD_TAG)\"
|
||||
GLOBAL_ASFLAGS += -DXBS_BUILD_TAG=\"$(XBS_BUILD_TAG)\"
|
||||
|
||||
# deal with the options.h file which is dynamically built from the OPTIONS make variable
|
||||
OPTIONS_HEADER_FILE := $(call TOSYMDIR,options.h)
|
||||
OPTIONS_HEADER_FILE_TEMP := $(call TOSYMDIR,options.h.temp)
|
||||
PRODUCT_ALLFLAGS += -include $(OPTIONS_HEADER_FILE)
|
||||
PRODUCT_SRCDEPS += $(OPTIONS_HEADER_FILE)
|
||||
|
||||
# Read the application makefile, which may add modules
|
||||
include $(APPDIR)/application.mk
|
||||
|
||||
# Application may adjust TARGET
|
||||
TARGET := $(SUB_TARGET)
|
||||
|
||||
# Read the target configuration, which may add modules
|
||||
# Allow the config file path to be overridden to support
|
||||
# configs outside of the application's regular location.
|
||||
CONFIG_FILE ?= $(APPDIR)/config/$(SUB_TARGET)-config.mk
|
||||
include $(CONFIG_FILE)
|
||||
|
||||
# The target configuration may elect to abort the build of this product
|
||||
ifeq ($(ABORT),true)
|
||||
$(warning Build of $(SUB_TARGET)-$(PRODUCT) $(CONFIG) $(BUILD) aborted by configuration)
|
||||
build:
|
||||
install:
|
||||
clean:
|
||||
library_list:
|
||||
else
|
||||
|
||||
# Ensure TARGET exists
|
||||
TARGET_UPPER := $(call UPCASE, $(TARGET))
|
||||
OPTIONS += TARGET_$(TARGET_UPPER)=1
|
||||
ifneq ($(CONFIG),)
|
||||
OPTIONS += TARGET_$(TARGET_UPPER)_CONFIG_$(CONFIG_UPPER)=1
|
||||
endif
|
||||
|
||||
# Ensure SUB_PLATFORM exists
|
||||
SUB_PLATFORM ?= $(PLATFORM)
|
||||
SUB_PLATFORM_UPPER := $(call UPCASE, $(SUB_PLATFORM))
|
||||
OPTIONS += SUB_PLATFORM_$(SUB_PLATFORM_UPPER)=1
|
||||
|
||||
# Create PLATFORM_NAME_STRING, PLATFORM_NAME_UNQUOTED
|
||||
OPTIONS += PLATFORM_NAME_STRING=\"$(SUB_PLATFORM)\"
|
||||
OPTIONS += PLATFORM_NAME_UNQUOTED=$(SUB_PLATFORM)
|
||||
|
||||
# Read module configurations
|
||||
MODULES_ALREADY_INCLUDED:=
|
||||
MODULES_VAR := MODULES
|
||||
MODULE_MAKEFILE := rules.mk
|
||||
include makefiles/main-nested-module.mk
|
||||
|
||||
# Now that we have processed modules, we know where common library objects will be located.
|
||||
LIBRARY_UNIQUE := $(subst ${empty} ${empty},-,$(sort ${LIBRARY_TAG}))
|
||||
LIBDIR := $(OBJROOT)/build/lib-$(LIBRARY_UNIQUE)-$(BUILD)
|
||||
|
||||
# Do library modules
|
||||
MODULES_ALREADY_INCLUDED:=
|
||||
MODULES_VAR := LIBRARY_MODULES
|
||||
MODULE_MAKEFILE := library.mk
|
||||
include makefiles/main-nested-module.mk
|
||||
LIBRARY_MODULE_LIST := $(sort $(MODULES_ALREADY_INCLUDED))
|
||||
|
||||
# Compute the static library set based on the build target list.
|
||||
# We have two sets of static libraries; common libraries are built by libraries.mk,
|
||||
# whilst local libraries are built here.
|
||||
# Note local libraries before common libraries to permit local->common depdendencies.
|
||||
# (We could list both sets twice...)
|
||||
COMMONLIB_TARGETVARS := $(addsuffix _BUILD,$(COMMONLIBS))
|
||||
COMMONLIB_LIBS := $(foreach i,$(COMMONLIB_TARGETVARS),$(value $i))
|
||||
LOCALLIB_TARGETVARS := $(addsuffix _BUILD,$(LOCALLIBS))
|
||||
LOCALLIB_LIBS := $(foreach i,$(LOCALLIB_TARGETVARS),$(value $i))
|
||||
ALL_STATICLIBS += $(LOCALLIB_LIBS) $(COMMONLIB_LIBS) $(EXTERNAL_STATICLIBS)
|
||||
|
||||
# At the very least, installing requires the product be built
|
||||
INSTALL_PREREQS = $(PRODUCT)
|
||||
|
||||
# If an image type is specified, enable the image format targets
|
||||
ifneq ($(IMAGE_TYPE),)
|
||||
ifeq ($(IMAGE_FORMAT),img3)
|
||||
INSTALL_PREREQS += install-image3
|
||||
else
|
||||
INSTALL_PREREQS += install-image4
|
||||
endif
|
||||
endif
|
||||
|
||||
# If a DFU image is being handled, enable the image format targets
|
||||
# In Image4, this collides with the DSTROOT products of EmbeddedFirmware
|
||||
# due to not having a unique extension. It is already installed under
|
||||
# /image4, which EmbeddedFirmware searches, so we can skip this duplicate.
|
||||
ifeq ($(DFU_IMAGE),true)
|
||||
ifeq ($(IMAGE_FORMAT),img3)
|
||||
INSTALL_PREREQS += install-dfuimage3
|
||||
endif
|
||||
endif
|
||||
|
||||
# If we are generating a plain binary, enable the target
|
||||
ifeq ($(BINARY_IMAGE),true)
|
||||
INSTALL_PREREQS += install-binary-image
|
||||
endif
|
||||
|
||||
# If a Secure ROM image is being handled, enable the target
|
||||
ifeq ($(ROM_IMAGE),true)
|
||||
INSTALL_PREREQS += install-romimage
|
||||
endif
|
||||
|
||||
# Intel Hex output, requires ROM_IMAGE_SIZE be set to pad the image
|
||||
ifeq ($(INTEL_HEX),true)
|
||||
INSTALL_PREREQS += install-intelhex
|
||||
endif
|
||||
|
||||
# If a header file is being generated, enable the target
|
||||
ifneq ($(IMAGE_WITH_HEADER),)
|
||||
INSTALL_PREREQS += install-headerfile
|
||||
endif
|
||||
|
||||
# If additional headers should be installed, enable the target that installs them
|
||||
ifneq ($(INSTALL_HEADERS),)
|
||||
INSTALL_PREREQS += install-additional-headers
|
||||
endif
|
||||
|
||||
# Default to no optional arguments to image3maker
|
||||
IMAGE3_OPTARGS :=
|
||||
|
||||
# If AES synch support is enabled, we need the header to be found.
|
||||
# This isn't generally safe as there are headers we own that get installed
|
||||
# there and we end up using a stale version.
|
||||
ifneq ($(AES_SYNCH_FIXUP),false)
|
||||
GLOBAL_INCLUDES += /usr/local/standalone/firmware
|
||||
endif
|
||||
|
||||
build: $(PRODUCT)
|
||||
|
||||
library_list: $(PRODUCT_HDRLIST) $(PRODUCT_LIBLIST)
|
||||
|
||||
$(PRODUCT): $(PRODUCT_BIN) $(PRODUCT_BUILD).size
|
||||
|
||||
install: $(INSTALL_PREREQS)
|
||||
|
||||
install-image3: PRODUCT_IMG = $(PRODUCT_BUILD).img3
|
||||
install-image3: $(PRODUCT)
|
||||
@echo installing Image3 object \'$(IMAGE_TYPE)\' from $(PRODUCT_BIN)
|
||||
$(_v)$(IMAGE3MAKER) \
|
||||
--create \
|
||||
--data $(PRODUCT_BIN) \
|
||||
--version $(XBS_BUILD_TAG) \
|
||||
--type $(IMAGE_TYPE) \
|
||||
--imagefile $(PRODUCT_IMG) \
|
||||
$(IMAGE3_OPTARGS)
|
||||
@mkdir -p $(INSTALL_DIR)/image3
|
||||
@install -C -m 644 $(PRODUCT_IMG) $(INSTALL_DIR)image3/$(INSTALL_NAME).img3
|
||||
|
||||
install-dfuimage3: PRODUCT_IMG = $(PRODUCT_BUILD).img3
|
||||
install-dfuimage3: $(PRODUCT) install-image3
|
||||
@echo installing DFU object $(PRODUCT_IMG) as $(INSTALL_NAME).img3
|
||||
ifneq ($(MAX_DFU_SIZE),)
|
||||
@if test "$(PRODUCT)" = "iBSS"; then \
|
||||
tools/check_product_size $(PRODUCT_IMG) $(MAX_DFU_SIZE) "MAX_DFU_SIZE" ; \
|
||||
fi
|
||||
endif
|
||||
@mkdir -p $(INSTALL_DIR)/dfu
|
||||
@install -C -m 644 $(PRODUCT_IMG) $(INSTALL_DIR)dfu/$(INSTALL_NAME).img3
|
||||
|
||||
install-image4: PRODUCT_IMG = $(PRODUCT_BUILD).im4p
|
||||
install-image4: $(PRODUCT)
|
||||
@echo installing Image4 object \'$(IMAGE_TYPE)\' from $(PRODUCT_BIN)
|
||||
$(_v)$(IMG4PAYLOAD) \
|
||||
-i $(PRODUCT_BIN) \
|
||||
-v $(XBS_BUILD_TAG) \
|
||||
-t $(IMAGE_TYPE) \
|
||||
-o $(PRODUCT_IMG)
|
||||
ifneq ($(MAX_DFU_SIZE),)
|
||||
@if test "$(PRODUCT)" = "iBSS" -o "$(PRODUCT)" = "LLB"; then \
|
||||
tools/check_product_size $(PRODUCT_IMG) $(MAX_DFU_SIZE) "MAX_DFU_SIZE"; \
|
||||
fi
|
||||
endif
|
||||
@mkdir -p $(INSTALL_DIR)/image4
|
||||
@install -C -m 644 $(PRODUCT_IMG) $(INSTALL_DIR)image4/$(INSTALL_NAME).im4p
|
||||
|
||||
install-binary-image: $(PRODUCT)
|
||||
@echo installing binary object $(PRODUCT_BIN) as $(INSTALL_NAME).bin
|
||||
@mkdir -p $(INSTALL_DIR)
|
||||
@install -C -m 644 $(PRODUCT_BIN) $(INSTALL_DIR)/$(INSTALL_NAME).bin
|
||||
|
||||
install-romimage: $(PRODUCT)
|
||||
@echo installing binary object $(PRODUCT_BIN) as $(INSTALL_NAME).bin
|
||||
@mkdir -p $(INSTALL_DIR)/SecureROM
|
||||
@install -C -m 644 $(PRODUCT_BIN) $(INSTALL_DIR)SecureROM/$(INSTALL_NAME).bin
|
||||
|
||||
install-intelhex: $(PRODUCT)
|
||||
@echo installing IntelHex file $(INSTALL_DIR)SecureROM/$(INSTALL_NAME).hex
|
||||
@$(BHC) -h $(PRODUCT_BIN) $(INSTALL_DIR)SecureROM/$(INSTALL_NAME).hex \
|
||||
$(ROM_IMAGE_SIZE) 2>&1 > /dev/null
|
||||
|
||||
install-headerfile: PRODUCT_HEADER = $(PRODUCT_BUILD).h
|
||||
install-headerfile: $(PRODUCT)
|
||||
@echo installing binary object $(PRODUCT_BIN) in headerfile $(INSTALL_NAME) using $(IMAGE_WITH_HEADER)
|
||||
@mkdir -p $(INSTALL_DIR)
|
||||
@NM=$(NM) \
|
||||
OBJFILE=$(PRODUCT_MACHO) \
|
||||
BINFILE=$(PRODUCT_BIN) \
|
||||
XBS_BUILD_TAG=$(XBS_BUILD_TAG) \
|
||||
$(AWK) -f $(SRCROOT)/makefiles/format-headerfile.awk < $(IMAGE_WITH_HEADER) > $(PRODUCT_HEADER)
|
||||
@install -C -m 644 $(PRODUCT_HEADER) $(INSTALL_DIR)$(INSTALL_NAME)
|
||||
|
||||
# Note that we can't use install -C here as it can race with another
|
||||
# install's unlink of the destination due to the same header(s) being
|
||||
# installed by more than one invocation simultaneously. Ssen notes
|
||||
# in rdar://8317733 that -S doesn't fix this.
|
||||
install-additional-headers: $(INSTALL_HEADERS)
|
||||
@echo installing additional headers: $(INSTALL_HEADERS)
|
||||
@mkdir -p $(INSTALL_DIR)
|
||||
@test -w $(INSTALL_DIR) || (echo "ERROR: I just created $(INSTALL_DIR) but now I cannot write files to it." && exit 1)
|
||||
@install -m 644 $(INSTALL_HEADERS) $(INSTALL_DIR)
|
||||
|
||||
# someone can request additional system dependencies
|
||||
$(PRODUCT): $(EXTRA_PRODUCTDEPS)
|
||||
|
||||
# Produce the prelinked binary image.
|
||||
#
|
||||
# Configuration may supply the following options:
|
||||
#
|
||||
# BIN_IMAGE_PREFIX
|
||||
# A binary image to be prepended to the image.
|
||||
#
|
||||
# BIN_INCLUDES_BSS
|
||||
# The image is padded to include the initialised BSS.
|
||||
#
|
||||
# BIN_ROUND_UP
|
||||
# The output image is padded to a multiple of the supplied value.
|
||||
#
|
||||
# BIN_FIXUP
|
||||
# The output image is passed to this command once fully assembled.
|
||||
#
|
||||
BIN_ROUND_UP ?= 1
|
||||
ifneq ($(BIN_ROUND_UP),1)
|
||||
ifeq ($(BIN_INCLUDES_BSS),true)
|
||||
$(error Cannot specify both BIN_ROUND_UP and BIN_INCLUDES_BSS)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(PRODUCT_BIN): $(PRODUCT_BUILD).stripped $(PRODUCT_DSYM) $(BIN_IMAGE_PREFIX)
|
||||
@$(SIZE) $<
|
||||
@echo BIN $@
|
||||
ifneq ($(BIN_IMAGE_PREFIX),)
|
||||
$(_v)dd if=$(BIN_IMAGE_PREFIX) of=$@
|
||||
else
|
||||
$(_v)dd if=/dev/zero of=$@ count=0
|
||||
endif
|
||||
$(_v)dd if=$< ibs=1 skip=$(shell $(OTOOL) -lv $< | grep -m1 '^ fileoff ' | cut -c 11-) \
|
||||
obs=$(BIN_ROUND_UP) conv=osync >> $@
|
||||
ifeq ($(BIN_INCLUDES_BSS),true)
|
||||
@echo PAD $@
|
||||
$(_v)dd if=/dev/zero \
|
||||
of=$@ \
|
||||
bs=1 \
|
||||
seek=`stat -f %z $@` \
|
||||
count=`expr \`$(SIZE) $< | tail -1 | cut -f 5\` - \`stat -f %z $@\``
|
||||
endif
|
||||
ifneq ($(BIN_FIXUP),)
|
||||
$(_v)$(BIN_FIXUP) $@
|
||||
endif
|
||||
ifneq ($(AES_SYNCH_FIXUP),false)
|
||||
$(AES_SYNCH_FIXUP) $(PRODUCT_BUILD)
|
||||
endif
|
||||
|
||||
$(PRODUCT_DSYM): $(PRODUCT_MACHO) tools/lldb_init_iboot.py tools/lldb_os_iboot.py
|
||||
@echo dSYM $@
|
||||
$(_v)$(DSYMUTIL) --out=$@ $<
|
||||
@mkdir -p $(PRODUCT_DSYM)/Contents/Resources/Python/
|
||||
@install -C -m 644 tools/lldb_init_iboot.py $(PRODUCT_DSYM)/Contents/Resources/Python/$(notdir $(PRODUCT_BUILD))-disabled.py
|
||||
@install -C -m 644 tools/lldb_os_iboot.py $(PRODUCT_DSYM)/Contents/Resources/Python/lldb_os_iboot.py
|
||||
|
||||
$(PRODUCT_BUILD).stripped: $(PRODUCT_MACHO)
|
||||
@echo STRIP $@
|
||||
$(_v)$(STRIP) -o $@ $<
|
||||
|
||||
$(PRODUCT_BUILD).size: $(PRODUCT_MACHO)
|
||||
@echo SIZE $@
|
||||
$(_v)$(SIZE) $(ALL_OBJS) > $@
|
||||
|
||||
$(PRODUCT_HDRLIST): $(MAKEFILE_LIST)
|
||||
$(_v)$(MKDIR)
|
||||
$(_v)rm -f $(PRODUCT_HDRLIST)
|
||||
$(_v)touch $(PRODUCT_HDRLIST)
|
||||
$(_v)for i in $(GLOBAL_HEADERS) ; do \
|
||||
echo "$(HDRDIR)@$$i" >> $(PRODUCT_HDRLIST) ; \
|
||||
done
|
||||
|
||||
ENCODED_LIBRARY_OPTIONS := $(subst $(empty) ,~,$(addprefix -D,$(strip $(LIBRARY_OPTIONS))))
|
||||
ENCODED_LIBRARY_FLAGS := $(subst $(empty) ,~,$(strip $(GLOBAL_ALLFLAGS) $(LIBRARY_ALLFLAGS)))
|
||||
$(PRODUCT_LIBLIST): $(MAKEFILE_LIST)
|
||||
$(_v)$(MKDIR)
|
||||
$(_v)rm -f $(PRODUCT_LIBLIST)
|
||||
$(_v)touch $(PRODUCT_LIBLIST)
|
||||
$(_v)for i in $(LIBRARY_MODULE_LIST) ; do \
|
||||
echo "$$i~$(LIBRARY_UNIQUE)-$(BUILD)~$(ENCODED_LIBRARY_OPTIONS)~$(ENCODED_LIBRARY_FLAGS)" \
|
||||
>> $(PRODUCT_LIBLIST) ; \
|
||||
done
|
||||
$(_v)$(CHECK_LIBLIST) $(PRODUCT_LIBLIST)
|
||||
|
||||
# XXX build static libraries the 'libraries' pass didn't get
|
||||
# XXX need to differentiate these...
|
||||
$(LOCALLIB_LIBS): objs = $(value $(addsuffix _OBJS,$(basename $(notdir $@))))
|
||||
$(LOCALLIB_LIBS):
|
||||
@$(MKDIR)
|
||||
@echo AR $@
|
||||
$(_v)$(AR) -crS $@ $(objs)
|
||||
$(_v)$(RANLIB) $@
|
||||
|
||||
# build the options.h file from the OPTIONS variable
|
||||
$(OPTIONS_HEADER_FILE): $(MAKEFILE_LIST)
|
||||
@$(MKDIR)
|
||||
@rm -f $(OPTIONS_HEADER_FILE_TEMP); \
|
||||
(for o in $(OPTIONS); do \
|
||||
echo "#define $$o"; \
|
||||
done) | sort | sed s/=/\ / >> $(OPTIONS_HEADER_FILE_TEMP); \
|
||||
if [ -f "$(OPTIONS_HEADER_FILE)" ]; then \
|
||||
if cmp "$(OPTIONS_HEADER_FILE_TEMP)" "$(OPTIONS_HEADER_FILE)"; then \
|
||||
rm -f $(OPTIONS_HEADER_FILE_TEMP) ; \
|
||||
else \
|
||||
echo UPD $@ ; \
|
||||
mv $(OPTIONS_HEADER_FILE_TEMP) $(OPTIONS_HEADER_FILE) ; \
|
||||
fi \
|
||||
else \
|
||||
echo GEN $@ ; \
|
||||
mv $(OPTIONS_HEADER_FILE_TEMP) $(OPTIONS_HEADER_FILE) ; \
|
||||
fi \
|
||||
|
||||
# Now we can define object build rules
|
||||
include makefiles/build.mk
|
||||
|
||||
clean:
|
||||
$(_v)rm -rf $(BUILDDIR)
|
||||
|
||||
# Defining CLEAN_INCLUDE_TEST turns on this snippet which will cause an
|
||||
# error on 'make clean' if any directory mentioned in GLOBAL_INCLUDES does not exist
|
||||
ifneq ($(CLEAN_INCLUDE_TEST),)
|
||||
clean-include-test: $(filter-out $(BUILDDIR)/include,$(patsubst -I%,%,$(GLOBAL_INCLUDES)))
|
||||
clean: clean-include-test
|
||||
endif
|
||||
|
||||
# Empty rule for .d files
|
||||
%.d:
|
||||
%.Td:
|
||||
|
||||
ifeq ($(filter $(MAKECMDGOALS), clean), )
|
||||
-include $(ALL_DEPS)
|
||||
endif
|
||||
|
||||
# !ABORT
|
||||
endif
|
||||
@@ -0,0 +1,97 @@
|
||||
# Copyright (C) 2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# XXX update this
|
||||
# Makefile to build a unit test binary
|
||||
#
|
||||
# We expect the following to be set:
|
||||
#
|
||||
# TEST_MAKEFILE
|
||||
# XXX update this
|
||||
#
|
||||
|
||||
# Read the test makefile after reinitializing all variables the test might test
|
||||
#
|
||||
|
||||
include makefiles/macros.mk
|
||||
include makefiles/config.mk
|
||||
|
||||
TEST_OBJS :=
|
||||
|
||||
TEST_SUPPORT_OBJS :=
|
||||
|
||||
EXTRA_TEST_PRODUCTS :=
|
||||
|
||||
# TESTDIR is the directory inside TESTSDIR that houses this test's
|
||||
# object files and binaries. We need a unique tree per test because
|
||||
# some source files may be compiled multiple times with different options
|
||||
TESTDIR = $(TESTSDIR)/$(TEST_NAME)
|
||||
|
||||
include $(TEST_MAKEFILE)
|
||||
|
||||
TESTBIN := $(call TOTESTDIR,$(TEST_NAME))
|
||||
|
||||
COMMON_CFLAGS := -DWITH_HOST_LIBC=1 -DENABLE_RELEASE_ASSERTS=1 -funsigned-char -fno-strict-aliasing -g -Oz
|
||||
COMMON_CFLAGS += -fstack-protector-all
|
||||
COMMON_INCLUDES := $(SRCROOT)/include usr $(SRCROOT)/tests/include $(OBJROOT)/build/include
|
||||
|
||||
# XXX: should fix up tests so that this isn't needed
|
||||
CWARNFLAGS += -Wno-missing-field-initializers
|
||||
|
||||
ifeq ($(BUILD_OS),linux)
|
||||
# iBoot assumes some BSDisms are available from the libc, but
|
||||
# this isn't the case when building with Linux's libc, including
|
||||
# the required prototypes in every .c file is somewhat of a dirty
|
||||
# hack, but it gets the job done
|
||||
COMMON_CFLAGS += -include $(SRCROOT)/tests/include/non-posix.h
|
||||
TEST_SUPPORT_OBJS += tests/non-posix.o
|
||||
endif
|
||||
|
||||
ifeq ($(COVERAGE),YES)
|
||||
COVERAGE_CFLAGS := -ftest-coverage -fprofile-arcs
|
||||
COMMON_LDFLAGS += -ftest-coverage -fprofile-arcs
|
||||
endif
|
||||
|
||||
_CFLAGS := $(COMMON_CFLAGS) $(CWARNFLAGS) $(SANITIZE_CFLAGS) $(TEST_CFLAGS) -DHOST_TEST=1
|
||||
_INCLUDES := $(addprefix -I,$(TEST_INCLUDES)) $(addprefix -I,$(COMMON_INCLUDES))
|
||||
_LDFLAGS := $(COMMON_LDFLAGS) $(SANITIZE_LDFLAGS) $(TEST_LDFLAGS)
|
||||
ifeq ($(BUILD_OS),darwin)
|
||||
_LDFLAGS += -Wl,-no_pie
|
||||
endif
|
||||
|
||||
BUILT_OBJS := $(call TOTESTDIR,$(TEST_OBJS) $(TEST_SUPPORT_OBJS))
|
||||
ALL_DEPS += $(BUILT_OBJS:%.o=%.d)
|
||||
|
||||
GLOBAL_SRCDEPS += $(MAKEFILE_LIST)
|
||||
|
||||
# rule to build object files, omitting coverage info for files listed in TEST_SUPPORT_OBJS
|
||||
$(TESTDIR)/%.o: _cflags = $(_CFLAGS) $(and $(filter-out $(addprefix %,$(TEST_SUPPORT_OBJS)),$@),$(COVERAGE_CFLAGS))
|
||||
$(TESTDIR)/%.o: gcda = $(@:%.o=%.gcda)
|
||||
$(TESTDIR)/%.o: $(SRCROOT)/%.c $(GLOBAL_SRCDEPS)
|
||||
@echo HOST_CC $@
|
||||
@$(MKDIR)
|
||||
@[ ! -f "$(gcda)" ] || rm "$(gcda)" # remove test coverage data files
|
||||
$(_v)${HOST_CC} -c -o $@ $(_cflags) $(DEBUG_FILE_HASH) $(_INCLUDES) -MD -MT $@ -MF $(@:%o=%d) $<
|
||||
|
||||
$(TESTBIN): $(BUILT_OBJS) $(GLOBAL_SRCDEPS)
|
||||
@echo HOST_LD $@
|
||||
$(_v)$(HOST_CC) $(_LDFLAGS) -o $@ $(BUILT_OBJS)
|
||||
|
||||
BUILD_PREREQS += $(TESTBIN) $(EXTRA_TEST_PRODUCTS)
|
||||
|
||||
build: $(BUILD_PREREQS)
|
||||
|
||||
ifeq ($(filter $(MAKECMDGOALS), clean), )
|
||||
-include $(ALL_DEPS)
|
||||
endif
|
||||
# Empty rule for .d files
|
||||
%.d:
|
||||
%.Td:
|
||||
@@ -0,0 +1,129 @@
|
||||
# Copyright (C) 2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Makefile to build unit tests
|
||||
#
|
||||
# Currently this only handles unit tests compiled for Mac OS/x86, but
|
||||
# it should be possible to extend this to also compile for arm and run
|
||||
# on targets (either in iOS or on bare metal)
|
||||
#
|
||||
# To add a test, add its makefile for TEST_MAKEFILES below. Each makefile
|
||||
# describes a single binary, and must define the following:
|
||||
# TEST_NAME - The name of the test, will be used to name the binary
|
||||
# TEST_OBJS - The object files that go into the test
|
||||
#
|
||||
# Makefiles may optionally define the following:
|
||||
# TEST_INCLUDES - List of directories with include files for the test
|
||||
# TEST_CFLAGS - Flags to pass to the compiler for the test
|
||||
# TEST_SUPPORT_OBJS - Object files that go into the test without coverage info
|
||||
|
||||
TEST_MAKEFILES := tests/unittest-tests.mk \
|
||||
drivers/sha1/tests.mk \
|
||||
lib/blockdev/tests.mk \
|
||||
lib/cksum/tests.mk \
|
||||
lib/devicetree/tests.mk \
|
||||
lib/env/tests.mk \
|
||||
lib/fs/apfs/tests-fuzz.mk \
|
||||
lib/fs/hfs/tests.mk \
|
||||
lib/fs/hfs/tests-fuzz.mk \
|
||||
lib/heap/tests.mk \
|
||||
lib/heap/tests-debugging.mk \
|
||||
lib/libc/tests.mk \
|
||||
lib/libc/tests-release.mk \
|
||||
lib/lzss/tests.mk \
|
||||
lib/nvram/tests.mk \
|
||||
lib/paint/tests.mk \
|
||||
lib/syscfg/tests.mk \
|
||||
drivers/sha1/tests.mk \
|
||||
sys/tests.mk
|
||||
|
||||
# arch/arm64/tests-mmu.mk \
|
||||
|
||||
BUILD_ONLY_TEST_MAKEFILES := \
|
||||
lib/devicetree/tests-fuzz.mk \
|
||||
lib/nvram/tests-fuzz.mk \
|
||||
lib/ticket/tests-fuzz.mk
|
||||
|
||||
#
|
||||
# Gory details follow
|
||||
#
|
||||
|
||||
include makefiles/macros.mk
|
||||
|
||||
ALL_TEST_MAKEFILES := $(TEST_MAKEFILES) $(BUILD_ONLY_TEST_MAKEFILES)
|
||||
|
||||
ACTIONS := $(addprefix build~,$(ALL_TEST_MAKEFILES))
|
||||
|
||||
TESTS_FLAVOR ?= tests-$(BUILD_OS)
|
||||
ifeq ($(COVERAGE),YES)
|
||||
TESTS_FLAVOR := $(TESTS_FLAVOR)-coverage
|
||||
endif
|
||||
ifeq ($(SANITIZE),YES)
|
||||
TESTS_FLAVOR := $(TESTS_FLAVOR)-sanitize
|
||||
endif
|
||||
|
||||
export TESTSDIR := $(OBJROOT)/build/$(TESTS_FLAVOR)
|
||||
RUN_SH := $(TESTSDIR)/run.sh
|
||||
|
||||
$(ACTIONS): $(ALL_TEST_MAKEFILES) $(MAKEFILE_LIST)
|
||||
$(ACTIONS): spec = $(subst ~, ,$@)
|
||||
$(ACTIONS): action = $(word 1,$(spec))
|
||||
$(ACTIONS): TEST_MAKEFILE = $(word 2,$(spec))
|
||||
$(ACTIONS):
|
||||
@echo %%%% Building tests $(TEST_MAKEFILE)
|
||||
@$(MAKE) -f makefiles/test.mk \
|
||||
TEST_MAKEFILE="$(TEST_MAKEFILE)"
|
||||
|
||||
RUN_TESTBINS :=
|
||||
BUILD_TESTBINS :=
|
||||
|
||||
define template
|
||||
include $$(TEST_MAKEFILE)
|
||||
TESTBIN := $$(TESTSDIR)/$$(TEST_NAME)/$$(TEST_NAME)
|
||||
|
||||
ifeq ($$(filter $$(TEST_MAKEFILE),$$(BUILD_ONLY_TEST_MAKEFILES)),)
|
||||
RUN_TESTBINS += $$(TESTBIN)
|
||||
else
|
||||
BUILD_TESTBINS += $$(TESTBIN)
|
||||
endif
|
||||
|
||||
$$(TESTBIN): build~$$(TEST_MAKEFILE)
|
||||
endef
|
||||
|
||||
$(foreach TEST_MAKEFILE,$(ALL_TEST_MAKEFILES),$(eval $(template)))
|
||||
|
||||
$(RUN_SH): $(RUN_TESTBINS) $(MAKEFILE_LIST)
|
||||
@$(MKDIR)
|
||||
$(_v)echo '#!/bin/bash' > $@
|
||||
$(_v)echo 'result=0' >> $@
|
||||
$(_v)for i in $(RUN_TESTBINS); do \
|
||||
echo "echo 'TEST $$i'" >> $@; \
|
||||
echo "(cd $$(dirname $$i); ./$$(basename $$i)); test_result=\$$?" >> $@; \
|
||||
echo "[[ \$$test_result == 0 ]] || echo '!!! Test Failed:' $$i" >> $@; \
|
||||
echo "result=\$$((\$$result || \$$test_result))" >> $@; \
|
||||
echo >> $@; \
|
||||
done
|
||||
$(_v)echo 'exit $$result' >> $@
|
||||
$(_v)chmod a+x $@
|
||||
|
||||
.PHONY: build
|
||||
build: $(RUN_SH) $(BUILD_TESTBINS)
|
||||
|
||||
run: build
|
||||
@echo
|
||||
@echo %%%% Running tests
|
||||
@echo
|
||||
@$(RUN_SH)
|
||||
ifeq ($(COVERAGE),YES)
|
||||
@mkdir -p $(SYMROOT)/build/coverage
|
||||
@echo COVERAGE
|
||||
$(_v)./tools/gcovr -b -r $(OBJROOT) --html -o $(SYMROOT)/build/coverage/index.html --html-details
|
||||
endif
|
||||
@@ -0,0 +1,97 @@
|
||||
# -*- make -*-
|
||||
# Copyright (C) 2007-2014 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Tools used by makefiles.
|
||||
#
|
||||
# We look these up just once and cache their paths accordingly.
|
||||
# This is less important for things that we expect to always exist, but for
|
||||
# optional tools, xcrun does no negative caching.
|
||||
#
|
||||
|
||||
export CP := /bin/cp
|
||||
export AWK := /usr/bin/awk
|
||||
|
||||
# Project local scripts.
|
||||
export CHECK_LIBLIST := tools/check_liblist.py
|
||||
|
||||
# Note that it's not safe to look up any of the toolchain pieces
|
||||
# for the 'installsrc' and 'clean' targets, as they can be invoked by the
|
||||
# project submission process on a system with no tools installed.
|
||||
|
||||
ifeq ($(filter clean installsrc,$(MAKECMDGOALS)),)
|
||||
|
||||
ifeq ($(BUILD_OS),darwin)
|
||||
# xcrun only makes sense when building on OS X, but even there we
|
||||
# may sometimes want to use a non-xcode SDK compiler
|
||||
USE_XCRUN ?= YES
|
||||
USE_XCRUN_HOST ?= $(USE_XCRUN)
|
||||
endif
|
||||
|
||||
ifeq ($(USE_XCRUN),YES)
|
||||
|
||||
$(info %%%% locating platform tools with xcrun)
|
||||
|
||||
export CC := $(shell xcrun -sdk $(SDKROOT) -find clang)
|
||||
export CPP := $(shell xcrun -sdk $(SDKROOT) -find c++)
|
||||
export SIZE := $(shell xcrun -sdk $(SDKROOT) -find size)
|
||||
export STRIP := $(shell xcrun -sdk $(SDKROOT) -find strip)
|
||||
export IMAGE3MAKER := $(shell xcrun -sdk $(SDKROOT) -find image3maker)
|
||||
export IMG4PAYLOAD := $(shell xcrun -sdk $(SDKROOT) -find img4payload)
|
||||
export AR := $(shell xcrun -sdk $(SDKROOT) -find ar)
|
||||
export NM := $(shell xcrun -sdk $(SDKROOT) -find nm)
|
||||
export RANLIB := $(shell xcrun -sdk $(SDKROOT) -find ranlib)
|
||||
export DSYMUTIL := $(shell xcrun -sdk $(SDKROOT) -find dsymutil)
|
||||
export DEVICEMAP := $(shell xcrun -sdk $(SDKROOT) -find embedded_device_map)
|
||||
export OTOOL := $(shell xcrun -sdk $(SDKROOT) -find otool)
|
||||
export ANALYZER := $(CC)
|
||||
export ANALYZERPP := $(CPP)
|
||||
|
||||
# XXX WTF is this?
|
||||
# this may not exist, so we have to resolve it here
|
||||
export AES_SYNCH_FIXUP := $(shell xcrun -sdk $(SDKROOT) -find aes-synch-fixup.sh 2>/dev/null || echo /notfound)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(USE_XCRUN_HOST),YES)
|
||||
export HOST_AR := $(shell xcrun -sdk $(HOST_SDKROOT) -find ar)
|
||||
export HOST_CC := $(shell xcrun -sdk $(HOST_SDKROOT) -find clang) -isysroot $(HOST_SDKROOT)
|
||||
export HOST_CPP := $(shell xcrun -sdk $(HOST_SDKROOT) -find clang++) -isysroot $(HOST_SDKROOT)
|
||||
#export HOST_CC := /Users/jfortier/src/PR-afl/afl-0.87b/afl-clang -isysroot $(HOST_SDKROOT)
|
||||
else
|
||||
export HOST_AR ?= ar
|
||||
export HOST_CC ?= clang
|
||||
export HOST_CPP ?= clang++
|
||||
endif
|
||||
|
||||
# Log the paths to all of the tools that we have located, so that there is no
|
||||
# room for doubt about what we're invoking.
|
||||
|
||||
$(info CP $(CP))
|
||||
$(info AWK $(AWK))
|
||||
$(info CC $(CC))
|
||||
$(info CPP $(CPP))
|
||||
$(info SIZE $(SIZE))
|
||||
$(info STRIP $(STRIP))
|
||||
$(info IMAGE3MAKER $(IMAGE3MAKER))
|
||||
$(info IMG4PAYLOAD $(IMG4PAYLOAD))
|
||||
$(info AR $(AR))
|
||||
$(info NM $(NM))
|
||||
$(info RANLIB $(RANLIB))
|
||||
$(info DSYMUTIL $(DSYMUTIL))
|
||||
$(info DEVICEMAP $(DEVICEMAP))
|
||||
$(info OTOOL $(OTOOL))
|
||||
$(info HOST_AR $(HOST_AR))
|
||||
$(info HOST_CC $(HOST_CC))
|
||||
$(info HOST_CPP $(HOST_CPP))
|
||||
|
||||
endif
|
||||
Reference in new issue
Block a user