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