| 1 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 110 |
|
| 111 |
include $(srck)/Makefile.mk |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 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 |
|
| 151 |
|
| 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 |
|
| 164 |
|
| 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 |
|
| 189 |
|
| 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 |
|
| 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 |
|
| 210 |
|
| 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 |
|
| 219 |
|
| 220 |
ifneq ($(NOCOMPILE),1) |
| 221 |
$(shell rm -f $(CCACHE_STATSLOG)) |
| 222 |
endif |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
real-all: site-local-target real-target |
| 227 |
|
| 228 |
|
| 229 |
.SECONDARY: |
| 230 |
.SECONDEXPANSION: |
| 231 |
.DELETE_ON_ERROR: |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 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 |
|
| 253 |
add-class= \ |
| 254 |
$(eval $(1)-srcs:=) \ |
| 255 |
$(eval $(1)-objs:=) \ |
| 256 |
$(eval classes+=$(1)) |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
add-special-class= \ |
| 264 |
$(eval $(1):=) \ |
| 265 |
$(eval special-classes+=$(1)) |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 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 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 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 |
|
| 298 |
|
| 299 |
|
| 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 |
|
| 315 |
|
| 316 |
|
| 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 |
|
| 327 |
subdirs:=$(TOPLEVEL) |
| 328 |
postinclude-hooks := |
| 329 |
|
| 330 |
|
| 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 |
|
| 342 |
$(eval $(postinclude-hooks)) |
| 343 |
|
| 344 |
|
| 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 |
|
| 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 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 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 |
|
| 375 |
$(foreach class,$(classes),$(eval $(class)-ada-dirs:=$(sort $(dir $(filter %.ads %.adb,$($(class)-srcs)) $($(class)-extra-specs))))) |
| 376 |
|
| 377 |
|
| 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 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 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 |
|
| 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 |
|
| 434 |
|
| 435 |
|
| 436 |
define gnatbind_template |
| 437 |
|
| 438 |
$$(obj)/$(1)/b__$(1).adb: $$$$(filter-out $$(obj)/$(1)/b__$(1).ali,$$$$($(1)-alis)) |
| 439 |
@printf " BIND $$(subst $$(obj)/,,$$@)\n" |
| 440 |
|
| 441 |
|
| 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 |
|
| 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 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 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 |