18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciHOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
38c2ecf20Sopenharmony_ci                                  -e s/sun4u/sparc/ -e s/sparc64/sparc/ \
48c2ecf20Sopenharmony_ci                                  -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \
58c2ecf20Sopenharmony_ci                                  -e s/s390x/s390/ -e s/parisc64/parisc/ \
68c2ecf20Sopenharmony_ci                                  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
78c2ecf20Sopenharmony_ci                                  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
88c2ecf20Sopenharmony_ci				  -e s/loongarch.*/loongarch/)
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciifndef ARCH
118c2ecf20Sopenharmony_ciARCH := $(HOSTARCH)
128c2ecf20Sopenharmony_ciendif
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciSRCARCH := $(ARCH)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci# Additional ARCH settings for x86
178c2ecf20Sopenharmony_ciifeq ($(ARCH),i386)
188c2ecf20Sopenharmony_ci        SRCARCH := x86
198c2ecf20Sopenharmony_ciendif
208c2ecf20Sopenharmony_ciifeq ($(ARCH),x86_64)
218c2ecf20Sopenharmony_ci        SRCARCH := x86
228c2ecf20Sopenharmony_ciendif
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci# Additional ARCH settings for sparc
258c2ecf20Sopenharmony_ciifeq ($(ARCH),sparc32)
268c2ecf20Sopenharmony_ci       SRCARCH := sparc
278c2ecf20Sopenharmony_ciendif
288c2ecf20Sopenharmony_ciifeq ($(ARCH),sparc64)
298c2ecf20Sopenharmony_ci       SRCARCH := sparc
308c2ecf20Sopenharmony_ciendif
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci# Additional ARCH settings for sh
338c2ecf20Sopenharmony_ciifeq ($(ARCH),sh64)
348c2ecf20Sopenharmony_ci       SRCARCH := sh
358c2ecf20Sopenharmony_ciendif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci# Additional ARCH settings for loongarch
388c2ecf20Sopenharmony_ciifeq ($(ARCH),loongarch32)
398c2ecf20Sopenharmony_ci       SRCARCH := loongarch
408c2ecf20Sopenharmony_ciendif
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciifeq ($(ARCH),loongarch64)
438c2ecf20Sopenharmony_ci       SRCARCH := loongarch
448c2ecf20Sopenharmony_ciendif
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciLP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
478c2ecf20Sopenharmony_ciifeq ($(LP64), 1)
488c2ecf20Sopenharmony_ci  IS_64_BIT := 1
498c2ecf20Sopenharmony_cielse
508c2ecf20Sopenharmony_ci  IS_64_BIT := 0
518c2ecf20Sopenharmony_ciendif
52