Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 1 | VERSION_GENERATION = 2 |
| 2 | VERSION_MAJOR = 2 |
| 3 | VERSION_MINOR = 3 |
| 4 | VERSION_REVISION = 0 |
| 5 | VERSION_RESERVED = 0 |
| 6 | PATCHLEVEL = 0 |
| 7 | SUBLEVEL = 0 |
| 8 | NAME = Tiny Mountain |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 9 | |
Juan Manuel Cruz | de1cec2 | 2015-05-11 19:19:37 -0500 | [diff] [blame] | 10 | export SOURCE_DIR PROJECT VPFILE KLIBC_DIR |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 11 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 12 | # *DOCUMENTATION* |
| 13 | # To see a list of typical targets execute "make help" |
| 14 | # More info can be located in ./README |
| 15 | # Comments in this file are targeted only to the developer, do not |
| 16 | # expect to learn how to build the kernel reading this file. |
| 17 | |
| 18 | # Do not use make's built-in rules and variables |
| 19 | # (this increases performance and avoids hard-to-debug behaviour); |
| 20 | MAKEFLAGS += -rR |
| 21 | |
| 22 | # Avoid funny character set dependencies |
| 23 | unexport LC_ALL |
| 24 | LC_COLLATE=C |
| 25 | LC_NUMERIC=C |
| 26 | export LC_COLLATE LC_NUMERIC |
| 27 | |
| 28 | # Avoid interference with shell env settings |
| 29 | unexport GREP_OPTIONS |
| 30 | |
| 31 | # We are using a recursive build, so we need to do a little thinking |
| 32 | # to get the ordering right. |
| 33 | # |
| 34 | # Most importantly: sub-Makefiles should only ever modify files in |
| 35 | # their own directory. If in some directory we have a dependency on |
| 36 | # a file in another dir (which doesn't happen often, but it's often |
| 37 | # unavoidable when linking the built-in.o targets which finally |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 38 | # turn into tinymountain), we will call a sub make in that other dir, and |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 39 | # after that we are sure that everything which is in that other dir |
| 40 | # is now up to date. |
| 41 | # |
| 42 | # The only cases where we need to modify files which have global |
| 43 | # effects are thus separated out and done before the recursive |
| 44 | # descending is started. They are now explicitly listed as the |
| 45 | # prepare rule. |
| 46 | |
| 47 | # Beautify output |
| 48 | # --------------------------------------------------------------------------- |
| 49 | # |
| 50 | # Normally, we echo the whole command before executing it. By making |
| 51 | # that echo $($(quiet)$(cmd)), we now have the possibility to set |
| 52 | # $(quiet) to choose other forms of output instead, e.g. |
| 53 | # |
| 54 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ |
| 55 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
| 56 | # |
| 57 | # If $(quiet) is empty, the whole command will be printed. |
| 58 | # If it is set to "quiet_", only the short version will be printed. |
| 59 | # If it is set to "silent_", nothing will be printed at all, since |
| 60 | # the variable $(silent_cmd_cc_o_c) doesn't exist. |
| 61 | # |
| 62 | # A simple variant is to prefix commands with $(Q) - that's useful |
| 63 | # for commands that shall be hidden in non-verbose mode. |
| 64 | # |
| 65 | # $(Q)ln $@ :< |
| 66 | # |
| 67 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. |
| 68 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. |
| 69 | # |
| 70 | # To put more focus on warnings, be less verbose as default |
| 71 | # Use 'make V=1' to see the full commands |
| 72 | |
| 73 | ifeq ("$(origin V)", "command line") |
| 74 | KBUILD_VERBOSE = $(V) |
| 75 | endif |
| 76 | ifndef KBUILD_VERBOSE |
| 77 | KBUILD_VERBOSE = 0 |
| 78 | endif |
| 79 | |
| 80 | ifeq ($(KBUILD_VERBOSE),1) |
| 81 | quiet = |
| 82 | Q = |
| 83 | else |
| 84 | quiet=quiet_ |
| 85 | Q = @ |
| 86 | endif |
| 87 | |
| 88 | # If the user is running make -s (silent mode), suppress echoing of |
| 89 | # commands |
| 90 | |
| 91 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 |
| 92 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) |
| 93 | quiet=silent_ |
| 94 | endif |
| 95 | else # make-3.8x |
| 96 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) |
| 97 | quiet=silent_ |
| 98 | endif |
| 99 | endif |
| 100 | |
| 101 | export quiet Q KBUILD_VERBOSE |
| 102 | |
| 103 | # kbuild supports saving output files in a separate directory. |
| 104 | # To locate output files in a separate directory two syntaxes are supported. |
| 105 | # In both cases the working directory must be the root of the kernel src. |
| 106 | # 1) O= |
| 107 | # Use "make O=dir/to/store/output/files/" |
| 108 | # |
| 109 | # 2) Set KBUILD_OUTPUT |
| 110 | # Set the environment variable KBUILD_OUTPUT to point to the directory |
| 111 | # where the output files shall be placed. |
| 112 | # export KBUILD_OUTPUT=dir/to/store/output/files/ |
| 113 | # make |
| 114 | # |
| 115 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment |
| 116 | # variable. |
| 117 | |
| 118 | # KBUILD_SRC is set on invocation of make in OBJ directory |
| 119 | # KBUILD_SRC is not intended to be used by the regular user (for now) |
| 120 | ifeq ($(KBUILD_SRC),) |
| 121 | |
| 122 | # OK, Make called in directory where kernel src resides |
| 123 | # Do we want to locate output files in a separate directory? |
| 124 | ifeq ("$(origin O)", "command line") |
| 125 | KBUILD_OUTPUT := $(O) |
| 126 | endif |
| 127 | |
| 128 | # That's our default target when none is given on the command line |
| 129 | PHONY := _all |
| 130 | _all: |
| 131 | |
| 132 | # Cancel implicit rules on top Makefile |
| 133 | $(CURDIR)/Makefile Makefile: ; |
| 134 | |
| 135 | ifneq ($(KBUILD_OUTPUT),) |
| 136 | # Invoke a second make in the output directory, passing relevant variables |
| 137 | # check that the output directory actually exists |
| 138 | saved-output := $(KBUILD_OUTPUT) |
| 139 | KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ |
| 140 | && /bin/pwd) |
| 141 | $(if $(KBUILD_OUTPUT),, \ |
| 142 | $(error failed to create output directory "$(saved-output)")) |
| 143 | |
| 144 | PHONY += $(MAKECMDGOALS) sub-make |
| 145 | |
| 146 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make |
| 147 | @: |
| 148 | |
| 149 | sub-make: FORCE |
| 150 | $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ |
| 151 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) |
| 152 | |
| 153 | # Leave processing to above invocation of make |
| 154 | skip-makefile := 1 |
| 155 | endif # ifneq ($(KBUILD_OUTPUT),) |
| 156 | endif # ifeq ($(KBUILD_SRC),) |
| 157 | |
| 158 | # We process the rest of the Makefile if this is the final invocation of make |
| 159 | ifeq ($(skip-makefile),) |
| 160 | |
| 161 | # Do not print "Entering directory ...", |
| 162 | # but we want to display it when entering to the output directory |
| 163 | # so that IDEs/editors are able to understand relative filenames. |
| 164 | MAKEFLAGS += --no-print-directory |
| 165 | |
| 166 | # Call a source code checker (by default, "sparse") as part of the |
| 167 | # C compilation. |
| 168 | # |
| 169 | # Use 'make C=1' to enable checking of only re-compiled files. |
| 170 | # Use 'make C=2' to enable checking of *all* source files, regardless |
| 171 | # of whether they are re-compiled or not. |
| 172 | # |
| 173 | # See the file "Documentation/sparse.txt" for more details, including |
| 174 | # where to get the "sparse" utility. |
| 175 | |
| 176 | ifeq ("$(origin C)", "command line") |
| 177 | KBUILD_CHECKSRC = $(C) |
| 178 | endif |
| 179 | ifndef KBUILD_CHECKSRC |
| 180 | KBUILD_CHECKSRC = 0 |
| 181 | endif |
| 182 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 183 | PHONY += all |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 184 | _all: all |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 185 | |
| 186 | ifeq ($(KBUILD_SRC),) |
| 187 | # building in the source tree |
| 188 | srctree := . |
| 189 | else |
| 190 | ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) |
| 191 | # building in a subdirectory of the source tree |
| 192 | srctree := .. |
| 193 | else |
| 194 | srctree := $(KBUILD_SRC) |
| 195 | endif |
| 196 | endif |
| 197 | objtree := . |
| 198 | src := $(srctree) |
| 199 | obj := $(objtree) |
| 200 | |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 201 | VPATH := $(srctree) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 202 | |
| 203 | export srctree objtree VPATH |
| 204 | |
| 205 | |
| 206 | # SUBARCH tells the usermode build what the underlying arch is. That is set |
| 207 | # first, and if a usermode build is happening, the "ARCH=um" on the command |
| 208 | # line overrides the setting of ARCH below. If a native build is happening, |
| 209 | # then ARCH is assigned, getting whatever value it gets normally, and |
| 210 | # SUBARCH is subsequently ignored. |
| 211 | |
| 212 | SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ |
| 213 | -e s/sun4u/sparc64/ \ |
| 214 | -e s/arm.*/arm/ -e s/sa110/arm/ \ |
| 215 | -e s/s390x/s390/ -e s/parisc64/parisc/ \ |
| 216 | -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ |
| 217 | -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) |
| 218 | |
| 219 | # Cross compiling and selecting different set of gcc/bin-utils |
| 220 | # --------------------------------------------------------------------------- |
| 221 | # |
| 222 | # When performing cross compilation for other architectures ARCH shall be set |
| 223 | # to the target architecture. (See arch/* for the possibilities). |
| 224 | # ARCH can be set during invocation of make: |
Anas Nashif | 67fc206 | 2015-04-24 18:29:24 -0400 | [diff] [blame] | 225 | # make ARCH=x86 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 226 | # Another way is to have ARCH set in the environment. |
| 227 | # The default ARCH is the host where make is executed. |
| 228 | |
| 229 | # CROSS_COMPILE specify the prefix used for all executables used |
| 230 | # during compilation. Only gcc and related bin-utils executables |
| 231 | # are prefixed with $(CROSS_COMPILE). |
| 232 | # CROSS_COMPILE can be set on the command line |
Anas Nashif | 67fc206 | 2015-04-24 18:29:24 -0400 | [diff] [blame] | 233 | # make CROSS_COMPILE=i586-pc-elf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 234 | # Alternatively CROSS_COMPILE can be set in the environment. |
| 235 | # A third alternative is to store a setting in .config so that plain |
| 236 | # "make" in the configured kernel build directory always uses that. |
| 237 | # Default value for CROSS_COMPILE is not to prefix executables |
| 238 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile |
| 239 | ARCH ?= $(SUBARCH) |
| 240 | CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) |
| 241 | |
| 242 | # Architecture as present in compile.h |
| 243 | UTS_MACHINE := $(ARCH) |
| 244 | SRCARCH := $(ARCH) |
| 245 | |
| 246 | # Additional ARCH settings for x86 |
| 247 | ifeq ($(ARCH),i386) |
| 248 | SRCARCH := x86 |
| 249 | endif |
| 250 | ifeq ($(ARCH),x86_64) |
| 251 | SRCARCH := x86 |
| 252 | endif |
| 253 | |
| 254 | # Additional ARCH settings for sparc |
| 255 | ifeq ($(ARCH),sparc32) |
| 256 | SRCARCH := sparc |
| 257 | endif |
| 258 | ifeq ($(ARCH),sparc64) |
| 259 | SRCARCH := sparc |
| 260 | endif |
| 261 | |
| 262 | # Additional ARCH settings for sh |
| 263 | ifeq ($(ARCH),sh64) |
| 264 | SRCARCH := sh |
| 265 | endif |
| 266 | |
| 267 | # Additional ARCH settings for tile |
| 268 | ifeq ($(ARCH),tilepro) |
| 269 | SRCARCH := tile |
| 270 | endif |
| 271 | ifeq ($(ARCH),tilegx) |
| 272 | SRCARCH := tile |
| 273 | endif |
| 274 | |
| 275 | # Where to locate arch specific headers |
| 276 | hdr-arch := $(SRCARCH) |
| 277 | |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 278 | ifdef O |
| 279 | KCONFIG_CONFIG := $(O)/.config |
| 280 | KCONFIG_AUTOCONFIG := $(O)/include/config/auto.conf |
| 281 | KCONFIG_AUTOHEADER := $(O)/include/generated/autoconf.h |
| 282 | KCONFIG_TRISTATE := $(O)/include/config/tristate.conf |
| 283 | KCONFIG_AUTOCMD := $(O)/include/config/auto.conf.cmd |
| 284 | else |
| 285 | KCONFIG_CONFIG := .config |
| 286 | endif |
| 287 | |
| 288 | export KCONFIG_CONFIG KCONFIG_AUTOCONFIG KCONFIG_AUTOHEADER KCONFIG_TRISTATE KCONFIG_AUTOCMD |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 289 | |
| 290 | # SHELL used by kbuild |
| 291 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
| 292 | else if [ -x /bin/bash ]; then echo /bin/bash; \ |
| 293 | else echo sh; fi ; fi) |
| 294 | |
| 295 | HOSTCC = gcc |
| 296 | HOSTCXX = g++ |
| 297 | HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 |
| 298 | HOSTCXXFLAGS = -O2 |
| 299 | |
| 300 | ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) |
| 301 | HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ |
| 302 | -Wno-missing-field-initializers -fno-delete-null-pointer-checks |
| 303 | endif |
| 304 | |
| 305 | # Decide whether to build built-in, modular, or both. |
| 306 | # Normally, just do built-in. |
| 307 | |
| 308 | KBUILD_MODULES := |
| 309 | KBUILD_BUILTIN := 1 |
| 310 | |
| 311 | # If we have only "make modules", don't compile built-in objects. |
| 312 | # When we're building modules with modversions, we need to consider |
| 313 | # the built-in objects during the descend as well, in order to |
| 314 | # make sure the checksums are up to date before we record them. |
| 315 | |
| 316 | ifeq ($(MAKECMDGOALS),modules) |
| 317 | KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) |
| 318 | endif |
| 319 | |
| 320 | # If we have "make <whatever> modules", compile modules |
| 321 | # in addition to whatever we do anyway. |
| 322 | # Just "make" or "make all" shall build modules as well |
| 323 | |
| 324 | ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) |
| 325 | KBUILD_MODULES := 1 |
| 326 | endif |
| 327 | |
| 328 | ifeq ($(MAKECMDGOALS),) |
| 329 | KBUILD_MODULES := 1 |
| 330 | endif |
| 331 | |
| 332 | export KBUILD_MODULES KBUILD_BUILTIN |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 333 | export KBUILD_CHECKSRC KBUILD_SRC |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 334 | |
| 335 | ifneq ($(CC),) |
| 336 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) |
| 337 | COMPILER := clang |
| 338 | else |
| 339 | COMPILER := gcc |
| 340 | endif |
| 341 | export COMPILER |
| 342 | endif |
| 343 | |
| 344 | # Look for make include files relative to root of kernel src |
| 345 | MAKEFLAGS += --include-dir=$(srctree) |
| 346 | |
| 347 | # We need some generic definitions (do not try to remake the file). |
| 348 | $(srctree)/scripts/Kbuild.include: ; |
| 349 | include $(srctree)/scripts/Kbuild.include |
| 350 | |
| 351 | # Make variables (CC, etc...) |
| 352 | AS = $(CROSS_COMPILE)as |
| 353 | LD = $(CROSS_COMPILE)ld |
| 354 | CC = $(CROSS_COMPILE)gcc |
| 355 | CPP = $(CC) -E |
| 356 | AR = $(CROSS_COMPILE)ar |
| 357 | NM = $(CROSS_COMPILE)nm |
| 358 | STRIP = $(CROSS_COMPILE)strip |
| 359 | OBJCOPY = $(CROSS_COMPILE)objcopy |
| 360 | OBJDUMP = $(CROSS_COMPILE)objdump |
| 361 | AWK = awk |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 362 | GENKSYMS = $(TIMO_BASE)/scripts/genksyms/genksyms |
| 363 | GENIDT = $(TIMO_BASE)/scripts/gen_idt/gen_idt |
| 364 | FIXDEP = $(TIMO_BASE)/scripts/basic/fixdep |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 365 | INSTALLKERNEL := installkernel |
| 366 | DEPMOD = /sbin/depmod |
| 367 | PERL = perl |
| 368 | PYTHON = python |
| 369 | CHECK = sparse |
| 370 | |
Anas Nashif | 6afc485 | 2015-04-24 18:30:36 -0400 | [diff] [blame] | 371 | CHECKFLAGS := -Wbitwise -Wno-return-void $(CF) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 372 | CFLAGS_MODULE = |
| 373 | AFLAGS_MODULE = |
| 374 | LDFLAGS_MODULE = |
| 375 | CFLAGS_KERNEL = |
| 376 | AFLAGS_KERNEL = |
| 377 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage |
| 378 | |
| 379 | |
| 380 | # Use USERINCLUDE when you must reference the UAPI directories only. |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 381 | USERINCLUDE := -include $(CURDIR)/include/generated/autoconf.h |
| 382 | PROJECTINCLUDE := $(strip -I$(srctree)/include/microkernel \ |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 383 | -I$(CURDIR)/misc/generated/sysgen) \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 384 | $(USERINCLUDE) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 385 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 386 | # Use TIMOINCLUDE when you must reference the include/ directory. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 387 | # Needed to be compatible with the O= option |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 388 | TIMOINCLUDE := \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 389 | -I$(srctree)/arch/$(hdr-arch)/include \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 390 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 391 | -I$(srctree)/include \ |
| 392 | -I$(CURDIR)/include/generated \ |
| 393 | $(USERINCLUDE) \ |
| 394 | $(STDINCLUDE) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 395 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 396 | KBUILD_CPPFLAGS := -DKERNEL |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 397 | |
Juan Manuel Cruz | 4d8c725 | 2015-05-04 17:13:48 -0500 | [diff] [blame] | 398 | DEFAULTFLAGS ?= -Os |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 399 | |
Juan Manuel Cruz | 068ebc0 | 2015-05-06 10:41:08 -0500 | [diff] [blame] | 400 | KBUILD_CFLAGS := -c -g -std=c99 \ |
Juan Manuel Cruz | 4d8c725 | 2015-05-04 17:13:48 -0500 | [diff] [blame] | 401 | $(DEFAULTFLAGS) \ |
| 402 | $(CONFIG_COMPILER_OPT) \ |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 403 | -fno-reorder-functions \ |
| 404 | -fno-asynchronous-unwind-tables \ |
| 405 | -fno-omit-frame-pointer \ |
| 406 | -fno-defer-pop -Wall \ |
| 407 | -Wno-unused-but-set-variable \ |
| 408 | -Wno-main -ffreestanding |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 409 | |
| 410 | KBUILD_AFLAGS_KERNEL := |
| 411 | KBUILD_CFLAGS_KERNEL := |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 412 | KBUILD_AFLAGS := -c -g -xassembler-with-cpp |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 413 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 414 | LDFLAGS += $(call cc-ldoption,-nostartfiles) |
| 415 | LDFLAGS += $(call cc-ldoption,-nodefaultlibs) |
| 416 | LDFLAGS += $(call cc-ldoption,-nostdlib) |
| 417 | LDFLAGS += $(call cc-ldoption,-static) |
Juan Manuel Cruz | 0c47e4f | 2015-05-13 11:52:55 -0500 | [diff] [blame] | 418 | LDLIBS_TOOLCHAIN ?= -lgcc |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 419 | |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 420 | KERNELVERSION = $(VERSION_GENERATION).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 421 | |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 422 | export VERSION_GENERATION VERSION_MAJOR VERSION_MINOR VERSION_REVISION VERSION_RESERVED |
| 423 | export PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 424 | export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC |
| 425 | export CPP AR NM STRIP OBJCOPY OBJDUMP |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 426 | export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE GENIDT FIXDEP |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 427 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
| 428 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 429 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS TIMOINCLUDE OBJCOPYFLAGS LDFLAGS |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 430 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV |
| 431 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
| 432 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE |
| 433 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL |
Juan Manuel Cruz | 0c47e4f | 2015-05-13 11:52:55 -0500 | [diff] [blame] | 434 | export KBUILD_ARFLAGS PROJECTINCLUDE LDLIBS_TOOLCHAIN |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 435 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 436 | |
| 437 | # Files to ignore in find ... statements |
| 438 | |
| 439 | export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ |
| 440 | -name CVS -o -name .pc -o -name .hg -o -name .git \) \ |
| 441 | -prune -o |
| 442 | export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ |
| 443 | --exclude CVS --exclude .pc --exclude .hg --exclude .git |
| 444 | |
| 445 | # =========================================================================== |
| 446 | # Rules shared between *config targets and build targets |
| 447 | |
| 448 | # Basic helpers built in scripts/ |
| 449 | PHONY += scripts_basic |
| 450 | scripts_basic: |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 451 | $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/basic |
| 452 | $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/gen_idt |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 453 | $(Q)rm -f .tmp_quiet_recordmcount |
| 454 | |
| 455 | # To avoid any implicit rule to kick in, define an empty command. |
| 456 | scripts/basic/%: scripts_basic ; |
| 457 | |
| 458 | PHONY += outputmakefile |
| 459 | # outputmakefile generates a Makefile in the output directory, if using a |
| 460 | # separate output directory. This allows convenient use of make in the |
| 461 | # output directory. |
| 462 | outputmakefile: |
| 463 | ifneq ($(KBUILD_SRC),) |
| 464 | $(Q)ln -fsn $(srctree) source |
| 465 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ |
| 466 | $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) |
| 467 | endif |
| 468 | |
| 469 | # Support for using generic headers in asm-generic |
| 470 | PHONY += asm-generic |
| 471 | asm-generic: |
| 472 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ |
| 473 | src=asm obj=arch/$(SRCARCH)/include/generated/asm |
| 474 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ |
| 475 | src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm |
| 476 | |
| 477 | # To make sure we do not include .config for any of the *config targets |
| 478 | # catch them early, and hand them over to scripts/kconfig/Makefile |
| 479 | # It is allowed to specify more targets when calling make, including |
| 480 | # mixing *config targets and build targets. |
| 481 | # For example 'make oldconfig all'. |
| 482 | # Detect when mixed targets is specified, and make a second invocation |
| 483 | # of make so .config is not included in this case either (for *config). |
| 484 | |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 485 | version_h := include/generated/version.h |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 486 | |
| 487 | no-dot-config-targets := clean mrproper distclean \ |
| 488 | cscope gtags TAGS tags help% %docs check% coccicheck \ |
| 489 | $(version_h) headers_% archheaders archscripts \ |
| 490 | kernelversion %src-pkg |
| 491 | |
| 492 | config-targets := 0 |
| 493 | mixed-targets := 0 |
| 494 | dot-config := 1 |
| 495 | |
| 496 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 497 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) |
| 498 | dot-config := 0 |
| 499 | endif |
| 500 | endif |
| 501 | |
Anas Nashif | d6ebd18 | 2015-05-28 12:54:03 -0400 | [diff] [blame] | 502 | ifneq ($(filter config %config,$(MAKECMDGOALS)),) |
| 503 | config-targets := 1 |
| 504 | ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) |
| 505 | mixed-targets := 1 |
| 506 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 507 | endif |
| 508 | |
| 509 | ifeq ($(mixed-targets),1) |
| 510 | # =========================================================================== |
| 511 | # We're called with mixed targets (*config and build targets). |
| 512 | # Handle them one by one. |
| 513 | |
| 514 | PHONY += $(MAKECMDGOALS) __build_one_by_one |
| 515 | |
| 516 | $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one |
| 517 | @: |
| 518 | |
| 519 | __build_one_by_one: |
| 520 | $(Q)set -e; \ |
| 521 | for i in $(MAKECMDGOALS); do \ |
| 522 | $(MAKE) -f $(srctree)/Makefile $$i; \ |
| 523 | done |
| 524 | |
| 525 | else |
| 526 | ifeq ($(config-targets),1) |
| 527 | # =========================================================================== |
| 528 | # *config targets only - make sure prerequisites are updated, and descend |
| 529 | # in scripts/kconfig to make the *config target |
| 530 | |
| 531 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. |
| 532 | # KBUILD_DEFCONFIG may point out an alternative default configuration |
| 533 | # used for 'make defconfig' |
| 534 | include $(srctree)/arch/$(SRCARCH)/Makefile |
| 535 | export KBUILD_DEFCONFIG KBUILD_KCONFIG |
| 536 | |
| 537 | config: scripts_basic outputmakefile FORCE |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 538 | $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 539 | |
| 540 | %config: scripts_basic outputmakefile FORCE |
Juan Manuel Cruz | 4d7f954 | 2015-05-25 18:15:11 -0500 | [diff] [blame] | 541 | $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/kconfig $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 542 | |
| 543 | else |
| 544 | # =========================================================================== |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 545 | # Build targets only - this includes tinymountain, arch specific targets, clean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 546 | # targets and others. In general all targets except *config targets. |
| 547 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 548 | # Additional helpers built in scripts/ |
| 549 | # Carefully list dependencies so we do not try to build scripts twice |
| 550 | # in parallel |
| 551 | PHONY += scripts |
Dirk Brandewie | 991e9d3 | 2015-06-01 09:48:10 -0700 | [diff] [blame] | 552 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 553 | $(Q)$(MAKE) $(build)=$(@) |
| 554 | |
Anas Nashif | 3b9199d | 2015-05-18 09:00:49 -0400 | [diff] [blame] | 555 | |
Juan Manuel Cruz | de1cec2 | 2015-05-11 19:19:37 -0500 | [diff] [blame] | 556 | core-y := arch/ kernel/ misc/ net/ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 557 | bsp-y := drivers/ |
| 558 | |
| 559 | ifneq ($(strip $(PROJECT)),) |
Anas Nashif | 5c8ff0f | 2015-05-09 18:34:57 -0400 | [diff] [blame] | 560 | core-y += $(SOURCE_DIR) |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 561 | endif |
| 562 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 563 | |
| 564 | ifeq ($(dot-config),1) |
| 565 | # Read in config |
| 566 | -include include/config/auto.conf |
| 567 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 568 | # Read in dependencies to all Kconfig* files, make sure to run |
| 569 | # oldconfig if changes are detected. |
| 570 | -include include/config/auto.conf.cmd |
| 571 | |
| 572 | # To avoid any implicit rule to kick in, define an empty command |
| 573 | $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; |
| 574 | |
| 575 | # If .config is newer than include/config/auto.conf, someone tinkered |
| 576 | # with it and forgot to run make oldconfig. |
| 577 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so |
| 578 | # we execute the config step to be sure to catch updated Kconfig files |
| 579 | include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd |
| 580 | $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 581 | |
| 582 | else |
| 583 | # Dummy target needed, because used as prerequisite |
| 584 | include/config/auto.conf: ; |
| 585 | endif # $(dot-config) |
| 586 | |
Anas Nashif | 3b9199d | 2015-05-18 09:00:49 -0400 | [diff] [blame] | 587 | ifdef CONFIG_MINIMAL_LIBC |
| 588 | # Objects we will link into tinymountain / subdirs we need to visit |
| 589 | KLIBC_DIR := lib/libc/minimal |
| 590 | libs-y := $(KLIBC_DIR)/ |
| 591 | TIMOINCLUDE += -I$(srctree)/lib/libc/minimal/include |
| 592 | endif |
| 593 | |
Anas Nashif | 19f0ff2 | 2015-05-18 08:57:17 -0400 | [diff] [blame] | 594 | ifdef CONFIG_TOOLCHAIN_NEWLIB |
| 595 | libs-y += lib/libc/newlib/ |
Anas Nashif | e439f51 | 2015-05-18 19:55:02 -0400 | [diff] [blame] | 596 | ALL_LIBS += c m |
Anas Nashif | 19f0ff2 | 2015-05-18 08:57:17 -0400 | [diff] [blame] | 597 | endif |
| 598 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 599 | #File that includes all prepare special embedded architecture targets. |
| 600 | include $(srctree)/scripts/Makefile.preparch |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 601 | sinclude $(srctree)/scripts/Makefile.$(SRCARCH).preparch |
Anas Nashif | aca245d | 2015-05-13 00:44:22 -0400 | [diff] [blame] | 602 | ifdef VXMICRO_GCC_VARIANT |
| 603 | include $(srctree)/scripts/Makefile.toolchain.$(VXMICRO_GCC_VARIANT) |
| 604 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 605 | |
Anas Nashif | f1c7c17 | 2015-06-01 10:34:57 -0400 | [diff] [blame] | 606 | QEMU_BIN_PATH ?= /usr/bin |
| 607 | QEMU = $(QEMU_BIN_PATH)/$(QEMU_$(SRCARCH)) |
| 608 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 609 | # The all: target is the default when no target is given on the |
| 610 | # command line. |
| 611 | # This allow a user to issue only 'make' to build a kernel including modules |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 612 | # Defaults to tinymountain, but the arch makefile usually adds further targets |
| 613 | all: tinymountain |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 614 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 615 | ifdef CONFIG_READABLE_ASM |
| 616 | # Disable optimizations that make assembler listings hard to read. |
| 617 | # reorder blocks reorders the control in the function |
| 618 | # ipa clone creates specialized cloned functions |
| 619 | # partial inlining inlines only parts of functions |
| 620 | KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ |
| 621 | $(call cc-option,-fno-ipa-cp-clone,) \ |
| 622 | $(call cc-option,-fno-partial-inlining) |
| 623 | endif |
| 624 | |
Juan Manuel Cruz | fbc5956 | 2015-05-04 17:31:43 -0500 | [diff] [blame] | 625 | ISA_FLAG=$(ISA_FLAG_$(SRCARCH)) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 626 | |
| 627 | STACK_CANARIES_FLAG_y = $(call cc-option,-fstack-protector-all,) |
| 628 | STACK_CANARIES_FLAG_ = $(call cc-option,-fno-stack-protector,) |
| 629 | STACK_CANARIES_FLAG = $(STACK_CANARIES_FLAG_$(CONFIG_STACK_CANARIES)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 630 | |
| 631 | # Handle stack protector mode. |
| 632 | # |
| 633 | # Since kbuild can potentially perform two passes (first with the old |
| 634 | # .config values and then with updated .config values), we cannot error out |
| 635 | # if a desired compiler option is unsupported. If we were to error, kbuild |
| 636 | # could never get to the second pass and actually notice that we changed |
| 637 | # the option to something that was supported. |
| 638 | # |
| 639 | # Additionally, we don't want to fallback and/or silently change which compiler |
| 640 | # flags will be used, since that leads to producing kernels with different |
| 641 | # security feature characteristics depending on the compiler used. ("But I |
| 642 | # selected CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!") |
| 643 | # |
| 644 | # The middle ground is to warn here so that the failed option is obvious, but |
| 645 | # to let the build fail with bad compiler flags so that we can't produce a |
| 646 | # kernel when there is a CONFIG and compiler mismatch. |
| 647 | # |
| 648 | ifdef CONFIG_CC_STACKPROTECTOR_REGULAR |
| 649 | stackp-flag := -fstack-protector |
| 650 | ifeq ($(call cc-option, $(stackp-flag)),) |
| 651 | $(warning Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: \ |
| 652 | -fstack-protector not supported by compiler) |
| 653 | endif |
| 654 | else |
| 655 | ifdef CONFIG_CC_STACKPROTECTOR_STRONG |
| 656 | stackp-flag := -fstack-protector-strong |
| 657 | ifeq ($(call cc-option, $(stackp-flag)),) |
| 658 | $(warning Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: \ |
| 659 | -fstack-protector-strong not supported by compiler) |
| 660 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 661 | endif |
| 662 | endif |
| 663 | KBUILD_CFLAGS += $(stackp-flag) |
| 664 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 665 | export x86_FLAGS arm_FLAGS arc_FLAGS LDFLAG_LINKERCMD |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 666 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 667 | ARCHFLAGS = $($(SRCARCH)_FLAGS) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 668 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 669 | KBUILD_CFLAGS += $(SSE_FP_MATH_FLAG) \ |
| 670 | $(ISA_FLAG) \ |
| 671 | $(STACK_CANARIES_FLAG) \ |
| 672 | $(ARCHFLAGS) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 673 | |
| 674 | ifdef CONFIG_DEBUG_INFO_REDUCED |
| 675 | KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ |
| 676 | $(call cc-option,-fno-var-tracking) |
| 677 | endif |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 678 | KBUILD_CFLAGS += $(CFLAGS) |
Juan Manuel Cruz | fbc5956 | 2015-05-04 17:31:43 -0500 | [diff] [blame] | 679 | KBUILD_AFLAGS += $(ARCHFLAGS) $(ISA_FLAG) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 680 | KBUILD_AFLAGS += $(CFLAGS) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 681 | |
| 682 | ifdef CONFIG_FUNCTION_TRACER |
| 683 | ifdef CONFIG_HAVE_FENTRY |
| 684 | CC_USING_FENTRY := $(call cc-option, -mfentry -DCC_USING_FENTRY) |
| 685 | endif |
| 686 | KBUILD_CFLAGS += -pg $(CC_USING_FENTRY) |
| 687 | KBUILD_AFLAGS += $(CC_USING_FENTRY) |
| 688 | ifdef CONFIG_DYNAMIC_FTRACE |
| 689 | ifdef CONFIG_HAVE_C_RECORDMCOUNT |
| 690 | BUILD_C_RECORDMCOUNT := y |
| 691 | export BUILD_C_RECORDMCOUNT |
| 692 | endif |
| 693 | endif |
| 694 | endif |
| 695 | |
| 696 | # We trigger additional mismatches with less inlining |
| 697 | ifdef CONFIG_DEBUG_SECTION_MISMATCH |
| 698 | KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) |
| 699 | endif |
| 700 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 701 | # Adding specific KBUILD_CFLAGS. This one is an specific example of how to set up KBUILD flags |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 702 | KBUILD_ARFLAGS := $(call ar-option,D) |
| 703 | |
| 704 | #FIXME This group of flags are under review |
| 705 | ifdef REVIEW_BLOCK |
| 706 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 707 | # arch Makefile may override CC so keep this after arch Makefile is included |
| 708 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
| 709 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
| 710 | |
| 711 | # warn about C99 declaration after statement |
| 712 | KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) |
| 713 | |
| 714 | # disable pointer signed / unsigned warnings in gcc 4.0 |
| 715 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) |
| 716 | |
| 717 | # disable invalid "can't wrap" optimizations for signed / pointers |
| 718 | KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) |
| 719 | |
| 720 | # conserve stack if available |
| 721 | KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) |
| 722 | |
| 723 | # disallow errors like 'EXPORT_GPL(foo);' with missing header |
| 724 | KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) |
| 725 | |
| 726 | # require functions to have arguments in prototypes, not empty 'int foo()' |
| 727 | KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) |
| 728 | |
| 729 | # Prohibit date/time macros, which would make the build non-deterministic |
| 730 | KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 731 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 732 | |
| 733 | # use the deterministic mode of AR if available |
| 734 | KBUILD_ARFLAGS := $(call ar-option,D) |
| 735 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 736 | include $(srctree)/scripts/Makefile.extrawarn |
| 737 | |
| 738 | # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments |
| 739 | KBUILD_CPPFLAGS += $(KCPPFLAGS) |
| 740 | KBUILD_AFLAGS += $(KAFLAGS) |
| 741 | KBUILD_CFLAGS += $(KCFLAGS) |
| 742 | |
| 743 | # Use --build-id when available. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 744 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 745 | LDFLAGS_tinymountain += $(call cc-ldoption,-nostartfiles) |
| 746 | LDFLAGS_tinymountain += $(call cc-ldoption,-nodefaultlibs) |
| 747 | LDFLAGS_tinymountain += $(call cc-ldoption,-nostdlib) |
| 748 | LDFLAGS_tinymountain += $(call cc-ldoption,-static) |
Anas Nashif | 3a4073d | 2015-05-09 10:47:33 -0400 | [diff] [blame] | 749 | #LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--unresolved-symbols=ignore-in-object-files) |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 750 | LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)-X) |
| 751 | LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)-N) |
| 752 | LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--gc-sections) |
| 753 | LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--build-id=none) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 754 | |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 755 | LD_TOOLCHAIN ?= -D__GCC_LINKER_CMD__ |
Juan Manuel Cruz | 1c8f5a7 | 2015-04-30 17:19:04 -0500 | [diff] [blame] | 756 | |
| 757 | ifeq ("$(CONFIG_MICROKERNEL)", "y") |
| 758 | KERNEL_NAME=microkernel |
| 759 | else |
| 760 | KERNEL_NAME=nanokernel |
| 761 | endif |
| 762 | |
| 763 | export LD_TOOLCHAIN KERNEL_NAME |
Juan Manuel Cruz | 0d01f5b | 2015-02-22 14:29:18 -0600 | [diff] [blame] | 764 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 765 | # Default kernel image to build when no specific target is given. |
| 766 | # KBUILD_IMAGE may be overruled on the command line or |
| 767 | # set in the environment |
| 768 | # Also any assignments in arch/$(ARCH)/Makefile take precedence over |
| 769 | # this default value |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 770 | export KBUILD_IMAGE ?= tinymountain |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 771 | |
| 772 | # |
| 773 | # INSTALL_PATH specifies where to place the updated kernel and system map |
| 774 | # images. Default is /boot, but you can set it to other values |
| 775 | export INSTALL_PATH ?= /boot |
| 776 | |
| 777 | # |
| 778 | # INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots. |
| 779 | # Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as |
| 780 | # an argument if needed. Otherwise it defaults to the kernel install path |
| 781 | # |
| 782 | export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) |
| 783 | |
| 784 | # |
| 785 | # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory |
| 786 | # relocations required by build roots. This is not defined in the |
| 787 | # makefile but the argument can be passed to make if needed. |
| 788 | # |
| 789 | |
| 790 | MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) |
| 791 | export MODLIB |
| 792 | |
| 793 | # |
| 794 | # INSTALL_MOD_STRIP, if defined, will cause modules to be |
| 795 | # stripped after they are installed. If INSTALL_MOD_STRIP is '1', then |
| 796 | # the default option --strip-debug will be used. Otherwise, |
| 797 | # INSTALL_MOD_STRIP value will be used as the options to the strip command. |
| 798 | |
| 799 | ifdef INSTALL_MOD_STRIP |
| 800 | ifeq ($(INSTALL_MOD_STRIP),1) |
| 801 | mod_strip_cmd = $(STRIP) --strip-debug |
| 802 | else |
| 803 | mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) |
| 804 | endif # INSTALL_MOD_STRIP=1 |
| 805 | else |
| 806 | mod_strip_cmd = true |
| 807 | endif # INSTALL_MOD_STRIP |
| 808 | export mod_strip_cmd |
| 809 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 810 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 811 | |
| 812 | ifdef CONFIG_MODULE_SIG_ALL |
| 813 | MODSECKEY = ./signing_key.priv |
| 814 | MODPUBKEY = ./signing_key.x509 |
| 815 | export MODPUBKEY |
| 816 | mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY) |
| 817 | else |
| 818 | mod_sign_cmd = true |
| 819 | endif |
| 820 | export mod_sign_cmd |
| 821 | |
| 822 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 823 | core-y += |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 824 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 825 | tinymountain-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 826 | $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 827 | $(bsp-y) $(bsp-m) $(libs-y) $(libs-m))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 828 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 829 | tinymountain-alldirs := $(sort $(tinymountain-dirs) $(patsubst %/,%,$(filter %/, \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 830 | $(init-) $(core-) $(drivers-) $(bsp-) $(libs-)))) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 831 | |
| 832 | init-y := $(patsubst %/, %/built-in.o, $(init-y)) |
| 833 | core-y := $(patsubst %/, %/built-in.o, $(core-y)) |
| 834 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 835 | bsp-y := $(patsubst %/, %/built-in.o, $(bsp-y)) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 836 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
| 837 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) |
| 838 | libs-y := $(libs-y1) $(libs-y2) |
| 839 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 840 | # Externally visible symbols (used by link-tinymountain.sh) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 841 | DQUOTE = " |
| 842 | #This comment line is to fix the highlighting of some editors due the quote effect." |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 843 | export KBUILD_TIMO_INIT := $(head-y) $(init-y) |
| 844 | export KBUILD_TIMO_MAIN := $(core-y) $(libs-y) $(drivers-y) $(bsp-y) |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 845 | export KBUILD_LDS := $(srctree)/arch/$(SRCARCH)/$(subst $(DQUOTE),,$(CONFIG_BSP_DIR))/linker.cmd |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 846 | export LDFLAGS_tinymountain |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 847 | # used by scripts/pacmage/Makefile |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 848 | export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(tinymountain-alldirs)) arch Documentation include samples scripts tools virt) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 849 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 850 | tinymountain-deps := $(KBUILD_LDS) $(KBUILD_TIMO_INIT) $(KBUILD_TIMO_MAIN) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 851 | |
Anas Nashif | 369cf08 | 2015-05-17 08:55:21 -0400 | [diff] [blame] | 852 | ALL_LIBS += $(TOOLCHAIN_LIBS) |
| 853 | export ALL_LIBS |
| 854 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 855 | # Final link of tinymountain |
Anas Nashif | 369cf08 | 2015-05-17 08:55:21 -0400 | [diff] [blame] | 856 | cmd_link-tinymountain = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_tinymountain) $(LIB_INCLUDE_DIR) $(ALL_LIBS) |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 857 | quiet_cmd_link-tinymountain = LINK $@ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 858 | |
| 859 | # Include targets which we want to |
| 860 | # execute if the rest of the kernel build went well. |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 861 | tinymountain: scripts/link-tinymountain.sh $(tinymountain-deps) FORCE |
Dirk Brandewie | bc9c884 | 2015-06-01 09:48:10 -0700 | [diff] [blame] | 862 | @touch tinymountain |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 863 | ifdef CONFIG_HEADERS_CHECK |
| 864 | $(Q)$(MAKE) -f $(srctree)/Makefile headers_check |
| 865 | endif |
| 866 | ifdef CONFIG_SAMPLES |
| 867 | $(Q)$(MAKE) $(build)=samples |
| 868 | endif |
| 869 | ifdef CONFIG_BUILD_DOCSRC |
| 870 | $(Q)$(MAKE) $(build)=Documentation |
| 871 | endif |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 872 | |
| 873 | ifneq ($(strip $(PROJECT)),) |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 874 | +$(call if_changed,link-tinymountain) |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 875 | endif |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 876 | |
| 877 | # The actual objects are generated when descending, |
| 878 | # make sure no implicit rule kicks in |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 879 | $(sort $(tinymountain-deps)): $(tinymountain-dirs) ; |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 880 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 881 | # Handle descending into subdirectories listed in $(tinymountain-dirs) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 882 | # Preset locale variables to speed up the build process. Limit locale |
| 883 | # tweaks to this spot to avoid wrong language settings when running |
| 884 | # make menuconfig etc. |
| 885 | # Error messages still appears in the original language |
| 886 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 887 | PHONY += $(tinymountain-dirs) |
| 888 | $(tinymountain-dirs): prepare scripts |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 889 | $(Q)$(MAKE) $(build)=$@ |
| 890 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 891 | # Things we need to do before we recursively start building the kernel |
| 892 | # or the modules are listed in "prepare". |
| 893 | # A multi level approach is used. prepareN is processed before prepareN-1. |
| 894 | # archprepare is used in arch Makefiles and when processed asm symlink, |
| 895 | # version.h and scripts_basic is processed / created. |
| 896 | |
| 897 | # Listed in dependency order |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 898 | PHONY += prepare prepare1 prepare2 prepare3 |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 899 | |
| 900 | # prepare3 is used to check if we are building in a separate output directory, |
| 901 | # and if so do: |
| 902 | # 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] | 903 | prepare3: |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 904 | ifneq ($(KBUILD_SRC),) |
| 905 | @$(kecho) ' Using $(srctree) as source for kernel' |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 906 | $(Q)if [ -f $(srctree)/.config ]; then \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 907 | echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ |
| 908 | echo >&2 " in the '$(srctree)' directory.";\ |
| 909 | /bin/false; \ |
| 910 | fi; |
| 911 | endif |
| 912 | |
| 913 | # prepare2 creates a makefile if using a separate output directory |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 914 | prepare2: prepare3 outputmakefile |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 915 | |
Juan Manuel Cruz | 8b16a17 | 2015-05-22 18:38:45 -0500 | [diff] [blame] | 916 | prepare1: prepare2 $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 917 | include/config/auto.conf |
| 918 | $(cmd_crmodverdir) |
| 919 | |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 920 | ifneq ($(strip $(PROJECT)),) |
| 921 | SYSGEN_EXEC=y |
| 922 | endif |
| 923 | |
| 924 | ifneq ($(CONFIG_MICROKERNEL),y) |
| 925 | SYSGEN_EXEC=n |
| 926 | endif |
| 927 | |
| 928 | export SYSGEN_EXEC |
| 929 | |
| 930 | archprepare_common = $(strip \ |
| 931 | archheaders archscripts prepare1 scripts_basic \ |
| 932 | misc/generated/configs.c \ |
| 933 | include/generated/offsets.h \ |
| 934 | ) |
| 935 | |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 936 | archprepare_microkernel-y = misc/generated/sysgen/kernel_main.c |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 937 | |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 938 | archprepare = $(strip \ |
Juan Manuel Cruz | ba741fe | 2015-02-15 14:12:00 -0600 | [diff] [blame] | 939 | $(archprepare_common) \ |
| 940 | $(archprepare_microkernel-$(SYSGEN_EXEC)) \ |
| 941 | ) |
| 942 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 943 | # All the preparing.. |
Juan Manuel Cruz | 0167ee4 | 2015-06-05 13:08:53 -0500 | [diff] [blame] | 944 | prepare: $(archprepare) FORCE |
| 945 | $(Q)$(MAKE) $(build)=. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 946 | |
| 947 | # Generate some files |
| 948 | # --------------------------------------------------------------------------- |
| 949 | |
| 950 | # KERNELRELEASE can change from a few different places, meaning version.h |
| 951 | # needs to be updated, so this check is forced on all builds |
| 952 | |
Juan Manuel Cruz | a0b5466 | 2015-02-17 11:16:47 -0600 | [diff] [blame] | 953 | KERNEL_VERSION_HEX=0x$(VERSION_GENERATION)$(VERSION_MAJOR)$(VERSION_MINOR)$(VERSION_REVISION) |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 954 | KERNEL_CODE=40 |
| 955 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 956 | define filechk_version.h |
Juan Manuel Cruz | 6de3400 | 2015-02-15 21:46:45 -0600 | [diff] [blame] | 957 | (echo "#ifndef _KERNEL_VERSION_H_"; \ |
| 958 | echo "#define _KERNEL_VERSION_H_"; \ |
| 959 | echo ;\ |
| 960 | echo "#define KERNELVERSION \\"; \ |
| 961 | echo "$(KERNEL_VERSION_HEX)$(KERNEL_CODE)$(VERSION_RESERVED)"; \ |
| 962 | echo "#define KERNEL_VERSION_NUMBER $(KERNEL_VERSION_HEX)"; \ |
| 963 | echo "#define KERNEL_VERSION_GENERATION $(VERSION_GENERATION)"; \ |
| 964 | echo "#define KERNEL_VERSION_MAJOR $(VERSION_MAJOR)"; \ |
| 965 | echo "#define KERNEL_VERSION_MINOR $(VERSION_MINOR)"; \ |
| 966 | echo "#define KERNEL_VERSION_REVISION $(VERSION_REVISION)"; \ |
| 967 | echo "#define KERNEL_VERSION_STRING \"$(KERNELVERSION)\""; \ |
| 968 | echo; \ |
| 969 | echo "#endif /* _KERNEL_VERSION_H_ */";) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 970 | endef |
| 971 | |
| 972 | $(version_h): $(srctree)/Makefile FORCE |
| 973 | $(call filechk,version.h) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 974 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 975 | PHONY += headerdep |
| 976 | headerdep: |
| 977 | $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ |
| 978 | $(srctree)/scripts/headerdep.pl -I$(srctree)/include |
| 979 | |
| 980 | # --------------------------------------------------------------------------- |
| 981 | |
| 982 | PHONY += depend dep |
| 983 | depend dep: |
| 984 | @echo '*** Warning: make $@ is unnecessary now.' |
| 985 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 986 | |
| 987 | # --------------------------------------------------------------------------- |
| 988 | # Kernel headers |
| 989 | |
| 990 | #Default location for installed headers |
| 991 | export INSTALL_HDR_PATH = $(objtree)/usr |
| 992 | |
| 993 | # If we do an all arch process set dst to asm-$(hdr-arch) |
| 994 | hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm) |
| 995 | |
| 996 | PHONY += archheaders |
| 997 | archheaders: |
| 998 | |
| 999 | PHONY += archscripts |
| 1000 | archscripts: |
| 1001 | |
| 1002 | PHONY += __headers |
| 1003 | __headers: $(version_h) scripts_basic asm-generic archheaders archscripts FORCE |
| 1004 | $(Q)$(MAKE) $(build)=scripts build_unifdef |
| 1005 | |
| 1006 | PHONY += headers_install_all |
| 1007 | headers_install_all: |
| 1008 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install |
| 1009 | |
| 1010 | PHONY += headers_install |
| 1011 | headers_install: __headers |
| 1012 | $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/uapi/asm/Kbuild),, \ |
| 1013 | $(error Headers not exportable for the $(SRCARCH) architecture)) |
| 1014 | $(Q)$(MAKE) $(hdr-inst)=include/uapi |
| 1015 | $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) |
| 1016 | |
| 1017 | PHONY += headers_check_all |
| 1018 | headers_check_all: headers_install_all |
| 1019 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check |
| 1020 | |
| 1021 | PHONY += headers_check |
| 1022 | headers_check: headers_install |
| 1023 | $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1 |
| 1024 | $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1 |
| 1025 | |
| 1026 | # --------------------------------------------------------------------------- |
| 1027 | # Kernel selftest |
| 1028 | |
| 1029 | PHONY += kselftest |
| 1030 | kselftest: |
| 1031 | $(Q)$(MAKE) -C tools/testing/selftests run_tests |
| 1032 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1033 | |
| 1034 | ### |
| 1035 | # Cleaning is done on three levels. |
| 1036 | # make clean Delete most generated files |
| 1037 | # Leave enough to build external modules |
| 1038 | # make mrproper Delete the current configuration, and all generated files |
| 1039 | # make distclean Remove editor backup files, patch leftover files and the like |
| 1040 | |
| 1041 | # Directories & files removed with 'make clean' |
| 1042 | CLEAN_DIRS += $(MODVERDIR) |
| 1043 | |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 1044 | CLEAN_FILES += misc/generated/sysgen/kernel_main.c \ |
Allan Stephens | 5b291d3 | 2015-06-05 08:32:54 -0400 | [diff] [blame] | 1045 | misc/generated/sysgen/zephyr.h \ |
Anas Nashif | 8e9d8eb | 2015-05-29 11:48:25 -0400 | [diff] [blame] | 1046 | misc/generated/sysgen/prj.vpf |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1047 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1048 | # Directories & files removed with 'make mrproper' |
| 1049 | MRPROPER_DIRS += include/config usr/include include/generated \ |
| 1050 | arch/*/include/generated .tmp_objdiff |
Anas Nashif | 1e8dc5a | 2015-04-24 18:32:55 -0400 | [diff] [blame] | 1051 | MRPROPER_FILES += .config .config.old .version $(version_h) \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1052 | Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ |
| 1053 | signing_key.priv signing_key.x509 x509.genkey \ |
| 1054 | extra_certificates signing_key.x509.keyid \ |
| 1055 | signing_key.x509.signer |
| 1056 | |
| 1057 | # clean - Delete most, but leave enough to build external modules |
| 1058 | # |
| 1059 | clean: rm-dirs := $(CLEAN_DIRS) |
| 1060 | clean: rm-files := $(CLEAN_FILES) |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1061 | clean-dirs := $(addprefix _clean_, . $(tinymountain-alldirs) ) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1062 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1063 | PHONY += $(clean-dirs) clean archclean tinymountainclean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1064 | $(clean-dirs): |
| 1065 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
| 1066 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1067 | tinymountainclean: |
| 1068 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-tinymountain.sh clean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1069 | |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1070 | clean: archclean tinymountainclean |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1071 | |
| 1072 | # mrproper - Delete all generated files, including .config |
| 1073 | # |
| 1074 | mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) |
| 1075 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1076 | mrproper-dirs := $(addprefix _mrproper_,scripts) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1077 | |
| 1078 | PHONY += $(mrproper-dirs) mrproper archmrproper |
| 1079 | $(mrproper-dirs): |
| 1080 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) |
| 1081 | |
| 1082 | mrproper: clean archmrproper $(mrproper-dirs) |
| 1083 | $(call cmd,rmdirs) |
| 1084 | $(call cmd,rmfiles) |
| 1085 | |
| 1086 | # distclean |
| 1087 | # |
| 1088 | PHONY += distclean |
| 1089 | |
| 1090 | distclean: mrproper |
| 1091 | @find $(srctree) $(RCS_FIND_IGNORE) \ |
| 1092 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
| 1093 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ |
| 1094 | -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \ |
| 1095 | -type f -print | xargs rm -f |
| 1096 | |
| 1097 | |
| 1098 | # Packaging of the kernel to various formats |
| 1099 | # --------------------------------------------------------------------------- |
| 1100 | # rpm target kept for backward compatibility |
| 1101 | package-dir := scripts/package |
| 1102 | |
| 1103 | %src-pkg: FORCE |
| 1104 | $(Q)$(MAKE) $(build)=$(package-dir) $@ |
Juan Manuel Cruz | ef07b96 | 2015-06-05 12:58:50 -0500 | [diff] [blame] | 1105 | %pkg: $(version_h) FORCE |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1106 | $(Q)$(MAKE) $(build)=$(package-dir) $@ |
Juan Manuel Cruz | ef07b96 | 2015-06-05 12:58:50 -0500 | [diff] [blame] | 1107 | rpm: $(version_h) FORCE |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1108 | $(Q)$(MAKE) $(build)=$(package-dir) $@ |
| 1109 | |
| 1110 | |
| 1111 | # Brief documentation of the typical targets used |
| 1112 | # --------------------------------------------------------------------------- |
| 1113 | |
| 1114 | boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) |
| 1115 | boards := $(sort $(notdir $(boards))) |
| 1116 | board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) |
| 1117 | board-dirs := $(sort $(notdir $(board-dirs:/=))) |
| 1118 | |
| 1119 | help: |
| 1120 | @echo 'Cleaning targets:' |
| 1121 | @echo ' clean - Remove most generated files but keep the config and' |
| 1122 | @echo ' enough build support to build external modules' |
| 1123 | @echo ' mrproper - Remove all generated files + config + various backup files' |
| 1124 | @echo ' distclean - mrproper + remove editor backup and patch files' |
| 1125 | @echo '' |
| 1126 | @echo 'Configuration targets:' |
| 1127 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help |
| 1128 | @echo '' |
| 1129 | @echo 'Other generic targets:' |
| 1130 | @echo ' all - Build all targets marked with [*]' |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1131 | @echo '* tinymountain - Build the bare kernel' |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1132 | @echo ' qemu - Build the bare kernel and runs the emulation with qemu' |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1133 | @echo 'Architecture specific targets ($(SRCARCH)):' |
| 1134 | @$(if $(archhelp),$(archhelp),\ |
| 1135 | echo ' No architecture specific help defined for $(SRCARCH)') |
| 1136 | @echo '' |
| 1137 | @$(if $(boards), \ |
| 1138 | $(foreach b, $(boards), \ |
| 1139 | printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ |
| 1140 | echo '') |
| 1141 | @$(if $(board-dirs), \ |
| 1142 | $(foreach b, $(board-dirs), \ |
| 1143 | printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ |
| 1144 | printf " %-16s - Show all of the above\\n" help-boards; \ |
| 1145 | echo '') |
| 1146 | |
| 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 [*] ' |
| 1160 | @echo 'For further info see the ./README file' |
| 1161 | |
| 1162 | |
| 1163 | help-board-dirs := $(addprefix help-,$(board-dirs)) |
| 1164 | |
| 1165 | help-boards: $(help-board-dirs) |
| 1166 | |
| 1167 | boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))) |
| 1168 | |
| 1169 | $(help-board-dirs): help-%: |
| 1170 | @echo 'Architecture specific targets ($(SRCARCH) $*):' |
| 1171 | @$(if $(boards-per-dir), \ |
| 1172 | $(foreach b, $(boards-per-dir), \ |
| 1173 | printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ |
| 1174 | echo '') |
| 1175 | |
| 1176 | |
| 1177 | # Documentation targets |
| 1178 | # --------------------------------------------------------------------------- |
| 1179 | %docs: scripts_basic FORCE |
| 1180 | $(Q)$(MAKE) $(build)=scripts build_docproc |
| 1181 | $(Q)$(MAKE) $(build)=Documentation/DocBook $@ |
| 1182 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1183 | |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1184 | #BUG [oas] regular expression is substituted by [oa] to ommit the removal |
| 1185 | # of .s files. This change can be undone once all .s files have been |
| 1186 | # renamed to .S files. |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1187 | clean: $(clean-dirs) |
| 1188 | $(call cmd,rmdirs) |
| 1189 | $(call cmd,rmfiles) |
| 1190 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ |
Juan Manuel Cruz | ce3533a | 2015-02-23 16:48:02 -0600 | [diff] [blame] | 1191 | \( -name '*.[oa]' -o -name '*.ko' -o -name '.*.cmd' \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1192 | -o -name '*.ko.*' \ |
| 1193 | -o -name '*.dwo' \ |
| 1194 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
Dirk Brandewie | 0876039 | 2015-06-01 09:48:10 -0700 | [diff] [blame] | 1195 | -o -name '*.symtypes' \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1196 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ |
| 1197 | -o -name '*.gcno' \) -type f -print | xargs rm -f |
| 1198 | |
| 1199 | # Generate tags for editors |
| 1200 | # --------------------------------------------------------------------------- |
| 1201 | quiet_cmd_tags = GEN $@ |
| 1202 | cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ |
| 1203 | |
| 1204 | tags TAGS cscope gtags: FORCE |
| 1205 | $(call cmd,tags) |
| 1206 | |
| 1207 | # Scripts to check various things for consistency |
| 1208 | # --------------------------------------------------------------------------- |
| 1209 | |
| 1210 | PHONY += includecheck versioncheck coccicheck namespacecheck export_report |
| 1211 | |
| 1212 | includecheck: |
| 1213 | find $(srctree)/* $(RCS_FIND_IGNORE) \ |
| 1214 | -name '*.[hcS]' -type f -print | sort \ |
| 1215 | | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl |
| 1216 | |
| 1217 | versioncheck: |
| 1218 | find $(srctree)/* $(RCS_FIND_IGNORE) \ |
| 1219 | -name '*.[hcS]' -type f -print | sort \ |
| 1220 | | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl |
| 1221 | |
| 1222 | coccicheck: |
| 1223 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ |
| 1224 | |
| 1225 | namespacecheck: |
| 1226 | $(PERL) $(srctree)/scripts/namespace.pl |
| 1227 | |
| 1228 | export_report: |
| 1229 | $(PERL) $(srctree)/scripts/export_report.pl |
| 1230 | |
| 1231 | endif #ifeq ($(config-targets),1) |
| 1232 | endif #ifeq ($(mixed-targets),1) |
| 1233 | |
Juan Manuel Cruz | ef07b96 | 2015-06-05 12:58:50 -0500 | [diff] [blame] | 1234 | PHONY += checkstack kernelversion image_name |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1235 | |
| 1236 | # UML needs a little special treatment here. It wants to use the host |
| 1237 | # toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone |
| 1238 | # else wants $(ARCH), including people doing cross-builds, which means |
| 1239 | # that $(SUBARCH) doesn't work here. |
| 1240 | ifeq ($(ARCH), um) |
| 1241 | CHECKSTACK_ARCH := $(SUBARCH) |
| 1242 | else |
| 1243 | CHECKSTACK_ARCH := $(ARCH) |
| 1244 | endif |
| 1245 | checkstack: |
Juan Manuel Cruz | 7ac851a | 2015-04-08 17:19:22 -0500 | [diff] [blame] | 1246 | $(OBJDUMP) -d tinymountain $$(find . -name '*.ko') | \ |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1247 | $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
| 1248 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1249 | kernelversion: |
| 1250 | @echo $(KERNELVERSION) |
| 1251 | |
| 1252 | image_name: |
| 1253 | @echo $(KBUILD_IMAGE) |
| 1254 | |
| 1255 | # Clear a bunch of variables before executing the submake |
| 1256 | tools/: FORCE |
| 1257 | $(Q)mkdir -p $(objtree)/tools |
| 1258 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ |
| 1259 | |
| 1260 | tools/%: FORCE |
| 1261 | $(Q)mkdir -p $(objtree)/tools |
| 1262 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $* |
| 1263 | |
Anas Nashif | 848c5c8 | 2015-05-10 18:44:17 -0400 | [diff] [blame] | 1264 | QEMU_FLAGS = $(QEMU_FLAGS_$(SRCARCH)) -pidfile qemu.pid |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1265 | |
| 1266 | qemu: tinymountain |
Anas Nashif | 848c5c8 | 2015-05-10 18:44:17 -0400 | [diff] [blame] | 1267 | @echo "To exit from QEMU enter: 'CTRL+a, x'" |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1268 | @echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(SRCARCH))' |
Juan Manuel Cruz | 638fb2c | 2015-05-10 21:52:56 -0500 | [diff] [blame] | 1269 | $(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_NAME).elf |
Juan Manuel Cruz | e7de0f6 | 2015-04-30 14:14:29 -0500 | [diff] [blame] | 1270 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1271 | # Single targets |
| 1272 | # --------------------------------------------------------------------------- |
| 1273 | # Single targets are compatible with: |
| 1274 | # - build with mixed source and output |
| 1275 | # - build with separate output dir 'make O=...' |
| 1276 | # - external modules |
| 1277 | # |
| 1278 | # target-dir => where to store outputfile |
| 1279 | # build-dir => directory in kernel source tree to use |
| 1280 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1281 | build-dir = $(patsubst %/,%,$(dir $@)) |
| 1282 | target-dir = $(dir $@) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1283 | |
| 1284 | %.s: %.c prepare scripts FORCE |
| 1285 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1286 | %.i: %.c prepare scripts FORCE |
| 1287 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1288 | %.o: %.c prepare scripts FORCE |
| 1289 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1290 | %.lst: %.c prepare scripts FORCE |
| 1291 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1292 | %.s: %.S prepare scripts FORCE |
| 1293 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1294 | %.o: %.S prepare scripts FORCE |
| 1295 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1296 | %.symtypes: %.c prepare scripts FORCE |
| 1297 | $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
| 1298 | |
| 1299 | # Modules |
| 1300 | /: prepare scripts FORCE |
| 1301 | $(cmd_crmodverdir) |
| 1302 | $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
| 1303 | $(build)=$(build-dir) |
| 1304 | # Make sure the latest headers are built for Documentation |
| 1305 | Documentation/: headers_install |
| 1306 | %/: prepare scripts FORCE |
| 1307 | $(cmd_crmodverdir) |
| 1308 | $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
| 1309 | $(build)=$(build-dir) |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1310 | |
| 1311 | # FIXME Should go into a make.lib or something |
| 1312 | # =========================================================================== |
| 1313 | |
| 1314 | quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) |
| 1315 | cmd_rmdirs = rm -rf $(rm-dirs) |
| 1316 | |
| 1317 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) |
| 1318 | cmd_rmfiles = rm -f $(rm-files) |
| 1319 | |
| 1320 | # Run depmod only if we have System.map and depmod is executable |
| 1321 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
| 1322 | cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ |
| 1323 | $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" |
| 1324 | |
Juan Manuel Cruz | a9b1c74 | 2015-01-29 15:22:58 -0600 | [diff] [blame] | 1325 | |
| 1326 | # read all saved command lines |
| 1327 | |
| 1328 | targets := $(wildcard $(sort $(targets))) |
| 1329 | cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
| 1330 | |
| 1331 | ifneq ($(cmd_files),) |
| 1332 | $(cmd_files): ; # Do not try to update included dependency files |
| 1333 | include $(cmd_files) |
| 1334 | endif |
| 1335 | |
| 1336 | endif # skip-makefile |
| 1337 | |
| 1338 | PHONY += FORCE |
| 1339 | FORCE: |
| 1340 | |
| 1341 | # Declare the contents of the .PHONY variable as phony. We keep that |
| 1342 | # information in a variable so we can use it in if_changed and friends. |
| 1343 | .PHONY: $(PHONY) |