From 3100da59abd272fc3f301a30ebabedf86b0b4a00 Mon Sep 17 00:00:00 2001
From: Sun Haiyong <sunhaiyong@loongson.cn>
Date: Tue, 21 Dec 2021 20:40:27 +0800
Subject: [PATCH] Add loongarch architecture support.

---
 installplatform | 12 ++++++++++++
 rpmrc.in        | 17 +++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/installplatform b/installplatform
index 12339fc..74c50a2 100755
--- a/installplatform
+++ b/installplatform
@@ -168,6 +168,18 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
 	CANONARCH=mips64r6el
 	CANONCOLOR=3
 	;;
+    loongarch32)
+	ISANAME=loongarch
+	ISABITS=32
+	CANONARCH=loongarch32
+	CANONCOLOR=0
+	;;
+    loongarch64)
+	ISANAME=loongarch
+	ISABITS=64
+	CANONARCH=loongarch64
+	CANONCOLOR=3
+	;;
     m68k)
 	ISANAME=m68k
 	ISABITS=32
diff --git a/rpmrc.in b/rpmrc.in
index 5bd9ba3..fc2932a 100644
--- a/rpmrc.in
+++ b/rpmrc.in
@@ -67,6 +67,8 @@ optflags: mipsr6el -O2 -g
 optflags: mips64r6 -O2 -g
 optflags: mips64r6el -O2 -g
 
+optflags: loongarch64 -O2 -g
+
 optflags: armv3l -O2 -g -march=armv3
 optflags: armv4b -O2 -g -march=armv4
 optflags: armv4l -O2 -g -march=armv4
@@ -137,6 +139,9 @@ archcolor: mipsr6el 1
 archcolor: mips64r6 2
 archcolor: mips64r6el 2
 
+archcolor: loongarch32 1
+archcolor: loongarch64 2
+
 archcolor: m68k 1
 
 archcolor: m68kmint 1
@@ -257,6 +262,9 @@ arch_canon:	mips64r6el: mips64r6el	21
 arch_canon:	riscv: riscv64	22
 arch_canon:	riscv64: riscv64	22
 
+arch_canon:	loongarch32:	loongarch32	25
+arch_canon:	loongarch64:	loongarch64	26
+
 #############################################################
 # Canonical OS names and numbers
 
@@ -360,6 +368,9 @@ buildarchtranslate: mipsr6el: mipsr6el
 buildarchtranslate: mips64r6: mips64r6
 buildarchtranslate: mips64r6el: mips64r6el
 
+buildarchtranslate: loongarch32: loongarch32
+buildarchtranslate: loongarch64: loongarch64
+
 buildarchtranslate: m68k: m68k
 
 buildarchtranslate: atarist: m68kmint
@@ -449,6 +460,9 @@ arch_compat: mipsr6el: noarch
 arch_compat: mips64r6: mipsr6
 arch_compat: mips64r6el: mipsr6el
 
+arch_compat: loongarch32: noarch
+arch_compat: loongarch64: loongarch32
+
 arch_compat: hppa2.0: hppa1.2
 arch_compat: hppa1.2: hppa1.1
 arch_compat: hppa1.1: hppa1.0
@@ -586,6 +600,9 @@ buildarch_compat: mipsr6el: noarch
 buildarch_compat: mips64r6: noarch
 buildarch_compat: mips64r6el: noarch
 
+buildarch_compat: loongarch32: noarch
+buildarch_compat: loongarch64: noarch
+
 buildarch_compat: armv4b: noarch
 buildarch_compat: armv8l: armv7l
 buildarch_compat: armv7l: armv6l
-- 
2.30.0

