Skip to content

Commit

Permalink
scripts/gdb: refactor rules for symlink creation
Browse files Browse the repository at this point in the history
gdb-scripts is not a real object, but (ab)used like a phony target.

Rewrite the code in a more Kbuild-ish way. Add symlinks to extra-y
and use if_changed.

Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Kieran Bingham <[email protected]>
  • Loading branch information
masahir0y committed Feb 27, 2019
1 parent 8d2e520 commit b513adf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/gdb/linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# SPDX-License-Identifier: GPL-2.0
always := gdb-scripts

SRCTREE := $(abspath $(srctree))

$(obj)/gdb-scripts:
ifneq ($(KBUILD_SRC),)
$(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj)

symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))

quiet_cmd_symlink = SYMLINK $@
cmd_symlink = ln -fsn $(patsubst $(obj)/%,$(abspath $(srctree))/$(src)/%,$@) $@

extra-y += $(symlinks)
$(addprefix $(obj)/, $(symlinks)): FORCE
$(call if_changed,symlink)

endif
@:

quiet_cmd_gen_constants_py = GEN $@
cmd_gen_constants_py = \
Expand All @@ -18,4 +22,4 @@ extra-y += constants.py
$(obj)/constants.py: $(src)/constants.py.in FORCE
$(call if_changed_dep,gen_constants_py)

clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py)
clean-files := *.pyc *.pyo

0 comments on commit b513adf

Please sign in to comment.