162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ciHOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
362306a36Sopenharmony_ci                                  -e s/sun4u/sparc/ -e s/sparc64/sparc/ \
462306a36Sopenharmony_ci                                  -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \
562306a36Sopenharmony_ci                                  -e s/s390x/s390/ -e s/parisc64/parisc/ \
662306a36Sopenharmony_ci                                  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
762306a36Sopenharmony_ci                                  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
862306a36Sopenharmony_ci                                  -e s/riscv.*/riscv/ -e s/loongarch.*/loongarch/)
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciifndef ARCH
1162306a36Sopenharmony_ciARCH := $(HOSTARCH)
1262306a36Sopenharmony_ciendif
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciSRCARCH := $(ARCH)
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci# Additional ARCH settings for x86
1762306a36Sopenharmony_ciifeq ($(ARCH),i386)
1862306a36Sopenharmony_ci        SRCARCH := x86
1962306a36Sopenharmony_ciendif
2062306a36Sopenharmony_ciifeq ($(ARCH),x86_64)
2162306a36Sopenharmony_ci        SRCARCH := x86
2262306a36Sopenharmony_ciendif
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci# Additional ARCH settings for sparc
2562306a36Sopenharmony_ciifeq ($(ARCH),sparc32)
2662306a36Sopenharmony_ci       SRCARCH := sparc
2762306a36Sopenharmony_ciendif
2862306a36Sopenharmony_ciifeq ($(ARCH),sparc64)
2962306a36Sopenharmony_ci       SRCARCH := sparc
3062306a36Sopenharmony_ciendif
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci# Additional ARCH settings for loongarch
3362306a36Sopenharmony_ciifeq ($(ARCH),loongarch32)
3462306a36Sopenharmony_ci       SRCARCH := loongarch
3562306a36Sopenharmony_ciendif
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciifeq ($(ARCH),loongarch64)
3862306a36Sopenharmony_ci       SRCARCH := loongarch
3962306a36Sopenharmony_ciendif
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciLP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
4262306a36Sopenharmony_ciifeq ($(LP64), 1)
4362306a36Sopenharmony_ci  IS_64_BIT := 1
4462306a36Sopenharmony_cielse
4562306a36Sopenharmony_ci  IS_64_BIT := 0
4662306a36Sopenharmony_ciendif
47