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