1LOCAL_MAKEFILE:=$(lastword $(MAKEFILE_LIST)) 2 3BUILDROOT ?= . 4 5ifeq ($(MAKECMDGOALS),spotless) 6spotless: 7 rm -rf -- "$(BUILDROOT)"/build-* 8else 9 10ifndef LKROOT 11$(error please define LKROOT to the root of the lk build system) 12endif 13 14-include local.mk 15include make/macros.mk 16 17# If one of our goals (from the commandline) happens to have a 18# matching project/goal.mk, then we should re-invoke make with 19# that project name specified... 20 21project-name := $(firstword $(MAKECMDGOALS)) 22 23ifneq ($(project-name),) 24ifneq ($(strip $(foreach d,$(LKINC),$(wildcard $(d)/project/$(project-name).mk))),) 25do-nothing := 1 26$(MAKECMDGOALS) _all: make-make 27 @: 28make-make: 29 @PROJECT=$(project-name) $(MAKE) -rR -f $(LOCAL_MAKEFILE) $(filter-out $(project-name), $(MAKECMDGOALS)) 30 31.PHONY: make-make 32endif 33endif 34 35# some additional rules to print some help 36include make/help.mk 37 38ifeq ($(do-nothing),) 39 40ifeq ($(PROJECT),) 41 42ifneq ($(DEFAULT_PROJECT),) 43PROJECT := $(DEFAULT_PROJECT) 44else 45$(error No project specified. Use 'make list' for a list of projects or 'make help' for additional help) 46endif 47endif 48 49TEST_BUILD ?= 50 51DEBUG ?= 2 52 53# LOG_LEVEL_KERNEL controls LK_LOGLEVEL 54# when LOG_LEVEL_KERNEL = 1, dprintf INFO level is enabled 55# when LOG_LEVEL_KERNEL = 2, dprintf SPEW level is enabled 56LOG_LEVEL_KERNEL ?= $(DEBUG) 57 58# LOG_LEVEL_KERNEL_RUST controls LK_LOGLEVEL_RUST 59# when LOG_LEVEL_KERNEL_RUST = 0, Rust max log level is LevelFilter::Off 60# when LOG_LEVEL_KERNEL_RUST = 1, Rust max log level is LevelFilter::Error 61# when LOG_LEVEL_KERNEL_RUST = 2, Rust max log level is LogLevel::Warning 62# when LOG_LEVEL_KERNEL_RUST = 3, Rust max log level is LogLevel::Info 63# when LOG_LEVEL_KERNEL_RUST = 4, Rust max log level is LogLevel::Debug 64# when LOG_LEVEL_KERNEL_RUST = 5 or greater, the max log level is LogLevel::Trace 65LOG_LEVEL_KERNEL_RUST ?= $(LOG_LEVEL_KERNEL) 66 67# LOG_LEVEL_USER controls TLOG_LVL_DEFAULT 68# when LOG_LEVEL_USER = 2 TLOG_LVL_DEFAULT = 4 (info) 69# when LOG_LEVEL_USER = 3 TLOG_LVL_DEFAULT = 5 (debug) 70LOG_LEVEL_USER ?= $(DEBUG) 71 72BUILDDIR := $(BUILDROOT)/build-$(PROJECT) 73OUTBIN := $(BUILDDIR)/lk.bin 74OUTELF := $(BUILDDIR)/lk.elf 75CONFIGHEADER := $(BUILDDIR)/config.h 76TOOLCHAIN_CONFIG := $(BUILDDIR)/toolchain.config 77TRUSTY_HOST_LIBRARY_BUILDDIR := $(BUILDDIR)/host_lib 78TRUSTY_KERNEL_LIBRARY_BUILDDIR := $(BUILDDIR)/kernellib 79 80# Eliminate /usr/local/include and /usr/include to build kernel hermetically 81GLOBAL_KERNEL_COMPILEFLAGS += --sysroot=fake_sysroot 82GLOBAL_KERNEL_INCLUDES := $(addsuffix /include,$(LKINC)) 83# For backwards compatibility. 84GLOBAL_KERNEL_INCLUDES += $(addsuffix /include/uapi/uapi,$(LKINC)) $(addsuffix /include/shared/lk,$(LKINC)) 85GLOBAL_UAPI_INCLUDES := $(addsuffix /include/uapi,$(LKINC)) 86GLOBAL_SHARED_INCLUDES := $(addsuffix /include/shared,$(LKINC)) 87GLOBAL_USER_INCLUDES := $(addsuffix /include/user,$(LKINC)) 88GLOBAL_INCLUDES := $(BUILDDIR) $(GLOBAL_UAPI_INCLUDES) $(GLOBAL_SHARED_INCLUDES) $(GLOBAL_KERNEL_INCLUDES) 89GLOBAL_OPTFLAGS ?= $(ARCH_OPTFLAGS) 90GLOBAL_SHARED_COMPILEFLAGS := -glldb -fdebug-macro -include $(CONFIGHEADER) 91GLOBAL_SHARED_COMPILEFLAGS += -Werror -Wall -Wsign-compare -Wno-multichar -Wno-unused-function -Wno-unused-label 92GLOBAL_SHARED_COMPILEFLAGS += -fno-short-enums -fno-common 93GLOBAL_SHARED_COMPILEFLAGS += -fno-omit-frame-pointer 94GLOBAL_SHARED_CFLAGS := --std=c17 -Wstrict-prototypes -Wwrite-strings 95GLOBAL_SHARED_CPPFLAGS := --std=c++20 -fno-exceptions -fno-rtti -fno-threadsafe-statics 96# c99 array designators are not part of C++, but they are convenient and help avoid errors. 97GLOBAL_SHARED_CPPFLAGS += -Wno-c99-designator 98#GLOBAL_CPPFLAGS += -Weffc++ 99GLOBAL_SHARED_ASMFLAGS := -DASSEMBLY 100GLOBAL_LDFLAGS := 101GLOBAL_SHARED_LDFLAGS := 102GLOBAL_KERNEL_LDFLAGS := 103GLOBAL_KERNEL_RUSTFLAGS := -L dependency=$(TRUSTY_HOST_LIBRARY_BUILDDIR) -L dependency=$(TRUSTY_KERNEL_LIBRARY_BUILDDIR) 104 105# This function is referenced by the linker-generated exidx tables, but seems to 106# be being dropped before it is needed. Force it to be included in the link. 107GLOBAL_SHARED_LDFLAGS += --undefined=__aeabi_unwind_cpp_pr0 108 109GLOBAL_KERNEL_LDFLAGS += $(addprefix -L,$(LKINC)) 110 111GLOBAL_LTO_COMPILEFLAGS += \ 112 -fvisibility=hidden \ 113 -flto=full \ 114 -fvirtual-function-elimination \ 115 -fvisibility-inlines-hidden \ 116 117# Rust flags for proc macros 118GLOBAL_HOST_RUSTFLAGS := -L "$(RUST_HOST_LIBDIR)" -L dependency=$(TRUSTY_HOST_LIBRARY_BUILDDIR) 119 120# Rust flags, based on the flags used in AOSP 121GLOBAL_SHARED_RUSTFLAGS := -C codegen-units=1 -C debuginfo=2 -C opt-level=3 -C relocation-model=pic 122GLOBAL_SHARED_RUSTFLAGS += -C overflow-checks=on 123# Use v0 mangling to distinguish from C++ symbols 124GLOBAL_SHARED_RUSTFLAGS += -C symbol-mangling-version=v0 125GLOBAL_SHARED_RUSTFLAGS += -C panic=abort -Z link-native-libraries=no 126GLOBAL_SHARED_RUSTFLAGS += -Z panic_abort_tests 127GLOBAL_SHARED_RUSTFLAGS += --deny warnings 128 129# Architecture specific compile flags 130ARCH_COMPILEFLAGS := 131ARCH_CFLAGS := 132ARCH_CPPFLAGS := 133ARCH_ASMFLAGS := 134 135# top level rule 136all:: $(OUTBIN) $(OUTELF).sym $(OUTELF).sym.sorted $(OUTELF).size $(OUTELF).dump $(OUTELF).lst $(BUILDDIR)/srcfiles.txt $(BUILDDIR)/include_paths.txt 137 138# master module object list 139ALLOBJS_MODULE := 140 141# master object list (for dep generation) 142ALLOBJS := 143 144# master source file list 145ALLSRCS := 146 147# a linker script needs to be declared in one of the project/target/platform files 148LINKER_SCRIPT := 149 150# anything you add here will be deleted in make clean 151GENERATED := $(CONFIGHEADER) 152 153# anything added to GLOBAL_DEFINES will be put into $(BUILDDIR)/config.h 154GLOBAL_DEFINES := LK=1 __TRUSTY__=1 155 156# Anything added to GLOBAL_SRCDEPS will become a dependency of every source file in the system. 157# Useful for header files that may be included by one or more source files. 158GLOBAL_SRCDEPS := $(CONFIGHEADER) 159 160# these need to be filled out by the project/target/platform rules.mk files 161TARGET := 162PLATFORM := 163ARCH := 164ALLMODULES := 165ALLMODULE_CRATE_STEMS := 166 167# add any external module dependencies 168MODULES := $(EXTERNAL_MODULES) 169 170# any .mk specified here will be included before build.mk 171EXTRA_BUILDRULES := 172 173# any rules you put here will also be built by the system before considered being complete 174EXTRA_BUILDDEPS := 175 176# any rules you put here will be depended on in clean builds 177EXTRA_CLEANDEPS := 178 179# any objects you put here get linked with the final image 180EXTRA_OBJS := 181 182# any extra linker scripts to be put on the command line 183EXTRA_LINKER_SCRIPTS := 184 185# if someone defines this, the build id will be pulled into lib/version 186BUILDID ?= 187 188# comment out or override if you want to see the full output of each command 189NOECHO ?= @ 190 191GLOBAL_SHARED_COMPILEFLAGS += -Wimplicit-fallthrough 192# VLAs can have subtle security bugs and assist exploits, so ban them. 193GLOBAL_SHARED_COMPILEFLAGS += -Wvla 194 195# set the libc implementation to musl or lk 196LK_LIBC_IMPLEMENTATION ?= musl 197 198# try to include the project file 199-include project/$(PROJECT).mk 200ifndef TARGET 201$(error couldn't find project or project doesn't define target) 202endif 203include target/$(TARGET)/rules.mk 204ifndef PLATFORM 205$(error couldn't find target or target doesn't define platform) 206endif 207include platform/$(PLATFORM)/rules.mk 208 209# use linker garbage collection, if requested 210ifeq ($(WITH_LINKER_GC),1) 211GLOBAL_SHARED_COMPILEFLAGS += -ffunction-sections -fdata-sections 212GLOBAL_SHARED_LDFLAGS += --gc-sections 213endif 214 215# Control function inlining 216KERNEL_INLINE_FUNCTIONS ?= true 217ifeq ($(call TOBOOL,$(KERNEL_INLINE_FUNCTIONS)),true) 218GLOBAL_KERNEL_COMPILEFLAGS += -finline 219else 220GLOBAL_KERNEL_COMPILEFLAGS += -fno-inline-functions 221endif 222 223# We need all .lk_init entries to be included, even though they are not 224# referenced by symbol, so the linker needs to include all objects from each 225# module archive. 226GLOBAL_KERNEL_LDFLAGS += --whole-archive 227 228# We are not Linux, and some libraries check this macro 229# and incorrectly target the wrong OS 230# TODO(b/224064243): remove this when we have a proper triple 231GLOBAL_SHARED_COMPILEFLAGS += -U__linux__ 232 233# Enable LTO for all Rust modules. 234# 235# If the kernel has CFI enabled it needs to use linker LTO instead of the one 236# built into rustc. We need split LTO enabled for both languages 237# to avoid linking issues from mismatches between object files. 238# clang selects this by default, but rustc currently needs it to be selected 239# manually. 240ifeq (true,$(call TOBOOL,$(KERNEL_CFI_ENABLED))) 241GLOBAL_USER_RUSTFLAGS += -C lto=thin 242GLOBAL_KERNEL_RUSTFLAGS += -C linker-plugin-lto -Zsplit-lto-unit 243else 244GLOBAL_SHARED_RUSTFLAGS += -C lto=thin 245endif 246 247# Decide on the branch protection scheme. 248# Must mirror the MODULE_COMPILEFLAGS set in make/module.mk. We don't set 249# MODULE_RUSTFLAGS there since the lk-crates.a wrapper obj, which does not 250# use module.mk, needs the same flags. 251ifeq (true,$(call TOBOOL,$(KERNEL_BTI_ENABLED))) 252ifeq (true,$(call TOBOOL,$(KERNEL_PAC_ENABLED))) 253GLOBAL_KERNEL_RUSTFLAGS += -Z branch-protection=bti,pac-ret 254else 255GLOBAL_KERNEL_RUSTFLAGS += -Z branch-protection=bti 256endif 257else # !KERNEL_BTI_ENABLED 258ifeq (true,$(call TOBOOL,$(KERNEL_PAC_ENABLED))) 259GLOBAL_KERNEL_RUSTFLAGS += -Z branch-protection=pac-ret 260endif 261endif 262 263ifneq ($(GLOBAL_COMPILEFLAGS),) 264$(error Setting GLOBAL_COMPILEFLAGS directly from project or platform makefiles is no longer supported. Please use either GLOBAL_SHARED_COMPILEFLAGS or GLOBAL_KERNEL_COMPILEFLAGS.) 265endif 266ifneq ($(GLOBAL_CFLAGS),) 267$(error Setting GLOBAL_CFLAGS directly from project or platform makefiles is no longer supported. Please use either GLOBAL_SHARED_CFLAGS or GLOBAL_KERNEL_CFLAGS.) 268endif 269ifneq ($(GLOBAL_CPPFLAGS),) 270$(error Setting GLOBAL_CPPFLAGS directly from project or platform makefiles is no longer supported. Please use either GLOBAL_SHARED_CPPFLAGS or GLOBAL_KERNEL_CPPFLAGS.) 271endif 272ifneq ($(GLOBAL_ASMFLAGS),) 273$(error Setting GLOBAL_ASMFLAGS directly from project or platform makefiles is no longer supported. Please use either GLOBAL_SHARED_ASMFLAGS or GLOBAL_KERNEL_ASMFLAGS.) 274endif 275ifneq ($(GLOBAL_LDFLAGS),) 276$(error Setting GLOBAL_LDFLAGS directly from project or platform makefiles is no longer supported. Please use either GLOBAL_SHARED_LDFLAGS or GLOBAL_KERNEL_LDFLAGS.) 277endif 278 279# Global flags should be set by now, we're moving on to building modules 280GLOBAL_COMPILEFLAGS := $(GLOBAL_SHARED_COMPILEFLAGS) $(GLOBAL_KERNEL_COMPILEFLAGS) 281GLOBAL_CFLAGS := $(GLOBAL_SHARED_CFLAGS) $(GLOBAL_KERNEL_CFLAGS) 282GLOBAL_CPPFLAGS := $(GLOBAL_SHARED_CPPFLAGS) $(GLOBAL_KERNEL_CPPFLAGS) 283GLOBAL_ASMFLAGS := $(GLOBAL_SHARED_ASMFLAGS) $(GLOBAL_KERNEL_ASMFLAGS) 284GLOBAL_LDFLAGS := $(GLOBAL_SHARED_LDFLAGS) $(GLOBAL_KERNEL_LDFLAGS) 285 286$(call INFO_LOG,Project entry) 287$(info PROJECT = $(PROJECT)) 288$(info PLATFORM = $(PLATFORM)) 289$(info TARGET = $(TARGET)) 290 291# Derive the standard arch name. 292$(eval $(call standard_name_for_arch,STANDARD_ARCH_NAME,$(ARCH),$(SUBARCH))) 293 294# Set arch-specific flags for shadow call stack? 295SCS_ENABLED = $(KERNEL_SCS_ENABLED) 296 297include arch/$(ARCH)/rules.mk 298include top/rules.mk 299 300$(call INFO_LOG,Include recurse.mk) 301# recursively include any modules in the MODULE variable, leaving a trail of included 302# modules in the ALLMODULES list 303include make/recurse.mk 304 305# add some automatic configuration defines 306GLOBAL_DEFINES += \ 307 PROJECT_$(PROJECT)=1 \ 308 PROJECT=\"$(PROJECT)\" \ 309 TARGET_$(TARGET)=1 \ 310 TARGET=\"$(TARGET)\" \ 311 PLATFORM_$(PLATFORM)=1 \ 312 PLATFORM=\"$(PLATFORM)\" \ 313 ARCH_$(ARCH)=1 \ 314 ARCH=\"$(ARCH)\" \ 315 $(addsuffix =1,$(addprefix WITH_,$(ALLMODULES))) 316 317GLOBAL_DEFINES += \ 318 LK_DEBUGLEVEL=$(DEBUG) \ 319 LK_LOGLEVEL=$(LOG_LEVEL_KERNEL) \ 320 LK_LOGLEVEL_RUST=$(LOG_LEVEL_KERNEL_RUST) \ 321 TLOG_LVL_DEFAULT=$$(($(LOG_LEVEL_USER)+2)) \ 322 323# add some automatic rust configuration flags 324GLOBAL_SHARED_RUSTFLAGS += \ 325 --cfg='PLAT_$(call normalize-rust-cfg,$(PLATFORM))' \ 326 --cfg='TARGET_$(call normalize-rust-cfg,$(TARGET))' 327 328# Add configuration flag if this is a test build 329ifeq (true,$(call TOBOOL,$(TEST_BUILD))) 330GLOBAL_SHARED_RUSTFLAGS += --cfg='TEST_BUILD' 331endif 332 333GLOBAL_USER_INCLUDES += $(addsuffix /arch/$(ARCH)/include,$(LKINC)) 334 335# test build? 336ifneq ($(TEST_BUILD),) 337GLOBAL_DEFINES += \ 338 TEST_BUILD=1 339endif 340 341# By default we can accept 64 connections on a port. Currently we only need more 342# if coverage is enabled (this is only true on fuzzing) 343IPC_MAX_HANDLES ?= 64 344GLOBAL_DEFINES += \ 345 IPC_MAX_HANDLES=$(IPC_MAX_HANDLES) 346 347#check if we are doing a release build, if not sure assume release 348RELEASE_BUILD ?= true 349ifeq ($(RELEASE_BUILD),false) 350GLOBAL_DEFINES += \ 351 RELEASE_BUILD=0 352else 353GLOBAL_DEFINES += \ 354 RELEASE_BUILD=1 355endif 356 357# ASLR 358ifneq ($(ASLR),false) 359GLOBAL_DEFINES += \ 360 ASLR=1 361endif 362 363# build with shadow call stacks used in user tasks 364ifeq (true,$(call TOBOOL,$(USER_SCS_ENABLED))) 365GLOBAL_DEFINES += \ 366 USER_SCS_ENABLED=1 367endif 368 369# build with shadow call stacks used in the kernel 370ifeq (true,$(call TOBOOL,$(KERNEL_SCS_ENABLED))) 371GLOBAL_DEFINES += \ 372 KERNEL_SCS_ENABLED=1 373endif 374 375# build the kernel with SCS support for user tasks, unless overridden 376USER_SCS_SUPPORTED ?= true 377 378ifeq (true,$(call TOBOOL,$(USER_SCS_SUPPORTED))) 379# guards allocation and deallocation of the SCS guard region in the kernel 380GLOBAL_DEFINES += \ 381 USER_SCS_SUPPORTED=1 382endif 383 384 385ifeq (true,$(call TOBOOL,$(PIE_KERNEL))) 386# Build a PIE kernel binary 387GLOBAL_COMPILEFLAGS += -fPIE -fvisibility=hidden 388GLOBAL_LDFLAGS += -pie --no-dynamic-linker -z text -Bsymbolic 389# Use the very compact SHT_RELR encoding for dynamic relative relocations. 390GLOBAL_LDFLAGS += --pack-dyn-relocs=relr 391# lld can emit either the DT_RELR or DT_ANDROID_RELR tags. 392# Neither objcopy nor objdump recognize the former tags 393# and complain very loudly when seeing them, while silently 394# ignoring the DT_ANDROID_RELR tags because they're above DT_LOOS. 395# Passing --use-android-relr-tags tells lld to use DT_ANDROID_RELR. 396GLOBAL_LDFLAGS += --use-android-relr-tags 397endif 398 399# KERNEL_BASE_ASLR controls run-time randomization for the 400# base virtual address of the kernel image, i.e., the dynamic 401# value of KERNEL_BASE. This is currently disabled by default 402# and should be enabled manually per project because it has 403# several requirements: 404# * The platform must provide a RNG by either linking in libsm 405# or implementing the appropriate APIs. 406# * An ARM platform must use the new dynamic GIC initialization 407# function arm_gic_init_map() to allocate dynamic addresses for the GIC 408# registers instead of using fixed addresses. 409# * Platforms should not use any hard-coded virtual addresses. 410ifeq ($(call TOBOOL,$(KERNEL_BASE_ASLR)), true) 411GLOBAL_DEFINES += KERNEL_BASE_ASLR=1 412endif 413 414# allow additional defines from outside the build system 415ifneq ($(EXTERNAL_DEFINES),) 416GLOBAL_DEFINES += $(EXTERNAL_DEFINES) 417$(info EXTERNAL_DEFINES = $(EXTERNAL_DEFINES)) 418endif 419 420 421# prefix all of the paths in GLOBAL_INCLUDES with -I 422GLOBAL_INCLUDES := $(addprefix -I,$(GLOBAL_INCLUDES)) 423 424# test for some old variables 425ifneq ($(INCLUDES),) 426$(error INCLUDES variable set, please move to GLOBAL_INCLUDES: $(INCLUDES)) 427endif 428ifneq ($(DEFINES),) 429$(error DEFINES variable set, please move to GLOBAL_DEFINES: $(DEFINES)) 430endif 431 432# default to no ccache 433CCACHE ?= 434ifeq ($(CLANG_BINDIR),) 435$(error clang directory not specified, please set CLANG_BINDIR) 436endif 437CC := $(CCACHE) $(CLANG_BINDIR)/clang 438AR := $(CLANG_BINDIR)/llvm-ar 439LD := $(CLANG_BINDIR)/ld.lld 440OBJDUMP := $(CLANG_BINDIR)/llvm-objdump 441OBJCOPY := $(CLANG_BINDIR)/llvm-objcopy 442CPPFILT := $(CLANG_BINDIR)/llvm-cxxfilt 443SIZE := $(CLANG_BINDIR)/llvm-size 444NM := $(CLANG_BINDIR)/llvm-nm 445STRIP := $(CLANG_BINDIR)/llvm-strip 446RUSTC := $(RUST_BINDIR)/rustc 447CLIPPY_DRIVER := $(RUST_BINDIR)/clippy-driver 448 449# Save the toolchain paths in order to rebuild the world if they change. This is 450# needed to force a rebuild when changing compiler versions. 451TOOLCHAIN_DEFINES := CLANG_BINDIR=\"$(subst $(SPACE),_,$(CLANG_BINDIR))\" 452TOOLCHAIN_DEFINES += CLANG_TOOLS_BINDIR=\"$(subst $(SPACE),_,$(CLANG_TOOLS_BINDIR))\" 453TOOLCHAIN_DEFINES += RUST_BINDIR=\"$(subst $(SPACE),_,$(RUST_BINDIR))\" 454$(TOOLCHAIN_CONFIG): configheader 455 @$(call INFO_DONE,toolchain,generating config file,$@) 456 @$(call MAKECONFIGHEADER,$@,TOOLCHAIN_DEFINES) 457 458GENERATED += $(TOOLCHAIN_CONFIG) 459 460GLOBAL_HOST_RUST_LINK_ARGS := -B $(CLANG_BINDIR) -B $(CLANG_HOST_SEARCHDIR) \ 461 $(addprefix -L ,$(CLANG_HOST_LDDIRS)) --sysroot $(CLANG_HOST_SYSROOT) -fuse-ld=lld 462GLOBAL_HOST_RUSTFLAGS += -C linker="$(CLANG_BINDIR)/clang++" -C link-args="$(GLOBAL_HOST_RUST_LINK_ARGS)" 463GLOBAL_SHARED_RUSTFLAGS += -C linker="$(LD)" 464 465# TODO: we could find the runtime like this. 466# LIBGCC := $(shell $(CC) $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) $(THUMBCFLAGS) --rtlib=compiler-rt -print-libgcc-file-name) 467# However the compiler currently does not contain non-x86 prebuilts for the 468# linux-gnu ABI. We could either get those prebuilts added to the toolchain or 469# switch to the android ABI. 470# Note there are two copies of compiler-rt in the toolchain - framework and NDK. 471# We're using the NDK version because the path is more stable and the difference 472# should not matter for this library. (The main difference is which version of 473# libcxx they link against, and the builtins do not use C++.) 474LIBGCC := $(CLANG_BINDIR)/../runtimes_ndk_cxx/libclang_rt.builtins-$(STANDARD_ARCH_NAME)-android.a 475 476# try to have the compiler output colorized error messages if available 477export GCC_COLORS ?= 1 478 479# link all rust rlibs into a single top-level .a 480include make/rust-toplevel.mk 481 482# the logic to compile and link stuff is in here 483include make/build.mk 484 485DEPS := $(ALLOBJS:%o=%d) 486 487# put all of the global build flags in config.h to force a rebuild if any change 488GLOBAL_DEFINES += GLOBAL_INCLUDES=\"$(subst $(SPACE),_,$(GLOBAL_INCLUDES))\" 489GLOBAL_DEFINES += GLOBAL_COMPILEFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_COMPILEFLAGS))\" 490GLOBAL_DEFINES += GLOBAL_OPTFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_OPTFLAGS))\" 491GLOBAL_DEFINES += GLOBAL_CFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_CFLAGS))\" 492GLOBAL_DEFINES += GLOBAL_CPPFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_CPPFLAGS))\" 493GLOBAL_DEFINES += GLOBAL_ASMFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_ASMFLAGS))\" 494GLOBAL_DEFINES += GLOBAL_LDFLAGS=\"$(subst $(SPACE),_,$(GLOBAL_LDFLAGS))\" 495GLOBAL_DEFINES += ARCH_COMPILEFLAGS=\"$(subst $(SPACE),_,$(ARCH_COMPILEFLAGS))\" 496GLOBAL_DEFINES += ARCH_CFLAGS=\"$(subst $(SPACE),_,$(ARCH_CFLAGS))\" 497GLOBAL_DEFINES += ARCH_CPPFLAGS=\"$(subst $(SPACE),_,$(ARCH_CPPFLAGS))\" 498GLOBAL_DEFINES += ARCH_ASMFLAGS=\"$(subst $(SPACE),_,$(ARCH_ASMFLAGS))\" 499 500ifneq ($(OBJS),) 501$(warning OBJS=$(OBJS)) 502$(error OBJS is not empty, please convert to new module format) 503endif 504ifneq ($(OPTFLAGS),) 505$(warning OPTFLAGS=$(OPTFLAGS)) 506$(error OPTFLAGS is not empty, please use GLOBAL_OPTFLAGS or MODULE_OPTFLAGS) 507endif 508ifneq ($(CFLAGS),) 509$(warning CFLAGS=$(CFLAGS)) 510$(error CFLAGS is not empty, please use GLOBAL_CFLAGS or MODULE_CFLAGS) 511endif 512ifneq ($(CPPFLAGS),) 513$(warning CPPFLAGS=$(CPPFLAGS)) 514$(error CPPFLAGS is not empty, please use GLOBAL_CPPFLAGS or MODULE_CPPFLAGS) 515endif 516 517$(info LIBGCC = $(LIBGCC)) 518$(info GLOBAL_COMPILEFLAGS = $(GLOBAL_COMPILEFLAGS)) 519$(info GLOBAL_OPTFLAGS = $(GLOBAL_OPTFLAGS)) 520 521# make all object files depend on any targets in GLOBAL_SRCDEPS 522$(ALLOBJS): $(GLOBAL_SRCDEPS) 523 524# any extra top level build dependencies that someone declared. 525# build.mk may add to EXTRA_BUILDDEPS, this must be evalauted after build.mk. 526all:: $(EXTRA_BUILDDEPS) 527 528clean: $(EXTRA_CLEANDEPS) 529 rm -f $(ALLOBJS) $(DEPS) $(GENERATED) $(OUTBIN) $(OUTELF) $(OUTELF).sym $(OUTELF).sym.sorted $(OUTELF).size $(OUTELF).hex $(OUTELF).dump $(OUTELF).lst 530 531install: all 532 scp $(OUTBIN) 192.168.0.4:/tftproot 533 534# generate a config.h file with all of the GLOBAL_DEFINES laid out in #define format 535configheader: 536 537$(CONFIGHEADER): configheader 538 @$(call INFO_DONE,global,generating config file,$@) 539 @$(call MAKECONFIGHEADER,$@,GLOBAL_DEFINES) 540 541# Empty rule for the .d files. The above rules will build .d files as a side 542# effect. Only works on gcc 3.x and above, however. 543%.d: 544 545ifeq ($(filter $(MAKECMDGOALS), clean), ) 546-include $(DEPS) 547endif 548 549.PHONY: configheader 550 551# all build rules are defined, start build process 552$(call INFO_LOG,Start building) 553 554endif 555 556endif # make spotless 557