1# Copyright 2016 The Fuchsia Authors 2# Copyright (c) 2008-2015 Travis Geiselbrecht 3# 4# Use of this source code is governed by a MIT-style 5# license that can be found in the LICENSE file or at 6# https://opensource.org/licenses/MIT 7 8LOCAL_MAKEFILE:=$(MAKEFILE_LIST) 9 10# include settings for prebuilts that are auto-updated by checkout scripts 11-include prebuilt/config.mk 12 13# try to include a file in the local dir to let the user semi-permanently set options 14-include local.mk 15include make/macros.mk 16 17# various command line and environment arguments 18# default them to something so when they're referenced in the make instance they're not undefined 19BUILDROOT ?= . 20DEBUG ?= 2 21DEBUG_HARD ?= false 22ENABLE_BUILD_LISTFILES ?= false 23ENABLE_BUILD_SYSROOT ?= false 24ENABLE_BUILD_LISTFILES := $(call TOBOOL,$(ENABLE_BUILD_LISTFILES)) 25ENABLE_BUILD_SYSROOT := $(call TOBOOL,$(ENABLE_BUILD_SYSROOT)) 26ENABLE_INSTALL_SAMPLES ?= false 27ENABLE_NEW_BOOTDATA := true 28ENABLE_LOCK_DEP ?= false 29ENABLE_LOCK_DEP_TESTS ?= $(ENABLE_LOCK_DEP) 30DISABLE_UTEST ?= false 31ENABLE_ULIB_ONLY ?= false 32ENABLE_DRIVER_TRACING ?= true 33ENABLE_DRIVER_TRACING := $(call TOBOOL,$(ENABLE_DRIVER_TRACING)) 34USE_ASAN ?= false 35USE_SANCOV ?= false 36USE_PROFILE ?= false 37USE_LTO ?= false 38USE_THINLTO ?= $(USE_LTO) 39USE_CLANG ?= $(firstword $(filter true,$(call TOBOOL,$(USE_ASAN)) \ 40 $(call TOBOOL,$(USE_SANCOV)) \ 41 $(call TOBOOL,$(USE_PROFILE)) \ 42 $(call TOBOOL,$(USE_LTO))) \ 43 false) 44USE_LLD ?= $(USE_CLANG) 45ifeq ($(call TOBOOL,$(USE_LLD)),true) 46USE_GOLD := false 47else 48USE_GOLD ?= true 49endif 50THINLTO_CACHE_DIR ?= $(BUILDDIR)/thinlto-cache 51CLANG_TARGET_FUCHSIA ?= false 52USER_USE_LINKER_GC ?= true 53KERNEL_USE_LINKER_GC ?= true 54HOST_USE_ASAN ?= false 55 56ifeq ($(call TOBOOL,$(ENABLE_ULIB_ONLY)),true) 57ENABLE_BUILD_SYSROOT := false 58ifeq (,$(strip $(TOOLS))) 59$(error ENABLE_ULIB_ONLY=true requires TOOLS=build-.../tools on command line) 60endif 61endif 62 63# If no build directory suffix has been explicitly supplied by the environment, 64# generate a default based on build options. Start with no suffix, then add 65# "-clang" if we are building with clang, and "-release" if we are building with 66# DEBUG=0 67ifeq ($(origin BUILDDIR_SUFFIX),undefined) 68BUILDDIR_SUFFIX := 69 70ifeq ($(call TOBOOL,$(USE_ASAN)),true) 71BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-asan 72else ifeq ($(call TOBOOL,$(USE_PROFILE)),true) 73BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-profile 74else ifeq ($(call TOBOOL,$(USE_LTO)),true) 75ifeq ($(call TOBOOL,$(USE_THINLTO)),true) 76BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-thinlto 77else 78BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-lto 79endif 80else ifeq ($(call TOBOOL,$(USE_CLANG)),true) 81BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-clang 82endif 83 84ifeq ($(call TOBOOL,$(DEBUG)),false) 85BUILDDIR_SUFFIX := $(BUILDDIR_SUFFIX)-release 86endif 87 88endif # if BUILDDIR_SUFFIX is empty 89 90# special rule for handling make spotless 91ifeq ($(MAKECMDGOALS),spotless) 92spotless: 93 rm -rf -- "$(BUILDROOT)"/build-* 94else 95 96# If one of our goals (from the commandline) happens to have a 97# matching project/goal.mk, then we should re-invoke make with 98# that project name specified... 99 100project-name := $(firstword $(MAKECMDGOALS)) 101 102ifneq ($(project-name),) 103ifneq ($(strip $(wildcard kernel/project/$(project-name).mk \ 104 kernel/project/alias/$(project-name).mk)),) 105do-nothing := 1 106$(MAKECMDGOALS) _all: make-make 107make-make: 108 @PROJECT=$(project-name) $(MAKE) -rR -f $(LOCAL_MAKEFILE) $(filter-out $(project-name), $(MAKECMDGOALS)) 109 110.PHONY: make-make 111endif 112endif 113 114# some additional rules to print some help 115include make/help.mk 116 117ifeq ($(do-nothing),) 118 119ifeq ($(PROJECT),) 120 121ifneq ($(DEFAULT_PROJECT),) 122PROJECT := $(DEFAULT_PROJECT) 123else 124$(error No project specified. Use 'make list' for a list of projects or 'make help' for additional help) 125endif 126endif 127 128# DEBUG_HARD enables limited optimizations and full debug symbols for use with gdb/lldb 129ifeq ($(call TOBOOL,$(DEBUG_HARD)),true) 130GLOBAL_DEBUGFLAGS := -O0 -g3 131endif 132GLOBAL_DEBUGFLAGS ?= -O2 -g 133 134BUILDDIR := $(BUILDROOT)/build-$(PROJECT)$(BUILDDIR_SUFFIX) 135GENERATED_INCLUDES:=$(BUILDDIR)/gen/global/include 136ZIRCON_BOOTIMAGE := $(BUILDDIR)/zircon.zbi 137KERNEL_ZBI := $(BUILDDIR)/kernel.zbi 138KERNEL_ELF := $(BUILDDIR)/zircon.elf 139KERNEL_IMAGE := $(BUILDDIR)/kernel-image.elf 140GLOBAL_CONFIG_HEADER := $(BUILDDIR)/config-global.h 141KERNEL_CONFIG_HEADER := $(BUILDDIR)/config-kernel.h 142USER_CONFIG_HEADER := $(BUILDDIR)/config-user.h 143HOST_CONFIG_HEADER := $(BUILDDIR)/config-host.h 144GLOBAL_INCLUDES := system/public system/private $(GENERATED_INCLUDES) 145GLOBAL_OPTFLAGS ?= $(ARCH_OPTFLAGS) 146# When embedding source file locations in debugging information, by default 147# the compiler will record the absolute path of the current directory and 148# make everything relative to that. Instead, we tell the compiler to map 149# the current directory to $(DEBUG_BUILDROOT), which is the "relative" 150# location of the zircon source tree (i.e. usually . in a standalone build). 151DEBUG_BUILDROOT ?= $(BUILDROOT) 152GLOBAL_COMPILEFLAGS := $(GLOBAL_DEBUGFLAGS) 153GLOBAL_COMPILEFLAGS += -fdebug-prefix-map=$(shell pwd)=$(DEBUG_BUILDROOT) 154GLOBAL_COMPILEFLAGS += -finline -include $(GLOBAL_CONFIG_HEADER) 155GLOBAL_COMPILEFLAGS += -Wall -Wextra -Wno-multichar -Werror -Wno-error=deprecated-declarations 156GLOBAL_COMPILEFLAGS += -Wno-unused-parameter -Wno-unused-function -Werror=unused-label -Werror=return-type 157GLOBAL_COMPILEFLAGS += -fno-common 158# kernel/include/lib/counters.h and kernel.ld depend on -fdata-sections. 159GLOBAL_COMPILEFLAGS += -ffunction-sections -fdata-sections 160ifeq ($(call TOBOOL,$(USE_CLANG)),true) 161GLOBAL_COMPILEFLAGS += -no-canonical-prefixes 162GLOBAL_COMPILEFLAGS += -Wno-address-of-packed-member 163GLOBAL_COMPILEFLAGS += -Wthread-safety 164GLOBAL_COMPILEFLAGS += -Wimplicit-fallthrough 165else 166GLOBAL_COMPILEFLAGS += -Wno-nonnull-compare 167# TODO(mcgrathr): New warning in GCC 7 biting a lot of code; figure it out. 168GLOBAL_COMPILEFLAGS += -Wno-format-truncation 169endif 170GLOBAL_CFLAGS := -std=c11 -Werror-implicit-function-declaration -Wstrict-prototypes -Wwrite-strings 171GLOBAL_CPPFLAGS := -std=c++17 -fno-exceptions -fno-rtti -fno-threadsafe-statics -Wconversion -Wno-sign-conversion 172#GLOBAL_CPPFLAGS += -Weffc++ 173GLOBAL_ASMFLAGS := 174GLOBAL_LDFLAGS := -nostdlib --build-id -z noexecstack 175ifeq ($(call TOBOOL,$(USE_LLD)),true) 176GLOBAL_LDFLAGS += --pack-dyn-relocs=relr 177GLOBAL_LDFLAGS += -color-diagnostics 178endif 179# $(addprefix -L,$(LKINC)) XXX 180GLOBAL_MODULE_LDFLAGS := 181 182# By default the sysroot is generated in "sysroot" under 183# the build directory, but this is overrideable 184ifeq ($(BUILDSYSROOT),) 185BUILDSYSROOT := $(BUILDDIR)/sysroot 186else 187# be noisy if we are 188$(info BUILDSYSROOT = $(BUILDSYSROOT)) 189endif 190 191# Kernel compile flags 192KERNEL_INCLUDES := $(BUILDDIR) kernel/include 193KERNEL_COMPILEFLAGS := -ffreestanding -include $(KERNEL_CONFIG_HEADER) 194KERNEL_COMPILEFLAGS += -Wformat=2 -Wvla 195# GCC supports "-Wformat-signedness" but Clang currently does not. 196ifeq ($(call TOBOOL,$(USE_CLANG)),false) 197KERNEL_COMPILEFLAGS += -Wformat-signedness 198endif 199KERNEL_CFLAGS := -Wmissing-prototypes 200KERNEL_CPPFLAGS := 201KERNEL_ASMFLAGS := 202KERNEL_LDFLAGS := 203 204# Build flags for modules that want frame pointers. 205# ngunwind, backtrace use this so that the simplisitic unwinder will work with 206# them. These are recorded here so that modules don't need knowledge of the 207# details. They just need to do: 208# MODULE_COMPILEFLAGS += $(KEEP_FRAME_POINTER_COMPILEFLAGS) 209KEEP_FRAME_POINTER_COMPILEFLAGS := -fno-omit-frame-pointer 210 211# User space compile flags 212USER_COMPILEFLAGS := -include $(USER_CONFIG_HEADER) -fPIC -D_ALL_SOURCE=1 213USER_CFLAGS := 214USER_CPPFLAGS := 215USER_ASMFLAGS := 216 217# Allow driver tracing to be completely disabled (as if it didn't exist). 218ifeq ($(call TOBOOL,$(ENABLE_DRIVER_TRACING)),true) 219USER_COMPILEFLAGS += -DENABLE_DRIVER_TRACING=1 220endif 221 222# Additional flags for dynamic linking, both for dynamically-linked 223# executables and for shared libraries. 224USER_LDFLAGS := \ 225 -z combreloc -z relro -z now -z text \ 226 --hash-style=gnu --eh-frame-hdr 227 228ifeq ($(call TOBOOL,$(USE_LLD)),true) 229USER_LDFLAGS += -z rodynamic 230RODSO_LDFLAGS := 231else 232RODSO_LDFLAGS := -T scripts/rodso.ld 233endif 234 235# Use linker garbage collection if enabled. 236ifeq ($(call TOBOOL,$(KERNEL_USE_LINKER_GC)),true) 237KERNEL_LDFLAGS += --gc-sections 238endif 239ifeq ($(call TOBOOL,$(USER_USE_LINKER_GC)),true) 240USER_LDFLAGS += --gc-sections 241endif 242 243# Turn on -fasynchronous-unwind-tables to get .eh_frame. 244# This is necessary for unwinding through optimized code. 245# The unwind information is part of the loaded binary. It's not that much space 246# and it allows for unwinding of stripped binaries, pc -> source translation 247# can be done offline with, e.g., scripts/symbolize. 248USER_COMPILEFLAGS += -fasynchronous-unwind-tables 249 250# TODO(ZX-2361): Remove frame pointers when libunwind and our tooling agree on 251# unwind tables. Until then compile with frame pointers in debug builds to get 252# high-quality backtraces. 253ifeq ($(call TOBOOL,$(DEBUG)),true) 254USER_COMPILEFLAGS += $(KEEP_FRAME_POINTER_COMPILEFLAGS) 255endif 256 257# We want .debug_frame for the kernel. ZX-62 258# And we still want asynchronous unwind tables. Alas there's (currently) no way 259# to achieve this with our GCC. At the moment we compile with 260# -fno-omit-frame-pointer which is good because we link with -gc-sections which 261# means .eh_frame gets discarded so GCC-built kernels don't have any unwind 262# info (except for assembly - heh)! 263# Assembler code has its own way of requesting .debug_frame vs .eh_frame with 264# the .cfi_sections directive. Sigh. 265KERNEL_COMPILEFLAGS += -fno-exceptions -fno-unwind-tables 266 267ifeq ($(call TOBOOL,$(USE_CLANG)),true) 268NO_SAFESTACK := -fno-sanitize=safe-stack -fno-stack-protector 269NO_SANITIZERS := -fno-sanitize=all -fno-stack-protector 270else 271NO_SAFESTACK := 272NO_SANITIZERS := 273endif 274 275USER_SCRT1_OBJ := $(BUILDDIR)/system/ulib/Scrt1.o 276 277# Additional flags for building shared libraries (ld -shared). 278USERLIB_SO_LDFLAGS := $(USER_LDFLAGS) -z defs 279 280# This is the string embedded into dynamically-linked executables 281# as PT_INTERP. The launchpad library looks this up via the 282# "loader service", so it should be a simple name rather than an 283# absolute pathname as is used for this on other systems. 284USER_SHARED_INTERP := ld.so.1 285 286# Programs built with ASan use the ASan-supporting dynamic linker. 287ifeq ($(call TOBOOL,$(USE_ASAN)),true) 288USER_SHARED_INTERP := asan/$(USER_SHARED_INTERP) 289endif 290 291# Additional flags for building dynamically-linked executables. 292USERAPP_LDFLAGS := \ 293 $(USER_LDFLAGS) -pie -dynamic-linker $(USER_SHARED_INTERP) 294 295ifeq ($(call TOBOOL,$(USE_GOLD)),false) 296# BFD ld stupidly insists on resolving dependency DSO's symbols when 297# doing a -shared -z defs link. To do this it needs to find 298# dependencies' dependencies, which requires -rpath-link. Gold does 299# not have this misfeature. Since ulib/musl needs ulib/zircon and 300# everything needs ulib/musl, this covers the actual needs in the 301# build today without resorting to resolving inter-module dependencies 302# to generate -rpath-link in a general fashion. Eventually we should 303# always use gold or lld for all the user-mode links, and then we'll 304# never need this. 305USERAPP_LDFLAGS += -rpath-link $(BUILDDIR)/ulib/zircon 306endif 307 308# Architecture specific compile flags 309ARCH_COMPILEFLAGS := 310ARCH_CFLAGS := 311ARCH_CPPFLAGS := 312ARCH_ASMFLAGS := 313 314# top level rule 315all:: 316 317# master module object list 318ALLOBJS_MODULE := 319 320# all module objects for the target (does not include hostapp) 321ALL_TARGET_OBJS := 322 323# master object list (for dep generation) 324ALLOBJS := 325 326# master source file list 327ALLSRCS := 328 329# master list of packages for export 330ALLPKGS := 331 332# anything you add here will be deleted in make clean 333GENERATED := 334 335# anything added to GLOBAL_DEFINES will be put into $(BUILDDIR)/config-global.h 336GLOBAL_DEFINES := 337 338# anything added to KERNEL_DEFINES will be put into $(BUILDDIR)/config-kernel.h 339KERNEL_DEFINES := LK=1 _KERNEL=1 ZIRCON_TOOLCHAIN=1 340 341# anything added to USER_DEFINES will be put into $(BUILDDIR)/config-user.h 342USER_DEFINES := ZIRCON_TOOLCHAIN=1 343 344# anything added to HOST_DEFINES will be put into $(BUILDDIR)/config-host.h 345HOST_DEFINES := 346 347# Anything added to GLOBAL_SRCDEPS will become a dependency of every source file in the system. 348# Useful for header files that may be included by one or more source files. 349GLOBAL_SRCDEPS := $(GLOBAL_CONFIG_HEADER) 350 351# Anything added to TARGET_SRCDEPS will become a dependency of every target module file in the system. 352# Useful for header files that may be included by one or more source files. 353TARGET_MODDEPS := 354 355# these need to be filled out by the project/target/platform rules.mk files 356TARGET := 357PLATFORM := 358ARCH := 359ALLMODULES := 360 361# this is the *true* allmodules, to check for duplicate modules 362# (since submodules do not contribute to ALLMODULES) 363DUPMODULES := 364 365# add any external module dependencies 366MODULES := $(EXTERNAL_MODULES) 367 368# any .mk specified here will be included before build.mk 369EXTRA_BUILDRULES := 370 371# any rules you put here will also be built by the system before considered being complete 372EXTRA_BUILDDEPS := 373 374# any rules you put here will be built if the kernel is also being built 375EXTRA_KERNELDEPS := 376 377# any rules you put here will be depended on in clean builds 378EXTRA_CLEANDEPS := 379 380# build ids 381EXTRA_IDFILES := 382 383# All kernel modules contribute to this list. 384ALLMODULE_OBJS := 385 386# userspace apps to build and include in initfs 387ALLUSER_APPS := 388 389# userspace app modules 390ALLUSER_MODULES := 391 392# userspace lib modules 393ALLUSER_LIBS := 394 395# host apps to build 396ALLHOST_APPS := 397 398# host libs to build 399ALLHOST_LIBS := 400 401# EFI libs to build 402ALLEFI_LIBS := 403 404# sysroot (exported libraries and headers) 405SYSROOT_DEPS := 406 407# For now always enable frame pointers so kernel backtraces 408# can work and define WITH_PANIC_BACKTRACE to enable them in panics 409# ZX-623 410KERNEL_DEFINES += WITH_PANIC_BACKTRACE=1 WITH_FRAME_POINTERS=1 411KERNEL_COMPILEFLAGS += $(KEEP_FRAME_POINTER_COMPILEFLAGS) 412 413# TODO(cja) Used for the transition between Kernel and userspace PCI 414# Flip Kernel PCI on / off depending whether userspace PCI was enabled 415ifeq ($(call TOBOOL, $(ENABLE_USER_PCI)),false) 416KERNEL_DEFINES += WITH_KERNEL_PCIE=1 417endif 418 419# Kernel lock dependency tracking. 420ifeq ($(call TOBOOL,$(ENABLE_LOCK_DEP)),true) 421KERNEL_DEFINES += WITH_LOCK_DEP=1 422KERNEL_DEFINES += LOCK_DEP_ENABLE_VALIDATION=1 423endif 424 425# Kernel lock dependency tracking tests. By default this is enabled when 426# tracking is enabled, but can also be eanbled independently to assess whether 427# the tests build and *fail correctly* when lockdep is disabled. 428ifeq ($(call TOBOOL,$(ENABLE_LOCK_DEP_TESTS)),true) 429KERNEL_DEFINES += WITH_LOCK_DEP_TESTS=1 430endif 431 432# additional bootdata items to be included to bootdata.bin 433ADDITIONAL_BOOTDATA_ITEMS := 434 435# manifest of files to include in the user bootfs 436USER_MANIFEST := $(BUILDDIR)/bootfs.manifest 437USER_MANIFEST_LINES := 438# The contents of this are derived from BOOTFS_DEBUG_MODULES. 439USER_MANIFEST_DEBUG_INPUTS := 440# Filter on manifest lines by {group} prefix. 441ifeq ($(call TOBOOL,$(ENABLE_INSTALL_SAMPLES)),true) 442USER_MANIFEST_GROUPS := 443else 444USER_MANIFEST_GROUPS := --groups=!sample,!ddk-sample 445endif 446 447# Directory in the bootfs where MODULE_FIRMWARE files go. 448FIRMWARE_INSTALL_DIR := lib/firmware 449# Directory in the source tree where MODULE_FIRMWARE files are found. 450FIRMWARE_SRC_DIR := prebuilt/downloads/firmware 451# TODO(mcgrathr): Force an absolute path for this so that every rhs in the 452# manifest either starts with $(BUILDDIR) or is absolute. 453# //scripts/build-zircon.sh needs this. 454FIRMWARE_SRC_DIR := $(abspath $(FIRMWARE_SRC_DIR)) 455 456# if someone defines this, the build id will be pulled into lib/version 457BUILDID ?= 458 459# Tool locations. 460TOOLS := $(BUILDDIR)/tools 461FIDL := $(TOOLS)/fidlc 462BANJO := $(TOOLS)/banjoc 463ABIGEN := $(TOOLS)/abigen 464ZBI := $(TOOLS)/zbi 465 466# set V=1 in the environment if you want to see the full command line of every command 467ifeq ($(V),1) 468NOECHO := 469else 470NOECHO ?= @ 471endif 472 473# used to force a rule to run every time 474.PHONY: FORCE 475FORCE: 476 477# try to include the project file 478-include $(firstword $(wildcard kernel/project/$(PROJECT).mk \ 479 kernel/project/alias/$(PROJECT).mk)) 480ifndef TARGET 481$(error couldn't find project "$(PROJECT)" or project doesn't define target) 482endif 483include kernel/target/$(TARGET)/rules.mk 484ifndef PLATFORM 485$(error couldn't find target or target doesn't define platform) 486endif 487include kernel/platform/$(PLATFORM)/rules.mk 488 489ifeq ($(call TOBOOL,$(QUIET)),false) 490$(info PROJECT/PLATFORM/TARGET = $(PROJECT) / $(PLATFORM) / $(TARGET)) 491endif 492 493include system/host/rules.mk 494include kernel/arch/$(ARCH)/rules.mk 495include kernel/top/rules.mk 496include make/abigen.mk 497 498ifeq ($(call TOBOOL,$(USE_CLANG)),true) 499GLOBAL_COMPILEFLAGS += --target=$(CLANG_ARCH)-fuchsia 500endif 501 502ifeq ($(call TOBOOL,$(USE_LTO)),true) 503ifeq ($(call TOBOOL,$(USE_CLANG)),false) 504$(error USE_LTO requires USE_CLANG) 505endif 506ifeq ($(call TOBOOL,$(USE_LLD)),false) 507$(error USE_LTO requires USE_LLD) 508endif 509# LTO doesn't store -mcmodel=kernel information in the bitcode files as it 510# does for many other codegen options so we have to set it explicitly. This 511# can be removed when https://bugs.llvm.org/show_bug.cgi?id=33306 is fixed. 512KERNEL_LDFLAGS += $(patsubst -mcmodel=%,-mllvm -code-model=%,\ 513 $(filter -mcmodel=%,$(KERNEL_COMPILEFLAGS))) 514ifeq ($(call TOBOOL,$(USE_THINLTO)),true) 515GLOBAL_COMPILEFLAGS += -flto=thin 516GLOBAL_LDFLAGS += --thinlto-jobs=8 --thinlto-cache-dir=$(THINLTO_CACHE_DIR) 517else 518GLOBAL_COMPILEFLAGS += -flto -fwhole-program-vtables 519# Full LTO doesn't require any special ld flags. 520endif 521endif 522 523# This needs to find the standard C++ library headers for the header-only 524# facilities that can be used in Zircon C++ code. The only implementation 525# that's been tested is libc++ (aka libcxx) from the LLVM project. In the 526# prebuilt Fuchsia Clang/LLVM toolchain, the libc++ headers are provided 527# with the toolchain and the compiler puts them in the default include 528# path, so nothing is needed here. Normally when using the prebuilt 529# Fuchsia GCC toolchain, we just use the headers directly from the prebuilt 530# Clang toolchain since they're on hand. If using a different compiler, 531# set this to a directory where the include/ subdirectory from 532# https://git.llvm.org/git/libcxx is unpacked. 533LIBCXX_INCLUDES ?= 534ifeq ($(call TOBOOL,$(USE_CLANG))$(strip $(LIBC_INCLUDES)),false) 535LIBCXX_INCLUDES := \ 536 $(shell $(CLANG_TOOLCHAIN_PREFIX)clang --target=$(CLANG_ARCH) \ 537 -print-file-name=include/c++/v1) 538endif 539GLOBAL_INCLUDES += $(LIBCXX_INCLUDES) 540# Visibility annotations conflict with kernel/include/hidden.h. 541KERNEL_CPPFLAGS += -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS 542 543ifeq ($(call TOBOOL,$(USE_SANCOV)),true) 544ifeq ($(call TOBOOL,$(USE_ASAN)),false) 545$(error USE_SANCOV requires USE_ASAN) 546endif 547endif 548 549ifeq ($(call TOBOOL,$(USE_ASAN)),true) 550ifeq ($(call TOBOOL,$(USE_CLANG)),false) 551$(error USE_ASAN requires USE_CLANG) 552endif 553 554# Compile all of userland with ASan. ASan makes safe-stack superfluous 555# and ASan reporting doesn't really grok safe-stack, so disable it. 556# Individual modules can append $(NO_SANITIZERS) to counteract this. 557USER_COMPILEFLAGS += -fsanitize=address -fno-sanitize=safe-stack 558 559# The Clang toolchain includes a manifest for the shared libraries it provides. 560# The right-hand sides are relative to the directory containing the manifest. 561CLANG_MANIFEST := $(CLANG_TOOLCHAIN_PREFIX)../lib/$(CLANG_ARCH)-fuchsia.manifest 562CLANG_MANIFEST_LINES := \ 563 $(subst =,=$(CLANG_TOOLCHAIN_PREFIX)../lib/,$(shell cat $(CLANG_MANIFEST))) 564find-clang-solib = $(filter lib/$1=%,$(CLANG_MANIFEST_LINES)) 565# Every userland executable and shared library compiled with ASan 566# needs to link with $(ASAN_SOLIB). module-user{app,lib}.mk adds it 567# to MODULE_EXTRA_OBJS so the linking target will depend on it. 568ASAN_SONAME := libclang_rt.asan.so 569ASAN_SOLIB_MANIFEST := $(call find-clang-solib,$(ASAN_SONAME)) 570ASAN_SOLIB := $(word 2,$(subst =, ,$(ASAN_SOLIB_MANIFEST))) 571USER_MANIFEST_LINES += {core}$(ASAN_SOLIB_MANIFEST) 572 573# The ASan runtime DSO depends on more DSOs from the toolchain. We don't 574# link against those, so we don't need any build-time dependencies on them. 575# But we need them alongside the ASan runtime DSO in the bootfs. 576find-clang-asan-solib = $(or $(call find-clang-solib,asan/$1), \ 577 $(call find-clang-solib,$1)) 578ASAN_RUNTIME_SONAMES := libc++abi.so.1 libunwind.so.1 579ASAN_RUNTIME_MANIFEST := \ 580 $(foreach soname,$(ASAN_RUNTIME_SONAMES),\ 581 {core}$(call find-clang-asan-solib,$(soname))) 582USER_MANIFEST_LINES += $(ASAN_RUNTIME_MANIFEST) 583 584TOOLCHAIN_SOLIBS += \ 585 $(foreach entry,$(ASAN_SOLIB_MANIFEST) $(ASAN_RUNTIME_MANIFEST),\ 586 $(word 2,$(subst =, ,$(entry)))) 587endif 588 589ifeq ($(call TOBOOL,$(USE_SANCOV)),true) 590# Compile all of userland with coverage. 591USER_COMPILEFLAGS += -fsanitize-coverage=trace-pc-guard 592NO_SANCOV := -fno-sanitize-coverage=trace-pc-guard 593NO_SANITIZERS += $(NO_SANCOV) 594else 595NO_SANCOV := 596endif 597 598clang-print-file-name = $(shell $(CLANG_TOOLCHAIN_PREFIX)clang \ 599 $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) \ 600 -print-file-name=$1) 601 602# To use LibFuzzer, we need to provide it and its dependency to the linker 603# since we're not using Clang and its '-fsanitize=fuzzer' flag as a driver to 604# lld. Additionally, we need to make sure the shared objects are available on 605# the device. 606ifeq ($(call TOBOOL,$(USE_ASAN)),true) 607FUZZ_ALIB := $(call clang-print-file-name,libclang_rt.fuzzer.a) 608 609FUZZ_RUNTIME_SONAMES := libc++abi.so.1 610FUZZ_RUNTIME_SOLIBS := $(foreach soname,$(FUZZ_RUNTIME_SONAMES),\ 611 $(word 2,$(subst =, ,$(call find-clang-asan-solib,$(soname))))) 612 613FUZZ_EXTRA_OBJS := $(FUZZ_ALIB) $(FUZZ_RUNTIME_SOLIBS) 614else 615FUZZ_EXTRA_OBJS := 616endif 617 618ifeq ($(call TOBOOL,$(USE_PROFILE)),true) 619USER_COMPILEFLAGS += -fprofile-instr-generate -fcoverage-mapping 620NO_PROFILE := -fno-profile-instr-generate -fno-coverage-mapping 621NO_SANITIZERS += $(NO_PROFILE) 622PROFILE_LIB := $(call clang-print-file-name,libclang_rt.profile.a) 623else 624NO_PROFILE := 625PROFILE_LIB := 626endif 627 628# Save these for the first module.mk iteration to see. 629SAVED_EXTRA_BUILDDEPS := $(EXTRA_BUILDDEPS) 630SAVED_GENERATED := $(GENERATED) 631SAVED_USER_MANIFEST_LINES := $(USER_MANIFEST_LINES) 632 633# recursively include any modules in the MODULE variable, leaving a trail of included 634# modules in the ALLMODULES list 635include make/recurse.mk 636 637define link-toolchain-file-cmd 638$(call BUILDECHO,generating $@) 639$(NOECHO)ln -n -f -L $< $@ 2> /dev/null || cp -f $< $@ 640endef 641define toolchain-id-files 642$(foreach lib,$(TOOLCHAIN_SOLIBS), 643EXTRA_IDFILES += $$(BUILDDIR)/$(notdir $(lib)).id 644$$(BUILDDIR)/$(notdir $(lib)): $(lib); $$(link-toolchain-file-cmd) 645) 646endef 647$(eval $(toolchain-id-files)) 648 649ifeq ($(call TOBOOL,$(ENABLE_ULIB_ONLY)),false) 650EXTRA_IDFILES += $(KERNEL_ELF).id 651endif 652 653ifneq ($(EXTRA_IDFILES),) 654$(BUILDDIR)/ids.txt: $(EXTRA_IDFILES) 655 $(call BUILDECHO,generating $@) 656 @rm -f -- "$@.tmp" 657 @for f in $(EXTRA_IDFILES); do \ 658 echo `cat $$f` `echo $$f | sed 's/\.id$$//g'` >> $@.tmp; \ 659 done; \ 660 mv $@.tmp $@ 661 662EXTRA_BUILDDEPS += $(BUILDDIR)/ids.txt 663GENERATED += $(BUILDDIR)/ids.txt 664GENERATED += $(EXTRA_IDFILES) 665endif 666 667# include some rules for generating sysroot/ and contents in the build dir 668include make/sysroot.mk 669 670# make the build depend on all of the user apps 671all:: $(foreach app,$(ALLUSER_APPS),$(app) $(app).strip) 672 673# and all host tools 674all:: $(ALLHOST_APPS) $(ALLHOST_LIBS) 675 676tools:: $(ALLHOST_APPS) $(ALLHOST_LIBS) 677 678# meta rule for the kernel 679.PHONY: kernel 680kernel: $(KERNEL_ZBI) $(EXTRA_KERNELDEPS) 681ifeq ($(ENABLE_BUILD_LISTFILES),true) 682kernel: $(KERNEL_ELF).lst $(KERNEL_ELF).sym $(KERNEL_ELF).sym.sorted $(KERNEL_ELF).size 683endif 684 685ifeq ($(call TOBOOL,$(ENABLE_ULIB_ONLY)),false) 686# add the kernel to the build 687all:: kernel 688else 689# No kernel, but we want the bootfs.manifest listing the installed libraries. 690all:: user-manifest 691endif 692 693# meta rule for building just packages 694.PHONY: packages 695packages: $(ALLPKGS) $(BUILDDIR)/export/manifest 696 697$(BUILDDIR)/export/manifest: FORCE 698 @$(call BUILDECHO,generating $@ ;)\ 699 $(MKDIR) ;\ 700 rm -f $@.tmp ;\ 701 (for p in $(sort $(notdir $(ALLPKGS))) ; do echo $$p ; done) > $@.tmp ;\ 702 $(call TESTANDREPLACEFILE,$@.tmp,$@) 703 704# build depends on all packages 705all:: packages 706 707# add some automatic configuration defines 708KERNEL_DEFINES += \ 709 PROJECT_$(PROJECT)=1 \ 710 PROJECT=\"$(PROJECT)\" \ 711 TARGET_$(TARGET)=1 \ 712 TARGET=\"$(TARGET)\" \ 713 PLATFORM_$(PLATFORM)=1 \ 714 PLATFORM=\"$(PLATFORM)\" \ 715 ARCH_$(ARCH)=1 \ 716 ARCH=\"$(ARCH)\" \ 717 718# allow additional defines from outside the build system 719ifneq ($(EXTERNAL_DEFINES),) 720GLOBAL_DEFINES += $(EXTERNAL_DEFINES) 721$(info EXTERNAL_DEFINES = $(EXTERNAL_DEFINES)) 722endif 723 724# Modules are added earlier before the recurse stage, so just print the info here 725ifneq ($(EXTERNAL_MODULES),) 726$(info EXTERNAL_MODULES = $(EXTERNAL_MODULES)) 727endif 728 729ifneq ($(EXTERNAL_KERNEL_DEFINES),) 730KERNEL_DEFINES += $(EXTERNAL_KERNEL_DEFINES) 731$(info EXTERNAL_KERNEL_DEFINES = $(EXTERNAL_KERNEL_DEFINES)) 732endif 733 734# prefix all of the paths in GLOBAL_INCLUDES and KERNEL_INCLUDES with -I 735GLOBAL_INCLUDES := $(addprefix -I,$(GLOBAL_INCLUDES)) 736KERNEL_INCLUDES := $(addprefix -I,$(KERNEL_INCLUDES)) 737 738# Path to the Goma compiler wrapper. Defaults to using no wrapper. 739GOMACC ?= 740 741# set up paths to various tools 742ifeq ($(call TOBOOL,$(USE_CLANG)),true) 743CC := $(GOMACC) $(CLANG_TOOLCHAIN_PREFIX)clang 744AR := $(CLANG_TOOLCHAIN_PREFIX)llvm-ar 745OBJDUMP := $(CLANG_TOOLCHAIN_PREFIX)llvm-objdump 746READELF := $(CLANG_TOOLCHAIN_PREFIX)llvm-readelf 747CPPFILT := $(CLANG_TOOLCHAIN_PREFIX)llvm-cxxfilt 748SIZE := $(CLANG_TOOLCHAIN_PREFIX)llvm-size 749NM := $(CLANG_TOOLCHAIN_PREFIX)llvm-nm 750OBJCOPY := $(CLANG_TOOLCHAIN_PREFIX)llvm-objcopy 751STRIP := $(CLANG_TOOLCHAIN_PREFIX)llvm-objcopy --strip-sections 752else 753CC := $(GOMACC) $(TOOLCHAIN_PREFIX)gcc 754AR := $(TOOLCHAIN_PREFIX)ar 755OBJDUMP := $(TOOLCHAIN_PREFIX)objdump 756READELF := $(TOOLCHAIN_PREFIX)readelf 757CPPFILT := $(TOOLCHAIN_PREFIX)c++filt 758SIZE := $(TOOLCHAIN_PREFIX)size 759NM := $(TOOLCHAIN_PREFIX)nm 760OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy 761STRIP := $(TOOLCHAIN_PREFIX)objcopy --strip-all 762endif 763LD := $(TOOLCHAIN_PREFIX)ld 764ifeq ($(call TOBOOL,$(USE_LLD)),true) 765LD := $(CLANG_TOOLCHAIN_PREFIX)ld.lld 766endif 767ifeq ($(call TOBOOL,$(USE_GOLD)),true) 768USER_LD := $(LD).gold 769else 770USER_LD := $(LD) 771endif 772 773LIBGCC := $(shell $(CC) $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) -print-libgcc-file-name) 774ifeq ($(LIBGCC),) 775$(error cannot find runtime library, please set LIBGCC) 776endif 777 778# try to have the compiler output colorized error messages if available 779export GCC_COLORS ?= 1 780 781# setup bootloader toolchain 782ifeq ($(ARCH),x86) 783EFI_ARCH := x86_64 784else ifeq ($(ARCH),arm64) 785EFI_ARCH := aarch64 786endif 787 788ifeq ($(call TOBOOL,$(USE_CLANG)),true) 789EFI_AR := $(CLANG_TOOLCHAIN_PREFIX)llvm-ar 790EFI_CC := $(CLANG_TOOLCHAIN_PREFIX)clang 791EFI_CXX := $(CLANG_TOOLCHAIN_PREFIX)clang++ 792EFI_LD := $(CLANG_TOOLCHAIN_PREFIX)lld-link 793EFI_COMPILEFLAGS := --target=$(EFI_ARCH)-windows-msvc 794else 795EFI_AR := $(TOOLCHAIN_PREFIX)ar 796EFI_CC := $(TOOLCHAIN_PREFIX)gcc 797EFI_CXX := $(TOOLCHAIN_PREFIX)g++ 798EFI_LD := $(TOOLCHAIN_PREFIX)ld 799EFI_COMPILEFLAGS := -fPIE 800endif 801 802EFI_OPTFLAGS := -O2 803EFI_COMPILEFLAGS += -fno-stack-protector 804EFI_COMPILEFLAGS += -Wall 805EFI_CFLAGS := -fshort-wchar -std=c99 -ffreestanding 806ifeq ($(EFI_ARCH),x86_64) 807EFI_CFLAGS += -mno-red-zone 808endif 809 810 811# setup host toolchain 812# default to prebuilt clang 813FOUND_HOST_GCC ?= $(shell which $(HOST_TOOLCHAIN_PREFIX)gcc) 814HOST_TOOLCHAIN_PREFIX ?= $(CLANG_TOOLCHAIN_PREFIX) 815HOST_USE_CLANG ?= $(shell which $(HOST_TOOLCHAIN_PREFIX)clang) 816ifneq ($(HOST_USE_CLANG),) 817HOST_CC := $(GOMACC) $(HOST_TOOLCHAIN_PREFIX)clang 818HOST_CXX := $(GOMACC) $(HOST_TOOLCHAIN_PREFIX)clang++ 819HOST_AR := $(HOST_TOOLCHAIN_PREFIX)llvm-ar 820else 821ifeq ($(FOUND_HOST_GCC),) 822$(error cannot find toolchain, please set HOST_TOOLCHAIN_PREFIX or add it to your path) 823endif 824HOST_CC := $(GOMACC) $(HOST_TOOLCHAIN_PREFIX)gcc 825HOST_CXX := $(GOMACC) $(HOST_TOOLCHAIN_PREFIX)g++ 826HOST_AR := $(HOST_TOOLCHAIN_PREFIX)ar 827endif 828 829# Host compile flags 830HOST_COMPILEFLAGS := -g -O2 -Isystem/public -Isystem/private -I$(GENERATED_INCLUDES) 831HOST_COMPILEFLAGS += -Wall -Wextra 832HOST_COMPILEFLAGS += -Wno-unused-parameter -Wno-sign-compare 833HOST_COMPILEFLAGS += -include $(HOST_CONFIG_HEADER) 834HOST_CFLAGS := -std=c11 835HOST_CPPFLAGS := -std=c++17 -fno-exceptions -fno-rtti 836HOST_LDFLAGS := 837ifneq ($(HOST_USE_CLANG),) 838# We need to use our provided libc++ and libc++abi (and their pthread 839# dependency) rather than the host library. The only exception is the 840# case when we are cross-compiling the host tools in which case we use 841# the C++ library from the sysroot. 842# TODO(TC-78): This can be removed once the Clang 843# toolchain ships with a cross-compiled C++ runtime. 844ifeq ($(HOST_TARGET),) 845ifeq ($(HOST_PLATFORM),linux) 846ifeq ($(HOST_ARCH),x86_64) 847HOST_SYSROOT ?= $(SYSROOT_linux-amd64_PATH) 848else ifeq ($(HOST_ARCH),aarch64) 849HOST_SYSROOT ?= $(SYSROOT_linux-arm64_PATH) 850endif 851# TODO(TC-77): Using explicit sysroot currently overrides location of C++ 852# runtime so we need to explicitly add it here. 853HOST_LDFLAGS += -Lprebuilt/downloads/clang/lib 854# The implicitly linked static libc++.a depends on these. 855HOST_LDFLAGS += -ldl -lpthread 856endif 857endif 858HOST_LDFLAGS += -static-libstdc++ 859# For host tools without C++, ignore the unused arguments. 860HOST_LDFLAGS += -Wno-unused-command-line-argument 861endif 862HOST_ASMFLAGS := 863 864ifneq ($(HOST_TARGET),) 865HOST_COMPILEFLAGS += --target=$(HOST_TARGET) 866ifeq ($(HOST_TARGET),x86_64-linux-gnu) 867HOST_SYSROOT ?= $(SYSROOT_linux-amd64_PATH) 868else ifeq ($(HOST_TARGET),aarch64-linux-gnu) 869HOST_SYSROOT ?= $(SYSROOT_linux-arm64_PATH) 870endif 871endif 872 873ifneq ($(HOST_USE_CLANG),) 874ifeq ($(HOST_PLATFORM),darwin) 875HOST_SYSROOT ?= $(shell xcrun --show-sdk-path) 876endif 877endif 878 879ifneq ($(HOST_SYSROOT),) 880HOST_COMPILEFLAGS += --sysroot=$(HOST_SYSROOT) 881endif 882 883ifeq ($(call TOBOOL,$(HOST_USE_ASAN)),true) 884HOST_COMPILEFLAGS += -fsanitize=address 885export ASAN_SYMBOLIZER_PATH := $(HOST_TOOLCHAIN_PREFIX)llvm-symbolizer 886endif 887 888# the logic to compile and link stuff is in here 889include make/build.mk 890 891# top level target to just build the bootloader 892.PHONY: bootloader 893bootloader: 894 895# build a bootloader if needed 896include bootloader/build.mk 897 898DEPS := $(ALLOBJS:%o=%d) 899 900# put all of the build flags in various config.h files to force a rebuild if any change 901GLOBAL_DEFINES += GLOBAL_INCLUDES=\"$(subst $(SPACE),_,$(GLOBAL_INCLUDES))\" 902GLOBAL_DEFINES += GLOBAL_COMPILEFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_COMPILEFLAGS))\" 903GLOBAL_DEFINES += GLOBAL_OPTFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_OPTFLAGS))\" 904GLOBAL_DEFINES += GLOBAL_CFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_CFLAGS))\" 905GLOBAL_DEFINES += GLOBAL_CPPFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_CPPFLAGS))\" 906GLOBAL_DEFINES += GLOBAL_ASMFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_ASMFLAGS))\" 907GLOBAL_DEFINES += GLOBAL_LDFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_LDFLAGS))\" 908GLOBAL_DEFINES += ARCH_COMPILEFLAGS=\"$(subst $(SPACE),_,$(ARCH_COMPILEFLAGS))\" 909GLOBAL_DEFINES += ARCH_CFLAGS=\"$(subst $(SPACE),_,$(ARCH_CFLAGS))\" 910GLOBAL_DEFINES += ARCH_CPPFLAGS=\"$(subst $(SPACE),_,$(ARCH_CPPFLAGS))\" 911GLOBAL_DEFINES += ARCH_ASMFLAGS=\"$(subst $(SPACE),_,$(ARCH_ASMFLAGS))\" 912 913KERNEL_DEFINES += KERNEL_INCLUDES=\"$(subst $(SPACE),_,$(KERNEL_INCLUDES))\" 914KERNEL_DEFINES += KERNEL_COMPILEFLAGS=\"$(subst $(SPACE),_,$(KERNEL_COMPILEFLAGS))\" 915KERNEL_DEFINES += KERNEL_CFLAGS=\"$(subst $(SPACE),_,$(KERNEL_CFLAGS))\" 916KERNEL_DEFINES += KERNEL_CPPFLAGS=\"$(subst $(SPACE),_,$(KERNEL_CPPFLAGS))\" 917KERNEL_DEFINES += KERNEL_ASMFLAGS=\"$(subst $(SPACE),_,$(KERNEL_ASMFLAGS))\" 918KERNEL_DEFINES += KERNEL_LDFLAGS=\"$(subst $(SPACE),_,$(KERNEL_LDFLAGS))\" 919 920USER_DEFINES += USER_COMPILEFLAGS=\"$(subst $(SPACE),_,$(USER_COMPILEFLAGS))\" 921USER_DEFINES += USER_CFLAGS=\"$(subst $(SPACE),_,$(USER_CFLAGS))\" 922USER_DEFINES += USER_CPPFLAGS=\"$(subst $(SPACE),_,$(USER_CPPFLAGS))\" 923USER_DEFINES += USER_ASMFLAGS=\"$(subst $(SPACE),_,$(USER_ASMFLAGS))\" 924USER_DEFINES += USER_LDFLAGS=\"$(subst $(SPACE),_,$(USER_LDFLAGS))\" 925 926HOST_DEFINES += HOST_COMPILEFLAGS=\"$(subst $(SPACE),_,$(HOST_COMPILEFLAGS))\" 927HOST_DEFINES += HOST_CFLAGS=\"$(subst $(SPACE),_,$(HOST_CFLAGS))\" 928HOST_DEFINES += HOST_CPPFLAGS=\"$(subst $(SPACE),_,$(HOST_CPPFLAGS))\" 929HOST_DEFINES += HOST_ASMFLAGS=\"$(subst $(SPACE),_,$(HOST_ASMFLAGS))\" 930HOST_DEFINES += HOST_LDFLAGS=\"$(subst $(SPACE),_,$(HOST_LDFLAGS))\" 931 932# debug build? 933# TODO(johngro) : Make LK and ZX debug levels independently controlable. 934ifneq ($(DEBUG),) 935GLOBAL_DEFINES += \ 936 LK_DEBUGLEVEL=$(DEBUG) \ 937 ZX_DEBUGLEVEL=$(DEBUG) 938HOST_DEFINES += \ 939 LK_DEBUGLEVEL=$(DEBUG) \ 940 ZX_DEBUGLEVEL=$(DEBUG) 941endif 942 943ifeq ($(DEBUG),0) 944GLOBAL_DEFINES += NDEBUG 945endif 946 947#$(info LIBGCC = $(LIBGCC)) 948#$(info GLOBAL_COMPILEFLAGS = $(GLOBAL_COMPILEFLAGS)) 949#$(info GLOBAL_OPTFLAGS = $(GLOBAL_OPTFLAGS)) 950 951# make all object files depend on any targets in GLOBAL_SRCDEPS 952$(ALLOBJS): $(GLOBAL_SRCDEPS) 953 954# make all target object files depend on any targets in TARGET_MODDEPS 955$(ALL_TARGET_OBJS): $(TARGET_MODDEPS) 956 957# any extra top level build dependencies that someone may have declared 958all:: $(EXTRA_BUILDDEPS) 959 960define RM_ONE 961@rm -f $(1) 962 963endef 964 965clean: $(EXTRA_CLEANDEPS) 966 $(foreach o,$(ALLOBJS), $(call RM_ONE,$o)) 967 $(foreach o,$(DEPS), $(call RM_ONE,$o)) 968 $(foreach o,$(GENERATED), $(call RM_ONE,$o)) 969 rm -f $(KERNEL_ZBI) $(KERNEL_IMAGE) $(KERNEL_ELF) $(KERNEL_ELF).lst $(KERNEL_ELF).debug.lst $(KERNEL_ELF).sym $(KERNEL_ELF).sym.sorted $(KERNEL_ELF).size $(KERNEL_ELF).hex $(KERNEL_ELF).dump $(KERNEL_ELF)-gdb.py 970 rm -f $(foreach app,$(ALLUSER_APPS),$(app) $(app).lst $(app).dump $(app).strip) 971 972install: all 973 scp $(KERNEL_ZBI) 192.168.0.4:/tftproot 974 975# generate a config-global.h file with all of the GLOBAL_DEFINES laid out in #define format 976$(GLOBAL_CONFIG_HEADER): FORCE 977 @$(call MAKECONFIGHEADER,$@,GLOBAL_DEFINES,"#define __Fuchsia__ 1") 978 979# generate a config-kernel.h file with all of the KERNEL_DEFINES laid out in #define format 980$(KERNEL_CONFIG_HEADER): FORCE 981 @$(call MAKECONFIGHEADER,$@,KERNEL_DEFINES,"") 982 983# generate a config-user.h file with all of the USER_DEFINES laid out in #define format 984$(USER_CONFIG_HEADER): FORCE 985 @$(call MAKECONFIGHEADER,$@,USER_DEFINES,"") 986 987$(HOST_CONFIG_HEADER): FORCE 988 @$(call MAKECONFIGHEADER,$@,HOST_DEFINES,"") 989 990GENERATED += $(GLOBAL_CONFIG_HEADER) $(KERNEL_CONFIG_HEADER) $(USER_CONFIG_HEADER) $(HOST_CONFIG_HEADER) 991 992# Empty rule for the .d files. The above rules will build .d files as a side 993# effect. Only works on gcc 3.x and above, however. 994%.d: 995 996ifeq ($(filter $(MAKECMDGOALS), clean), ) 997-include $(DEPS) 998endif 999 1000endif 1001 1002endif # make spotless 1003