Skip to contentSkip to conversation

Makefile: Add cscope support

PATCH New Tan En De 4 participants 5 messages Oct 13, 2022 – Oct 23, 2022 Kbuild

lore
Share & tools
lore

Tan En De

author
#0 lore raw

PATCH 1/1 Makefile: Add cscope support

Add cscope support so that running make cscope will generate/update cscope files used for source code browsing, while running make distclean will remove the cscope files.

Also add entry in .gitignore to ignore generated cscope files.

---
 .gitignore |  1 +
 Makefile   | 13 +++++++++++++
 2 files changed, 14 insertions(+)
.gitignore +1 -0
index 534ad64..95692bb 100644
@@ -9,3 +9,4 @@ install/
 
 # Development friendly files
 tags
+cscope*
Makefile +13 -0
index 0ab9f22..4b175a0 100644
@@ -623,6 +623,17 @@ install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsb
 install_docs: $(build_dir)/docs/latex/refman.pdf
 	$(call inst_file,$(install_root_dir)/$(install_docs_path)/refman.pdf,$(build_dir)/docs/latex/refman.pdf)
 
+.PHONY: cscope
+cscope:
+	$(CMD_PREFIX)find \
+		"$(src_dir)/firmware" \
+		"$(src_dir)/include" \
+		"$(src_dir)/lib" \
+		"$(platform_src_dir)" \
+	-name "*.[chS]" -print > cscope.files
+	$(CMD_PREFIX)echo "$(KCONFIG_AUTOHEADER)" >> cscope.files
+	$(CMD_PREFIX)cscope -bkq -i cscope.files -f cscope.out
+
 # Rule for "make clean"
 .PHONY: clean
 clean:
@@ -652,6 +663,8 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr)
 	$(if $(V), @echo " RM        $(install_root_dir_default)")
 	$(CMD_PREFIX)rm -rf $(install_root_dir_default)
 endif
+	$(if $(V), @echo " RM        $(src_dir)/cscope*")
+	$(CMD_PREFIX)rm -f $(src_dir)/cscope*
 
 .PHONY: FORCE
 FORCE:
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 Makefile: Add cscope support

? 2022-10-13???? 09:26 +0800?Tan En De???

Quoted 7 lines

Add cscope support so that running make cscope will generate/update cscope files used for source code browsing, while running make distclean will remove the cscope files.

Also add entry in .gitignore to ignore generated cscope files.

LGTM

Quoted 49 lines

---
?.gitignore |? 1 +
?Makefile?? | 13 +++++++++++++
?2 files changed, 14 insertions(+)

.gitignore +0 -0
index 534ad64..95692bb 100644
@@ -9,3 +9,4 @@ install/

?
?# Development friendly files
?tags

.gitignore +1 -0
+cscope*
Makefile +0 -0
index 0ab9f22..4b175a0 100644
@@ -623,6 +623,17 @@ install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsb

?install_docs: $(build_dir)/docs/latex/refman.pdf
????????$(call inst_file,$(install_root_dir)/$(install_docs_path)/refman.pdf,$(build_dir)/docs/latex/refman.pdf) ?
+.PHONY: cscope

Makefile +10 -0
+cscope:
+???????$(CMD_PREFIX)find \
+???????????????"$(src_dir)/firmware" \
+???????????????"$(src_dir)/include" \
+???????????????"$(src_dir)/lib" \
+???????????????"$(platform_src_dir)" \
+???????-name "*.[chS]" -print > cscope.files
+???????$(CMD_PREFIX)echo "$(KCONFIG_AUTOHEADER)" >> cscope.files
+???????$(CMD_PREFIX)cscope -bkq -i cscope.files -f cscope.out
+

?# Rule for "make clean"
?.PHONY: clean
?clean:

Makefile +0 -0
@@ -652,6 +663,8 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr)
 ????????$(if $(V), @echo " RM??????? $(install_root_dir_default)")
 ????????$(CMD_PREFIX)rm -rf $(install_root_dir_default)

?endif
+???????$(if $(V), @echo " RM??????? $(src_dir)/cscope*") +???????$(CMD_PREFIX)rm -f $(src_dir)/cscope*
?
?.PHONY: FORCE
?FORCE:

Signature · 1 line
2.34.1
#2 lore raw

PATCH 1/1 Makefile: Add cscope support

In reply to Tan En De
Quoted 8 lines · Tan En De

