Anas Nashif | 027b69e | 2016-02-08 21:32:24 -0500 | [diff] [blame] | 1 | VERSION_MAJOR = 1 |
Anas Nashif | 0e6c11a | 2016-08-25 07:14:47 -0400 | [diff] [blame] | 2 | VERSION_MINOR = 5 |
Anas Nashif | 0a3946a | 2016-10-24 08:38:13 -0400 | [diff] [blame] | 3 | PATCHLEVEL = 99 |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 4 | VERSION_RESERVED = 0 |
Anas Nashif | 5ca45ba | 2016-08-26 17:35:49 -0400 | [diff] [blame] | 5 | EXTRAVERSION = |
Anas Nashif | ac47c45 | 2015-06-19 21:21:48 -0400 | [diff] [blame] | 6 | NAME = Zephyr Kernel |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 7 | |
Anas Nashif | 3315b1f | 2015-12-27 16:35:28 -0500 | [diff] [blame] | 8 | export SOURCE_DIR PROJECT MDEF_FILE |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 9 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 10 | ifeq ($(MAKECMDGOALS),) |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 11 | $(error Invoking make from top-level kernel directory is not supported) |
| 12 | endif |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 13 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 14 | # *DOCUMENTATION* |
| 15 | # To see a list of typical targets execute "make help" |
| 16 | # More info can be located in ./README |
| 17 | # Comments in this file are targeted only to the developer, do not |
| 18 | # expect to learn how to build the kernel reading this file. |
Anas Nashif | e3ac090 | 2015-08-23 11:22:40 -0400 | [diff] [blame] | 19 | # |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 20 | |
Anas Nashif | e3ac090 | 2015-08-23 11:22:40 -0400 | [diff] [blame] | 21 | # o Do not use make's built-in rules and variables |
| 22 | # (this increases performance and avoids hard-to-debug behaviour); |
| 23 | # o Look for make include files relative to root of kernel src |
| 24 | MAKEFLAGS += -rR --include-dir=$(CURDIR) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 25 | |
Louise Mendoza | 0c3f05b | 2015-12-30 16:17:36 -0600 | [diff] [blame] | 26 | UNAME := $(shell uname) |
| 27 | ifeq (MINGW, $(findstring MINGW, $(UNAME))) |
| 28 | HOST_OS=MINGW |
| 29 | PWD_OPT=-W |
Anas Nashif | 3cf1d29 | 2016-02-01 13:29:43 -0500 | [diff] [blame] | 30 | DISABLE_TRYRUN=y |
Juan Manuel Cruz | 5516bca | 2016-04-27 10:15:14 -0500 | [diff] [blame] | 31 | CPATH ?= $(MIGW_DIR)/include |
| 32 | LIBRARY_PATH ?= $(MINGW_DIR)/lib |
| 33 | export CPATH LIBRARY_PATH |
Louise Mendoza | 0c3f05b | 2015-12-30 16:17:36 -0600 | [diff] [blame] | 34 | else ifeq (Linux, $(findstring Linux, $(UNAME))) |
| 35 | HOST_OS=Linux |
| 36 | else ifeq (Darwin, $(findstring Darwin, $(UNAME))) |
| 37 | HOST_OS=Darwin |
| 38 | endif |
| 39 | export HOST_OS |
| 40 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 41 | # Avoid funny character set dependencies |
| 42 | unexport LC_ALL |
| 43 | LC_COLLATE=C |
| 44 | LC_NUMERIC=C |
| 45 | export LC_COLLATE LC_NUMERIC |
| 46 | |
| 47 | # Avoid interference with shell env settings |
| 48 | unexport GREP_OPTIONS |
| 49 | |
Anas Nashif | 3852c8c | 2015-08-22 18:14:42 -0400 | [diff] [blame] | 50 | DQUOTE = " |
| 51 | #This comment line is to fix the highlighting of some editors due the quote effect." |
Maureen Helm | 280eadf | 2016-06-11 09:33:31 -0500 | [diff] [blame] | 52 | export DQUOTE |
Anas Nashif | 3852c8c | 2015-08-22 18:14:42 -0400 | [diff] [blame] | 53 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 54 | # We are using a recursive build, so we need to do a little thinking |
| 55 | # to get the ordering right. |
| 56 | # |
| 57 | # Most importantly: sub-Makefiles should only ever modify files in |
| 58 | # their own directory. If in some directory we have a dependency on |
| 59 | # a file in another dir (which doesn't happen often, but it's often |
| 60 | # unavoidable when linking the built-in.o targets which finally |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 61 | # turn into the kernel binary), we will call a sub make in that other |
| 62 | # dir, and after that we are sure that everything which is in that |
| 63 | # other dir is now up to date. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 64 | # |
| 65 | # The only cases where we need to modify files which have global |
| 66 | # effects are thus separated out and done before the recursive |
| 67 | # descending is started. They are now explicitly listed as the |
| 68 | # prepare rule. |
| 69 | |
| 70 | # Beautify output |
| 71 | # --------------------------------------------------------------------------- |
| 72 | # |
| 73 | # Normally, we echo the whole command before executing it. By making |
| 74 | # that echo $($(quiet)$(cmd)), we now have the possibility to set |
| 75 | # $(quiet) to choose other forms of output instead, e.g. |
| 76 | # |
| 77 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ |
| 78 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
| 79 | # |
| 80 | # If $(quiet) is empty, the whole command will be printed. |
| 81 | # If it is set to "quiet_", only the short version will be printed. |
| 82 | # If it is set to "silent_", nothing will be printed at all, since |
| 83 | # the variable $(silent_cmd_cc_o_c) doesn't exist. |
| 84 | # |
| 85 | # A simple variant is to prefix commands with $(Q) - that's useful |
| 86 | # for commands that shall be hidden in non-verbose mode. |
| 87 | # |
| 88 | # $(Q)ln $@ :< |
| 89 | # |
| 90 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. |
| 91 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. |
| 92 | # |
| 93 | # To put more focus on warnings, be less verbose as default |
| 94 | # Use 'make V=1' to see the full commands |
| 95 | |
| 96 | ifeq ("$(origin V)", "command line") |
| 97 | KBUILD_VERBOSE = $(V) |
| 98 | endif |
| 99 | ifndef KBUILD_VERBOSE |
| 100 | KBUILD_VERBOSE = 0 |
| 101 | endif |
| 102 | |
| 103 | ifeq ($(KBUILD_VERBOSE),1) |
| 104 | quiet = |
| 105 | Q = |
Andrew Boie | 0d03e32 | 2016-07-26 11:36:31 -0700 | [diff] [blame] | 106 | GENIDT_EXTRA_ARGS = -d |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 107 | else |
| 108 | quiet=quiet_ |
| 109 | Q = @ |
Andrew Boie | 0d03e32 | 2016-07-26 11:36:31 -0700 | [diff] [blame] | 110 | GENIDT_EXTRA_ARGS = |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 111 | endif |
| 112 | |
| 113 | # If the user is running make -s (silent mode), suppress echoing of |
| 114 | # commands |
| 115 | |
| 116 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 |
| 117 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) |
| 118 | quiet=silent_ |
| 119 | endif |
| 120 | else # make-3.8x |
| 121 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) |
| 122 | quiet=silent_ |
| 123 | endif |
| 124 | endif |
| 125 | |
| 126 | export quiet Q KBUILD_VERBOSE |
| 127 | |
| 128 | # kbuild supports saving output files in a separate directory. |
| 129 | # To locate output files in a separate directory two syntaxes are supported. |
| 130 | # In both cases the working directory must be the root of the kernel src. |
| 131 | # 1) O= |
| 132 | # Use "make O=dir/to/store/output/files/" |
| 133 | # |
| 134 | # 2) Set KBUILD_OUTPUT |
| 135 | # Set the environment variable KBUILD_OUTPUT to point to the directory |
| 136 | # where the output files shall be placed. |
| 137 | # export KBUILD_OUTPUT=dir/to/store/output/files/ |
| 138 | # make |
| 139 | # |
| 140 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment |
| 141 | # variable. |
| 142 | |
| 143 | # KBUILD_SRC is set on invocation of make in OBJ directory |
| 144 | # KBUILD_SRC is not intended to be used by the regular user (for now) |
| 145 | ifeq ($(KBUILD_SRC),) |
| 146 | |
| 147 | # OK, Make called in directory where kernel src resides |
| 148 | # Do we want to locate output files in a separate directory? |
| 149 | ifeq ("$(origin O)", "command line") |
| 150 | KBUILD_OUTPUT := $(O) |
| 151 | endif |
| 152 | |
| 153 | # That's our default target when none is given on the command line |
| 154 | PHONY := _all |
| 155 | _all: |
| 156 | |
| 157 | # Cancel implicit rules on top Makefile |
| 158 | $(CURDIR)/Makefile Makefile: ; |
| 159 | |
| 160 | ifneq ($(KBUILD_OUTPUT),) |
| 161 | # Invoke a second make in the output directory, passing relevant variables |
| 162 | # check that the output directory actually exists |
| 163 | saved-output := $(KBUILD_OUTPUT) |
| 164 | KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ |
Louise Mendoza | 0c3f05b | 2015-12-30 16:17:36 -0600 | [diff] [blame] | 165 | && pwd $(PWD_OPT)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 166 | $(if $(KBUILD_OUTPUT),, \ |
| 167 | $(error failed to create output directory "$(saved-output)")) |
| 168 | |
| 169 | PHONY += $(MAKECMDGOALS) sub-make |
| 170 | |
| 171 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make |
| 172 | @: |
| 173 | |
| 174 | sub-make: FORCE |
| 175 | $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ |
| 176 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) |
| 177 | |
| 178 | # Leave processing to above invocation of make |
| 179 | skip-makefile := 1 |
| 180 | endif # ifneq ($(KBUILD_OUTPUT),) |
| 181 | endif # ifeq ($(KBUILD_SRC),) |
| 182 | |
| 183 | # We process the rest of the Makefile if this is the final invocation of make |
| 184 | ifeq ($(skip-makefile),) |
| 185 | |
| 186 | # Do not print "Entering directory ...", |
| 187 | # but we want to display it when entering to the output directory |
| 188 | # so that IDEs/editors are able to understand relative filenames. |
| 189 | MAKEFLAGS += --no-print-directory |
| 190 | |
| 191 | # Call a source code checker (by default, "sparse") as part of the |
| 192 | # C compilation. |
| 193 | # |
| 194 | # Use 'make C=1' to enable checking of only re-compiled files. |
| 195 | # Use 'make C=2' to enable checking of *all* source files, regardless |
| 196 | # of whether they are re-compiled or not. |
| 197 | # |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 198 | ifeq ("$(origin C)", "command line") |
| 199 | KBUILD_CHECKSRC = $(C) |
| 200 | endif |
| 201 | ifndef KBUILD_CHECKSRC |
| 202 | KBUILD_CHECKSRC = 0 |
| 203 | endif |
| 204 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 205 | PHONY += all |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 206 | _all: all |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 207 | |
| 208 | ifeq ($(KBUILD_SRC),) |
| 209 | # building in the source tree |
| 210 | srctree := . |
| 211 | else |
| 212 | ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) |
| 213 | # building in a subdirectory of the source tree |
| 214 | srctree := .. |
| 215 | else |
| 216 | srctree := $(KBUILD_SRC) |
| 217 | endif |
| 218 | endif |
| 219 | objtree := . |
| 220 | src := $(srctree) |
| 221 | obj := $(objtree) |
| 222 | |
Kumar Gala | 23af1e9 | 2016-06-03 09:51:56 -0500 | [diff] [blame] | 223 | VPATH := $(SOURCE_DIR_PARENT) $(srctree) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 224 | |
| 225 | export srctree objtree VPATH |
| 226 | |
| 227 | |
| 228 | # SUBARCH tells the usermode build what the underlying arch is. That is set |
| 229 | # first, and if a usermode build is happening, the "ARCH=um" on the command |
| 230 | # line overrides the setting of ARCH below. If a native build is happening, |
| 231 | # then ARCH is assigned, getting whatever value it gets normally, and |
| 232 | # SUBARCH is subsequently ignored. |
| 233 | |
| 234 | SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ |
| 235 | -e s/sun4u/sparc64/ \ |
| 236 | -e s/arm.*/arm/ -e s/sa110/arm/ \ |
| 237 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ |
| 238 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ |
| 239 | -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) |
| 240 | |
| 241 | # Cross compiling and selecting different set of gcc/bin-utils |
| 242 | # --------------------------------------------------------------------------- |
| 243 | # |
| 244 | # When performing cross compilation for other architectures ARCH shall be set |
| 245 | # to the target architecture. (See arch/* for the possibilities). |
| 246 | # ARCH can be set during invocation of make: |
Anas Nashif | 67fc206 | 2015-04-24 18:29:24 -0400 | [diff] [blame] | 247 | # make ARCH=x86 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 248 | # Another way is to have ARCH set in the environment. |
| 249 | # The default ARCH is the host where make is executed. |
| 250 | |
| 251 | # CROSS_COMPILE specify the prefix used for all executables used |
| 252 | # during compilation. Only gcc and related bin-utils executables |
| 253 | # are prefixed with $(CROSS_COMPILE). |
| 254 | # CROSS_COMPILE can be set on the command line |
Anas Nashif | 67fc206 | 2015-04-24 18:29:24 -0400 | [diff] [blame] | 255 | # make CROSS_COMPILE=i586-pc-elf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 256 | # Alternatively CROSS_COMPILE can be set in the environment. |
| 257 | # A third alternative is to store a setting in .config so that plain |
| 258 | # "make" in the configured kernel build directory always uses that. |
| 259 | # Default value for CROSS_COMPILE is not to prefix executables |
| 260 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile |
| 261 | ARCH ?= $(SUBARCH) |
| 262 | CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) |
| 263 | |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 264 | KCONFIG_CONFIG ?= .config |
| 265 | export KCONFIG_CONFIG |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 266 | |
| 267 | # SHELL used by kbuild |
| 268 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
| 269 | else if [ -x /bin/bash ]; then echo /bin/bash; \ |
| 270 | else echo sh; fi ; fi) |
| 271 | |
Vinicius Costa Gomes | 28b7919 | 2015-12-18 18:40:30 -0200 | [diff] [blame] | 272 | HOSTCC ?= gcc |
| 273 | HOSTCXX ?= g++ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 274 | HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 |
| 275 | HOSTCXXFLAGS = -O2 |
| 276 | |
| 277 | ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) |
| 278 | HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ |
| 279 | -Wno-missing-field-initializers -fno-delete-null-pointer-checks |
| 280 | endif |
| 281 | |
| 282 | # Decide whether to build built-in, modular, or both. |
| 283 | # Normally, just do built-in. |
| 284 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 285 | KBUILD_BUILTIN := 1 |
| 286 | |
Anas Nashif | ace0e22 | 2015-12-30 19:01:20 -0500 | [diff] [blame] | 287 | export KBUILD_BUILTIN |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 288 | export KBUILD_CHECKSRC KBUILD_SRC |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 289 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 290 | # Look for make include files relative to root of kernel src |
| 291 | MAKEFLAGS += --include-dir=$(srctree) |
| 292 | |
| 293 | # We need some generic definitions (do not try to remake the file). |
| 294 | $(srctree)/scripts/Kbuild.include: ; |
| 295 | include $(srctree)/scripts/Kbuild.include |
Andrew Boie | 285c054 | 2015-07-27 11:04:24 -0700 | [diff] [blame] | 296 | ifeq ($(USE_CCACHE),1) |
| 297 | CCACHE := ccache |
| 298 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 299 | |
| 300 | # Make variables (CC, etc...) |
| 301 | AS = $(CROSS_COMPILE)as |
| 302 | LD = $(CROSS_COMPILE)ld |
Fabien Chereau | 6d1ee7e | 2015-08-19 15:34:02 +0200 | [diff] [blame] | 303 | ifeq ($(USE_CCACHE),1) |
Andrew Boie | 285c054 | 2015-07-27 11:04:24 -0700 | [diff] [blame] | 304 | CC = $(CCACHE) $(CROSS_COMPILE)gcc |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 305 | CXX = $(CCACHE) $(CROSS_COMPILE)g++ |
Fabien Chereau | 6d1ee7e | 2015-08-19 15:34:02 +0200 | [diff] [blame] | 306 | else |
Juan Manuel Cruz | 164ecd0 | 2016-04-27 10:25:23 -0500 | [diff] [blame] | 307 | CC ?= $(CROSS_COMPILE)gcc |
| 308 | CXX ?= $(CROSS_COMPILE)g++ |
Fabien Chereau | 6d1ee7e | 2015-08-19 15:34:02 +0200 | [diff] [blame] | 309 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 310 | CPP = $(CC) -E |
| 311 | AR = $(CROSS_COMPILE)ar |
| 312 | NM = $(CROSS_COMPILE)nm |
| 313 | STRIP = $(CROSS_COMPILE)strip |
| 314 | OBJCOPY = $(CROSS_COMPILE)objcopy |
| 315 | OBJDUMP = $(CROSS_COMPILE)objdump |
Anas Nashif | c0c1556 | 2016-02-01 19:54:32 -0500 | [diff] [blame] | 316 | GDB = $(CROSS_COMPILE)gdb |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 317 | READELF = $(CROSS_COMPILE)readelf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 318 | AWK = awk |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 319 | GENIDT = scripts/gen_idt/gen_idt |
Anas Nashif | bd22748 | 2015-08-25 10:04:04 -0400 | [diff] [blame] | 320 | GENOFFSET_H = scripts/gen_offset_header/gen_offset_header |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 321 | PERL = perl |
| 322 | PYTHON = python |
| 323 | CHECK = sparse |
| 324 | |
Anas Nashif | 6afc485 | 2015-04-24 18:30:36 -0400 | [diff] [blame] | 325 | CHECKFLAGS := -Wbitwise -Wno-return-void $(CF) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 326 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage |
| 327 | |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 328 | ifeq ($(COMPILER),clang) |
| 329 | ifneq ($(CROSS_COMPILE),) |
| 330 | CLANG_TARGET := -target $(notdir $(CROSS_COMPILE:%-=%)) |
| 331 | GCC_TOOLCHAIN := $(dir $(CROSS_COMPILE)) |
| 332 | endif |
| 333 | ifneq ($(GCC_TOOLCHAIN),) |
| 334 | CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN) |
| 335 | endif |
| 336 | ifneq ($(IA),1) |
| 337 | CLANG_IA_FLAG = -no-integrated-as |
| 338 | endif |
| 339 | CLANG_FLAGS := $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_IA_FLAG) |
| 340 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 341 | |
| 342 | # Use USERINCLUDE when you must reference the UAPI directories only. |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 343 | USERINCLUDE := -include $(CURDIR)/include/generated/autoconf.h |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 344 | |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 345 | SOC_NAME = $(subst $(DQUOTE),,$(CONFIG_SOC)) |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 346 | SOC_SERIES = $(subst $(DQUOTE),,$(CONFIG_SOC_SERIES)) |
Anas Nashif | a02c34e | 2016-03-31 08:07:42 -0400 | [diff] [blame] | 347 | SOC_FAMILY = $(subst $(DQUOTE),,$(CONFIG_SOC_FAMILY)) |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 348 | |
Anas Nashif | fe039db | 2016-01-22 13:51:50 -0500 | [diff] [blame] | 349 | override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH)) |
Anas Nashif | 2d76224 | 2015-12-07 20:20:25 -0500 | [diff] [blame] | 350 | BOARD_NAME = $(subst $(DQUOTE),,$(CONFIG_BOARD)) |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 351 | KERNEL_NAME = $(subst $(DQUOTE),,$(CONFIG_KERNEL_BIN_NAME)) |
| 352 | KERNEL_ELF_NAME = $(KERNEL_NAME).elf |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 353 | KERNEL_BIN_NAME = $(KERNEL_NAME).bin |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 354 | KERNEL_HEX_NAME = $(KERNEL_NAME).hex |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 355 | KERNEL_STAT_NAME = $(KERNEL_NAME).stat |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 356 | |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 357 | export SOC_FAMILY SOC_SERIES SOC_PATH SOC_NAME BOARD_NAME |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 358 | export ARCH KERNEL_NAME KERNEL_ELF_NAME KERNEL_BIN_NAME KERNEL_HEX_NAME |
Anas Nashif | b882377 | 2015-06-05 22:46:00 -0400 | [diff] [blame] | 359 | # Use ZEPHYRINCLUDE when you must reference the include/ directory. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 360 | # Needed to be compatible with the O= option |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 361 | ZEPHYRINCLUDE = \ |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 362 | -I$(srctree)/arch/$(ARCH)/include \ |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 363 | -I$(srctree)/arch/$(ARCH)/soc/$(SOC_PATH) \ |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 364 | -I$(srctree)/boards/$(ARCH)/$(BOARD_NAME) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 365 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 366 | -I$(srctree)/include \ |
| 367 | -I$(CURDIR)/include/generated \ |
Anas Nashif | 8b45f4e | 2015-10-21 07:24:39 -0400 | [diff] [blame] | 368 | -I$(CURDIR)/misc/generated/sysgen \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 369 | $(USERINCLUDE) \ |
| 370 | $(STDINCLUDE) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 371 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 372 | KBUILD_CPPFLAGS := -DKERNEL |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 373 | |
Juan Manuel Cruz | 068ebc0 | 2015-05-06 10:41:08 -0500 | [diff] [blame] | 374 | KBUILD_CFLAGS := -c -g -std=c99 \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 375 | -fno-asynchronous-unwind-tables \ |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 376 | -Wall \ |
Andrew Boie | 5bb0631 | 2015-08-11 12:46:06 -0700 | [diff] [blame] | 377 | -Wno-format-zero-length \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 378 | -Wno-main -ffreestanding |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 379 | |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 380 | KBUILD_CXXFLAGS := -c -g -std=c++11 \ |
| 381 | -fno-reorder-functions \ |
| 382 | -fno-asynchronous-unwind-tables \ |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 383 | -fcheck-new \ |
| 384 | -fno-defer-pop -Wall \ |
| 385 | -Wno-unused-but-set-variable \ |
| 386 | -Wno-format-zero-length \ |
| 387 | -Wno-main -ffreestanding \ |
| 388 | -ffunction-sections -fdata-sections \ |
| 389 | -fno-rtti -fno-exceptions |
| 390 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 391 | KBUILD_AFLAGS := -c -g -xassembler-with-cpp |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 392 | |
Peter Mitsis | 61eff49 | 2015-06-01 11:27:55 -0400 | [diff] [blame] | 393 | LDFLAGS += $(call ld-option,-nostartfiles) |
| 394 | LDFLAGS += $(call ld-option,-nodefaultlibs) |
| 395 | LDFLAGS += $(call ld-option,-nostdlib) |
| 396 | LDFLAGS += $(call ld-option,-static) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 397 | |
Anas Nashif | 32bff69 | 2015-06-23 21:11:04 -0400 | [diff] [blame] | 398 | KERNELVERSION = $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR)$(if $(PATCHLEVEL),.$(PATCHLEVEL)))$(EXTRAVERSION) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 399 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 400 | exports += VERSION_MAJOR VERSION_MINOR PATCHLEVEL VERSION_RESERVED EXTRAVERSION |
| 401 | exports += KERNELRELEASE KERNELVERSION |
| 402 | exports += ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC CXX |
| 403 | exports += CPP AR NM STRIP OBJCOPY OBJDUMP GDB |
| 404 | exports += MAKE AWK INSTALLKERNEL PERL PYTHON GENIDT GENOFFSET_H |
| 405 | exports += HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 406 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 407 | exports += KBUILD_CPPFLAGS NOSTDINC_FLAGS ZEPHYRINCLUDE OBJCOPYFLAGS LDFLAGS |
| 408 | exports += KBUILD_CFLAGS KBUILD_CXXFLAGS CFLAGS_GCOV KBUILD_AFLAGS AFLAGS_KERNEL |
| 409 | exports += KBUILD_ARFLAGS |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 410 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 411 | # Push the exports to sub-processes |
| 412 | export $(exports) |
| 413 | |
| 414 | # Make the exports available to third-party build systems |
| 415 | PHONY += outputexports |
| 416 | outputexports: Makefile.export |
| 417 | Makefile.export: include/config/auto.conf FORCE |
| 418 | $(call filechk,Makefile.export) |
| 419 | |
| 420 | define filechk_Makefile.export |
| 421 | (echo "# file is auto-generated, do not modify !"; \ |
| 422 | echo "BOARD=$(BOARD)"; \ |
| 423 | echo; \ |
Daniel Thompson | 4f0c6f4 | 2016-11-08 22:17:36 +0000 | [diff] [blame] | 424 | $(foreach e,$(exports),echo $(e)=$($(e));) echo; \ |
| 425 | echo "include $(O)/include/config/auto.conf";) |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 426 | endef |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 427 | |
| 428 | # Files to ignore in find ... statements |
| 429 | |
| 430 | export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ |
| 431 | -name CVS -o -name .pc -o -name .hg -o -name .git \) \ |
| 432 | -prune -o |
| 433 | export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ |
| 434 | --exclude CVS --exclude .pc --exclude .hg --exclude .git |
| 435 | |
| 436 | # =========================================================================== |
| 437 | # Rules shared between *config targets and build targets |
| 438 | |
| 439 | # Basic helpers built in scripts/ |
| 440 | PHONY += scripts_basic |
| 441 | scripts_basic: |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 442 | $(Q)$(MAKE) $(build)=scripts/basic |
| 443 | $(Q)$(MAKE) $(build)=scripts/gen_idt |
Anas Nashif | bd22748 | 2015-08-25 10:04:04 -0400 | [diff] [blame] | 444 | $(Q)$(MAKE) $(build)=scripts/gen_offset_header |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 445 | |
| 446 | # To avoid any implicit rule to kick in, define an empty command. |
| 447 | scripts/basic/%: scripts_basic ; |
| 448 | |
| 449 | PHONY += outputmakefile |
| 450 | # outputmakefile generates a Makefile in the output directory, if using a |
| 451 | # separate output directory. This allows convenient use of make in the |
| 452 | # output directory. |
| 453 | outputmakefile: |
| 454 | ifneq ($(KBUILD_SRC),) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 455 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ |
Anas Nashif | fde80d7 | 2015-08-22 14:40:43 -0400 | [diff] [blame] | 456 | $(srctree) $(objtree) $(VERSION_MAJOR) $(VERSION_MINOR) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 457 | endif |
| 458 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 459 | # To make sure we do not include .config for any of the *config targets |
| 460 | # catch them early, and hand them over to scripts/kconfig/Makefile |
| 461 | # It is allowed to specify more targets when calling make, including |
| 462 | # mixing *config targets and build targets. |
| 463 | # For example 'make oldconfig all'. |
| 464 | # Detect when mixed targets is specified, and make a second invocation |
| 465 | # of make so .config is not included in this case either (for *config). |
| 466 | |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 467 | version_h := include/generated/version.h |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 468 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 469 | no-dot-config-targets := pristine distclean clean mrproper help kconfig-help \ |
Anas Nashif | b214717 | 2015-11-01 17:55:27 -0500 | [diff] [blame] | 470 | cscope gtags TAGS tags help% %docs check% \ |
| 471 | $(version_h) headers_% kernelversion %src-pkg |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 472 | |
| 473 | config-targets := 0 |
| 474 | mixed-targets := 0 |
| 475 | dot-config := 1 |
| 476 | |
| 477 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 478 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 479 | dot-config := 0 |
| 480 | endif |
| 481 | endif |
| 482 | |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 483 | ifneq ($(filter config %config,$(MAKECMDGOALS)),) |
| 484 | config-targets := 1 |
| 485 | ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) |
| 486 | mixed-targets := 1 |
| 487 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 488 | endif |
| 489 | |
| 490 | ifeq ($(mixed-targets),1) |
| 491 | # =========================================================================== |
| 492 | # We're called with mixed targets (*config and build targets). |
| 493 | # Handle them one by one. |
| 494 | |
| 495 | PHONY += $(MAKECMDGOALS) __build_one_by_one |
| 496 | |
| 497 | $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one |
| 498 | @: |
| 499 | |
| 500 | __build_one_by_one: |
| 501 | $(Q)set -e; \ |
| 502 | for i in $(MAKECMDGOALS); do \ |
| 503 | $(MAKE) -f $(srctree)/Makefile $$i; \ |
| 504 | done |
| 505 | |
| 506 | else |
| 507 | ifeq ($(config-targets),1) |
| 508 | # =========================================================================== |
| 509 | # *config targets only - make sure prerequisites are updated, and descend |
| 510 | # in scripts/kconfig to make the *config target |
| 511 | |
| 512 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. |
| 513 | # KBUILD_DEFCONFIG may point out an alternative default configuration |
| 514 | # used for 'make defconfig' |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 515 | include $(srctree)/arch/$(subst $(DQUOTE),,$(CONFIG_ARCH))/Makefile |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 516 | export KBUILD_DEFCONFIG KBUILD_KCONFIG |
| 517 | |
| 518 | config: scripts_basic outputmakefile FORCE |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 519 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 520 | |
| 521 | %config: scripts_basic outputmakefile FORCE |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 522 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 523 | |
| 524 | else |
| 525 | # =========================================================================== |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 526 | # Build targets only - this includes zephyr, arch specific targets, clean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 527 | # targets and others. In general all targets except *config targets. |
| 528 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 529 | # Additional helpers built in scripts/ |
| 530 | # Carefully list dependencies so we do not try to build scripts twice |
| 531 | # in parallel |
| 532 | PHONY += scripts |
Dirk Brandewie | 991e9d3 | 2015-06-01 09:48:10 -0700 | [diff] [blame] | 533 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 534 | $(Q)$(MAKE) $(build)=$(@) |
| 535 | |
Andrew Boie | d9a84c5 | 2016-07-26 14:45:14 -0700 | [diff] [blame] | 536 | # arch/ must be last here so that .gnu.linkonce magic for interrupts/exceptions |
| 537 | # works as expected |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 538 | |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 539 | ifneq ($(strip $(MAKEFILE_APP_DIR)),) |
| 540 | MAKEFILE_APP := $(realpath $(MAKEFILE_APP_DIR)/Makefile.app) |
| 541 | endif |
| 542 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 543 | ifneq ($(strip $(PROJECT)),) |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 544 | ifneq ($(strip $(MAKEFILE_APP)), ) |
| 545 | include $(MAKEFILE_APP) |
| 546 | else |
Anas Nashif | a8259af | 2015-08-10 10:01:15 -0400 | [diff] [blame] | 547 | -include $(PROJECT)/Makefile.app |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 548 | endif |
Anas Nashif | a8259af | 2015-08-10 10:01:15 -0400 | [diff] [blame] | 549 | ifneq ($(strip $(KBUILD_ZEPHYR_APP)),) |
| 550 | export KBUILD_ZEPHYR_APP |
| 551 | endif |
Anas Nashif | 0c39517 | 2015-10-25 09:42:58 -0400 | [diff] [blame] | 552 | app-y := $(SOURCE_DIR) |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 553 | endif |
| 554 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 555 | |
| 556 | ifeq ($(dot-config),1) |
| 557 | # Read in config |
| 558 | -include include/config/auto.conf |
| 559 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 560 | # Read in dependencies to all Kconfig* files, make sure to run |
| 561 | # oldconfig if changes are detected. |
| 562 | -include include/config/auto.conf.cmd |
| 563 | |
| 564 | # To avoid any implicit rule to kick in, define an empty command |
| 565 | $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; |
| 566 | |
| 567 | # If .config is newer than include/config/auto.conf, someone tinkered |
| 568 | # with it and forgot to run make oldconfig. |
| 569 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so |
| 570 | # we execute the config step to be sure to catch updated Kconfig files |
| 571 | include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd |
| 572 | $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 573 | |
| 574 | else |
| 575 | # Dummy target needed, because used as prerequisite |
| 576 | include/config/auto.conf: ; |
| 577 | endif # $(dot-config) |
| 578 | |
Andrew Boie | 625acd5 | 2016-11-07 10:27:45 -0800 | [diff] [blame] | 579 | # kernel objects are built as a static library |
Dmitriy Korovkin | 9558d47 | 2016-09-09 13:59:17 -0400 | [diff] [blame] | 580 | libs-y := kernel/unified/ |
Anas Nashif | 4d090e0 | 2016-10-30 16:33:25 -0400 | [diff] [blame] | 581 | core-y := lib/ misc/ net/ boards/ ext/ subsys/ tests/ arch/ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 582 | drivers-y := drivers/ |
Dmitriy Korovkin | 9558d47 | 2016-09-09 13:59:17 -0400 | [diff] [blame] | 583 | |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 584 | ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH)) |
| 585 | export ARCH |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 586 | |
Allan Stephens | 74b98c1 | 2015-06-08 11:43:13 -0400 | [diff] [blame] | 587 | ifdef ZEPHYR_GCC_VARIANT |
| 588 | include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT) |
Anas Nashif | 83d4ea9 | 2015-06-18 18:59:37 -0400 | [diff] [blame] | 589 | else |
| 590 | $(if $(CROSS_COMPILE),, \ |
| 591 | $(error ZEPHYR_GCC_VARIANT is not set. )) |
Anas Nashif | aca245d | 2015-05-13 00:44:22 -0400 | [diff] [blame] | 592 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 593 | |
Anas Nashif | 37b1d1e | 2016-05-25 09:03:33 -0400 | [diff] [blame] | 594 | -include $(srctree)/ext/Makefile |
Anas Nashif | 1aaa11b | 2016-06-13 18:35:02 -0400 | [diff] [blame] | 595 | -include $(srctree)/lib/Makefile |
Anas Nashif | 37b1d1e | 2016-05-25 09:03:33 -0400 | [diff] [blame] | 596 | |
Juan Manuel Cruz | 2170ca7 | 2016-04-05 16:34:54 -0500 | [diff] [blame] | 597 | ifneq ($(CC),) |
| 598 | ifeq ($(shell $(CC) -v 2>&1 | grep -Ec "clang version|icx version"), 1) |
| 599 | COMPILER := clang |
| 600 | else |
| 601 | COMPILER := gcc |
| 602 | endif |
| 603 | export COMPILER |
| 604 | endif |
| 605 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 606 | # The all: target is the default when no target is given on the |
| 607 | # command line. |
| 608 | # This allow a user to issue only 'make' to build a kernel including modules |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 609 | # Defaults to zephyr, but the arch makefile usually adds further targets |
| 610 | all: zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 611 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 612 | ifdef CONFIG_READABLE_ASM |
| 613 | # Disable optimizations that make assembler listings hard to read. |
| 614 | # reorder blocks reorders the control in the function |
| 615 | # ipa clone creates specialized cloned functions |
| 616 | # partial inlining inlines only parts of functions |
| 617 | KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ |
| 618 | $(call cc-option,-fno-ipa-cp-clone,) \ |
| 619 | $(call cc-option,-fno-partial-inlining) |
| 620 | endif |
| 621 | |
Anas Nashif | eb1fdf5 | 2015-07-29 09:33:32 -0400 | [diff] [blame] | 622 | ifeq ($(CONFIG_DEBUG),y) |
Andrew Boie | 11693c1 | 2016-07-22 12:15:40 -0700 | [diff] [blame] | 623 | KBUILD_CFLAGS += -Og |
Anas Nashif | eb1fdf5 | 2015-07-29 09:33:32 -0400 | [diff] [blame] | 624 | else |
| 625 | KBUILD_CFLAGS += -Os |
| 626 | endif |
| 627 | |
Andre Guedes | 1622e4f | 2016-01-07 14:21:22 -0200 | [diff] [blame] | 628 | ifeq ($(CONFIG_STACK_CANARIES),y) |
| 629 | KBUILD_CFLAGS += $(call cc-option,-fstack-protector-all,) |
| 630 | else |
| 631 | KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector,) |
| 632 | endif |
| 633 | |
Andrew Boie | 63cea24 | 2016-06-14 10:55:57 -0700 | [diff] [blame] | 634 | ifeq ($(CONFIG_OMIT_FRAME_POINTER),y) |
| 635 | fp_arg := $(call cc-option,-fomit-frame-pointer,) |
| 636 | else |
| 637 | fp_arg := $(call cc-option,-fno-omit-frame-pointer,) |
| 638 | endif |
| 639 | KBUILD_CFLAGS += $(fp_arg) |
| 640 | KBUILD_CXXFLAGS += $(fp_arg) |
| 641 | |
Anas Nashif | 3852c8c | 2015-08-22 18:14:42 -0400 | [diff] [blame] | 642 | KBUILD_CFLAGS += $(subst $(DQUOTE),,$(CONFIG_COMPILER_OPT)) |
| 643 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 644 | export LDFLAG_LINKERCMD |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 645 | |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 646 | ifeq ($(SOC_SERIES),) |
| 647 | SOC_PATH = $(SOC_NAME) |
| 648 | else |
| 649 | SOC_PATH = $(SOC_FAMILY)/$(SOC_SERIES) |
| 650 | endif |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 651 | include arch/$(ARCH)/Makefile |
Anas Nashif | d9af71b | 2015-09-23 15:54:28 -0400 | [diff] [blame] | 652 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 653 | KBUILD_CFLAGS += $(CFLAGS) |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 654 | KBUILD_CXXFLAGS += $(CXXFLAGS) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 655 | KBUILD_AFLAGS += $(CFLAGS) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 656 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 657 | |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 658 | ifeq ($(COMPILER),clang) |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 659 | KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) |
| 660 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) |
| 661 | KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) |
| 662 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) |
| 663 | # Quiet clang warning: comparison of unsigned expression < 0 is always false |
| 664 | KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) |
| 665 | else |
| 666 | |
| 667 | # This warning generated too much noise in a regular build. |
| 668 | # Use make W=1 to enable this warning (see scripts/Makefile.build) |
| 669 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) |
| 670 | KBUILD_CFLAGS += $(call cc-option,-fno-reorder-functions) |
| 671 | KBUILD_CFLAGS += $(call cc-option,-fno-defer-pop) |
| 672 | endif |
| 673 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 674 | # We trigger additional mismatches with less inlining |
| 675 | ifdef CONFIG_DEBUG_SECTION_MISMATCH |
| 676 | KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) |
| 677 | endif |
| 678 | |
| 679 | # arch Makefile may override CC so keep this after arch Makefile is included |
| 680 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
Anas Nashif | ef2fc59 | 2016-04-17 11:18:39 +0800 | [diff] [blame] | 681 | NOSTDINC_FLAGS += -isystem $(shell $(CC) -print-file-name=include-fixed) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 682 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
| 683 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 684 | # disable pointer signed / unsigned warnings in gcc 4.0 |
| 685 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) |
| 686 | |
| 687 | # disable invalid "can't wrap" optimizations for signed / pointers |
| 688 | KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) |
| 689 | |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 690 | # generate an extra file that specifies the maximum amount of stack used, |
| 691 | # on a per-function basis. |
Anas Nashif | 9fe306b | 2015-12-05 09:36:38 -0500 | [diff] [blame] | 692 | ifdef CONFIG_STACK_USAGE |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 693 | KBUILD_CFLAGS += $(call cc-option,-fstack-usage) |
Anas Nashif | 9fe306b | 2015-12-05 09:36:38 -0500 | [diff] [blame] | 694 | endif |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 695 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 696 | |
| 697 | # disallow errors like 'EXPORT_GPL(foo);' with missing header |
| 698 | KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) |
| 699 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 700 | # Prohibit date/time macros, which would make the build non-deterministic |
Anas Nashif | 47f8088 | 2015-06-22 19:44:37 -0400 | [diff] [blame] | 701 | # KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 702 | |
| 703 | # use the deterministic mode of AR if available |
| 704 | KBUILD_ARFLAGS := $(call ar-option,D) |
| 705 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 706 | include $(srctree)/scripts/Makefile.extrawarn |
| 707 | |
| 708 | # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments |
| 709 | KBUILD_CPPFLAGS += $(KCPPFLAGS) |
| 710 | KBUILD_AFLAGS += $(KAFLAGS) |
| 711 | KBUILD_CFLAGS += $(KCFLAGS) |
| 712 | |
| 713 | # Use --build-id when available. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 714 | |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 715 | LINKFLAGPREFIX ?= -Wl, |
Anas Nashif | 204b66d | 2015-12-31 12:08:23 -0500 | [diff] [blame] | 716 | LDFLAGS_zephyr += $(LDFLAGS) |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 717 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)-X) |
| 718 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)-N) |
| 719 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)--gc-sections) |
| 720 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)--build-id=none) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 721 | |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 722 | LD_TOOLCHAIN ?= -D__GCC_LINKER_CMD__ |
Juan Manuel Cruz | 1c8f5a7 | 2015-04-30 17:19:04 -0500 | [diff] [blame] | 723 | |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 724 | ifdef CONFIG_HAVE_CUSTOM_LINKER_SCRIPT |
Benjamin Walsh | ec89a10 | 2016-08-15 17:24:28 -0400 | [diff] [blame] | 725 | KBUILD_LDS := $(subst $(DQUOTE),,$(PROJECT_BASE)/$(CONFIG_CUSTOM_LINKER_SCRIPT)) |
| 726 | ifeq ($(wildcard $(KBUILD_LDS)),) |
| 727 | KBUILD_LDS := $(subst $(DQUOTE),,$(CONFIG_CUSTOM_LINKER_SCRIPT)) |
| 728 | endif |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 729 | else |
| 730 | # Try a board specific linker file |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 731 | KBUILD_LDS := $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/linker.ld |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 732 | |
| 733 | # If not available, try an SoC specific linker file |
| 734 | ifeq ($(wildcard $(KBUILD_LDS)),) |
Andrew Boie | ff872dc | 2016-05-04 13:13:56 -0700 | [diff] [blame] | 735 | KBUILD_LDS := $(srctree)/arch/$(ARCH)/soc/$(SOC_PATH)/linker.ld |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 736 | endif |
| 737 | endif |
| 738 | |
| 739 | export LD_TOOLCHAIN KBUILD_LDS |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 740 | |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 741 | ifdef MAKEFILE_TOOLCHAIN_DO_PASS2 |
| 742 | # KBUILD_CFLAGS known at this point. |
| 743 | # We can now determine which multilib libraries to use |
| 744 | include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT) |
| 745 | endif |
| 746 | |
Daniel Thompson | 389ed15 | 2016-09-11 20:51:22 +0100 | [diff] [blame] | 747 | QEMU = $(addsuffix /,$(QEMU_BIN_PATH))$(QEMU_$(ARCH)) |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 748 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 749 | # The all: target is the default when no target is given on the |
| 750 | # command line. |
| 751 | # This allow a user to issue only 'make' to build a kernel including modules |
| 752 | # Defaults to zephyr, but the arch makefile usually adds further targets |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 753 | all: $(KERNEL_BIN_NAME) $(KERNEL_STAT_NAME) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 754 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 755 | # Default kernel image to build when no specific target is given. |
| 756 | # KBUILD_IMAGE may be overruled on the command line or |
| 757 | # set in the environment |
| 758 | # Also any assignments in arch/$(ARCH)/Makefile take precedence over |
| 759 | # this default value |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 760 | export KBUILD_IMAGE ?= zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 761 | |
Anas Nashif | c0078cf | 2015-10-25 14:02:19 -0400 | [diff] [blame] | 762 | zephyr-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(drivers-y) \ |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 763 | $(libs-y))) |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 764 | |
| 765 | # Workaround for some make notdir implementations that require |
| 766 | # the paramenter not to end in "/". |
| 767 | zephyr-app-dir-root-name := $(patsubst %/,%, $(SOURCE_DIR)) |
| 768 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 769 | zephyr-app-dir-root := $(abspath $(patsubst %, %/.., $(SOURCE_DIR))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 770 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 771 | zephyr-alldirs := $(sort $(zephyr-dirs) $(SOURCE_DIR) $(patsubst %/,%,$(filter %/, \ |
Anas Nashif | ce5dc6a | 2015-12-06 20:02:33 -0500 | [diff] [blame] | 772 | $(core-) $(drivers-) $(libs-) $(app-)))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 773 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 774 | core-y := $(patsubst %/, %/built-in.o, $(core-y)) |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 775 | app-y := $(patsubst %, %/built-in.o, $(notdir $(zephyr-app-dir-root-name))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 776 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 777 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
| 778 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) |
| 779 | libs-y := $(libs-y1) $(libs-y2) |
| 780 | |
Andrew Boie | d9a84c5 | 2016-07-26 14:45:14 -0700 | [diff] [blame] | 781 | # core-y must be last here. several arches use .gnu.linkonce magic |
| 782 | # to register interrupt or exception handlers, and defaults under |
| 783 | # arch/ (part of core-y) must be linked after drivers or libs. |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 784 | export KBUILD_ZEPHYR_MAIN := $(drivers-y) $(libs-y) $(core-y) |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 785 | export LDFLAGS_zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 786 | |
Anas Nashif | 369cf08 | 2015-05-17 08:55:21 -0400 | [diff] [blame] | 787 | ALL_LIBS += $(TOOLCHAIN_LIBS) |
| 788 | export ALL_LIBS |
| 789 | |
Daniel Thompson | 608abd9 | 2016-09-29 17:49:51 -0700 | [diff] [blame] | 790 | zephyr-deps := $(KBUILD_LDS) $(KBUILD_ZEPHYR_MAIN) $(app-y) $(ALL_LIBS) |
| 791 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 792 | LINK_LIBS := $(foreach l,$(ALL_LIBS), -l$(l)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 793 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 794 | OUTPUT_FORMAT ?= elf32-i386 |
| 795 | OUTPUT_ARCH ?= i386 |
| 796 | |
Kumar Gala | 44b712d | 2016-06-03 10:52:12 -0500 | [diff] [blame] | 797 | quiet_cmd_ar_target = AR $@ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 798 | # Do not put lib.a into libzephyr.a. lib.a files are to be linked separately to |
| 799 | # the final image |
Dmitriy Korovkin | 9558d47 | 2016-09-09 13:59:17 -0400 | [diff] [blame] | 800 | cmd_ar_target = rm -f $@; $(AR) rcT$(KBUILD_ARFLAGS) $@ \ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 801 | $(filter-out %/lib.a, $(KBUILD_ZEPHYR_MAIN)) |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 802 | libzephyr.a: $(zephyr-deps) |
Kumar Gala | 44b712d | 2016-06-03 10:52:12 -0500 | [diff] [blame] | 803 | $(call cmd,ar_target) |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 804 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 805 | quiet_cmd_create-lnk = LINK $@ |
| 806 | cmd_create-lnk = \ |
| 807 | ( \ |
| 808 | echo $(LDFLAGS_zephyr); \ |
Anas Nashif | d53c237 | 2016-06-13 18:31:00 -0400 | [diff] [blame] | 809 | echo "$(LINKFLAGPREFIX)-Map=$(KERNEL_NAME).map"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 810 | echo "-L $(objtree)/include/generated"; \ |
| 811 | echo "-u _OffsetAbsSyms -u _ConfigAbsSyms"; \ |
| 812 | echo "-e __start"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 813 | echo "$(LINKFLAGPREFIX)--start-group"; \ |
| 814 | echo "$(LINKFLAGPREFIX)--whole-archive"; \ |
| 815 | echo "$(KBUILD_ZEPHYR_APP)"; \ |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 816 | echo "$(app-y)"; \ |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 817 | echo "libzephyr.a"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 818 | echo "$(LINKFLAGPREFIX)--no-whole-archive"; \ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 819 | echo "$(filter %/lib.a, $(KBUILD_ZEPHYR_MAIN))"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 820 | echo "$(objtree)/arch/$(ARCH)/core/offsets/offsets.o"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 821 | echo "$(LINKFLAGPREFIX)--end-group"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 822 | echo "$(LIB_INCLUDE_DIR) $(LINK_LIBS)"; \ |
| 823 | ) > $@ |
| 824 | |
Anas Nashif | a0cf03b | 2016-05-14 21:56:35 -0400 | [diff] [blame] | 825 | $(KERNEL_NAME).lnk: $(zephyr-deps) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 826 | $(call cmd,create-lnk) |
| 827 | |
Anas Nashif | 872676c | 2016-02-02 07:58:26 -0500 | [diff] [blame] | 828 | linker.cmd: $(zephyr-deps) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 829 | $(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P \ |
| 830 | $(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) -I$(srctree)/include \ |
Anas Nashif | 20fe678 | 2016-01-31 04:46:37 -0500 | [diff] [blame] | 831 | -I$(objtree)/include/generated $(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 832 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 833 | PREBUILT_KERNEL = $(KERNEL_NAME)_prebuilt.elf |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 834 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 835 | $(PREBUILT_KERNEL): $(zephyr-deps) libzephyr.a $(KBUILD_ZEPHYR_APP) $(app-y) linker.cmd $(KERNEL_NAME).lnk |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 836 | $(Q)$(CC) -T linker.cmd @$(KERNEL_NAME).lnk -o $@ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 837 | |
| 838 | quiet_cmd_gen_idt = SIDT $@ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 839 | cmd_gen_idt = \ |
| 840 | ( \ |
| 841 | $(OBJCOPY) -I $(OUTPUT_FORMAT) -O binary -j intList $< isrList.bin && \ |
| 842 | $(GENIDT) -i isrList.bin -n $(CONFIG_IDT_NUM_VECTORS) -o staticIdt.bin \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 843 | -m irq_int_vector_map.bin \ |
Andrew Boie | 0d03e32 | 2016-07-26 11:36:31 -0700 | [diff] [blame] | 844 | -l $(CONFIG_MAX_IRQ_LINES) $(GENIDT_EXTRA_ARGS) && \ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 845 | $(OBJCOPY) -I binary -B $(OUTPUT_ARCH) -O $(OUTPUT_FORMAT) \ |
| 846 | --rename-section .data=staticIdt staticIdt.bin staticIdt.o && \ |
| 847 | $(OBJCOPY) -I binary -B $(OUTPUT_ARCH) -O $(OUTPUT_FORMAT) \ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 848 | --rename-section .data=irq_int_vector_map irq_int_vector_map.bin \ |
| 849 | irq_int_vector_map.o && \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 850 | rm staticIdt.bin irq_int_vector_map.bin isrList.bin \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 851 | ) |
| 852 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 853 | staticIdt.o: $(PREBUILT_KERNEL) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 854 | $(call cmd,gen_idt) |
| 855 | |
| 856 | quiet_cmd_lnk_elf = LINK $@ |
| 857 | cmd_lnk_elf = \ |
| 858 | ( \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 859 | $(CC) -T linker.cmd @$(KERNEL_NAME).lnk staticIdt.o \ |
| 860 | irq_int_vector_map.o -o $@; \ |
Ido Yariv | a8c48ea | 2016-01-04 14:59:09 -0500 | [diff] [blame] | 861 | ${OBJCOPY} --change-section-address intList=${CONFIG_PHYS_LOAD_ADDR} $@ elf.tmp;\ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 862 | $(OBJCOPY) -R intList elf.tmp $@; \ |
| 863 | rm elf.tmp \ |
| 864 | ) |
| 865 | |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 866 | ASSERT_WARNING_STR := \ |
| 867 | "\n ------------------------------------------------------------" \ |
| 868 | "\n --- WARNING: __ASSERT() statements are globally ENABLED ---" \ |
| 869 | "\n --- The kernel will run more slowly and uses more memory ---" \ |
| 870 | "\n ------------------------------------------------------------\n\n" \ |
| 871 | |
| 872 | WARN_ABOUT_ASSERT := $(if $(CONFIG_ASSERT),echo -e -n $(ASSERT_WARNING_STR),true) |
| 873 | |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 874 | |
| 875 | DEPRECATION_WARNING_STR := \ |
| 876 | "\n WARNING: The board '$(BOARD)' is deprecated and will be" \ |
| 877 | "\n removed in version $(CONFIG_BOARD_DEPRECATED)\n\n" |
| 878 | |
| 879 | WARN_ABOUT_DEPRECATION := $(if $(CONFIG_BOARD_DEPRECATED),echo -e \ |
| 880 | -n $(DEPRECATION_WARNING_STR),true) |
| 881 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 882 | ifeq ($(ARCH),x86) |
Andrew Boie | caf19b2 | 2016-10-21 10:39:43 -0700 | [diff] [blame] | 883 | $(KERNEL_ELF_NAME): staticIdt.o linker.cmd |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 884 | $(call cmd,lnk_elf) |
Andy Ross | 4cc228b | 2016-10-03 12:20:39 -0700 | [diff] [blame] | 885 | @$(srctree)/scripts/check_link_map.py $(KERNEL_NAME).map |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 886 | @$(WARN_ABOUT_ASSERT) |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 887 | @$(WARN_ABOUT_DEPRECATION) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 888 | else |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 889 | $(KERNEL_ELF_NAME): $(PREBUILT_KERNEL) |
| 890 | @cp $(PREBUILT_KERNEL) $(KERNEL_ELF_NAME) |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 891 | @$(WARN_ABOUT_ASSERT) |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 892 | @$(WARN_ABOUT_DEPRECATION) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 893 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 894 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 895 | |
| 896 | quiet_cmd_gen_bin = BIN $@ |
| 897 | cmd_gen_bin = \ |
| 898 | ( \ |
| 899 | $(OBJDUMP) -S $< > $(KERNEL_NAME).lst; \ |
| 900 | $(OBJCOPY) -S -O binary -R .note -R .comment -R COMMON -R .eh_frame $< $@; \ |
| 901 | $(STRIP) -s -o $(KERNEL_NAME).strip $<; \ |
| 902 | ) |
| 903 | |
| 904 | $(KERNEL_BIN_NAME): $(KERNEL_ELF_NAME) |
| 905 | $(call cmd,gen_bin) |
| 906 | |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 907 | quiet_cmd_gen_hex = HEX $@ |
| 908 | cmd_gen_hex = \ |
| 909 | ( \ |
| 910 | $(OBJCOPY) -S -O ihex -R .note -R .comment -R COMMON -R .eh_frame $< $@; \ |
| 911 | ) |
| 912 | |
| 913 | $(KERNEL_HEX_NAME): $(KERNEL_ELF_NAME) |
| 914 | $(call cmd,gen_hex) |
| 915 | |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 916 | $(KERNEL_STAT_NAME): $(KERNEL_BIN_NAME) $(KERNEL_ELF_NAME) |
| 917 | @$(READELF) -e $(KERNEL_ELF_NAME) > $@ |
| 918 | |
| 919 | ram_report: $(KERNEL_STAT_NAME) |
| 920 | @$(srctree)/scripts/size_report -r -o $(O) |
| 921 | rom_report: $(KERNEL_STAT_NAME) |
| 922 | @$(srctree)/scripts/size_report -F -o $(O) |
| 923 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 924 | zephyr: $(zephyr-deps) $(KERNEL_BIN_NAME) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 925 | |
| 926 | # The actual objects are generated when descending, |
| 927 | # make sure no implicit rule kicks in |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 928 | $(sort $(zephyr-deps)): $(zephyr-dirs) zephyr-app-dir ; |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 929 | |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 930 | # Handle descending into subdirectories listed in $(zephyr-dirs) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 931 | # Preset locale variables to speed up the build process. Limit locale |
| 932 | # tweaks to this spot to avoid wrong language settings when running |
| 933 | # make menuconfig etc. |
| 934 | # Error messages still appears in the original language |
| 935 | |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 936 | PHONY += $(zephyr-dirs) |
| 937 | $(zephyr-dirs): prepare scripts |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 938 | $(Q)$(MAKE) $(build)=$@ |
| 939 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 940 | PHONY += zephyr-app-dir |
| 941 | zephyr-app-dir: prepare scripts |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 942 | $(Q)$(MAKE) $(build)=$(notdir $(zephyr-app-dir-root-name)) \ |
| 943 | srctree=$(zephyr-app-dir-root) |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 944 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 945 | # Things we need to do before we recursively start building the kernel |
| 946 | # or the modules are listed in "prepare". |
| 947 | # A multi level approach is used. prepareN is processed before prepareN-1. |
| 948 | # archprepare is used in arch Makefiles and when processed asm symlink, |
| 949 | # version.h and scripts_basic is processed / created. |
| 950 | |
| 951 | # Listed in dependency order |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 952 | PHONY += prepare prepare1 prepare2 prepare3 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 953 | |
| 954 | # prepare3 is used to check if we are building in a separate output directory, |
| 955 | # and if so do: |
| 956 | # 1) Check that make has not been executed in the kernel src $(srctree) |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 957 | prepare3: |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 958 | ifneq ($(KBUILD_SRC),) |
| 959 | @$(kecho) ' Using $(srctree) as source for kernel' |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 960 | $(Q)if [ -f $(srctree)/.config ]; then \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 961 | echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ |
| 962 | echo >&2 " in the '$(srctree)' directory.";\ |
| 963 | /bin/false; \ |
| 964 | fi; |
| 965 | endif |
| 966 | |
| 967 | # prepare2 creates a makefile if using a separate output directory |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 968 | prepare2: prepare3 outputmakefile |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 969 | |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 970 | prepare1: prepare2 $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 971 | include/config/auto.conf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 972 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 973 | archprepare_common = $(strip \ |
Anas Nashif | b214717 | 2015-11-01 17:55:27 -0500 | [diff] [blame] | 974 | prepare1 scripts_basic \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 975 | ) |
| 976 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 977 | |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 978 | archprepare = $(strip \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 979 | $(archprepare_common) \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 980 | ) |
| 981 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 982 | # All the preparing.. |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 983 | prepare: $(archprepare) FORCE |
| 984 | $(Q)$(MAKE) $(build)=. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 985 | |
| 986 | # Generate some files |
| 987 | # --------------------------------------------------------------------------- |
| 988 | |
| 989 | # KERNELRELEASE can change from a few different places, meaning version.h |
| 990 | # needs to be updated, so this check is forced on all builds |
| 991 | |
Anas Nashif | 71bed17 | 2015-06-23 19:10:06 -0400 | [diff] [blame] | 992 | VERSION_MAJOR_HEX=$(shell printf '%02x\n' ${VERSION_MAJOR}) |
| 993 | VERSION_MINOR_HEX=$(shell printf '%02x\n' ${VERSION_MINOR}) |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 994 | PATCHLEVEL_HEX=$(shell printf '%02x\n' ${PATCHLEVEL}) |
Anas Nashif | 8ad4878 | 2015-06-23 10:29:17 -0400 | [diff] [blame] | 995 | VERSION_RESERVED_HEX=00 |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 996 | KERNEL_VERSION_HEX=0x$(VERSION_MAJOR_HEX)$(VERSION_MINOR_HEX)$(PATCHLEVEL_HEX) |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 997 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 998 | define filechk_version.h |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 999 | (echo "#ifndef _KERNEL_VERSION_H_"; \ |
| 1000 | echo "#define _KERNEL_VERSION_H_"; \ |
| 1001 | echo ;\ |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1002 | (echo \#define ZEPHYR_VERSION_CODE $(shell \ |
| 1003 | expr $(VERSION_MAJOR) \* 65536 + 0$(VERSION_MINOR) \* 256 + 0$(PATCHLEVEL)); \ |
| 1004 | echo '#define ZEPHYR_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';); \ |
| 1005 | echo ;\ |
Anas Nashif | 9c72cf5 | 2015-08-25 10:44:41 -0400 | [diff] [blame] | 1006 | echo "#define KERNELVERSION \\"; \ |
Anas Nashif | 71bed17 | 2015-06-23 19:10:06 -0400 | [diff] [blame] | 1007 | echo "$(KERNEL_VERSION_HEX)$(VERSION_RESERVED_HEX)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1008 | echo "#define KERNEL_VERSION_NUMBER $(KERNEL_VERSION_HEX)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1009 | echo "#define KERNEL_VERSION_MAJOR $(VERSION_MAJOR)"; \ |
| 1010 | echo "#define KERNEL_VERSION_MINOR $(VERSION_MINOR)"; \ |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1011 | echo "#define KERNEL_PATCHLEVEL $(PATCHLEVEL)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1012 | echo "#define KERNEL_VERSION_STRING \"$(KERNELVERSION)\""; \ |
| 1013 | echo; \ |
| 1014 | echo "#endif /* _KERNEL_VERSION_H_ */";) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1015 | endef |
| 1016 | |
| 1017 | $(version_h): $(srctree)/Makefile FORCE |
| 1018 | $(call filechk,version.h) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1019 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1020 | PHONY += headerdep |
| 1021 | headerdep: |
| 1022 | $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ |
| 1023 | $(srctree)/scripts/headerdep.pl -I$(srctree)/include |
| 1024 | |
| 1025 | # --------------------------------------------------------------------------- |
| 1026 | |
| 1027 | PHONY += depend dep |
| 1028 | depend dep: |
| 1029 | @echo '*** Warning: make $@ is unnecessary now.' |
| 1030 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1031 | ### |
| 1032 | # Cleaning is done on three levels. |
| 1033 | # make clean Delete most generated files |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1034 | # make mrproper Delete the current configuration, and all generated files |
| 1035 | # make distclean Remove editor backup files, patch leftover files and the like |
| 1036 | |
| 1037 | # Directories & files removed with 'make clean' |
| 1038 | CLEAN_DIRS += $(MODVERDIR) |
| 1039 | |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 1040 | CLEAN_FILES += misc/generated/sysgen/kernel_main.c \ |
Anas Nashif | 8b45f4e | 2015-10-21 07:24:39 -0400 | [diff] [blame] | 1041 | misc/generated/sysgen/sysgen.h \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1042 | misc/generated/sysgen/prj.mdef \ |
Kumar Gala | 62a9f9c | 2016-07-09 09:30:52 -0500 | [diff] [blame] | 1043 | misc/generated/sysgen/micro_private_types.h \ |
| 1044 | misc/generated/sysgen/kernel_main.h \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1045 | .old_version .tmp_System.map .tmp_version \ |
| 1046 | .tmp_* System.map *.lnk *.map *.elf *.lst \ |
Kumar Gala | bdd7764 | 2016-10-24 11:00:32 -0500 | [diff] [blame] | 1047 | *.bin *.hex *.stat *.strip staticIdt.o linker.cmd |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1048 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1049 | # Directories & files removed with 'make mrproper' |
| 1050 | MRPROPER_DIRS += include/config usr/include include/generated \ |
| 1051 | arch/*/include/generated .tmp_objdiff |
Anas Nashif | 1e8dc5a | 2015-04-24 18:32:55 -0400 | [diff] [blame] | 1052 | MRPROPER_FILES += .config .config.old .version $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1053 | Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ |
| 1054 | signing_key.priv signing_key.x509 x509.genkey \ |
| 1055 | extra_certificates signing_key.x509.keyid \ |
| 1056 | signing_key.x509.signer |
| 1057 | |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1058 | # clean - Delete most |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1059 | # |
| 1060 | clean: rm-dirs := $(CLEAN_DIRS) |
| 1061 | clean: rm-files := $(CLEAN_FILES) |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 1062 | clean-dirs := $(addprefix _clean_, . $(zephyr-alldirs) ) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1063 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 1064 | PHONY += clean-dirs-target clean archclean zephyrclean |
| 1065 | clean-dirs-target: |
| 1066 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$(clean-dirs)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1067 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1068 | clean: archclean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1069 | |
| 1070 | # mrproper - Delete all generated files, including .config |
| 1071 | # |
| 1072 | mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) |
| 1073 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1074 | mrproper-dirs := $(addprefix _mrproper_,scripts) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1075 | |
| 1076 | PHONY += $(mrproper-dirs) mrproper archmrproper |
| 1077 | $(mrproper-dirs): |
| 1078 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) |
| 1079 | |
| 1080 | mrproper: clean archmrproper $(mrproper-dirs) |
| 1081 | $(call cmd,rmdirs) |
| 1082 | $(call cmd,rmfiles) |
| 1083 | |
| 1084 | # distclean |
| 1085 | # |
| 1086 | PHONY += distclean |
| 1087 | |
| 1088 | distclean: mrproper |
| 1089 | @find $(srctree) $(RCS_FIND_IGNORE) \ |
| 1090 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
| 1091 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ |
| 1092 | -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \ |
| 1093 | -type f -print | xargs rm -f |
| 1094 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1095 | # Brief documentation of the typical targets used |
| 1096 | # --------------------------------------------------------------------------- |
| 1097 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1098 | boards := $(wildcard $(srctree)/boards/*/*/*_defconfig) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1099 | boards := $(sort $(notdir $(boards))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1100 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1101 | kconfig-help: |
| 1102 | @echo 'Configuration targets:' |
| 1103 | @echo '' |
| 1104 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help |
| 1105 | @echo '' |
| 1106 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1107 | help: |
| 1108 | @echo 'Cleaning targets:' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1109 | @echo ' clean - Remove most generated files but keep configuration and backup files' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1110 | @echo ' mrproper - Remove all generated files + config + various backup files' |
| 1111 | @echo ' distclean - mrproper + remove editor backup and patch files' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1112 | @echo ' pristine - Remove the output directory with all generated files' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1113 | @echo '' |
| 1114 | @echo 'Configuration targets:' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1115 | @echo '' |
| 1116 | @echo ' run <make kconfig-help>' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1117 | @echo '' |
| 1118 | @echo 'Other generic targets:' |
| 1119 | @echo ' all - Build all targets marked with [*]' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1120 | @echo '* zephyr - Build a zephyr application' |
| 1121 | @echo ' qemu - Build a zephyr application and run it in qemu' |
Andrew Boie | be13e26 | 2016-06-23 11:33:55 -0700 | [diff] [blame] | 1122 | @echo ' qemugdb - Same as 'qemu' but start a GDB server on port 1234' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1123 | @echo ' flash - Build and flash an application' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1124 | @echo ' debug - Build and debug an application using GDB' |
Anas Nashif | 1b4742f | 2016-09-24 15:07:28 -0400 | [diff] [blame] | 1125 | @echo ' ram_report - Build and create RAM usage report' |
| 1126 | @echo ' rom_report - Build and create ROM usage report' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1127 | @echo '' |
Anas Nashif | 10bb38c | 2015-12-17 08:54:35 -0500 | [diff] [blame] | 1128 | @echo 'Supported Boards:' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1129 | @echo '' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1130 | @echo ' To build an image for one of the supported boards below, run:' |
| 1131 | @echo '' |
| 1132 | @echo ' make BOARD=<BOARD NAME>' |
| 1133 | @echo ' in the application directory.' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1134 | @echo '' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1135 | @echo ' To flash the image (if supported), run:' |
| 1136 | @echo '' |
| 1137 | @echo ' make BOARD=<BOARD NAME> flash' |
| 1138 | @echo '' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1139 | @$(if $(boards), \ |
| 1140 | $(foreach b, $(boards), \ |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1141 | printf " make BOARD=%-24s - Build for %s\\n" $(subst _defconfig,,$(b)) $(subst _defconfig,,$(b));) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1142 | echo '') |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1143 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1144 | @echo '' |
| 1145 | @echo 'Build flags:' |
| 1146 | @echo '' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1147 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' |
| 1148 | @echo ' make V=2 [targets] 2 => give reason for rebuild of target' |
| 1149 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' |
| 1150 | @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' |
| 1151 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' |
| 1152 | @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' |
| 1153 | @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' |
| 1154 | @echo ' 1: warnings which may be relevant and do not occur too often' |
| 1155 | @echo ' 2: warnings which occur quite often but may still be relevant' |
| 1156 | @echo ' 3: more obscure warnings, can most likely be ignored' |
| 1157 | @echo ' Multiple levels can be combined with W=12 or W=123' |
| 1158 | @echo '' |
| 1159 | @echo 'Execute "make" or "make all" to build all targets marked with [*] ' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1160 | |
| 1161 | |
| 1162 | help-board-dirs := $(addprefix help-,$(board-dirs)) |
| 1163 | |
| 1164 | help-boards: $(help-board-dirs) |
| 1165 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1166 | boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/boards/*/$*/*_defconfig))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1167 | |
| 1168 | $(help-board-dirs): help-%: |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1169 | @echo 'Architecture specific targets ($(ARCH) $*):' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1170 | @$(if $(boards-per-dir), \ |
| 1171 | $(foreach b, $(boards-per-dir), \ |
| 1172 | printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ |
| 1173 | echo '') |
| 1174 | |
| 1175 | |
| 1176 | # Documentation targets |
| 1177 | # --------------------------------------------------------------------------- |
Anas Nashif | 486a2a1 | 2015-07-30 07:06:40 -0400 | [diff] [blame] | 1178 | %docs: FORCE |
| 1179 | $(Q)$(MAKE) -C doc htmldocs |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1180 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 1181 | clean: clean-dirs-target |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1182 | $(call cmd,rmdirs) |
| 1183 | $(call cmd,rmfiles) |
| 1184 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ |
Anas Nashif | 801874d | 2015-12-06 09:09:03 -0500 | [diff] [blame] | 1185 | \( -name '*.[oas]' -o -name '.*.cmd' \ |
| 1186 | -o -name '*.dwo' -o -name '.*.d' -o -name '.*.tmp' \ |
Anas Nashif | 3bdae61 | 2015-12-06 19:38:53 -0500 | [diff] [blame] | 1187 | -o -name '.tmp_*.o.*' -o -name '*.gcno' \) -type f \ |
| 1188 | -print | xargs rm -f |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1189 | |
| 1190 | # Generate tags for editors |
| 1191 | # --------------------------------------------------------------------------- |
| 1192 | quiet_cmd_tags = GEN $@ |
| 1193 | cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ |
| 1194 | |
| 1195 | tags TAGS cscope gtags: FORCE |
| 1196 | $(call cmd,tags) |
| 1197 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1198 | endif #ifeq ($(config-targets),1) |
| 1199 | endif #ifeq ($(mixed-targets),1) |
| 1200 | |
Juan Manuel Cruz | ef07b96 | 2015-06-05 12:58:50 -0500 | [diff] [blame] | 1201 | PHONY += checkstack kernelversion image_name |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1202 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1203 | CHECKSTACK_ARCH := $(ARCH) |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1204 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1205 | checkstack: |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1206 | $(OBJDUMP) -d $(O)/$(KERNEL_ELF_NAME) | \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1207 | $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
| 1208 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1209 | kernelversion: |
| 1210 | @echo $(KERNELVERSION) |
| 1211 | |
| 1212 | image_name: |
| 1213 | @echo $(KBUILD_IMAGE) |
| 1214 | |
| 1215 | # Clear a bunch of variables before executing the submake |
| 1216 | tools/: FORCE |
| 1217 | $(Q)mkdir -p $(objtree)/tools |
| 1218 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ |
| 1219 | |
| 1220 | tools/%: FORCE |
| 1221 | $(Q)mkdir -p $(objtree)/tools |
| 1222 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $* |
| 1223 | |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1224 | QEMU_FLAGS = $(QEMU_FLAGS_$(ARCH)) -pidfile qemu.pid |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1225 | |
Fabrice Olivero | 35dcc0a | 2016-04-15 10:46:30 +0200 | [diff] [blame] | 1226 | ifneq ($(QEMU_PTY),) |
| 1227 | QEMU_FLAGS += -serial pty |
| 1228 | else |
Andrew Boie | 84fed36 | 2015-07-16 10:59:01 -0700 | [diff] [blame] | 1229 | ifneq ($(QEMU_PIPE),) |
Andrew Boie | 22c3fa3 | 2015-07-29 14:25:29 -0700 | [diff] [blame] | 1230 | # Send console output to a pipe, used for running automated sanity tests |
| 1231 | QEMU_FLAGS += -serial pipe:$(QEMU_PIPE) |
Andrew Boie | 84fed36 | 2015-07-16 10:59:01 -0700 | [diff] [blame] | 1232 | else |
Andrew Boie | 206d0b4 | 2016-06-29 13:33:05 -0700 | [diff] [blame] | 1233 | QEMU_FLAGS += -serial mon:stdio |
Andrew Boie | 84fed36 | 2015-07-16 10:59:01 -0700 | [diff] [blame] | 1234 | endif |
Fabrice Olivero | 35dcc0a | 2016-04-15 10:46:30 +0200 | [diff] [blame] | 1235 | endif |
Andrew Boie | 84fed36 | 2015-07-16 10:59:01 -0700 | [diff] [blame] | 1236 | |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 1237 | qemu: zephyr |
Andrew Boie | 84fed36 | 2015-07-16 10:59:01 -0700 | [diff] [blame] | 1238 | $(if $(QEMU_PIPE),,@echo "To exit from QEMU enter: 'CTRL+a, x'") |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1239 | @echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(ARCH))' |
Andrew Boie | e79c960 | 2016-03-10 16:02:24 -0800 | [diff] [blame] | 1240 | $(if $(CONFIG_X86_IAMCU),python $(ZEPHYR_BASE)/scripts/qemu-machine-hack.py $(KERNEL_ELF_NAME)) |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1241 | $(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_ELF_NAME) |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1242 | |
Andrew Boie | be13e26 | 2016-06-23 11:33:55 -0700 | [diff] [blame] | 1243 | qemugdb: QEMU_EXTRA_FLAGS += -s -S |
| 1244 | qemugdb: qemu |
| 1245 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1246 | -include $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/Makefile.board |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1247 | ifneq ($(FLASH_SCRIPT),) |
Anas Nashif | 51be9a5 | 2016-01-15 12:18:53 -0500 | [diff] [blame] | 1248 | flash: zephyr |
| 1249 | @echo "Flashing $(BOARD_NAME)" |
| 1250 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/support/$(FLASH_SCRIPT) flash |
| 1251 | |
Anas Nashif | a49762c | 2016-02-01 22:24:21 -0500 | [diff] [blame] | 1252 | debug: zephyr |
| 1253 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/support/$(FLASH_SCRIPT) debug |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1254 | else |
| 1255 | flash: FORCE |
| 1256 | @echo Flashing not supported with this board. |
| 1257 | @echo Please check the documentation for alternate instructions. |
| 1258 | |
| 1259 | debug: FORCE |
| 1260 | @echo Debugging not supported with this board. |
| 1261 | @echo Please check the documentation for alternate instructions. |
| 1262 | endif |
Anas Nashif | a49762c | 2016-02-01 22:24:21 -0500 | [diff] [blame] | 1263 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1264 | # Single targets |
| 1265 | # --------------------------------------------------------------------------- |
| 1266 | # Single targets are compatible with: |
| 1267 | # - build with mixed source and output |
| 1268 | # - build with separate output dir 'make O=...' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1269 | # |
| 1270 | # target-dir => where to store outputfile |
| 1271 | # build-dir => directory in kernel source tree to use |
| 1272 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1273 | build-dir = $(patsubst %/,%,$(dir $@)) |
| 1274 | target-dir = $(dir $@) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1275 | |
| 1276 | %.s: %.c prepare scripts FORCE |
| 1277 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1278 | %.i: %.c prepare scripts FORCE |
| 1279 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1280 | %.o: %.c prepare scripts FORCE |
| 1281 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 1282 | %.o: %.cpp prepare scripts FORCE |
| 1283 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1284 | %.o: %.cxx prepare scripts FORCE |
| 1285 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1286 | %.lst: %.c prepare scripts FORCE |
| 1287 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1288 | %.s: %.S prepare scripts FORCE |
| 1289 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1290 | %.o: %.S prepare scripts FORCE |
| 1291 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1292 | %.symtypes: %.c prepare scripts FORCE |
| 1293 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1294 | |
| 1295 | # Modules |
| 1296 | /: prepare scripts FORCE |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1297 | $(Q)$(MAKE) $(build)=$(build-dir) |
Anas Nashif | 7b9455b | 2015-08-22 11:41:34 -0400 | [diff] [blame] | 1298 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1299 | %/: prepare scripts FORCE |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1300 | $(Q)$(MAKE) $(build)=$(build-dir) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1301 | |
| 1302 | # FIXME Should go into a make.lib or something |
| 1303 | # =========================================================================== |
| 1304 | |
| 1305 | quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) |
| 1306 | cmd_rmdirs = rm -rf $(rm-dirs) |
| 1307 | |
| 1308 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) |
| 1309 | cmd_rmfiles = rm -f $(rm-files) |
| 1310 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1311 | # read all saved command lines |
| 1312 | |
| 1313 | targets := $(wildcard $(sort $(targets))) |
| 1314 | cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
| 1315 | |
| 1316 | ifneq ($(cmd_files),) |
| 1317 | $(cmd_files): ; # Do not try to update included dependency files |
| 1318 | include $(cmd_files) |
| 1319 | endif |
| 1320 | |
| 1321 | endif # skip-makefile |
| 1322 | |
| 1323 | PHONY += FORCE |
| 1324 | FORCE: |
| 1325 | |
| 1326 | # Declare the contents of the .PHONY variable as phony. We keep that |
| 1327 | # information in a variable so we can use it in if_changed and friends. |
| 1328 | .PHONY: $(PHONY) |