| # | |
| # Copyright (c) 2010-2011 Nest, Inc. | |
| # All rights reserved. | |
| # | |
| # This document is the property of Nest Labs. It is considered | |
| # confidential and proprietary information. | |
| # | |
| # This document may not be reproduced or transmitted in any form, | |
| # in whole or in part, without the express written permission of | |
| # Nest Labs. | |
| # | |
| # Description: | |
| # This file is the makefile for the Universal Bootloader, u-boot. | |
| # | |
| EnableParallel = Yes | |
| include pre.mak | |
| PackageRoot := . | |
| PackageSeparator := | |
| PackageVersion := | |
| PackageSourceDir := $(PackageRoot)/$(UBootPackageName)$(PackageSeparator)$(PackageVersion) | |
| PackageBuildMakefile = $(call GenerateBuildPaths,include/config.mk) | |
| CleanPaths += $(PackageLicenseFile) | |
| # | |
| # Build and result paths for staging targets | |
| # | |
| UBootResultBinDir := $(call GenerateResultPaths,,bin) | |
| UBootResultSbinDir := $(call GenerateResultPaths,,sbin) | |
| UBootPrintEnvBuildPath := $(call GenerateBuildPaths,tools/env/fw_printenv) | |
| UBootPrintEnvResultPath := $(call GenerateResultPaths,,sbin/fw_printenv) | |
| UBootSetEnvResultPath := $(call GenerateResultPaths,,sbin/fw_setenv) | |
| UBootMkimageBuildPath := $(call GenerateBuildPaths,tools/mkimage) | |
| UBootMkimageResultPath := $(call GenerateResultPaths,,bin/mkimage) | |
| NestBuildDefines := NEST_BUILD_CONFIG_$(call ToUpper,$(BuildConfig)) NEST_BUILD_CONFIG=\\\"$(BuildConfig)\\\" | |
| NestBuildDefineFlags := $(call ToolGenerateDefineArgument,$(NestBuildDefines)) | |
| all: $(PackageDefaultGoal) | |
| # Generate the package license contents. | |
| $(PackageSourceDir)/COPYING: source | |
| $(PackageLicenseFile): $(PackageSourceDir)/COPYING | |
| $(copy-result) | |
| # We are building this package from version-controller source, so | |
| # there is nothing to do for this target goal. | |
| $(PackageSourceDir): | |
| # Prepare the sources. | |
| .PHONY: source | |
| source: | $(PackageSourceDir) | |
| # Patch the sources, if necessary. | |
| .PHONY: patch | |
| patch: source | |
| # U-Boot has no way of explicitly setting CC, LD, OBJCOPY, et al and | |
| # instead relies on the value of CROSS_COMPILE. Consequently, we have | |
| # to ensure that 'ToolBinDir' is in 'PATH' so that the kernel build | |
| # infrastructure can find $(CROSS_COMPILE)gcc, $(CROSS_COMPILE)ld, et | |
| # al. | |
| configure build build-uboot build-tools stage: PATH := $(PATH):$(ToolBinDir) | |
| configure build build-uboot build-tools stage: CROSS_COMPILE := $(CCACHE) $(CROSS_COMPILE) | |
| # Generate the package build makefile. | |
| $(PackageBuildMakefile): | $(PackageSourceDir) $(BuildDirectory) | |
| $(Verbose)unset MAKEFLAGS && \ | |
| $(MAKE) $(JOBSFLAG) -C $(PackageSourceDir) \ | |
| INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ | |
| O=$(CURDIR)/$(BuildDirectory) \ | |
| $(UBootDefaultConfig) | |
| # Configure the source for building. | |
| .PHONY: configure | |
| configure: source $(PackageBuildMakefile) | |
| # Build the source. | |
| .PHONY: build build-uboot build-tools | |
| build: build-uboot build-tools | |
| build-uboot: configure | |
| $(Verbose)unset MAKEFLAGS && \ | |
| $(MAKE) $(JOBSFLAG) -C $(PackageSourceDir) \ | |
| INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ | |
| O=$(CURDIR)/$(BuildDirectory) \ | |
| NestBuildDefineFlags="$(NestBuildDefineFlags)" \ | |
| all | |
| build-tools: configure build-uboot | |
| $(Verbose)unset MAKEFLAGS && \ | |
| $(MAKE) $(JOBSFLAG) -C $(PackageSourceDir) \ | |
| INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ | |
| O=$(CURDIR)/$(BuildDirectory) \ | |
| HOSTCC="$(CC)" \ | |
| HOSTSTRIP=$(STRIP) \ | |
| TOOLSUBDIRS=env \ | |
| NestBuildDefineFlags="$(NestBuildDefineFlags)" \ | |
| tools | |
| # Stage the build to a temporary installation area. | |
| # | |
| # U-Boot does not support a notion of installing, so we have to | |
| # cherry-pick the components we want from the build directory and | |
| # copy/install them to the results directory. | |
| .PHONY: stage stage-target stage-target-tools stage-host-tools | |
| stage: stage-target stage-target-tools stage-host-tools | |
| stage-target: build | $(ResultDirectory) | |
| $(Verbose)cp -f $(wildcard $(call GenerateBuildPaths,u-boot*)) $(ResultDirectory) | |
| $(Verbose)cp -f $(call GenerateBuildPaths,System.map) $(ResultDirectory) | |
| # | |
| # Targets and commands for staging target (i.e cross-compiled) tools. | |
| # | |
| $(UBootResultSbinDir): | $(ResultDirectory) | |
| $(create-directory) | |
| $(UBootPrintEnvBuildPath): build | |
| $(UBootPrintEnvResultPath): $(UBootPrintEnvBuildPath) | $(UBootResultSbinDir) | |
| $(copy-result) | |
| $(UBootSetEnvResultPath): | |
| $(Echo) "Creating \"$(call GenerateBuildRootEllipsedPath,$@)\"" | |
| $(Verbose)ln -sf fw_printenv "$(@)" | |
| stage-target-tools: $(UBootPrintEnvResultPath) $(UBootSetEnvResultPath) | |
| # | |
| # Targets and commands for staging host (i.e. natively-compiled) tools | |
| # that may be used elsewhere in the build. | |
| # | |
| $(UBootResultBinDir): | $(ResultDirectory) | |
| $(create-directory) | |
| $(UBootMkimageBuildPath): build | |
| $(UBootMkimageResultPath): $(UBootMkimageBuildPath) | $(UBootResultBinDir) | |
| $(copy-result) | |
| stage-host-tools: $(UBootMkimageResultPath) | |
| clean: | |
| $(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory) | |
| $(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory) | |
| include post.mak |