Skip to contentSkip to conversation

Codesamples/depends.mk : Replace non-portable uname '-p' with '-m'

PATCH New Leonardo Bras 1 participant 1 message Feb 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Codesamples/depends.mk : Replace non-portable uname '-p' with '-m'

uname -p returns 'unknown' for current coreutils.

On GNU coreutils 9.1, the uname --help text says:

uname --help
Usage: uname [OPTION]...
[...]

  -v, --kernel-version     print the kernel version
  -m, --machine            print the machine hardware name
  -p, --processor          print the processor type (non-portable)
  -i, --hardware-platform  print the hardware platform (non-portable)

[...]

Looking deeper, I noticed that '-p' is supposed to be printing the processor type when available, and not necessarily the architecture.

For printing the architecture, it's recommended to use uname -m, instead. Even so, it seems like some distros make '-p' to return the same as '-m' for compatibility purposes.

Anyway, change '-p' to '-m' on depends.mk to avoid getting arch=unknown.

---
 CodeSamples/depends.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/depends.mk +1 -1
index 30810339..2086fe00 100644
@@ -1,5 +1,5 @@
 ifeq ($(strip $(arch)),)
-arch := $(shell uname -p)
+arch := $(shell uname -m)
 endif
 
 ifeq ($(strip $(os)),)
Signature · 1 line
2.39.1