Add cscope support so that running make cscope will generate/update cscope files used for source code browsing, while running make distclean will remove the cscope files.

Also add entry in .gitignore to ignore generated cscope files.

Looks good to me.

Regards,
Anup

Quoted 53 lines
---
 .gitignore |  1 +
 Makefile   | 13 +++++++++++++
 2 files changed, 14 insertions(+)
.gitignore +1 -0
index 534ad64..95692bb 100644
@@ -9,3 +9,4 @@ install/
 
 # Development friendly files
 tags
+cscope*
Makefile +13 -1
index 0ab9f22..4b175a0 100644
@@ -623,6 +623,17 @@ install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsb
 install_docs: $(build_dir)/docs/latex/refman.pdf
        $(call inst_file,$(install_root_dir)/$(install_docs_path)/refman.pdf,$(build_dir)/docs/latex/refman.pdf)
 
+.PHONY: cscope
+cscope:
+       $(CMD_PREFIX)find \
+               "$(src_dir)/firmware" \
+               "$(src_dir)/include" \
+               "$(src_dir)/lib" \
+               "$(platform_src_dir)" \
+       -name "*.[chS]" -print > cscope.files
+       $(CMD_PREFIX)echo "$(KCONFIG_AUTOHEADER)" >> cscope.files
+       $(CMD_PREFIX)cscope -bkq -i cscope.files -f cscope.out
+
 # Rule for "make clean"
 .PHONY: clean
 clean:
@@ -652,6 +663,8 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr)
        $(if $(V), @echo " RM        $(install_root_dir_default)")
        $(CMD_PREFIX)rm -rf $(install_root_dir_default)
 endif
+       $(if $(V), @echo " RM        $(src_dir)/cscope*")
+       $(CMD_PREFIX)rm -f $(src_dir)/cscope*
 
 .PHONY: FORCE
 FORCE:
--

2.34.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#3 lore raw

PATCH 1/1 Makefile: Add cscope support

In reply to Tan En De
Quoted 11 lines · Tan En De

Add cscope support so that running make cscope will generate/update cscope files used for source code browsing, while running make distclean will remove the cscope files.

Also add entry in .gitignore to ignore generated cscope files.

---
 .gitignore |  1 +
 Makefile   | 13 +++++++++++++
 2 files changed, 14 insertions(+)

As a cscope user myself, thank you for this!

Applied
#4 lore raw

PATCH 1/1 Makefile: Add cscope support

In reply to Tan En De
Quoted 8 lines · Tan En De

Add cscope support so that running make cscope will generate/update cscope files used for source code browsing, while running make distclean will remove the cscope files.

Also add entry in .gitignore to ignore generated cscope files.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 53 lines
---
 .gitignore |  1 +
 Makefile   | 13 +++++++++++++
 2 files changed, 14 insertions(+)
.gitignore +1 -0
index 534ad64..95692bb 100644
@@ -9,3 +9,4 @@ install/
 
 # Development friendly files
 tags
+cscope*
Makefile +13 -1
index 0ab9f22..4b175a0 100644
@@ -623,6 +623,17 @@ install_firmwares: $(platform_build_dir)/lib/libplatsbi.a $(build_dir)/lib/libsb
 install_docs: $(build_dir)/docs/latex/refman.pdf
        $(call inst_file,$(install_root_dir)/$(install_docs_path)/refman.pdf,$(build_dir)/docs/latex/refman.pdf)
 
+.PHONY: cscope
+cscope:
+       $(CMD_PREFIX)find \
+               "$(src_dir)/firmware" \
+               "$(src_dir)/include" \
+               "$(src_dir)/lib" \
+               "$(platform_src_dir)" \
+       -name "*.[chS]" -print > cscope.files
+       $(CMD_PREFIX)echo "$(KCONFIG_AUTOHEADER)" >> cscope.files
+       $(CMD_PREFIX)cscope -bkq -i cscope.files -f cscope.out
+
 # Rule for "make clean"
 .PHONY: clean
 clean:
@@ -652,6 +663,8 @@ ifeq ($(install_root_dir),$(install_root_dir_default)/usr)
        $(if $(V), @echo " RM        $(install_root_dir_default)")
        $(CMD_PREFIX)rm -rf $(install_root_dir_default)
 endif
+       $(if $(V), @echo " RM        $(src_dir)/cscope*")
+       $(CMD_PREFIX)rm -f $(src_dir)/cscope*
 
 .PHONY: FORCE
 FORCE:
--

2.34.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi