From 000034a74bd306535c4c4ca715587c08142c6b55 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Fri, 12 Jun 2026 17:53:48 +0800
Subject: [PATCH] Add top build shell script

---
 qt/build.sh |  184 +++++++++++++++++++++++----------------------
 1 files changed, 93 insertions(+), 91 deletions(-)

diff --git a/qt/build.sh b/qt/build.sh
index 8bce607..b8c060e 100755
--- a/qt/build.sh
+++ b/qt/build.sh
@@ -2,7 +2,11 @@
 #+--------------------------------------------------------------------------------------------
 #|   WARNNING:  QT >= 5.7 need crosstool g++ support C++11 support
 #|              QT configure need host g++ support C++11, so need config g++ on ubuntu host:
-#|              sudo update-alternatives --config g++
+#|
+#| guowenxue@ubuntu22:~$ sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
+#| guowenxue@ubuntu22:~$ sudo update-alternatives --config g++
+#| guowenxue@ubuntu22:~$ arm-linux-gnueabihf-g++ -v
+#| gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04.3)
 #+--------------------------------------------------------------------------------------------
 
 # library name and version
@@ -11,14 +15,11 @@
 SRC_NAME=qt-everywhere-src-5.15.10
 PACK_SUFIX=tar.xz
 
-# LingYun source code FTP server
-LY_FTP=http://master.weike-iot.com:8021/src/qt
-
 # library download URL address
-LIB_URL=$LY_FTP
+LIB_URL=http://master.weike-iot.com:8021/src/qt
 
-# Cross compiler for cross compile on Linux server
-CROSS_COMPILE=arm-linux-gnueabihf-
+# QT should use this cross compiler
+CROSS_TOOLS=arm-linux-gnueabihf-
 
 # compile jobs
 JOBS=`cat /proc/cpuinfo |grep "processor"|wc -l`
@@ -36,7 +37,7 @@
 INC_PATH=$PREFIX_PATH/include
 
 # check installed or not file
-INST_FILE=$PREFIX_PATH/lib/libQt5Core.so
+INST_FILE=$PREFIX_PATH/lib/libqlinuxfb.so
 
 # shell script will exit once get command error
 set -e
@@ -46,132 +47,133 @@
 #+-------------------------+
 
 function pr_error() {
-	echo -e "\033[40;31m $1 \033[0m"
+    echo -e "\033[40;31m $1 \033[0m"
 }
 
 function pr_warn() {
-	echo -e "\033[40;33m $1 \033[0m"
+    echo -e "\033[40;33m $1 \033[0m"
 }
 
 function pr_info() {
-	echo -e "\033[40;32m $1 \033[0m"
+    echo -e "\033[40;32m $1 \033[0m"
 }
 
 function check_result()
 {
-	if [ $? != 0 ] ; then
-		pr_error $1
-	fi
+    if [ $? != 0 ] ; then
+        pr_error $1
+    fi
 }
+
 # decompress a packet to destination path
 function do_unpack()
 {
-	tarball=$1
-	dstpath=`pwd`
+    tarball=$1
+    dstpath=`pwd`
 
-	if [[ $# == 2 ]] ; then
-		dstpath=$2
-	fi
+    if [[ $# == 2 ]] ; then
+        dstpath=$2
+    fi
 
-	pr_info "decompress $tarball => $dstpath"
+    pr_info "decompress $tarball => $dstpath"
 
-	mkdir -p $dstpath
-	case $tarball in
-		*.tar.gz)
-			tar -xzf $tarball -C $dstpath
-			;;
+    mkdir -p $dstpath
+    case $tarball in
+        *.tar.gz)
+            tar -xzf $tarball -C $dstpath
+            ;;
 
-		*.tar.bz2)
-			tar -xjf $tarball -C $dstpath
-			;;
+        *.tar.bz2)
+            tar -xjf $tarball -C $dstpath
+            ;;
 
-		*.tar.xz)
-			tar -xJf $tarball -C $dstpath
-			;;
+        *.tar.xz)
+            tar -xJf $tarball -C $dstpath
+            ;;
 
-		*.tar.zst)
-			tar -I zstd -xf $tarball -C $dstpath
-			;;
+        *.tar.zst)
+            tar -I zstd -xf $tarball -C $dstpath
+            ;;
 
-		*.tar)
-			tar -xf $tarball -C $dstpath
-			;;
+        *.tar)
+            tar -xf $tarball -C $dstpath
+            ;;
 
-		*.zip)
-			unzip -qo $tarball -d $dstpath
-			;;
+        *.zip)
+            unzip -qo $tarball -d $dstpath
+            ;;
 
