Skip to contentSkip to conversation

Makefile: Don't trust PWD

PATCH Applied Andrew Jones 3 participants 4 messages Aug 27, 2021 – Aug 31, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: Don't trust PWD

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index f7b9f28c9319..6792b93c4e16 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
 	cscope -bk
 
 .PHONY: tags
Signature · 1 line
2.31.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 16 lines · Andrew Jones

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

---
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c9319..6792b93c4e16 100644

Makefile cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a · line 125

Quoted 8 lines
Makefile +1 -1
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
  	$(RM) ./cscope.*
  	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
  	cscope -bk
 
  .PHONY: tags

Perfect for me, works as expected on Z.

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
Reviewed-by on v2 1/1
#2 lore raw
In reply to Andrew Jones
Quoted 16 lines · Andrew Jones

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

---
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c9319..6792b93c4e16 100644

Makefile cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a · line 125

Quoted 8 lines
Makefile +1 -1
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
  	$(RM) ./cscope.*
  	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
  	cscope -bk
 
  .PHONY: tags
author Applied
#3 lore raw
In reply to Andrew Jones
Quoted 26 lines · Andrew Jones

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index f7b9f28c9319..6792b93c4e16 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
 	cscope -bk
 
 .PHONY: tags
Signature · 1 line
2.31.1

Applied to misc/queue and merged to master.

Thanks,
drew