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