make-dist.sh 2.5 KB

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