make-dist.sh 2.4 KB

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