Debian Codegraph @

Makefile

raw symbols SCIP
1 ## SPDX-License-Identifier: BSD-3-Clause
2
3 ifneq ($(words $(CURDIR)),1)
4 $(error Error: Path to the main directory cannot contain spaces)
5 endif
6 top := $(CURDIR)
7 src := src
8 srck := $(top)/util/kconfig
9 obj ?= build
10 override obj := $(subst $(top)/,,$(abspath $(obj)))
11 xcompile ?= $(obj)/xcompile
12 objutil ?= $(obj)/util
13 objk := $(objutil)/kconfig
14 absobj := $(abspath $(obj))
15
16 additional-dirs :=
17
18 VBOOT_SOURCE ?= 3rdparty/vboot
19 VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib)
20
21 COREBOOT_EXPORTS := COREBOOT_EXPORTS
22 COREBOOT_EXPORTS += top src srck obj objutil objk
23
24 DOTCONFIG ?= $(top)/.config
25 KCONFIG_CONFIG = $(DOTCONFIG)
26 KCONFIG_AUTOADS := $(obj)/cb-config.ads
27 KCONFIG_RUSTCCFG := $(obj)/cb-config.rustcfg
28 KCONFIG_AUTOHEADER := $(obj)/config.h
29 KCONFIG_AUTOCONFIG := $(obj)/auto.conf
30 KCONFIG_DEPENDENCIES := $(obj)/auto.conf.cmd
31 KCONFIG_SPLITCONFIG := $(obj)/config/
32 KCONFIG_TRISTATE := $(obj)/tristate.conf
33 KCONFIG_NEGATIVES := 1
34 KCONFIG_WERROR := 1
35 KCONFIG_WARN_UNKNOWN_SYMBOLS := 1
36 KCONFIG_PACKAGE := CB.Config
37 KCONFIG_MAKEFILE_REAL ?= $(objk)/Makefile.real
38
39 COREBOOT_EXPORTS += KCONFIG_CONFIG KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG
40 COREBOOT_EXPORTS += KCONFIG_DEPENDENCIES KCONFIG_SPLITCONFIG KCONFIG_TRISTATE
41 COREBOOT_EXPORTS += KCONFIG_NEGATIVES
42 ifeq ($(filter %config,$(MAKECMDGOALS)),)
43 COREBOOT_EXPORTS += KCONFIG_WERROR
44 endif
45 COREBOOT_EXPORTS += KCONFIG_WARN_UNKNOWN_SYMBOLS
46 COREBOOT_EXPORTS += KCONFIG_AUTOADS KCONFIG_PACKAGE
47 COREBOOT_EXPORTS += KCONFIG_RUSTCCFG
48
49 # Make does not offer a recursive wildcard function, so here's one:
50 rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
51 SYMLINK_LIST = $(call rwildcard,site-local/,symlink.txt)
52
53
54 # Directory containing the toplevel Makefile.mk
55 TOPLEVEL := .
56
57 CONFIG_SHELL := sh
58 KBUILD_DEFCONFIG := configs/defconfig
59 UNAME_RELEASE := $(shell uname -r)
60 HAVE_DOTCONFIG := $(wildcard $(DOTCONFIG))
61 HAVE_KCONFIG_MAKEFILE_REAL := $(wildcard $(KCONFIG_MAKEFILE_REAL))
62 MAKEFLAGS += -rR --no-print-directory
63
64 # Make is silent per default, but 'make V=1' will show all compiler calls.
65 Q:=@
66 ifneq ($(V),1)
67 ifneq ($(Q),)
68 .SILENT:
69 MAKEFLAGS += -s
70 quiet_errors := 2>/dev/null
71 endif
72 endif
73
74 # Disable implicit/built-in rules to make Makefile errors fail fast.
75 .SUFFIXES:
76
77 HOSTCFLAGS := -g
78 HOSTCXXFLAGS := -g
79
80 HOSTPKG_CONFIG ?= pkg-config
81 COREBOOT_EXPORTS += HOSTPKG_CONFIG
82
83 PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
84
85 export $(COREBOOT_EXPORTS)
86
87 all: real-all
88
89 help_coreboot help::
90 @echo '*** coreboot platform targets ***'
91 @echo ' Use "make [target] V=1" for extra build debug information'
92 @echo ' all - Build coreboot'
93 @echo ' clean - Remove coreboot build artifacts'
94 @echo ' distclean - Remove build artifacts and config files'
95 @echo ' sphinx - Build sphinx documentation for coreboot'
96 @echo ' sphinx-lint - Build sphinx documentation for coreboot with warnings as errors'
97 @echo ' filelist - Show files used in current build'
98 @echo ' printall - Print makefile info for debugging'
99 @echo ' gitconfig - Set up git to submit patches to coreboot'
100 @echo ' ctags / ctags-project - Make ctags file for all of coreboot or current board'
101 @echo ' cscope / cscope-project - Make cscope.out file for coreboot or current board'
102 @echo
103 @echo '*** site-local related targets ***'
104 @echo ' symlink - Create symbolic links from site-local into coreboot tree'
105 @echo ' clean-symlink - Remove symbolic links created by "make symlink"'
106 @echo ' cleanall-symlink - Remove all symbolic links in the coreboot tree'
107 @echo
108
109 # This include must come _before_ the pattern rules below!
110 # Order _does_ matter for pattern rules.
111 include $(srck)/Makefile.mk
112
113 # The cases where we don't need fully populated $(obj) lists:
114 # 1. when no .config exists
115 # 2. When no $(obj)/util/kconfig/Makefile.real exists and we're building tools
116 # 3. when make config (in any flavour) is run
117 # 4. when make distclean is run
118 # Don't waste time on reading all Makefile.incs in these cases
119 ifeq ($(strip $(HAVE_DOTCONFIG)),)
120 NOCOMPILE:=1
121 endif
122 ifeq ($(strip $(HAVE_KCONFIG_MAKEFILE_REAL)),)
123 ifneq ($(MAKECMDGOALS),tools)
124 NOCOMPILE:=1
125 endif
126 endif
127 ifneq ($(MAKECMDGOALS),)
128 ifneq ($(filter %config %clean cross% clang iasl lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
129 NOCOMPILE:=1
130 endif
131 ifneq ($(filter %clean lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
132 NOMKDIR:=1
133 UNIT_TEST:=1
134 endif
135 endif
136
137 ifneq ($(filter help%, $(MAKECMDGOALS)), )
138 NOCOMPILE:=1
139 UNIT_TEST:=1
140 else
141 ifneq ($(filter %-test %-tests %coverage-report, $(MAKECMDGOALS)),)
142 ifneq ($(filter-out %-test %-tests %coverage-report, $(MAKECMDGOALS)),)
143 $(error Cannot mix unit-tests targets with other targets)
144 endif
145 UNIT_TEST:=1
146 NOCOMPILE:=
147 endif
148 endif
149
150 # When building the "tools" target, the BUILD_ALL_TOOLS variable needs
151 # to be set before reading the tools' Makefiles
152 ifneq ($(filter tools, $(MAKECMDGOALS)), )
153 BUILD_ALL_TOOLS:=1
154 endif
155
156 $(xcompile): util/xcompile/xcompile
157 rm -f $@
158 $< $(XGCCPATH) > [email protected]
159 \mv -f [email protected] $@ 2> /dev/null
160 rm -f [email protected]
161
162 ifeq ($(NOCOMPILE),1)
163 # We also don't use .xcompile in the no-compile situations, so
164 # provide some reasonable defaults.
165 HOSTCC ?= $(if $(shell type gcc 2>/dev/null),gcc,cc)
166 HOSTCXX ?= g++
167
168 include $(TOPLEVEL)/Makefile.mk
169 include $(TOPLEVEL)/payloads/Makefile.mk
170 include $(TOPLEVEL)/util/testing/Makefile.mk
171 -include $(TOPLEVEL)/site-local/Makefile.mk
172 -include $(TOPLEVEL)/site-local/Makefile.inc
173 include $(TOPLEVEL)/tests/Makefile.mk
174 printall real-all:
175 @echo "Error: Trying to build, but NOCOMPILE is set." >&2
176 @echo " Please file a bug with the following information:"
177 @echo "- MAKECMDGOALS: $(MAKECMDGOALS)" >&2
178 @echo "- HAVE_DOTCONFIG: $(HAVE_DOTCONFIG)" >&2
179 @echo "- HAVE_KCONFIG_MAKEFILE_REAL: $(HAVE_KCONFIG_MAKEFILE_REAL)" >&2
180 @exit 1
181
182 else
183
184 ifneq ($(UNIT_TEST),1)
185 include $(DOTCONFIG)
186 endif
187
188 # The toolchain requires xcompile to determine the ARCH_SUPPORTED, so we can't
189 # wait for make to generate the file.
190 $(if $(wildcard $(xcompile)),, $(shell \
191 mkdir -p $(dir $(xcompile)) && \
192 util/xcompile/xcompile $(XGCCPATH) > $(xcompile) || rm -f $(xcompile)))
193
194 include $(xcompile)
195
196 ifneq ($(XCOMPILE_COMPLETE),1)
197 $(shell rm -f $(xcompile))
198 $(error $(xcompile) deleted because it's invalid. \
199 Restarting the build should fix that, or explain the problem)
200 endif
201
202 # reproducible builds
203 LANG:=C
204 LC_ALL:=C
205 TZ:=UTC0
206 ifneq ($(NOCOMPILE),1)
207 SOURCE_DATE_EPOCH := $(shell $(top)/util/genbuild_h/genbuild_h.sh . | sed -n 's/^.define COREBOOT_BUILD_EPOCH\>.*"\(.*\)".*/\1/p')
208 endif
209 # don't use COREBOOT_EXPORTS to ensure build steps outside the coreboot build system
210 # are reproducible
211 export LANG LC_ALL TZ SOURCE_DATE_EPOCH
212
213 ifneq ($(UNIT_TEST),1)
214 include toolchain.mk
215 endif
216
217 strip_quotes = $(strip $(subst ",,$(subst \",,$(1))))
218 # fix makefile syntax highlighting after strip macro \" "))
219
220 ifneq ($(NOCOMPILE),1)
221 $(shell rm -f $(CCACHE_STATSLOG))
222 endif
223
224 # The primary target needs to be here before we include the
225 # other files
226 real-all: site-local-target real-target
227
228 # must come rather early
229 .SECONDARY:
230 .SECONDEXPANSION:
231 .DELETE_ON_ERROR:
232
233 # conf is treated as an intermediate target and may be built after config.h
234 # during a clean build due to the way GNU Make handles intermediates when the
235 # .SECONDARY target is present, forcing config.h and thus every object out of
236 # date on a subsequent no-op build. Mark it as not intermediate to prevent this
237 .NOTINTERMEDIATE: $(objutil)/kconfig/conf
238
239 $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) $(objutil)/kconfig/conf
240 $(MAKE) olddefconfig
241 $(MAKE) syncconfig
242
243 $(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER)
244 true
245
246 $(KCONFIG_AUTOADS): $(KCONFIG_CONFIG) $(KCONFIG_AUTOHEADER) $(objutil)/kconfig/toada
247 $(objutil)/kconfig/toada CB.Config <$< >$@
248
249 $(obj)/%/$(notdir $(KCONFIG_AUTOADS)): $(KCONFIG_AUTOADS)
250 cp $< $@
251
252 # Add a new class of source/object files to the build system
253 add-class= \
254 $(eval $(1)-srcs:=) \
255 $(eval $(1)-objs:=) \
256 $(eval classes+=$(1))
257
258 # Special classes are managed types with special behaviour
259 # On parse time, for each entry in variable $(1)-y
260 # a handler $(1)-handler is executed with the arguments:
261 # * $(1): directory the parser is in
262 # * $(2): current entry
263 add-special-class= \
264 $(eval $(1):=) \
265 $(eval special-classes+=$(1))
266
267 # Converts one or more source file paths to their corresponding build/ paths.
268 # Only .ads, adb, .c and .S get converted to .o, other files (like .ld) keep
269 # their name.
270 # $1 stage name
271 # $2 file path (list)
272 src-to-obj=\
273 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
274 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
275 $(patsubst 3rdparty/%,$(obj)/%,\
276 $(patsubst src/%,$(obj)/%,\
277 $(patsubst %.ads,%.o,\
278 $(patsubst %.adb,%.o,\
279 $(patsubst %.c,%.o,\
280 $(patsubst %.S,%.o,\
281 $(subst .$(1),,$(2))))))))))
282
283 # Converts one or more source file paths to the corresponding build/ paths
284 # of their Ada library information (.ali) files.
285 # $1 stage name
286 # $2 file path (list)
287 src-to-ali=\
288 $(patsubst $(obj)/%,$(obj)/$(1)/%,\
289 $(patsubst $(obj)/$(1)/%,$(obj)/%,\
290 $(patsubst 3rdparty/%,$(obj)/%,\
291 $(patsubst src/%,$(obj)/%,\
292 $(patsubst %.ads,%.ali,\
293 $(patsubst %.adb,%.ali,\
294 $(subst .$(1),,\
295 $(filter %.ads %.adb,$(2)))))))))
296
297 # Clean -y variables, include Makefile.mk & Makefile.inc
298 # Add paths to files in X-y to X-srcs
299 # Add subdirs-y to subdirs
300 includemakefiles= \
301 $(if $(wildcard $(1)), \
302 $(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
303 $(eval -include $(1)) \
304 $(foreach class,$(classes-y), $(call add-class,$(class))) \
305 $(foreach special,$(special-classes), \
306 $(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
307 $(foreach class,$(classes), \
308 $(eval $(class)-srcs+= \
309 $$(subst $(absobj)/,$(obj)/, \
310 $$(subst $(top)/,, \
311 $$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
312 $(eval subdirs+=$$(subst $(CURDIR)/,,$$(wildcard $$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))))
313
314 # For each path in $(subdirs) call includemakefiles
315 # Repeat until subdirs is empty
316 # TODO: Remove Makefile.inc support
317 evaluate_subdirs= \
318 $(eval cursubdirs:=$(subdirs)) \
319 $(eval subdirs:=) \
320 $(foreach dir,$(cursubdirs), \
321 $(eval $(call includemakefiles,$(dir)/Makefile.mk))) \
322 $(foreach dir,$(cursubdirs), \
323 $(eval $(call includemakefiles,$(dir)/Makefile.inc))) \
324 $(if $(subdirs),$(eval $(call evaluate_subdirs)))
325
326 # collect all object files eligible for building
327 subdirs:=$(TOPLEVEL)
328 postinclude-hooks :=
329
330 # Don't iterate through Makefiles under src/ when building tests
331 ifneq ($(UNIT_TEST),1)
332 $(eval $(call evaluate_subdirs))
333 else
334 include $(TOPLEVEL)/tests/Makefile.mk
335 endif
336
337 ifeq ($(FAILBUILD),1)
338 $(error cannot continue build)
339 endif
340
341 # Run hooks registered by subdirectories that need to be evaluated after all files have been parsed
342 $(eval $(postinclude-hooks))
343
344 # Eliminate duplicate mentions of source files in a class
345 $(foreach class,$(classes),$(eval $(class)-srcs:=$(sort $($(class)-srcs))))
346
347 ifeq ($(CONFIG_IWYU),y)
348 MAKEFLAGS += -k
349 SAVE_IWYU_OUTPUT := 2>&1 | grep "should\|\#include\|---\|include-list\|^[[:blank:]]\?\'" | tee -a $$(obj)/iwyu.txt
350 endif
351
352 # Build Kconfig .ads if necessary
353 ifeq ($(CONFIG_ROMSTAGE_ADA),y)
354 romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS))
355 endif
356 ifeq ($(CONFIG_RAMSTAGE_ADA),y)
357 ramstage-srcs += $(obj)/ramstage/$(notdir $(KCONFIG_AUTOADS))
358 endif
359
360 # To track dependencies, we need all Ada specification (.ads) files in
361 # *-srcs. Extract / filter all specification files that have a matching
362 # body (.adb) file here (specifications without a body are valid sources
363 # in Ada).
364 $(foreach class,$(classes),$(eval $(class)-extra-specs := \
365 $(filter \
366 $(addprefix %/,$(patsubst %.adb,%.ads,$(notdir $(filter %.adb,$($(class)-srcs))))), \
367 $(filter %.ads,$($(class)-srcs)))))
368 $(foreach class,$(classes),$(eval $(class)-srcs := \
369 $(filter-out $($(class)-extra-specs),$($(class)-srcs))))
370
371 $(foreach class,$(classes),$(eval $(class)-objs:=$(call src-to-obj,$(class),$($(class)-srcs))))
372 $(foreach class,$(classes),$(eval $(class)-alis:=$(call src-to-ali,$(class),$($(class)-srcs))))
373
374 # For Ada includes
375 $(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs)))))
376
377 # Call post-processors if they're defined
378 $(foreach class,$(classes),\
379 $(if $(value $(class)-postprocess),$(eval $(call $(class)-postprocess,$($(class)-objs)))))
380
381 allsrcs:=$(foreach var, $(addsuffix -srcs,$(classes)), $($(var)))
382 allobjs:=$(foreach var, $(addsuffix -objs,$(classes)), $($(var)))
383 alldirs:=$(sort $(abspath $(dir $(allobjs))))
384
385 # Reads dependencies from an Ada library information (.ali) file
386 # Only basenames (with suffix) are preserved so we have to look the
387 # paths up in $($(stage)-srcs).
388 # $1 stage name
389 # $2 ali file
390 create_ada_deps=$$(if $(2),\
391 gnat.adc \
392 $$(filter \
393 $$(addprefix %/,$$(shell sed -ne's/^D \([^\t]\+\).*$$$$/\1/p' $(2) 2>/dev/null)), \
394 $$($(1)-srcs) $$($(1)-extra-specs)))
395
396 # macro to define template macros that are used by use_template macro
397 define create_cc_template
398 # $1 obj class
399 # $2 source suffix (c, S, ld, ...)
400 # $3 additional compiler flags
401 # $4 additional dependencies
402 # $5 generated header dependencies
403 ifn$(EMPTY)def $(1)-objs_$(2)_template
404 de$(EMPTY)fine $(1)-objs_$(2)_template
405 ifn$(EMPTY)eq ($(filter ads adb,$(2)),)
406 $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $$(call create_ada_deps,$1,$$(call src-to-ali,$1,$$(1).$2)) $(4) | $(5)
407 @printf " GCC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
408 $(GCC_$(1)) \
409 $$$$(ADAFLAGS_$(1)) $$$$(addprefix -I,$$$$($(1)-ada-dirs)) \
410 $(3) -c -o $$$$@ $$$$<
411 el$(EMPTY)se
412 $$(call src-to-obj,$1,$$(1).$2): $$(1).$2 $(KCONFIG_AUTOHEADER) $(4) | $(5)
413 @printf " CC $$$$(subst $$$$(obj)/,,$$$$(@))\n"
414 $(CC_$(1)) \
415 -MMD $$$$(CPPFLAGS_$(1)) $$$$(CFLAGS_$(1)) -MT $$$$(@) \
416 $(3) -c -o $$$$@ $$$$< $(SAVE_IWYU_OUTPUT)
417 end$(EMPTY)if
418 en$(EMPTY)def
419 end$(EMPTY)if
420 endef
421
422 filetypes-of-class=$(subst .,,$(sort $(suffix $($(1)-srcs))))
423 $(foreach class,$(classes), \
424 $(foreach type,$(call filetypes-of-class,$(class)), \
425 $(eval $(class)-$(type)-ccopts += $(generic-$(type)-ccopts) $($(class)-generic-ccopts)) \
426 $(if $(generic-objs_$(type)_template_gen),$(eval $(call generic-objs_$(type)_template_gen,$(class))),\
427 $(eval $(call create_cc_template,$(class),$(type),$($(class)-$(type)-ccopts),$($(class)-$(type)-deps),$($(class)-$(type)-gen-deps))))))
428
429 foreach-src=$(foreach file,$($(1)-srcs),$(eval $(call $(1)-objs_$(subst .,,$(suffix $(file)))_template,$(basename $(file)))))
430 $(eval $(foreach class,$(classes),$(call foreach-src,$(class))))
431
432 # To supported complex package initializations, we need to call the
433 # emitted code explicitly. gnatbind gathers all the calls for us
434 # and exports them as a procedure $(stage)_adainit(). Every stage that
435 # uses Ada code has to call it!
436 define gnatbind_template
437 # $1 class
438 $$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis))
439 @printf " BIND $$(subst $$(obj)/,,$$@)\n"
440 # We have to give gnatbind a simple filename (without leading
441 # path components) so just cd there.
442 cd $$(dir $$@) && \
443 $$(GNATBIND_$(1)) -a -n \
444 --RTS=$$(absobj)/libgnat-$$(ARCH-$(1)-y)/ \
445 -L$(1)_ada -o $$(notdir $$@) \
446 $$(subst $$(dir $$@),,$$^)
447 $$(obj)/$(1)/b__$(1).o: $$(obj)/$(1)/b__$(1).adb
448 @printf " GCC $$(subst $$(obj)/,,$$@)\n"
449 $(GCC_$(1)) $$(ADAFLAGS_$(1)) -c -o $$@ $$<
450 $(1)-objs += $$(obj)/$(1)/b__$(1).o
451 $($(1)-alis): %.ali: %.o ;
452 endef
453
454 $(eval $(foreach class,$(filter-out libgnat-%,$(classes)), \
455 $(if $($(class)-alis),$(call gnatbind_template,$(class)))))
456
457 DEPENDENCIES += $(addsuffix .d,$(basename $(allobjs)))
458 -include $(DEPENDENCIES)
459
460 printall:
461 @$(foreach class,$(classes), echo $(class)-objs: $($(class)-objs) | tr ' ' '\n'; echo; )
462 @echo alldirs: $(alldirs) | tr ' ' '\n'; echo
463 @echo allsrcs: $(allsrcs) | tr ' ' '\n'; echo
464 @echo DEPENDENCIES: $(DEPENDENCIES) | tr ' ' '\n'; echo
465 @$(foreach class,$(special-classes),echo $(class):'$($(class))' | tr ' ' '\n'; echo; )
466 endif
467
468 ifndef NOMKDIR
469 $(shell mkdir -p $(KCONFIG_SPLITCONFIG) $(objk)/lxdialog $(additional-dirs) $(alldirs))
470 endif
471
472 $(obj)/project_filelist.txt:
473 if [ -z "$(wildcard $(obj)/coreboot.rom)" ]; then \
474 echo "*** Error: Project must be built before generating file list ***"; \
475 exit 1; \
476 fi
477 find $(obj) -path "$(obj)/util" -prune -o -path "$(obj)/external" -prune -o -path "$(obj)/3rdparty" -prune -o -name "*.d" -exec cat {} \; | \
478 sed "s|$(top)/||" | sed 's/[:\\]/ /g' | sed 's/ /\n/g' | sort | uniq | \
479 grep -v '\.o$$' > $(obj)/project_filelist.txt
480
481 filelist: $(obj)/project_filelist.txt
482 printf "\nFiles used in build:\n"
483 cat $(obj)/project_filelist.txt
484
485 #works with either exuberant ctags or ctags.emacs
486 ctags-project: clean-ctags $(obj)/project_filelist.txt
487 cat $(obj)/project_filelist.txt | \
488 xargs ctags -o tags
489
490 ctags:
491 ctags -R
492
493 cscope-project: clean-cscope $(obj)/project_filelist.txt
494 cat $(obj)/project_filelist.txt | xargs cscope -b
495
496 cscope:
497 cscope -bR
498
499 sphinx:
500 $(MAKE) -C Documentation sphinx
501
502 sphinx-lint:
503 $(MAKE) SPHINXOPTS=-W -C Documentation sphinx
504
505 # Look at all of the files in the SYMLINK_LIST and create the symbolic links
506 # into the coreboot tree. Each symlink.txt file in site-local should be in the
507 # directory linked from and have a single line with the path to the location to
508 # link to. The path must be relative to the top of the coreboot directory.
509 symlink:
510 if [ -z "$(SYMLINK_LIST)" ]; then \
511 echo "No site-local symbolic links to create."; \
512 exit 0; \
513 fi; \
514 echo "Creating symbolic links.."; \
515 for link in $(SYMLINK_LIST); do \
516 LINKTO="$(top)/$$(head -n 1 "$${link}")"; \
517 LINKFROM=$$(dirname "$$(realpath "$${link}")"); \
518 if [ -L "$${LINKTO}" ]; then \
519 echo " $${LINKTO} exists - skipping"; \
520 continue; \
521 fi; \
522 LINKTO="$$(realpath -m "$${LINKTO}")" 2>/dev/null; \
523 if [ "$${LINKTO}" = "$$(echo "$${LINKTO}" | sed "s|^$(top)||" )" ]; then \
524 echo " FAILED: $${LINKTO} is outside of current directory." >&2; \
525 continue; \
526 fi; \
527 if [ ! -e "$${LINKTO}" ]; then \
528 echo " LINK $${LINKTO} -> $${LINKFROM}"; \
529 ln -s "$${LINKFROM}" "$${LINKTO}" || \
530 echo "FAILED: Could not create link." >&2; \
531 else \
532 echo " FAILED: $${LINKTO} exists as a file or directory." >&2; \
533 fi; \
534 done
535
536 clean-symlink:
537 if [ -z "$(SYMLINK_LIST)" ]; then \
538 echo "No site-local symbolic links to clean."; \
539 exit 0; \
540 fi; \
541 echo "Removing site-local symbolic links from tree.."; \
542 for link in $(SYMLINK_LIST); do \
543 SYMLINK="$(top)/$$(head -n 1 "$${link}")"; \
544 if [ "$${SYMLINK}" = "$$(echo "$${SYMLINK}" | sed "s|^$(top)||")" ]; then \
545 echo " FAILED: $${SYMLINK} is outside of current directory." >&2; \
546 continue; \
547 elif [ ! -L "$${SYMLINK}" ]; then \
548 echo " $${SYMLINK} does not exist - skipping"; \
549 continue; \
550 fi; \
551 if [ -L "$${SYMLINK}" ]; then \
552 REALDIR="$$(realpath "$${link}")"; \
553 echo " UNLINK $${link} (linked from $${REALDIR})"; \
554 rm "$${SYMLINK}"; \
555 fi; \
556 done; \
557 EXISTING_SYMLINKS="$$(find $(top) -type l | grep -v "3rdparty\|crossgcc" )"; \
558 if [ -z "$${EXISTING_SYMLINKS}" ]; then \
559 echo " No remaining symbolic links found in tree."; \
560 else \
561 echo " Remaining symbolic links found:"; \
562 for link in $${EXISTING_SYMLINKS}; do \
563 echo " $${link}"; \
564 done; \
565 fi
566
567 cleanall-symlink:
568 echo "Deleting all symbolic links in the coreboot tree (excluding 3rdparty & crossgcc)"; \
569 EXISTING_SYMLINKS="$$(find $(top) -type l | grep -v "3rdparty\|crossgcc" )"; \
570 for link in $${EXISTING_SYMLINKS}; do \
571 if [ -L "$${link}" ]; then \
572 REALDIR="$$(realpath "$${link}")"; \
573 echo " UNLINK $${link} (linked from $${REALDIR})"; \
574 rm "$${link}"; \
575 fi; \
576 done
577
578 clean-for-update:
579 rm -rf $(obj) .xcompile
580
581 clean: clean-for-update clean-utils clean-payloads
582 rm -f .ccwrap
583
584 clean-cscope:
585 rm -f cscope.out
586
587 clean-ctags:
588 rm -f tags
589
590 clean-utils:
591 $(foreach tool, $(TOOLLIST), \
592 $(MAKE) -C util/$(tool) clean MFLAGS= MAKEFLAGS= ;)
593
594 distclean-utils:
595 $(foreach tool, $(TOOLLIST), \
596 $(MAKE) -C util/$(tool) distclean MFLAGS= MAKEFLAGS= ; \
597 rm -f /util/$(tool)/junit.xml;)
598
599 distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
600 rm -f .config .config.old ..config.tmp* .kconfig.d .tmpconfig* .ccwrap .xcompile
601 rm -rf coreboot-builds coreboot-builds-chromeos
602 rm -f abuild*.xml junit.xml* util/lint/junit.xml
603
604 .PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean sphinx sphinx-lint
605 .PHONY: ctags-project cscope-project clean-ctags
606 .PHONY: symlink clean-symlink cleanall-symlink