summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorChristian Walter <christian.walter@9elements.com>2022-07-01 11:12:25 +0200
committerMartin L Roth <gaumless@gmail.com>2022-10-17 14:00:46 +0000
commita8c10c8298f77b3d1343e116dcf66343ff4ed2e3 (patch)
tree679fe403ecfef6b2c5738b9a0761d2f5824f1cca /Makefile
parentccbb98880be2333b9d16dc6152addd8249ae6796 (diff)
Makefile: Add targets to add and remove symlinks
When "make symlink" is run, it looks for symlink.txt files recursively under site-local directory, and make symbolic links accordingly. "make clean-symlink" removes the symbolic links made. One application is for development of support for new processors and/or new mainboards, where new directories are added, along with some common code changes. Change-Id: I3fa119675ecca1626d70375a61e8a71abec6a53b Signed-off-by: Christian Walter <christian.walter@9elements.com> Signed-off-by: Jonathan Zhang <jonzhang@meta.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/65093 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile30
1 files changed, 29 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6bdd44a856..58cd85b7d3 100644
--- a/Makefile
+++ b/Makefile
@@ -38,6 +38,11 @@ COREBOOT_EXPORTS += KCONFIG_DEPENDENCIES KCONFIG_SPLITCONFIG KCONFIG_TRISTATE
COREBOOT_EXPORTS += KCONFIG_NEGATIVES KCONFIG_STRICT
COREBOOT_EXPORTS += KCONFIG_AUTOADS KCONFIG_PACKAGE
+# Make does not offer a recursive wildcard function, so here's one:
+rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
+SYMLINK_LIST = $(call rwildcard,site-local/,symlink.txt)
+
+
# directory containing the toplevel Makefile.inc
TOPLEVEL := .
@@ -455,6 +460,29 @@ sphinx:
sphinx-lint:
$(MAKE) SPHINXOPTS=-W -C Documentation -f Makefile.sphinx html
+symlink:
+ @echo "Creating Symbolic Links.."; \
+ for link in $(SYMLINK_LIST); do \
+ SYMLINK=`cat $$link`; \
+ REALPATH=`realpath $$link`; \
+ if [ -L "$$SYMLINK" ]; then \
+ continue; \
+ elif [ ! -e "$$SYMLINK" ]; then \
+ echo -e "\tLINK $$SYMLINK -> $$(dirname $$REALPATH)"; \
+ ln -s $$(dirname $$REALPATH) $$SYMLINK; \
+ else \
+ echo -e "\tFAILED: $$SYMLINK exists"; \
+ fi \
+ done
+
+clean-symlink:
+ @echo "Deleting symbolic link";\
+ EXISTING_SYMLINKS=`find -L ./src -xtype l | grep -v 3rdparty`; \
+ for link in $$EXISTING_SYMLINKS; do \
+ echo -e "\tUNLINK $$link"; \
+ rm "$$link"; \
+ done
+
clean-for-update:
rm -rf $(obj) .xcompile
@@ -482,4 +510,4 @@ distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
rm -f abuild*.xml junit.xml* util/lint/junit.xml
.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean sphinx sphinx-lint
-.PHONY: ctags-project cscope-project clean-ctags
+.PHONY: ctags-project cscope-project clean-ctags symlink clean-symlink