Anas Nashif | 027b69e | 2016-02-08 21:32:24 -0500 | [diff] [blame] | 1 | VERSION_MAJOR = 1 |
Anas Nashif | a70bbac | 2016-12-02 23:09:34 -0500 | [diff] [blame] | 2 | VERSION_MINOR = 6 |
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 | ff23cb5 | 2016-09-03 15:43:26 -0400 | [diff] [blame] | 319 | ifeq ($(PREBUILT_HOST_TOOLS),) |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 320 | GENIDT = scripts/gen_idt/gen_idt |
Anas Nashif | bd22748 | 2015-08-25 10:04:04 -0400 | [diff] [blame] | 321 | GENOFFSET_H = scripts/gen_offset_header/gen_offset_header |
Anas Nashif | ff23cb5 | 2016-09-03 15:43:26 -0400 | [diff] [blame] | 322 | FIXDEP = scripts/basic/fixdep |
| 323 | else |
| 324 | GENIDT = $(PREBUILT_HOST_TOOLS)/gen_idt |
| 325 | GENOFFSET_H = $(PREBUILT_HOST_TOOLS)/gen_offset_header |
| 326 | FIXDEP = $(PREBUILT_HOST_TOOLS)/fixdep |
| 327 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 328 | PERL = perl |
| 329 | PYTHON = python |
| 330 | CHECK = sparse |
| 331 | |
Anas Nashif | 6afc485 | 2015-04-24 18:30:36 -0400 | [diff] [blame] | 332 | CHECKFLAGS := -Wbitwise -Wno-return-void $(CF) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 333 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage |
| 334 | |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 335 | ifeq ($(COMPILER),clang) |
| 336 | ifneq ($(CROSS_COMPILE),) |
| 337 | CLANG_TARGET := -target $(notdir $(CROSS_COMPILE:%-=%)) |
| 338 | GCC_TOOLCHAIN := $(dir $(CROSS_COMPILE)) |
| 339 | endif |
| 340 | ifneq ($(GCC_TOOLCHAIN),) |
| 341 | CLANG_GCC_TC := -gcc-toolchain $(GCC_TOOLCHAIN) |
| 342 | endif |
| 343 | ifneq ($(IA),1) |
| 344 | CLANG_IA_FLAG = -no-integrated-as |
| 345 | endif |
| 346 | CLANG_FLAGS := $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_IA_FLAG) |
| 347 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 348 | |
| 349 | # Use USERINCLUDE when you must reference the UAPI directories only. |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 350 | USERINCLUDE := -include $(CURDIR)/include/generated/autoconf.h |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 351 | |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 352 | SOC_NAME = $(subst $(DQUOTE),,$(CONFIG_SOC)) |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 353 | SOC_SERIES = $(subst $(DQUOTE),,$(CONFIG_SOC_SERIES)) |
Anas Nashif | a02c34e | 2016-03-31 08:07:42 -0400 | [diff] [blame] | 354 | SOC_FAMILY = $(subst $(DQUOTE),,$(CONFIG_SOC_FAMILY)) |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 355 | |
Anas Nashif | fe039db | 2016-01-22 13:51:50 -0500 | [diff] [blame] | 356 | override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH)) |
Anas Nashif | 2d76224 | 2015-12-07 20:20:25 -0500 | [diff] [blame] | 357 | BOARD_NAME = $(subst $(DQUOTE),,$(CONFIG_BOARD)) |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 358 | KERNEL_NAME = $(subst $(DQUOTE),,$(CONFIG_KERNEL_BIN_NAME)) |
| 359 | KERNEL_ELF_NAME = $(KERNEL_NAME).elf |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 360 | KERNEL_BIN_NAME = $(KERNEL_NAME).bin |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 361 | KERNEL_HEX_NAME = $(KERNEL_NAME).hex |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 362 | KERNEL_STAT_NAME = $(KERNEL_NAME).stat |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 363 | |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 364 | export SOC_FAMILY SOC_SERIES SOC_PATH SOC_NAME BOARD_NAME |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 365 | 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] | 366 | # Use ZEPHYRINCLUDE when you must reference the include/ directory. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 367 | # Needed to be compatible with the O= option |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 368 | ZEPHYRINCLUDE = \ |
Anas Nashif | d687a95 | 2016-12-17 17:48:47 -0500 | [diff] [blame] | 369 | -I$(srctree)/kernel/include \ |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 370 | -I$(srctree)/arch/$(ARCH)/include \ |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 371 | -I$(srctree)/arch/$(ARCH)/soc/$(SOC_PATH) \ |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 372 | -I$(srctree)/boards/$(ARCH)/$(BOARD_NAME) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 373 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 374 | -I$(srctree)/include \ |
| 375 | -I$(CURDIR)/include/generated \ |
Anas Nashif | 8b45f4e | 2015-10-21 07:24:39 -0400 | [diff] [blame] | 376 | -I$(CURDIR)/misc/generated/sysgen \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 377 | $(USERINCLUDE) \ |
| 378 | $(STDINCLUDE) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 379 | |
Flavio Santes | be1dd33 | 2016-11-21 16:51:08 -0600 | [diff] [blame] | 380 | KBUILD_CPPFLAGS := -DKERNEL -D__ZEPHYR__=1 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 381 | |
Juan Manuel Cruz | 068ebc0 | 2015-05-06 10:41:08 -0500 | [diff] [blame] | 382 | KBUILD_CFLAGS := -c -g -std=c99 \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 383 | -fno-asynchronous-unwind-tables \ |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 384 | -Wall \ |
Anas Nashif | ce9cb26 | 2016-11-28 16:28:49 -0500 | [diff] [blame] | 385 | -Wformat \ |
| 386 | -Wformat-security \ |
| 387 | -D_FORTIFY_SOURCE=2 \ |
Andrew Boie | 5bb0631 | 2015-08-11 12:46:06 -0700 | [diff] [blame] | 388 | -Wno-format-zero-length \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 389 | -Wno-main -ffreestanding |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 390 | |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 391 | KBUILD_CXXFLAGS := -c -g -std=c++11 \ |
| 392 | -fno-reorder-functions \ |
| 393 | -fno-asynchronous-unwind-tables \ |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 394 | -fcheck-new \ |
| 395 | -fno-defer-pop -Wall \ |
| 396 | -Wno-unused-but-set-variable \ |
| 397 | -Wno-format-zero-length \ |
| 398 | -Wno-main -ffreestanding \ |
| 399 | -ffunction-sections -fdata-sections \ |
| 400 | -fno-rtti -fno-exceptions |
| 401 | |
Benjamin Walsh | ee659ae | 2017-01-22 18:06:10 -0500 | [diff] [blame] | 402 | KBUILD_AFLAGS := -c -g -xassembler-with-cpp -D_ASMLANGUAGE |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 403 | |
Peter Mitsis | 61eff49 | 2015-06-01 11:27:55 -0400 | [diff] [blame] | 404 | LDFLAGS += $(call ld-option,-nostartfiles) |
| 405 | LDFLAGS += $(call ld-option,-nodefaultlibs) |
| 406 | LDFLAGS += $(call ld-option,-nostdlib) |
| 407 | LDFLAGS += $(call ld-option,-static) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 408 | |
Anas Nashif | 32bff69 | 2015-06-23 21:11:04 -0400 | [diff] [blame] | 409 | 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] | 410 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 411 | exports += VERSION_MAJOR VERSION_MINOR PATCHLEVEL VERSION_RESERVED EXTRAVERSION |
| 412 | exports += KERNELRELEASE KERNELVERSION |
| 413 | exports += ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC CXX |
| 414 | exports += CPP AR NM STRIP OBJCOPY OBJDUMP GDB |
| 415 | exports += MAKE AWK INSTALLKERNEL PERL PYTHON GENIDT GENOFFSET_H |
| 416 | exports += HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 417 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 418 | exports += KBUILD_CPPFLAGS NOSTDINC_FLAGS ZEPHYRINCLUDE OBJCOPYFLAGS LDFLAGS |
| 419 | exports += KBUILD_CFLAGS KBUILD_CXXFLAGS CFLAGS_GCOV KBUILD_AFLAGS AFLAGS_KERNEL |
Anas Nashif | ff23cb5 | 2016-09-03 15:43:26 -0400 | [diff] [blame] | 420 | exports += KBUILD_ARFLAGS FIXDEP |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 421 | |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 422 | # Push the exports to sub-processes |
| 423 | export $(exports) |
| 424 | |
| 425 | # Make the exports available to third-party build systems |
| 426 | PHONY += outputexports |
| 427 | outputexports: Makefile.export |
| 428 | Makefile.export: include/config/auto.conf FORCE |
| 429 | $(call filechk,Makefile.export) |
| 430 | |
| 431 | define filechk_Makefile.export |
| 432 | (echo "# file is auto-generated, do not modify !"; \ |
| 433 | echo "BOARD=$(BOARD)"; \ |
| 434 | echo; \ |
Daniel Thompson | 4f0c6f4 | 2016-11-08 22:17:36 +0000 | [diff] [blame] | 435 | $(foreach e,$(exports),echo $(e)=$($(e));) echo; \ |
| 436 | echo "include $(O)/include/config/auto.conf";) |
Daniel Thompson | 90f6ae1 | 2016-09-22 15:00:21 +0100 | [diff] [blame] | 437 | endef |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 438 | |
| 439 | # Files to ignore in find ... statements |
| 440 | |
| 441 | export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ |
| 442 | -name CVS -o -name .pc -o -name .hg -o -name .git \) \ |
| 443 | -prune -o |
| 444 | export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ |
| 445 | --exclude CVS --exclude .pc --exclude .hg --exclude .git |
| 446 | |
| 447 | # =========================================================================== |
| 448 | # Rules shared between *config targets and build targets |
| 449 | |
| 450 | # Basic helpers built in scripts/ |
| 451 | PHONY += scripts_basic |
Anas Nashif | ff23cb5 | 2016-09-03 15:43:26 -0400 | [diff] [blame] | 452 | ifeq ($(PREBUILT_HOST_TOOLS),) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 453 | scripts_basic: |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 454 | $(Q)$(MAKE) $(build)=scripts/basic |
| 455 | $(Q)$(MAKE) $(build)=scripts/gen_idt |
Anas Nashif | bd22748 | 2015-08-25 10:04:04 -0400 | [diff] [blame] | 456 | $(Q)$(MAKE) $(build)=scripts/gen_offset_header |
Anas Nashif | ff23cb5 | 2016-09-03 15:43:26 -0400 | [diff] [blame] | 457 | else |
| 458 | scripts_basic: |
| 459 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 460 | |
| 461 | # To avoid any implicit rule to kick in, define an empty command. |
| 462 | scripts/basic/%: scripts_basic ; |
| 463 | |
| 464 | PHONY += outputmakefile |
| 465 | # outputmakefile generates a Makefile in the output directory, if using a |
| 466 | # separate output directory. This allows convenient use of make in the |
| 467 | # output directory. |
| 468 | outputmakefile: |
| 469 | ifneq ($(KBUILD_SRC),) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 470 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ |
Anas Nashif | fde80d7 | 2015-08-22 14:40:43 -0400 | [diff] [blame] | 471 | $(srctree) $(objtree) $(VERSION_MAJOR) $(VERSION_MINOR) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 472 | endif |
| 473 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 474 | # To make sure we do not include .config for any of the *config targets |
| 475 | # catch them early, and hand them over to scripts/kconfig/Makefile |
| 476 | # It is allowed to specify more targets when calling make, including |
| 477 | # mixing *config targets and build targets. |
| 478 | # For example 'make oldconfig all'. |
| 479 | # Detect when mixed targets is specified, and make a second invocation |
| 480 | # of make so .config is not included in this case either (for *config). |
| 481 | |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 482 | version_h := include/generated/version.h |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 483 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 484 | no-dot-config-targets := pristine distclean clean mrproper help kconfig-help \ |
Anas Nashif | b214717 | 2015-11-01 17:55:27 -0500 | [diff] [blame] | 485 | cscope gtags TAGS tags help% %docs check% \ |
| 486 | $(version_h) headers_% kernelversion %src-pkg |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 487 | |
| 488 | config-targets := 0 |
| 489 | mixed-targets := 0 |
| 490 | dot-config := 1 |
| 491 | |
| 492 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 493 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 494 | dot-config := 0 |
| 495 | endif |
| 496 | endif |
| 497 | |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 498 | ifneq ($(filter config %config,$(MAKECMDGOALS)),) |
| 499 | config-targets := 1 |
| 500 | ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) |
| 501 | mixed-targets := 1 |
| 502 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 503 | endif |
| 504 | |
| 505 | ifeq ($(mixed-targets),1) |
| 506 | # =========================================================================== |
| 507 | # We're called with mixed targets (*config and build targets). |
| 508 | # Handle them one by one. |
| 509 | |
| 510 | PHONY += $(MAKECMDGOALS) __build_one_by_one |
| 511 | |
| 512 | $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one |
| 513 | @: |
| 514 | |
| 515 | __build_one_by_one: |
| 516 | $(Q)set -e; \ |
| 517 | for i in $(MAKECMDGOALS); do \ |
| 518 | $(MAKE) -f $(srctree)/Makefile $$i; \ |
| 519 | done |
| 520 | |
| 521 | else |
| 522 | ifeq ($(config-targets),1) |
| 523 | # =========================================================================== |
| 524 | # *config targets only - make sure prerequisites are updated, and descend |
| 525 | # in scripts/kconfig to make the *config target |
| 526 | |
| 527 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. |
| 528 | # KBUILD_DEFCONFIG may point out an alternative default configuration |
| 529 | # used for 'make defconfig' |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 530 | include $(srctree)/arch/$(subst $(DQUOTE),,$(CONFIG_ARCH))/Makefile |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 531 | export KBUILD_DEFCONFIG KBUILD_KCONFIG |
| 532 | |
| 533 | config: scripts_basic outputmakefile FORCE |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 534 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 535 | |
| 536 | %config: scripts_basic outputmakefile FORCE |
Anas Nashif | 27603f4 | 2015-06-18 10:46:52 -0400 | [diff] [blame] | 537 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 538 | |
| 539 | else |
| 540 | # =========================================================================== |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 541 | # Build targets only - this includes zephyr, arch specific targets, clean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 542 | # targets and others. In general all targets except *config targets. |
| 543 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 544 | # Additional helpers built in scripts/ |
| 545 | # Carefully list dependencies so we do not try to build scripts twice |
| 546 | # in parallel |
| 547 | PHONY += scripts |
Dirk Brandewie | 991e9d3 | 2015-06-01 09:48:10 -0700 | [diff] [blame] | 548 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 549 | $(Q)$(MAKE) $(build)=$(@) |
| 550 | |
Andrew Boie | d9a84c5 | 2016-07-26 14:45:14 -0700 | [diff] [blame] | 551 | # arch/ must be last here so that .gnu.linkonce magic for interrupts/exceptions |
| 552 | # works as expected |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 553 | |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 554 | ifneq ($(strip $(MAKEFILE_APP_DIR)),) |
| 555 | MAKEFILE_APP := $(realpath $(MAKEFILE_APP_DIR)/Makefile.app) |
| 556 | endif |
| 557 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 558 | ifneq ($(strip $(PROJECT)),) |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 559 | ifneq ($(strip $(MAKEFILE_APP)), ) |
| 560 | include $(MAKEFILE_APP) |
| 561 | else |
Anas Nashif | a8259af | 2015-08-10 10:01:15 -0400 | [diff] [blame] | 562 | -include $(PROJECT)/Makefile.app |
Benjamin Walsh | 76c76a1 | 2016-02-10 14:36:39 -0500 | [diff] [blame] | 563 | endif |
Anas Nashif | a8259af | 2015-08-10 10:01:15 -0400 | [diff] [blame] | 564 | ifneq ($(strip $(KBUILD_ZEPHYR_APP)),) |
| 565 | export KBUILD_ZEPHYR_APP |
| 566 | endif |
Anas Nashif | 0c39517 | 2015-10-25 09:42:58 -0400 | [diff] [blame] | 567 | app-y := $(SOURCE_DIR) |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 568 | endif |
| 569 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 570 | |
| 571 | ifeq ($(dot-config),1) |
| 572 | # Read in config |
| 573 | -include include/config/auto.conf |
| 574 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 575 | # Read in dependencies to all Kconfig* files, make sure to run |
| 576 | # oldconfig if changes are detected. |
| 577 | -include include/config/auto.conf.cmd |
| 578 | |
| 579 | # To avoid any implicit rule to kick in, define an empty command |
| 580 | $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; |
| 581 | |
| 582 | # If .config is newer than include/config/auto.conf, someone tinkered |
| 583 | # with it and forgot to run make oldconfig. |
| 584 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so |
| 585 | # we execute the config step to be sure to catch updated Kconfig files |
| 586 | include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd |
| 587 | $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 588 | |
| 589 | else |
| 590 | # Dummy target needed, because used as prerequisite |
| 591 | include/config/auto.conf: ; |
| 592 | endif # $(dot-config) |
| 593 | |
Andrew Boie | 625acd5 | 2016-11-07 10:27:45 -0800 | [diff] [blame] | 594 | # kernel objects are built as a static library |
Anas Nashif | d687a95 | 2016-12-17 17:48:47 -0500 | [diff] [blame] | 595 | libs-y := kernel/ |
Jukka Rissanen | 3eaec41 | 2016-11-11 23:46:28 +0200 | [diff] [blame] | 596 | core-y := lib/ misc/ boards/ ext/ subsys/ tests/ arch/ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 597 | drivers-y := drivers/ |
Dmitriy Korovkin | 9558d47 | 2016-09-09 13:59:17 -0400 | [diff] [blame] | 598 | |
Anas Nashif | df73d32 | 2015-11-02 20:42:35 -0500 | [diff] [blame] | 599 | ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH)) |
| 600 | export ARCH |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 601 | |
Allan Stephens | 74b98c1 | 2015-06-08 11:43:13 -0400 | [diff] [blame] | 602 | ifdef ZEPHYR_GCC_VARIANT |
| 603 | include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT) |
Anas Nashif | 83d4ea9 | 2015-06-18 18:59:37 -0400 | [diff] [blame] | 604 | else |
Anas Nashif | 47be9a5 | 2017-01-15 18:19:59 -0500 | [diff] [blame] | 605 | ifneq ($(MAKECMDGOALS),htmldocs) |
Anas Nashif | 83d4ea9 | 2015-06-18 18:59:37 -0400 | [diff] [blame] | 606 | $(if $(CROSS_COMPILE),, \ |
| 607 | $(error ZEPHYR_GCC_VARIANT is not set. )) |
Anas Nashif | aca245d | 2015-05-13 00:44:22 -0400 | [diff] [blame] | 608 | endif |
Anas Nashif | 47be9a5 | 2017-01-15 18:19:59 -0500 | [diff] [blame] | 609 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 610 | |
Anas Nashif | 37b1d1e | 2016-05-25 09:03:33 -0400 | [diff] [blame] | 611 | -include $(srctree)/ext/Makefile |
Anas Nashif | 1aaa11b | 2016-06-13 18:35:02 -0400 | [diff] [blame] | 612 | -include $(srctree)/lib/Makefile |
Anas Nashif | 37b1d1e | 2016-05-25 09:03:33 -0400 | [diff] [blame] | 613 | |
Juan Manuel Cruz | 2170ca7 | 2016-04-05 16:34:54 -0500 | [diff] [blame] | 614 | ifneq ($(CC),) |
| 615 | ifeq ($(shell $(CC) -v 2>&1 | grep -Ec "clang version|icx version"), 1) |
| 616 | COMPILER := clang |
| 617 | else |
| 618 | COMPILER := gcc |
| 619 | endif |
| 620 | export COMPILER |
| 621 | endif |
| 622 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 623 | # The all: target is the default when no target is given on the |
| 624 | # command line. |
| 625 | # 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] | 626 | # Defaults to zephyr, but the arch makefile usually adds further targets |
| 627 | all: zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 628 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 629 | ifdef CONFIG_READABLE_ASM |
| 630 | # Disable optimizations that make assembler listings hard to read. |
| 631 | # reorder blocks reorders the control in the function |
| 632 | # ipa clone creates specialized cloned functions |
| 633 | # partial inlining inlines only parts of functions |
| 634 | KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ |
| 635 | $(call cc-option,-fno-ipa-cp-clone,) \ |
| 636 | $(call cc-option,-fno-partial-inlining) |
| 637 | endif |
| 638 | |
Anas Nashif | eb1fdf5 | 2015-07-29 09:33:32 -0400 | [diff] [blame] | 639 | ifeq ($(CONFIG_DEBUG),y) |
Andrew Boie | 11693c1 | 2016-07-22 12:15:40 -0700 | [diff] [blame] | 640 | KBUILD_CFLAGS += -Og |
Anas Nashif | eb1fdf5 | 2015-07-29 09:33:32 -0400 | [diff] [blame] | 641 | else |
| 642 | KBUILD_CFLAGS += -Os |
| 643 | endif |
| 644 | |
Andre Guedes | 1622e4f | 2016-01-07 14:21:22 -0200 | [diff] [blame] | 645 | ifeq ($(CONFIG_STACK_CANARIES),y) |
| 646 | KBUILD_CFLAGS += $(call cc-option,-fstack-protector-all,) |
| 647 | else |
| 648 | KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector,) |
| 649 | endif |
| 650 | |
Andrew Boie | 63cea24 | 2016-06-14 10:55:57 -0700 | [diff] [blame] | 651 | ifeq ($(CONFIG_OMIT_FRAME_POINTER),y) |
| 652 | fp_arg := $(call cc-option,-fomit-frame-pointer,) |
| 653 | else |
| 654 | fp_arg := $(call cc-option,-fno-omit-frame-pointer,) |
| 655 | endif |
| 656 | KBUILD_CFLAGS += $(fp_arg) |
| 657 | KBUILD_CXXFLAGS += $(fp_arg) |
| 658 | |
Anas Nashif | 3852c8c | 2015-08-22 18:14:42 -0400 | [diff] [blame] | 659 | KBUILD_CFLAGS += $(subst $(DQUOTE),,$(CONFIG_COMPILER_OPT)) |
| 660 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 661 | export LDFLAG_LINKERCMD |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 662 | |
Anas Nashif | d2f1c76 | 2016-04-03 09:37:43 -0400 | [diff] [blame] | 663 | ifeq ($(SOC_SERIES),) |
| 664 | SOC_PATH = $(SOC_NAME) |
| 665 | else |
| 666 | SOC_PATH = $(SOC_FAMILY)/$(SOC_SERIES) |
| 667 | endif |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 668 | include arch/$(ARCH)/Makefile |
Anas Nashif | d9af71b | 2015-09-23 15:54:28 -0400 | [diff] [blame] | 669 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 670 | KBUILD_CFLAGS += $(CFLAGS) |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 671 | KBUILD_CXXFLAGS += $(CXXFLAGS) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 672 | KBUILD_AFLAGS += $(CFLAGS) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 673 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 674 | |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 675 | ifeq ($(COMPILER),clang) |
Anas Nashif | 1b70215 | 2015-08-23 22:01:07 -0400 | [diff] [blame] | 676 | KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) |
| 677 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) |
| 678 | KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) |
| 679 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) |
| 680 | # Quiet clang warning: comparison of unsigned expression < 0 is always false |
| 681 | KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) |
| 682 | else |
| 683 | |
| 684 | # This warning generated too much noise in a regular build. |
| 685 | # Use make W=1 to enable this warning (see scripts/Makefile.build) |
| 686 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) |
| 687 | KBUILD_CFLAGS += $(call cc-option,-fno-reorder-functions) |
| 688 | KBUILD_CFLAGS += $(call cc-option,-fno-defer-pop) |
| 689 | endif |
| 690 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 691 | # We trigger additional mismatches with less inlining |
| 692 | ifdef CONFIG_DEBUG_SECTION_MISMATCH |
| 693 | KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) |
| 694 | endif |
| 695 | |
| 696 | # arch Makefile may override CC so keep this after arch Makefile is included |
| 697 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
Anas Nashif | ef2fc59 | 2016-04-17 11:18:39 +0800 | [diff] [blame] | 698 | NOSTDINC_FLAGS += -isystem $(shell $(CC) -print-file-name=include-fixed) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 699 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
| 700 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 701 | # disable pointer signed / unsigned warnings in gcc 4.0 |
| 702 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) |
| 703 | |
| 704 | # disable invalid "can't wrap" optimizations for signed / pointers |
| 705 | KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) |
| 706 | |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 707 | # generate an extra file that specifies the maximum amount of stack used, |
| 708 | # on a per-function basis. |
Anas Nashif | 9fe306b | 2015-12-05 09:36:38 -0500 | [diff] [blame] | 709 | ifdef CONFIG_STACK_USAGE |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 710 | KBUILD_CFLAGS += $(call cc-option,-fstack-usage) |
Anas Nashif | 9fe306b | 2015-12-05 09:36:38 -0500 | [diff] [blame] | 711 | endif |
Anas Nashif | 20439b4 | 2015-10-14 11:03:41 -0400 | [diff] [blame] | 712 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 713 | |
| 714 | # disallow errors like 'EXPORT_GPL(foo);' with missing header |
| 715 | KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) |
| 716 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 717 | # Prohibit date/time macros, which would make the build non-deterministic |
Anas Nashif | 47f8088 | 2015-06-22 19:44:37 -0400 | [diff] [blame] | 718 | # KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 719 | |
| 720 | # use the deterministic mode of AR if available |
| 721 | KBUILD_ARFLAGS := $(call ar-option,D) |
| 722 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 723 | include $(srctree)/scripts/Makefile.extrawarn |
| 724 | |
| 725 | # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments |
| 726 | KBUILD_CPPFLAGS += $(KCPPFLAGS) |
| 727 | KBUILD_AFLAGS += $(KAFLAGS) |
| 728 | KBUILD_CFLAGS += $(KCFLAGS) |
| 729 | |
| 730 | # Use --build-id when available. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 731 | |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 732 | LINKFLAGPREFIX ?= -Wl, |
Anas Nashif | 204b66d | 2015-12-31 12:08:23 -0500 | [diff] [blame] | 733 | LDFLAGS_zephyr += $(LDFLAGS) |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 734 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)-X) |
| 735 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)-N) |
| 736 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)--gc-sections) |
| 737 | LDFLAGS_zephyr += $(call cc-ldoption,$(LINKFLAGPREFIX)--build-id=none) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 738 | |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 739 | LD_TOOLCHAIN ?= -D__GCC_LINKER_CMD__ |
Juan Manuel Cruz | 1c8f5a7 | 2015-04-30 17:19:04 -0500 | [diff] [blame] | 740 | |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 741 | ifdef CONFIG_HAVE_CUSTOM_LINKER_SCRIPT |
Benjamin Walsh | ec89a10 | 2016-08-15 17:24:28 -0400 | [diff] [blame] | 742 | KBUILD_LDS := $(subst $(DQUOTE),,$(PROJECT_BASE)/$(CONFIG_CUSTOM_LINKER_SCRIPT)) |
| 743 | ifeq ($(wildcard $(KBUILD_LDS)),) |
| 744 | KBUILD_LDS := $(subst $(DQUOTE),,$(CONFIG_CUSTOM_LINKER_SCRIPT)) |
| 745 | endif |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 746 | else |
| 747 | # Try a board specific linker file |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 748 | KBUILD_LDS := $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/linker.ld |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 749 | |
| 750 | # If not available, try an SoC specific linker file |
| 751 | ifeq ($(wildcard $(KBUILD_LDS)),) |
Andrew Boie | ff872dc | 2016-05-04 13:13:56 -0700 | [diff] [blame] | 752 | KBUILD_LDS := $(srctree)/arch/$(ARCH)/soc/$(SOC_PATH)/linker.ld |
Anas Nashif | 6c5509f | 2016-01-05 08:42:23 -0500 | [diff] [blame] | 753 | endif |
| 754 | endif |
| 755 | |
| 756 | export LD_TOOLCHAIN KBUILD_LDS |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 757 | |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 758 | ifdef MAKEFILE_TOOLCHAIN_DO_PASS2 |
| 759 | # KBUILD_CFLAGS known at this point. |
| 760 | # We can now determine which multilib libraries to use |
| 761 | include $(srctree)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT) |
| 762 | endif |
| 763 | |
Daniel Thompson | 389ed15 | 2016-09-11 20:51:22 +0100 | [diff] [blame] | 764 | QEMU = $(addsuffix /,$(QEMU_BIN_PATH))$(QEMU_$(ARCH)) |
Juro Bystricky | f25ac09 | 2016-07-26 09:44:16 -0700 | [diff] [blame] | 765 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 766 | # The all: target is the default when no target is given on the |
| 767 | # command line. |
| 768 | # This allow a user to issue only 'make' to build a kernel including modules |
| 769 | # Defaults to zephyr, but the arch makefile usually adds further targets |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 770 | all: $(KERNEL_BIN_NAME) $(KERNEL_STAT_NAME) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 771 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 772 | # Default kernel image to build when no specific target is given. |
| 773 | # KBUILD_IMAGE may be overruled on the command line or |
| 774 | # set in the environment |
| 775 | # Also any assignments in arch/$(ARCH)/Makefile take precedence over |
| 776 | # this default value |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 777 | export KBUILD_IMAGE ?= zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 778 | |
Anas Nashif | c0078cf | 2015-10-25 14:02:19 -0400 | [diff] [blame] | 779 | zephyr-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(drivers-y) \ |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 780 | $(libs-y))) |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 781 | |
| 782 | # Workaround for some make notdir implementations that require |
| 783 | # the paramenter not to end in "/". |
| 784 | zephyr-app-dir-root-name := $(patsubst %/,%, $(SOURCE_DIR)) |
| 785 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 786 | zephyr-app-dir-root := $(abspath $(patsubst %, %/.., $(SOURCE_DIR))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 787 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 788 | zephyr-alldirs := $(sort $(zephyr-dirs) $(SOURCE_DIR) $(patsubst %/,%,$(filter %/, \ |
Anas Nashif | ce5dc6a | 2015-12-06 20:02:33 -0500 | [diff] [blame] | 789 | $(core-) $(drivers-) $(libs-) $(app-)))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 790 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 791 | core-y := $(patsubst %/, %/built-in.o, $(core-y)) |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 792 | 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] | 793 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 794 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
| 795 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) |
| 796 | libs-y := $(libs-y1) $(libs-y2) |
| 797 | |
Andrew Boie | d9a84c5 | 2016-07-26 14:45:14 -0700 | [diff] [blame] | 798 | # core-y must be last here. several arches use .gnu.linkonce magic |
| 799 | # to register interrupt or exception handlers, and defaults under |
| 800 | # arch/ (part of core-y) must be linked after drivers or libs. |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 801 | export KBUILD_ZEPHYR_MAIN := $(drivers-y) $(libs-y) $(core-y) |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 802 | export LDFLAGS_zephyr |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 803 | |
Anas Nashif | 1dd4960 | 2016-11-16 09:08:48 -0500 | [diff] [blame] | 804 | zephyr-deps := $(KBUILD_LDS) $(KBUILD_ZEPHYR_MAIN) $(app-y) |
| 805 | |
Anas Nashif | 369cf08 | 2015-05-17 08:55:21 -0400 | [diff] [blame] | 806 | ALL_LIBS += $(TOOLCHAIN_LIBS) |
| 807 | export ALL_LIBS |
| 808 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 809 | LINK_LIBS := $(foreach l,$(ALL_LIBS), -l$(l)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 810 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 811 | OUTPUT_FORMAT ?= elf32-i386 |
| 812 | OUTPUT_ARCH ?= i386 |
| 813 | |
Kumar Gala | 44b712d | 2016-06-03 10:52:12 -0500 | [diff] [blame] | 814 | quiet_cmd_ar_target = AR $@ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 815 | # Do not put lib.a into libzephyr.a. lib.a files are to be linked separately to |
| 816 | # the final image |
Dmitriy Korovkin | 9558d47 | 2016-09-09 13:59:17 -0400 | [diff] [blame] | 817 | cmd_ar_target = rm -f $@; $(AR) rcT$(KBUILD_ARFLAGS) $@ \ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 818 | $(filter-out %/lib.a, $(KBUILD_ZEPHYR_MAIN)) |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 819 | libzephyr.a: $(zephyr-deps) |
Kumar Gala | 44b712d | 2016-06-03 10:52:12 -0500 | [diff] [blame] | 820 | $(call cmd,ar_target) |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 821 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 822 | quiet_cmd_create-lnk = LINK $@ |
| 823 | cmd_create-lnk = \ |
| 824 | ( \ |
| 825 | echo $(LDFLAGS_zephyr); \ |
Anas Nashif | d53c237 | 2016-06-13 18:31:00 -0400 | [diff] [blame] | 826 | echo "$(LINKFLAGPREFIX)-Map=$(KERNEL_NAME).map"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 827 | echo "-L $(objtree)/include/generated"; \ |
| 828 | echo "-u _OffsetAbsSyms -u _ConfigAbsSyms"; \ |
| 829 | echo "-e __start"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 830 | echo "$(LINKFLAGPREFIX)--start-group"; \ |
| 831 | echo "$(LINKFLAGPREFIX)--whole-archive"; \ |
| 832 | echo "$(KBUILD_ZEPHYR_APP)"; \ |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 833 | echo "$(app-y)"; \ |
Anas Nashif | f4ed108 | 2015-12-06 19:27:22 -0500 | [diff] [blame] | 834 | echo "libzephyr.a"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 835 | echo "$(LINKFLAGPREFIX)--no-whole-archive"; \ |
Dmitriy Korovkin | 19f2884 | 2016-10-03 14:58:18 -0400 | [diff] [blame] | 836 | echo "$(filter %/lib.a, $(KBUILD_ZEPHYR_MAIN))"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 837 | echo "$(objtree)/arch/$(ARCH)/core/offsets/offsets.o"; \ |
Anas Nashif | 74326ec | 2016-05-01 17:44:15 -0400 | [diff] [blame] | 838 | echo "$(LINKFLAGPREFIX)--end-group"; \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 839 | echo "$(LIB_INCLUDE_DIR) $(LINK_LIBS)"; \ |
| 840 | ) > $@ |
| 841 | |
Anas Nashif | a0cf03b | 2016-05-14 21:56:35 -0400 | [diff] [blame] | 842 | $(KERNEL_NAME).lnk: $(zephyr-deps) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 843 | $(call cmd,create-lnk) |
| 844 | |
Anas Nashif | 872676c | 2016-02-02 07:58:26 -0500 | [diff] [blame] | 845 | linker.cmd: $(zephyr-deps) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 846 | $(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P \ |
| 847 | $(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) -I$(srctree)/include \ |
Andrew Boie | 82f11bf | 2016-11-21 14:16:11 -0800 | [diff] [blame] | 848 | -I$(SOURCE_DIR) \ |
Anas Nashif | 20fe678 | 2016-01-31 04:46:37 -0500 | [diff] [blame] | 849 | -I$(objtree)/include/generated $(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 850 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 851 | PREBUILT_KERNEL = $(KERNEL_NAME)_prebuilt.elf |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 852 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 853 | $(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] | 854 | $(Q)$(CC) -T linker.cmd @$(KERNEL_NAME).lnk -o $@ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 855 | |
| 856 | quiet_cmd_gen_idt = SIDT $@ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 857 | cmd_gen_idt = \ |
| 858 | ( \ |
| 859 | $(OBJCOPY) -I $(OUTPUT_FORMAT) -O binary -j intList $< isrList.bin && \ |
| 860 | $(GENIDT) -i isrList.bin -n $(CONFIG_IDT_NUM_VECTORS) -o staticIdt.bin \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 861 | -m irq_int_vector_map.bin \ |
Andrew Boie | 0d03e32 | 2016-07-26 11:36:31 -0700 | [diff] [blame] | 862 | -l $(CONFIG_MAX_IRQ_LINES) $(GENIDT_EXTRA_ARGS) && \ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 863 | $(OBJCOPY) -I binary -B $(OUTPUT_ARCH) -O $(OUTPUT_FORMAT) \ |
| 864 | --rename-section .data=staticIdt staticIdt.bin staticIdt.o && \ |
| 865 | $(OBJCOPY) -I binary -B $(OUTPUT_ARCH) -O $(OUTPUT_FORMAT) \ |
Andrew Boie | 2ee9aca | 2016-01-27 12:19:15 -0800 | [diff] [blame] | 866 | --rename-section .data=irq_int_vector_map irq_int_vector_map.bin \ |
| 867 | irq_int_vector_map.o && \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 868 | rm staticIdt.bin irq_int_vector_map.bin isrList.bin \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 869 | ) |
| 870 | |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 871 | staticIdt.o: $(PREBUILT_KERNEL) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 872 | $(call cmd,gen_idt) |
| 873 | |
| 874 | quiet_cmd_lnk_elf = LINK $@ |
| 875 | cmd_lnk_elf = \ |
| 876 | ( \ |
Andrew Boie | 238fe1f | 2016-10-21 10:30:21 -0700 | [diff] [blame] | 877 | $(CC) -T linker.cmd @$(KERNEL_NAME).lnk staticIdt.o \ |
| 878 | irq_int_vector_map.o -o $@; \ |
Ido Yariv | a8c48ea | 2016-01-04 14:59:09 -0500 | [diff] [blame] | 879 | ${OBJCOPY} --change-section-address intList=${CONFIG_PHYS_LOAD_ADDR} $@ elf.tmp;\ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 880 | $(OBJCOPY) -R intList elf.tmp $@; \ |
| 881 | rm elf.tmp \ |
| 882 | ) |
| 883 | |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 884 | ASSERT_WARNING_STR := \ |
| 885 | "\n ------------------------------------------------------------" \ |
| 886 | "\n --- WARNING: __ASSERT() statements are globally ENABLED ---" \ |
| 887 | "\n --- The kernel will run more slowly and uses more memory ---" \ |
| 888 | "\n ------------------------------------------------------------\n\n" \ |
| 889 | |
| 890 | WARN_ABOUT_ASSERT := $(if $(CONFIG_ASSERT),echo -e -n $(ASSERT_WARNING_STR),true) |
| 891 | |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 892 | |
| 893 | DEPRECATION_WARNING_STR := \ |
| 894 | "\n WARNING: The board '$(BOARD)' is deprecated and will be" \ |
| 895 | "\n removed in version $(CONFIG_BOARD_DEPRECATED)\n\n" |
| 896 | |
| 897 | WARN_ABOUT_DEPRECATION := $(if $(CONFIG_BOARD_DEPRECATED),echo -e \ |
| 898 | -n $(DEPRECATION_WARNING_STR),true) |
| 899 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 900 | ifeq ($(ARCH),x86) |
Andrew Boie | caf19b2 | 2016-10-21 10:39:43 -0700 | [diff] [blame] | 901 | $(KERNEL_ELF_NAME): staticIdt.o linker.cmd |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 902 | $(call cmd,lnk_elf) |
Andy Ross | 4cc228b | 2016-10-03 12:20:39 -0700 | [diff] [blame] | 903 | @$(srctree)/scripts/check_link_map.py $(KERNEL_NAME).map |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 904 | @$(WARN_ABOUT_ASSERT) |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 905 | @$(WARN_ABOUT_DEPRECATION) |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 906 | else |
Andy Ross | 018b831 | 2016-08-25 10:18:09 -0700 | [diff] [blame] | 907 | $(KERNEL_ELF_NAME): $(PREBUILT_KERNEL) |
| 908 | @cp $(PREBUILT_KERNEL) $(KERNEL_ELF_NAME) |
Benjamin Walsh | 0107c80 | 2016-05-18 16:24:59 -0400 | [diff] [blame] | 909 | @$(WARN_ABOUT_ASSERT) |
Andrew Boie | a5ae889 | 2016-10-19 13:05:35 -0700 | [diff] [blame] | 910 | @$(WARN_ABOUT_DEPRECATION) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 911 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 912 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 913 | |
| 914 | quiet_cmd_gen_bin = BIN $@ |
| 915 | cmd_gen_bin = \ |
| 916 | ( \ |
| 917 | $(OBJDUMP) -S $< > $(KERNEL_NAME).lst; \ |
| 918 | $(OBJCOPY) -S -O binary -R .note -R .comment -R COMMON -R .eh_frame $< $@; \ |
| 919 | $(STRIP) -s -o $(KERNEL_NAME).strip $<; \ |
| 920 | ) |
| 921 | |
| 922 | $(KERNEL_BIN_NAME): $(KERNEL_ELF_NAME) |
| 923 | $(call cmd,gen_bin) |
| 924 | |
Kumar Gala | bbf736c | 2016-10-24 10:57:46 -0500 | [diff] [blame] | 925 | quiet_cmd_gen_hex = HEX $@ |
| 926 | cmd_gen_hex = \ |
| 927 | ( \ |
| 928 | $(OBJCOPY) -S -O ihex -R .note -R .comment -R COMMON -R .eh_frame $< $@; \ |
| 929 | ) |
| 930 | |
| 931 | $(KERNEL_HEX_NAME): $(KERNEL_ELF_NAME) |
| 932 | $(call cmd,gen_hex) |
| 933 | |
Anas Nashif | 6361be2 | 2016-05-22 12:34:06 -0400 | [diff] [blame] | 934 | $(KERNEL_STAT_NAME): $(KERNEL_BIN_NAME) $(KERNEL_ELF_NAME) |
| 935 | @$(READELF) -e $(KERNEL_ELF_NAME) > $@ |
| 936 | |
| 937 | ram_report: $(KERNEL_STAT_NAME) |
| 938 | @$(srctree)/scripts/size_report -r -o $(O) |
| 939 | rom_report: $(KERNEL_STAT_NAME) |
| 940 | @$(srctree)/scripts/size_report -F -o $(O) |
| 941 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 942 | zephyr: $(zephyr-deps) $(KERNEL_BIN_NAME) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 943 | |
| 944 | # The actual objects are generated when descending, |
| 945 | # make sure no implicit rule kicks in |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 946 | $(sort $(zephyr-deps)): $(zephyr-dirs) zephyr-app-dir ; |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 947 | |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 948 | # Handle descending into subdirectories listed in $(zephyr-dirs) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 949 | # Preset locale variables to speed up the build process. Limit locale |
| 950 | # tweaks to this spot to avoid wrong language settings when running |
| 951 | # make menuconfig etc. |
| 952 | # Error messages still appears in the original language |
| 953 | |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 954 | PHONY += $(zephyr-dirs) |
| 955 | $(zephyr-dirs): prepare scripts |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 956 | $(Q)$(MAKE) $(build)=$@ |
| 957 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 958 | PHONY += zephyr-app-dir |
| 959 | zephyr-app-dir: prepare scripts |
Juan Manuel Cruz | 941059c | 2016-08-26 17:24:13 -0500 | [diff] [blame] | 960 | $(Q)$(MAKE) $(build)=$(notdir $(zephyr-app-dir-root-name)) \ |
| 961 | srctree=$(zephyr-app-dir-root) |
Kumar Gala | ff694e9 | 2016-06-16 16:16:46 -0500 | [diff] [blame] | 962 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 963 | # Things we need to do before we recursively start building the kernel |
| 964 | # or the modules are listed in "prepare". |
| 965 | # A multi level approach is used. prepareN is processed before prepareN-1. |
| 966 | # archprepare is used in arch Makefiles and when processed asm symlink, |
| 967 | # version.h and scripts_basic is processed / created. |
| 968 | |
| 969 | # Listed in dependency order |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 970 | PHONY += prepare prepare1 prepare2 prepare3 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 971 | |
| 972 | # prepare3 is used to check if we are building in a separate output directory, |
| 973 | # and if so do: |
| 974 | # 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] | 975 | prepare3: |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 976 | ifneq ($(KBUILD_SRC),) |
| 977 | @$(kecho) ' Using $(srctree) as source for kernel' |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 978 | $(Q)if [ -f $(srctree)/.config ]; then \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 979 | echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ |
| 980 | echo >&2 " in the '$(srctree)' directory.";\ |
| 981 | /bin/false; \ |
| 982 | fi; |
| 983 | endif |
| 984 | |
| 985 | # prepare2 creates a makefile if using a separate output directory |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 986 | prepare2: prepare3 outputmakefile |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 987 | |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 988 | prepare1: prepare2 $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 989 | include/config/auto.conf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 990 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 991 | archprepare_common = $(strip \ |
Anas Nashif | b214717 | 2015-11-01 17:55:27 -0500 | [diff] [blame] | 992 | prepare1 scripts_basic \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 993 | ) |
| 994 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 995 | |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 996 | archprepare = $(strip \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 997 | $(archprepare_common) \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 998 | ) |
| 999 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1000 | # All the preparing.. |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 1001 | prepare: $(archprepare) FORCE |
| 1002 | $(Q)$(MAKE) $(build)=. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1003 | |
| 1004 | # Generate some files |
| 1005 | # --------------------------------------------------------------------------- |
| 1006 | |
| 1007 | # KERNELRELEASE can change from a few different places, meaning version.h |
| 1008 | # needs to be updated, so this check is forced on all builds |
| 1009 | |
Anas Nashif | 71bed17 | 2015-06-23 19:10:06 -0400 | [diff] [blame] | 1010 | VERSION_MAJOR_HEX=$(shell printf '%02x\n' ${VERSION_MAJOR}) |
| 1011 | VERSION_MINOR_HEX=$(shell printf '%02x\n' ${VERSION_MINOR}) |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1012 | PATCHLEVEL_HEX=$(shell printf '%02x\n' ${PATCHLEVEL}) |
Anas Nashif | 8ad4878 | 2015-06-23 10:29:17 -0400 | [diff] [blame] | 1013 | VERSION_RESERVED_HEX=00 |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1014 | 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] | 1015 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1016 | define filechk_version.h |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1017 | (echo "#ifndef _KERNEL_VERSION_H_"; \ |
| 1018 | echo "#define _KERNEL_VERSION_H_"; \ |
| 1019 | echo ;\ |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1020 | (echo \#define ZEPHYR_VERSION_CODE $(shell \ |
| 1021 | expr $(VERSION_MAJOR) \* 65536 + 0$(VERSION_MINOR) \* 256 + 0$(PATCHLEVEL)); \ |
| 1022 | echo '#define ZEPHYR_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';); \ |
| 1023 | echo ;\ |
Anas Nashif | 9c72cf5 | 2015-08-25 10:44:41 -0400 | [diff] [blame] | 1024 | echo "#define KERNELVERSION \\"; \ |
Anas Nashif | 71bed17 | 2015-06-23 19:10:06 -0400 | [diff] [blame] | 1025 | echo "$(KERNEL_VERSION_HEX)$(VERSION_RESERVED_HEX)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1026 | echo "#define KERNEL_VERSION_NUMBER $(KERNEL_VERSION_HEX)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1027 | echo "#define KERNEL_VERSION_MAJOR $(VERSION_MAJOR)"; \ |
| 1028 | echo "#define KERNEL_VERSION_MINOR $(VERSION_MINOR)"; \ |
Anas Nashif | 4cf6c31 | 2015-06-23 19:19:45 -0400 | [diff] [blame] | 1029 | echo "#define KERNEL_PATCHLEVEL $(PATCHLEVEL)"; \ |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1030 | echo "#define KERNEL_VERSION_STRING \"$(KERNELVERSION)\""; \ |
| 1031 | echo; \ |
| 1032 | echo "#endif /* _KERNEL_VERSION_H_ */";) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1033 | endef |
| 1034 | |
| 1035 | $(version_h): $(srctree)/Makefile FORCE |
| 1036 | $(call filechk,version.h) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1037 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1038 | PHONY += headerdep |
| 1039 | headerdep: |
| 1040 | $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ |
| 1041 | $(srctree)/scripts/headerdep.pl -I$(srctree)/include |
| 1042 | |
| 1043 | # --------------------------------------------------------------------------- |
| 1044 | |
| 1045 | PHONY += depend dep |
| 1046 | depend dep: |
| 1047 | @echo '*** Warning: make $@ is unnecessary now.' |
| 1048 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1049 | ### |
| 1050 | # Cleaning is done on three levels. |
| 1051 | # make clean Delete most generated files |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1052 | # make mrproper Delete the current configuration, and all generated files |
| 1053 | # make distclean Remove editor backup files, patch leftover files and the like |
| 1054 | |
| 1055 | # Directories & files removed with 'make clean' |
| 1056 | CLEAN_DIRS += $(MODVERDIR) |
| 1057 | |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 1058 | CLEAN_FILES += misc/generated/sysgen/kernel_main.c \ |
Anas Nashif | 8b45f4e | 2015-10-21 07:24:39 -0400 | [diff] [blame] | 1059 | misc/generated/sysgen/sysgen.h \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1060 | misc/generated/sysgen/prj.mdef \ |
Kumar Gala | 62a9f9c | 2016-07-09 09:30:52 -0500 | [diff] [blame] | 1061 | misc/generated/sysgen/micro_private_types.h \ |
| 1062 | misc/generated/sysgen/kernel_main.h \ |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1063 | .old_version .tmp_System.map .tmp_version \ |
| 1064 | .tmp_* System.map *.lnk *.map *.elf *.lst \ |
Kumar Gala | bdd7764 | 2016-10-24 11:00:32 -0500 | [diff] [blame] | 1065 | *.bin *.hex *.stat *.strip staticIdt.o linker.cmd |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1066 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1067 | # Directories & files removed with 'make mrproper' |
| 1068 | MRPROPER_DIRS += include/config usr/include include/generated \ |
| 1069 | arch/*/include/generated .tmp_objdiff |
Anas Nashif | 1e8dc5a | 2015-04-24 18:32:55 -0400 | [diff] [blame] | 1070 | MRPROPER_FILES += .config .config.old .version $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1071 | Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ |
| 1072 | signing_key.priv signing_key.x509 x509.genkey \ |
| 1073 | extra_certificates signing_key.x509.keyid \ |
| 1074 | signing_key.x509.signer |
| 1075 | |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1076 | # clean - Delete most |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1077 | # |
| 1078 | clean: rm-dirs := $(CLEAN_DIRS) |
| 1079 | clean: rm-files := $(CLEAN_FILES) |
Anas Nashif | 6523094 | 2015-06-05 22:41:29 -0400 | [diff] [blame] | 1080 | clean-dirs := $(addprefix _clean_, . $(zephyr-alldirs) ) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1081 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 1082 | PHONY += clean-dirs-target clean archclean zephyrclean |
| 1083 | clean-dirs-target: |
| 1084 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$(clean-dirs)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1085 | |
Anas Nashif | 06e78de | 2015-11-01 11:59:09 -0500 | [diff] [blame] | 1086 | clean: archclean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1087 | |
| 1088 | # mrproper - Delete all generated files, including .config |
| 1089 | # |
| 1090 | mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) |
| 1091 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1092 | mrproper-dirs := $(addprefix _mrproper_,scripts) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1093 | |
| 1094 | PHONY += $(mrproper-dirs) mrproper archmrproper |
| 1095 | $(mrproper-dirs): |
| 1096 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) |
| 1097 | |
| 1098 | mrproper: clean archmrproper $(mrproper-dirs) |
| 1099 | $(call cmd,rmdirs) |
| 1100 | $(call cmd,rmfiles) |
| 1101 | |
| 1102 | # distclean |
| 1103 | # |
| 1104 | PHONY += distclean |
| 1105 | |
| 1106 | distclean: mrproper |
| 1107 | @find $(srctree) $(RCS_FIND_IGNORE) \ |
| 1108 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
| 1109 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ |
| 1110 | -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \ |
| 1111 | -type f -print | xargs rm -f |
| 1112 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1113 | # Brief documentation of the typical targets used |
| 1114 | # --------------------------------------------------------------------------- |
| 1115 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1116 | boards := $(wildcard $(srctree)/boards/*/*/*_defconfig) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1117 | boards := $(sort $(notdir $(boards))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1118 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1119 | kconfig-help: |
| 1120 | @echo 'Configuration targets:' |
| 1121 | @echo '' |
| 1122 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help |
| 1123 | @echo '' |
| 1124 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1125 | help: |
| 1126 | @echo 'Cleaning targets:' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1127 | @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] | 1128 | @echo ' mrproper - Remove all generated files + config + various backup files' |
| 1129 | @echo ' distclean - mrproper + remove editor backup and patch files' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1130 | @echo ' pristine - Remove the output directory with all generated files' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1131 | @echo '' |
| 1132 | @echo 'Configuration targets:' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1133 | @echo '' |
| 1134 | @echo ' run <make kconfig-help>' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1135 | @echo '' |
| 1136 | @echo 'Other generic targets:' |
| 1137 | @echo ' all - Build all targets marked with [*]' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1138 | @echo '* zephyr - Build a zephyr application' |
Anas Nashif | 2bc9d69 | 2017-01-07 16:31:34 -0500 | [diff] [blame] | 1139 | @echo ' run - Build a zephyr application and run it if board supports emulation' |
| 1140 | @echo ' qemu - Build a zephyr application and run it in qemu [deprecated]' |
| 1141 | @echo ' qemugdb - Same as 'qemu' but start a GDB server on port 1234 [deprecated]' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1142 | @echo ' flash - Build and flash an application' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1143 | @echo ' debug - Build and debug an application using GDB' |
Anas Nashif | 6d9ed99 | 2017-01-07 13:22:21 -0500 | [diff] [blame] | 1144 | @echo ' debugserver - Build and start a GDB server (port 1234 for Qemu targets)' |
Anas Nashif | 1b4742f | 2016-09-24 15:07:28 -0400 | [diff] [blame] | 1145 | @echo ' ram_report - Build and create RAM usage report' |
| 1146 | @echo ' rom_report - Build and create ROM usage report' |
Juan Manuel Cruz | a5a6ec3 | 2015-10-02 13:07:55 -0500 | [diff] [blame] | 1147 | @echo '' |
Anas Nashif | 10bb38c | 2015-12-17 08:54:35 -0500 | [diff] [blame] | 1148 | @echo 'Supported Boards:' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1149 | @echo '' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1150 | @echo ' To build an image for one of the supported boards below, run:' |
| 1151 | @echo '' |
| 1152 | @echo ' make BOARD=<BOARD NAME>' |
| 1153 | @echo ' in the application directory.' |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1154 | @echo '' |
Anas Nashif | 7d348b0 | 2016-01-31 08:22:18 -0500 | [diff] [blame] | 1155 | @echo ' To flash the image (if supported), run:' |
| 1156 | @echo '' |
| 1157 | @echo ' make BOARD=<BOARD NAME> flash' |
| 1158 | @echo '' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1159 | @$(if $(boards), \ |
| 1160 | $(foreach b, $(boards), \ |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1161 | 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] | 1162 | echo '') |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1163 | |
Anas Nashif | a77c7d8 | 2016-02-02 07:04:49 -0500 | [diff] [blame] | 1164 | @echo '' |
| 1165 | @echo 'Build flags:' |
| 1166 | @echo '' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1167 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' |
| 1168 | @echo ' make V=2 [targets] 2 => give reason for rebuild of target' |
| 1169 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' |
| 1170 | @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' |
| 1171 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' |
| 1172 | @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' |
| 1173 | @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' |
| 1174 | @echo ' 1: warnings which may be relevant and do not occur too often' |
| 1175 | @echo ' 2: warnings which occur quite often but may still be relevant' |
| 1176 | @echo ' 3: more obscure warnings, can most likely be ignored' |
| 1177 | @echo ' Multiple levels can be combined with W=12 or W=123' |
| 1178 | @echo '' |
| 1179 | @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] | 1180 | |
| 1181 | |
| 1182 | help-board-dirs := $(addprefix help-,$(board-dirs)) |
| 1183 | |
| 1184 | help-boards: $(help-board-dirs) |
| 1185 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1186 | boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/boards/*/$*/*_defconfig))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1187 | |
| 1188 | $(help-board-dirs): help-%: |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1189 | @echo 'Architecture specific targets ($(ARCH) $*):' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1190 | @$(if $(boards-per-dir), \ |
| 1191 | $(foreach b, $(boards-per-dir), \ |
| 1192 | printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ |
| 1193 | echo '') |
| 1194 | |
| 1195 | |
| 1196 | # Documentation targets |
| 1197 | # --------------------------------------------------------------------------- |
Anas Nashif | 486a2a1 | 2015-07-30 07:06:40 -0400 | [diff] [blame] | 1198 | %docs: FORCE |
| 1199 | $(Q)$(MAKE) -C doc htmldocs |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1200 | |
Juan Manuel Cruz | 5bd398d | 2016-08-23 15:06:38 -0500 | [diff] [blame] | 1201 | clean: clean-dirs-target |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1202 | $(call cmd,rmdirs) |
| 1203 | $(call cmd,rmfiles) |
| 1204 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ |
Anas Nashif | 801874d | 2015-12-06 09:09:03 -0500 | [diff] [blame] | 1205 | \( -name '*.[oas]' -o -name '.*.cmd' \ |
| 1206 | -o -name '*.dwo' -o -name '.*.d' -o -name '.*.tmp' \ |
Anas Nashif | 3bdae61 | 2015-12-06 19:38:53 -0500 | [diff] [blame] | 1207 | -o -name '.tmp_*.o.*' -o -name '*.gcno' \) -type f \ |
| 1208 | -print | xargs rm -f |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1209 | |
| 1210 | # Generate tags for editors |
| 1211 | # --------------------------------------------------------------------------- |
| 1212 | quiet_cmd_tags = GEN $@ |
| 1213 | cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ |
| 1214 | |
| 1215 | tags TAGS cscope gtags: FORCE |
| 1216 | $(call cmd,tags) |
| 1217 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1218 | endif #ifeq ($(config-targets),1) |
| 1219 | endif #ifeq ($(mixed-targets),1) |
| 1220 | |
Juan Manuel Cruz | ef07b96 | 2015-06-05 12:58:50 -0500 | [diff] [blame] | 1221 | PHONY += checkstack kernelversion image_name |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1222 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1223 | CHECKSTACK_ARCH := $(ARCH) |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1224 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1225 | checkstack: |
Anas Nashif | 3a87dae | 2015-12-06 09:51:33 -0500 | [diff] [blame] | 1226 | $(OBJDUMP) -d $(O)/$(KERNEL_ELF_NAME) | \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1227 | $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
| 1228 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1229 | kernelversion: |
| 1230 | @echo $(KERNELVERSION) |
| 1231 | |
| 1232 | image_name: |
| 1233 | @echo $(KBUILD_IMAGE) |
| 1234 | |
| 1235 | # Clear a bunch of variables before executing the submake |
| 1236 | tools/: FORCE |
| 1237 | $(Q)mkdir -p $(objtree)/tools |
| 1238 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ |
| 1239 | |
| 1240 | tools/%: FORCE |
| 1241 | $(Q)mkdir -p $(objtree)/tools |
| 1242 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $* |
| 1243 | |
Kumar Gala | 8d35760 | 2016-10-19 15:13:41 -0500 | [diff] [blame] | 1244 | -include $(srctree)/boards/$(ARCH)/$(BOARD_NAME)/Makefile.board |
Anas Nashif | 2bc9d69 | 2017-01-07 16:31:34 -0500 | [diff] [blame] | 1245 | |
| 1246 | ifneq ($(EMU_PLATFORM),) |
| 1247 | -include $(srctree)/scripts/Makefile.$(EMU_PLATFORM) |
| 1248 | else |
| 1249 | run: |
| 1250 | @echo =================================================== |
| 1251 | @echo Emulation/Simulation not supported with this board. |
| 1252 | @echo =================================================== |
| 1253 | endif |
| 1254 | |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1255 | ifneq ($(FLASH_SCRIPT),) |
Anas Nashif | 51be9a5 | 2016-01-15 12:18:53 -0500 | [diff] [blame] | 1256 | flash: zephyr |
| 1257 | @echo "Flashing $(BOARD_NAME)" |
| 1258 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/support/$(FLASH_SCRIPT) flash |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1259 | else |
| 1260 | flash: FORCE |
| 1261 | @echo Flashing not supported with this board. |
| 1262 | @echo Please check the documentation for alternate instructions. |
Anas Nashif | 6d9ed99 | 2017-01-07 13:22:21 -0500 | [diff] [blame] | 1263 | endif |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1264 | |
Anas Nashif | 6d9ed99 | 2017-01-07 13:22:21 -0500 | [diff] [blame] | 1265 | ifneq ($(DEBUG_SCRIPT),) |
| 1266 | debug: zephyr |
| 1267 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/support/$(DEBUG_SCRIPT) debug |
| 1268 | |
| 1269 | else |
Anas Nashif | 78e1b0e | 2016-02-01 23:30:37 -0500 | [diff] [blame] | 1270 | debug: FORCE |
| 1271 | @echo Debugging not supported with this board. |
| 1272 | @echo Please check the documentation for alternate instructions. |
| 1273 | endif |
Anas Nashif | a49762c | 2016-02-01 22:24:21 -0500 | [diff] [blame] | 1274 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1275 | # Single targets |
| 1276 | # --------------------------------------------------------------------------- |
| 1277 | # Single targets are compatible with: |
| 1278 | # - build with mixed source and output |
| 1279 | # - build with separate output dir 'make O=...' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1280 | # |
| 1281 | # target-dir => where to store outputfile |
| 1282 | # build-dir => directory in kernel source tree to use |
| 1283 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1284 | build-dir = $(patsubst %/,%,$(dir $@)) |
| 1285 | target-dir = $(dir $@) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1286 | |
| 1287 | %.s: %.c prepare scripts FORCE |
| 1288 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1289 | %.i: %.c prepare scripts FORCE |
| 1290 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1291 | %.o: %.c prepare scripts FORCE |
| 1292 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
Peter Mitsis | 8e35cc8 | 2016-01-13 13:02:56 -0500 | [diff] [blame] | 1293 | %.o: %.cpp prepare scripts FORCE |
| 1294 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1295 | %.o: %.cxx prepare scripts FORCE |
| 1296 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1297 | %.lst: %.c prepare scripts FORCE |
| 1298 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1299 | %.s: %.S prepare scripts FORCE |
| 1300 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1301 | %.o: %.S prepare scripts FORCE |
| 1302 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1303 | %.symtypes: %.c prepare scripts FORCE |
| 1304 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1305 | |
| 1306 | # Modules |
| 1307 | /: prepare scripts FORCE |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1308 | $(Q)$(MAKE) $(build)=$(build-dir) |
Anas Nashif | 7b9455b | 2015-08-22 11:41:34 -0400 | [diff] [blame] | 1309 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1310 | %/: prepare scripts FORCE |
Anas Nashif | f05ee8f | 2015-06-05 21:38:07 -0400 | [diff] [blame] | 1311 | $(Q)$(MAKE) $(build)=$(build-dir) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1312 | |
| 1313 | # FIXME Should go into a make.lib or something |
| 1314 | # =========================================================================== |
| 1315 | |
| 1316 | quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) |
| 1317 | cmd_rmdirs = rm -rf $(rm-dirs) |
| 1318 | |
| 1319 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) |
| 1320 | cmd_rmfiles = rm -f $(rm-files) |
| 1321 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1322 | # read all saved command lines |
| 1323 | |
| 1324 | targets := $(wildcard $(sort $(targets))) |
| 1325 | cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
| 1326 | |
| 1327 | ifneq ($(cmd_files),) |
| 1328 | $(cmd_files): ; # Do not try to update included dependency files |
| 1329 | include $(cmd_files) |
| 1330 | endif |
| 1331 | |
| 1332 | endif # skip-makefile |
| 1333 | |
| 1334 | PHONY += FORCE |
| 1335 | FORCE: |
| 1336 | |
| 1337 | # Declare the contents of the .PHONY variable as phony. We keep that |
| 1338 | # information in a variable so we can use it in if_changed and friends. |
| 1339 | .PHONY: $(PHONY) |