-		*)
-			pr_error "decompress Unsupport packet: $tarball"
-			return 1;
-			;;
-	esac
+        *)
+            pr_error "decompress Unsupport packet: $tarball"
+            return 1;
+            ;;
+    esac
 }
 
 function do_export()
 {
-	BUILD_ARCH=$(uname -m)
-	if [[ $BUILD_ARCH =~ "arm" ]] ; then
-		pr_warn "local($BUILD_ARCH) compile $LIB_NAME"
-		return ;
-	fi
+    BUILD_ARCH=$(uname -m)
+    if [[ $BUILD_ARCH =~ "arm" ]] ; then
+        pr_warn "local($BUILD_ARCH) compile $LIB_NAME"
+        return ;
+    fi
 
-	pr_warn "cross(${CROSS_COMPILE}) compile $LIB_NAME"
+    pr_warn "cross(${CROSS_TOOLS}) compile $LIB_NAME"
 
-	# export cross toolchain
-	export CC=${CROSS_COMPILE}gcc
-	export CXX=${CROSS_COMPILE}g++
-	export AS=${CROSS_COMPILE}as
-	export AR=${CROSS_COMPILE}ar
-	export LD=${CROSS_COMPILE}ld
-	export NM=${CROSS_COMPILE}nm
-	export RANLIB=${CROSS_COMPILE}ranlib
-	export OBJDUMP=${CROSS_COMPILE}objdump
-	export STRIP=${CROSS_COMPILE}strip
+    # export cross toolchain
+    export CC=${CROSS_TOOLS}gcc
+    export CXX=${CROSS_TOOLS}g++
+    export AS=${CROSS_TOOLS}as
+    export AR=${CROSS_TOOLS}ar
+    export LD=${CROSS_TOOLS}ld
+    export NM=${CROSS_TOOLS}nm
+    export RANLIB=${CROSS_TOOLS}ranlib
+    export OBJDUMP=${CROSS_TOOLS}objdump
+    export STRIP=${CROSS_TOOLS}strip
 
-	# export cross configure
-	export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux "
+    # export cross configure
+    export CONFIG_CROSS=" --build=i686-pc-linux --host=arm-linux "
 
-	# Clear LDFLAGS and CFLAGS
-	export LDFLAGS=
-	export CFLAGS=
+    # Clear LDFLAGS and CFLAGS
+    export LDFLAGS=
+    export CFLAGS=
 }
 
 function do_fetch()
 {
-	if [ -e ${INST_FILE} ] ; then
-		pr_warn "$LIB_NAME compile and installed alredy"
-		exit ;
-	fi
+    if [ -e ${INST_FILE} ] ; then
+        pr_warn "$LIB_NAME compile and installed alredy"
+        exit ;
+    fi
 
-	if [ -d $SRC_NAME ] ; then
-		pr_warn "$LIB_NAME fetch already"
-		return ;
-	fi
+    if [ -d $SRC_NAME ] ; then
+        pr_warn "$LIB_NAME fetch already"
+        return ;
+    fi
 
-	if [ ! -f ${LIB_NAME}.${PACK_SUFIX} ] ; then
-		wget ${LIB_URL}/${LIB_NAME}.${PACK_SUFIX}
-		check_result "ERROR: download ${LIB_NAME} failure"
-	fi
+    if [ ! -f ${LIB_NAME}.${PACK_SUFIX} ] ; then
+        wget ${LIB_URL}/${LIB_NAME}.${PACK_SUFIX}
+        check_result "ERROR: download ${LIB_NAME} failure"
+    fi
 
-	do_unpack ${LIB_NAME}.${PACK_SUFIX}
+    do_unpack ${LIB_NAME}.${PACK_SUFIX}
 }
 
 function do_build()
 {
-	cd $SRC_NAME
+    cd $SRC_NAME
 
     QMAKE_FILE=qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
 
-	set +e
-    grep "`basename ${CROSS_COMPILE}`" ${QMAKE_FILE} > /dev/null 2>&1
+    set +e
+    grep "`basename ${CROSS_TOOLS}`" ${QMAKE_FILE} > /dev/null 2>&1
     if [ $? != 0 ] ; then
-        sed -i "s|arm-linux-gnueabi-|`basename $CROSS_COMPILE`|" ${QMAKE_FILE}
+        sed -i "s|arm-linux-gnueabi-|`basename $CROSS_TOOLS`|" ${QMAKE_FILE}
     fi
-	set -e
+    set -e
 
-	QT_INST_PATH=$PREFIX_PATH
-    export CROSS_SYSROOT=`${CROSS_COMPILE}gcc -print-sysroot`
+    QT_INST_PATH=$PREFIX_PATH
+    export CROSS_SYSROOT=`${CROSS_TOOLS}gcc -print-sysroot`
 
     ./configure -opensource -confirm-license -release -shared -strip \
         -extprefix ${QT_INST_PATH} -prefix ${QT_INST_PATH} -sysroot ${CROSS_SYSROOT} -pkg-config \
@@ -189,19 +191,19 @@
     make -j${JOBS} && make install
     check_result "ERROR: compile ${LIB_NAME} failure"
 
-    cp ./qtbase/plugins/platforms/libqlinuxfb.so  ${QT_INST_PATH}/lib
+    install -D ./qtbase/plugins/platforms/libqlinuxfb.so  ${QT_INST_PATH}/lib/libqlinuxfb.so
     #cp -af ${LIB_PATH}/lib/libts*so* ${QT_INST_PATH}/lib
 }
 
 function do_clean()
 {
-	rm -rf *${LIB_NAME}*
+    rm -rf *${LIB_NAME}*
 }
 
 if [[ $# == 1 && $1 == -c ]] ;then
-	pr_warn "start clean ${LIB_NAME}"
-	do_clean
-	exit;
+    pr_warn "start clean ${LIB_NAME}"
+    do_clean
+    exit;
 fi
 
 do_fetch

--
Gitblit v1.10.0