From 9ec888231571f3c3cf06d1c769174418e49f7eed Mon Sep 17 00:00:00 2001 From: Jeremy Lorelli Date: Fri, 2 Feb 2024 13:08:20 -0800 Subject: [PATCH] src/defs.mak: Improve host system autodetection Allows RHEL version to be detected and HARCH_DEFAULT set accordingly This removes the need for setting HARCH explicitly on the command line or in config.mak --- config.mak | 2 +- src/arch-detect.mak | 20 ++++++++++++++++++++ src/defs.mak | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/arch-detect.mak diff --git a/config.mak b/config.mak index c5f4da6..9b3d932 100644 --- a/config.mak +++ b/config.mak @@ -21,7 +21,7 @@ PACKAGE_TOP=/afs/slac/g/lcls/package # you can redefine the name of the host architecture: # HARCH = www #HARCH=linux-x86_64 -HARCH=rhel6-x86_64 +#HARCH=rhel6-x86_64 # Assuming you also want 'xxx' and 'yyy' then you'd # add these to the 'ARCHES' variable: diff --git a/src/arch-detect.mak b/src/arch-detect.mak new file mode 100644 index 0000000..e80f31d --- /dev/null +++ b/src/arch-detect.mak @@ -0,0 +1,20 @@ +# //@C Copyright Notice +# //@C ================ +# //@C This file is part of CPSW. It is subject to the license terms in the LICENSE.txt +# //@C file found in the top-level directory of this distribution and at +# //@C https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +# //@C +# //@C No part of CPSW, including this file, may be copied, modified, propagated, or +# //@C distributed except according to the terms contained in the LICENSE.txt file. + +#=================================================# +# Simple utility script to detect host arch +#=================================================# + +HOST_ARCH:=$(shell uname -r | grep -Eo "el[0-9][0-9]?") +ifneq ($(HOST_ARCH),) + HOST_ARCH:=rhel$(subst el,,$(HOST_ARCH))-$(shell uname -m) +else + HOST_ARCH:=linux-$(shell uname -m) +endif + diff --git a/src/defs.mak b/src/defs.mak index 4ea8bea..aec3e62 100644 --- a/src/defs.mak +++ b/src/defs.mak @@ -10,8 +10,10 @@ # (Default) Definitions for CPSW Makefiles # host architecture -HARCH_DEFAULT:=linux-$(shell uname -m) +include $(CPSW_DIR)/arch-detect.mak +HARCH_DEFAULT:=$(HOST_ARCH) HARCH=$(HARCH_DEFAULT) + # Architectures to build ARCHES=$(HARCH)