Last active
July 10, 2025 05:34
-
-
Save abldg/8042bb746eb5d02e60c3f53193dfb7b8 to your computer and use it in GitHub Desktop.
build tool [ jq ] on Ubuntu-16.04+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ## coding=utf-8 | |
| ##==================================----------================================== | |
| ## FILE: 01_build_src_jq.sh | |
| ## MYPG: abldg, https://github.com/abldg | |
| ## LSCT: 2025-07-10 11:08:36 | |
| ## VERS: 0.2 | |
| ##==================================----------================================== | |
| dfn_bldsrc_jq() { | |
| case ${1:-$(arch)} in | |
| 1 | arm64 | aarch64) declare -r VARCH=arm64 VTPFX=aarch64-linux-gnu ;; | |
| 0 | amd64 | x64 | *) declare -r VARCH=amd64 VTPFX=x86_64-linux-gnu ;; | |
| esac | |
| ## | |
| [ XrootZ != "X${USER}Z" ] && SUDO=sudo | |
| if [ X = X$(command -v ${VTPFX}-gcc) ]; then | |
| tcky=crossbuild-essential-$VARCH | |
| $SUDO apt-get update -y | |
| $SUDO apt-get install -y automake autoconf libtool $tcky | |
| fi | |
| ## | |
| sdir=$(mktemp -d -t bldsrc_jq_$VARCH.XXXXXX) | |
| gc_opts='--recurse-submodules --depth=1' | |
| git clone https://github.com/jqlang/jq $gc_opts $sdir && ( | |
| copt='--disable-docs --enable-static --enable-all-static --host='$VTPFX | |
| cd $sdir && autoreconf -i && ./configure $copt --with-oniguruma=builtin \ | |
| CFLAGS="-O2 -pthread -fstack-protector-all" && | |
| make -j"$(nproc)" && file ./jq | |
| ) | |
| [ X1 = X${CLEAN_SRCDIR:-0} ] && rm -rf $sdir | |
| } | |
| dfn_bldsrc_jq $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment