make-dist.sh (2580B)
1 #!/bin/bash 2 3 # 4 # This file creates dist tarball. 5 # Optional autotools patches are applied for better toolchains 6 # compatibility. 7 # 8 # Based on Debian SID baseline files as of January 2024. 9 # 10 11 if ! grep -Eq -e '^PRETTY_NAME="Debian GNU/Linux 12 \(bookworm\)"$' /etc/os-release && \ 12 ! grep -Eq -e '^PRETTY_NAME="Debian GNU/Linux trixie/sid"$' /etc/os-release 13 then 14 echo "Only Debian 'bookworm' and 'trixie/sid' are supported by this script." >&2 15 exit 1 16 fi 17 18 if ! autoconf --version | head -1 | grep -Eq -e ' 2\.71$' - 19 then 20 echo "The only supported autoconf version is 2.71." >&2 21 exit 1 22 fi 23 24 25 tooldir=$(dirname $BASH_SOURCE) || exit 2 26 test -n "$tooldir" || exit 2 27 cd "$tooldir" || exit 2 28 tooldir="$PWD" || exit 2 29 cd "${tooldir}/.." || exit 2 30 rootsrcdir="$PWD" || exit 2 31 32 # Cleanup sources 33 echo '' 34 echo '*** Performing initial cleanup...' 35 echo '' 36 if [[ ! -f 'Makefile' ]] || ! make maintainer-clean 37 then 38 # Makefile needed for initial cleanup 39 if [[ ! -f 'Makefile.in' ]] || [[ ! -f 'configure' ]] || ! ./configure || ! make maintainer-clean 40 then 41 rm -f po/Makefile || exit 3 42 # Build 'configure' to build Makefile for initial cleanup 43 autoreconf -fvi || exit 3 44 ./configure || exit 3 45 make maintainer-clean || exit 3 46 fi 47 fi 48 echo '' 49 echo '** Initial cleanup completed.' 50 echo '' 51 52 # Copy latest autotools files 53 echo '' 54 echo '*** Copying autotools files...' 55 echo '' 56 autoreconf -fvi || exit 4 57 echo '' 58 echo '*** Performing intermediate cleanup...' 59 echo '' 60 ./configure || exit 4 61 make distclean || exit 4 62 rm -f ./configure ./aclocal.m4 || exit 4 63 rm -rf ./autom4te.cache || exit 4 64 echo '' 65 echo '** Intermediate cleanup completed.' 66 echo '' 67 68 # Patching local autotools files 69 echo '' 70 echo '*** Performing patching of local autotools files...' 71 echo '' 72 "$tooldir/fixes-libtool/apply-all.sh" || exit 5 73 "$tooldir/fixes-autoconf/apply-all.sh" || exit 5 74 echo '' 75 echo '** Local autotools files patched.' 76 echo '' 77 78 # Build the configure and the related files with patches 79 echo '' 80 echo '*** Building patched configure and related files...' 81 echo '' 82 autoreconf -v || exit 6 83 echo '' 84 echo '** Patched build system ready.' 85 echo '' 86 87 # Build the configure and the related files with patches 88 89 have_command() 90 { 91 command -v "$1" >/dev/null 2>&1 92 } 93 94 echo '' 95 echo '*** Building dist tarball...' 96 echo '' 97 ./configure || exit 7 98 if have_command zopfli; then 99 make dist-custm2 'ARC_CMD=zopfli -v --gzip --i25' 'ARC_EXT=tar.gz' || exit 7 100 else 101 make dist || exit 7 102 echo '* zopfli is not installed, tarball size is suboptimal.' 103 fi 104 echo '' 105 echo '** Dist tarball ready.' 106 echo '' 107 108 exit 0