1
0

autoconfiscate.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. #!/usr/bin/env bash
  2. set -e
  3. #
  4. # This script autoconficates the libopenmpt source tree and builds an
  5. # autotools-based release tarball.
  6. #
  7. # WARNING: The script expects to be run from the root of an OpenMPT svn
  8. # checkout. The invests no effort in verifying this precondition.
  9. #
  10. echo "Gathering version ..."
  11. . libopenmpt/libopenmpt_version.mk
  12. echo "Cleaning local build ..."
  13. make NO_SDL=1 NO_SDL2=1 clean
  14. echo "Cleaning dist-autotools.tar ..."
  15. rm -rf bin/dist-autotools.tar || true
  16. echo "Cleaning tmp directory ..."
  17. if [ -e bin/dist-autotools ]; then
  18. chmod -R u+rw bin/dist-autotools || true
  19. fi
  20. rm -rf bin/dist-autotools || true
  21. echo "Making tmp directory ..."
  22. mkdir bin/dist-autotools
  23. if `svn info . > /dev/null 2>&1` ; then
  24. echo "Exporting svn ..."
  25. svn export ./LICENSE bin/dist-autotools/LICENSE
  26. svn export ./README.md bin/dist-autotools/README.md
  27. svn export ./.clang-format bin/dist-autotools/.clang-format
  28. svn export ./common bin/dist-autotools/common
  29. mkdir bin/dist-autotools/doc
  30. svn export ./doc/contributing.md bin/dist-autotools/doc/contributing.md
  31. svn export ./doc/libopenmpt_styleguide.md bin/dist-autotools/doc/libopenmpt_styleguide.md
  32. svn export ./doc/module_formats.md bin/dist-autotools/doc/module_formats.md
  33. svn export ./doc/openmpt_styleguide.md bin/dist-autotools/doc/openmpt_styleguide.md
  34. svn export ./soundlib bin/dist-autotools/soundlib
  35. svn export ./sounddsp bin/dist-autotools/sounddsp
  36. mkdir -p bin/dist-autotools/src/mpt
  37. svn export ./src/mpt/.clang-format bin/dist-autotools/src/mpt/.clang-format
  38. svn export ./src/mpt/LICENSE.BSD-3-Clause.txt bin/dist-autotools/src/mpt/LICENSE.BSD-3-Clause.txt
  39. svn export ./src/mpt/LICENSE.BSL-1.0.txt bin/dist-autotools/src/mpt/LICENSE.BSL-1.0.txt
  40. svn export ./src/mpt/audio bin/dist-autotools/src/mpt/audio
  41. svn export ./src/mpt/base bin/dist-autotools/src/mpt/base
  42. svn export ./src/mpt/binary bin/dist-autotools/src/mpt/binary
  43. svn export ./src/mpt/check bin/dist-autotools/src/mpt/check
  44. svn export ./src/mpt/crc bin/dist-autotools/src/mpt/crc
  45. #svn export ./src/mpt/crypto bin/dist-autotools/src/mpt/crypto
  46. svn export ./src/mpt/detect bin/dist-autotools/src/mpt/detect
  47. svn export ./src/mpt/endian bin/dist-autotools/src/mpt/endian
  48. svn export ./src/mpt/environment bin/dist-autotools/src/mpt/environment
  49. svn export ./src/mpt/exception_text bin/dist-autotools/src/mpt/exception_text
  50. svn export ./src/mpt/format bin/dist-autotools/src/mpt/format
  51. svn export ./src/mpt/io bin/dist-autotools/src/mpt/io
  52. svn export ./src/mpt/io_read bin/dist-autotools/src/mpt/io_read
  53. svn export ./src/mpt/io_write bin/dist-autotools/src/mpt/io_write
  54. #svn export ./src/mpt/json bin/dist-autotools/src/mpt/json
  55. #svn export ./src/mpt/library bin/dist-autotools/src/mpt/library
  56. svn export ./src/mpt/mutex bin/dist-autotools/src/mpt/mutex
  57. svn export ./src/mpt/out_of_memory bin/dist-autotools/src/mpt/out_of_memory
  58. svn export ./src/mpt/osinfo bin/dist-autotools/src/mpt/osinfo
  59. svn export ./src/mpt/parse bin/dist-autotools/src/mpt/parse
  60. #svn export ./src/mpt/path bin/dist-autotools/src/mpt/path
  61. svn export ./src/mpt/random bin/dist-autotools/src/mpt/random
  62. svn export ./src/mpt/string bin/dist-autotools/src/mpt/string
  63. svn export ./src/mpt/string_transcode bin/dist-autotools/src/mpt/string_transcode
  64. svn export ./src/mpt/system_error bin/dist-autotools/src/mpt/system_error
  65. svn export ./src/mpt/test bin/dist-autotools/src/mpt/test
  66. svn export ./src/mpt/uuid bin/dist-autotools/src/mpt/uuid
  67. #svn export ./src/mpt/uuid_namespace bin/dist-autotools/src/mpt/uuid_namespace
  68. mkdir -p bin/dist-autotools/src/openmpt
  69. svn export ./src/openmpt/all bin/dist-autotools/src/openmpt/all
  70. svn export ./src/openmpt/base bin/dist-autotools/src/openmpt/base
  71. svn export ./src/openmpt/logging bin/dist-autotools/src/openmpt/logging
  72. svn export ./src/openmpt/random bin/dist-autotools/src/openmpt/random
  73. svn export ./src/openmpt/soundbase bin/dist-autotools/src/openmpt/soundbase
  74. svn export ./test bin/dist-autotools/test
  75. rm bin/dist-autotools/test/mpt_tests_crypto.cpp
  76. rm bin/dist-autotools/test/mpt_tests_uuid_namespace.cpp
  77. svn export ./libopenmpt bin/dist-autotools/libopenmpt
  78. svn export ./examples bin/dist-autotools/examples
  79. svn export ./openmpt123 bin/dist-autotools/openmpt123
  80. mkdir bin/dist-autotools/build
  81. mkdir bin/dist-autotools/build/svn_version
  82. svn export ./build/svn_version/svn_version.h bin/dist-autotools/build/svn_version/svn_version.h
  83. mkdir bin/dist-autotools/m4
  84. touch bin/dist-autotools/m4/emptydir
  85. svn export ./build/autotools/configure.ac bin/dist-autotools/configure.ac
  86. svn export ./build/autotools/Makefile.am bin/dist-autotools/Makefile.am
  87. else
  88. echo "Exporting git ..."
  89. cp -r ./LICENSE bin/dist-autotools/LICENSE
  90. cp -r ./README.md bin/dist-autotools/README.md
  91. cp -r ./.clang-format bin/dist-autotools/.clang-format
  92. cp -r ./common bin/dist-autotools/common
  93. mkdir bin/dist-autotools/doc
  94. cp -r ./doc/contributing.md bin/dist-autotools/doc/contributing.md
  95. cp -r ./doc/libopenmpt_styleguide.md bin/dist-autotools/doc/libopenmpt_styleguide.md
  96. cp -r ./doc/module_formats.md bin/dist-autotools/doc/module_formats.md
  97. cp -r ./doc/openmpt_styleguide.md bin/dist-autotools/doc/openmpt_styleguide.md
  98. cp -r ./soundlib bin/dist-autotools/soundlib
  99. cp -r ./sounddsp bin/dist-autotools/sounddsp
  100. mkdir -p bin/dist-autotools/src/mpt
  101. cp -r ./src/mpt/.clang-format bin/dist-autotools/src/mpt/.clang-format
  102. cp -r ./src/mpt/LICENSE.BSD-3-Clause.txt bin/dist-autotools/src/mpt/LICENSE.BSD-3-Clause.txt
  103. cp -r ./src/mpt/LICENSE.BSL-1.0.txt bin/dist-autotools/src/mpt/LICENSE.BSL-1.0.txt
  104. cp -r ./src/mpt/audio bin/dist-autotools/src/mpt/audio
  105. cp -r ./src/mpt/base bin/dist-autotools/src/mpt/base
  106. cp -r ./src/mpt/binary bin/dist-autotools/src/mpt/binary
  107. cp -r ./src/mpt/check bin/dist-autotools/src/mpt/check
  108. cp -r ./src/mpt/crc bin/dist-autotools/src/mpt/crc
  109. #cp -r ./src/mpt/crypto bin/dist-autotools/src/mpt/crypto
  110. cp -r ./src/mpt/detect bin/dist-autotools/src/mpt/detect
  111. cp -r ./src/mpt/endian bin/dist-autotools/src/mpt/endian
  112. cp -r ./src/mpt/environment bin/dist-autotools/src/mpt/environment
  113. cp -r ./src/mpt/exception_text bin/dist-autotools/src/mpt/exception_text
  114. cp -r ./src/mpt/format bin/dist-autotools/src/mpt/format
  115. cp -r ./src/mpt/io bin/dist-autotools/src/mpt/io
  116. cp -r ./src/mpt/io_read bin/dist-autotools/src/mpt/io_read
  117. cp -r ./src/mpt/io_write bin/dist-autotools/src/mpt/io_write
  118. #cp -r ./src/mpt/json bin/dist-autotools/src/mpt/json
  119. #cp -r ./src/mpt/library bin/dist-autotools/src/mpt/library
  120. cp -r ./src/mpt/mutex bin/dist-autotools/src/mpt/mutex
  121. cp -r ./src/mpt/out_of_memory bin/dist-autotools/src/mpt/out_of_memory
  122. cp -r ./src/mpt/osinfo bin/dist-autotools/src/mpt/osinfo
  123. cp -r ./src/mpt/parse bin/dist-autotools/src/mpt/parse
  124. #cp -r ./src/mpt/path bin/dist-autotools/src/mpt/path
  125. cp -r ./src/mpt/random bin/dist-autotools/src/mpt/random
  126. cp -r ./src/mpt/string bin/dist-autotools/src/mpt/string
  127. cp -r ./src/mpt/string_transcode bin/dist-autotools/src/mpt/string_transcode
  128. cp -r ./src/mpt/system_error bin/dist-autotools/src/mpt/system_error
  129. cp -r ./src/mpt/test bin/dist-autotools/src/mpt/test
  130. cp -r ./src/mpt/uuid bin/dist-autotools/src/mpt/uuid
  131. #cp -r ./src/mpt/uuid_namespace bin/dist-autotools/src/mpt/uuid_namespace
  132. mkdir -p bin/dist-autotools/src/openmpt
  133. cp -r ./src/openmpt/all bin/dist-autotools/src/openmpt/all
  134. cp -r ./src/openmpt/base bin/dist-autotools/src/openmpt/base
  135. cp -r ./src/openmpt/logging bin/dist-autotools/src/openmpt/logging
  136. cp -r ./src/openmpt/random bin/dist-autotools/src/openmpt/random
  137. cp -r ./src/openmpt/soundbase bin/dist-autotools/src/openmpt/soundbase
  138. cp -r ./test bin/dist-autotools/test
  139. rm bin/dist-autotools/test/mpt_tests_crypto.cpp
  140. rm bin/dist-autotools/test/mpt_tests_uuid_namespace.cpp
  141. cp -r ./libopenmpt bin/dist-autotools/libopenmpt
  142. cp -r ./examples bin/dist-autotools/examples
  143. cp -r ./openmpt123 bin/dist-autotools/openmpt123
  144. mkdir bin/dist-autotools/build
  145. mkdir bin/dist-autotools/build/svn_version
  146. cp -r ./build/svn_version/svn_version.h bin/dist-autotools/build/svn_version/svn_version.h
  147. mkdir bin/dist-autotools/m4
  148. touch bin/dist-autotools/m4/emptydir
  149. cp -r ./build/autotools/configure.ac bin/dist-autotools/configure.ac
  150. cp -r ./build/autotools/Makefile.am bin/dist-autotools/Makefile.am
  151. fi
  152. echo "Querying svn version ..."
  153. if `svn info . > /dev/null 2>&1` ; then
  154. BUILD_SVNURL="$(svn info --xml | grep '^<url>' | sed 's/<url>//g' | sed 's/<\/url>//g' | sed 's/\//\\\//g' )"
  155. BUILD_SVNVERSION="$(svnversion -n . | tr ':' '-' )"
  156. BUILD_SVNDATE="$(svn info --xml | grep '^<date>' | sed 's/<date>//g' | sed 's/<\/date>//g' )"
  157. else
  158. BUILD_SVNURL="$(git log --grep=git-svn-id -n 1 | grep git-svn-id | tail -n 1 | tr ' ' '\n' | tail -n 2 | head -n 1 | sed 's/@/ /g' | awk '{print $1;}' | sed 's/\//\\\//g')"
  159. BUILD_SVNVERSION="$(git log --grep=git-svn-id -n 1 | grep git-svn-id | tail -n 1 | tr ' ' '\n' | tail -n 2 | head -n 1 | sed 's/@/ /g' | awk '{print $2;}')$(if [ $(git rev-list $(git log --grep=git-svn-id -n 1 --format=format:'%H') ^$(git log -n 1 --format=format:'%H') --count ) -ne 0 ] ; then echo M ; fi)"
  160. BUILD_SVNDATE="$(git log -n 1 --date=iso --format=format:'%cd' | sed 's/ +0000/Z/g' | tr ' ' 'T')"
  161. fi
  162. echo " BUILD_SVNURL=${BUILD_SVNURL}"
  163. echo " BUILD_SVNVERSION=${BUILD_SVNVERSION}"
  164. echo " BUILD_SVNDATE=${BUILD_SVNDATE}"
  165. echo "Building man pages ..."
  166. make NO_SDL=1 NO_SDL2=1 bin/openmpt123.1
  167. echo "Copying man pages ..."
  168. mkdir bin/dist-autotools/man
  169. cp bin/openmpt123.1 bin/dist-autotools/man/openmpt123.1
  170. echo "Cleaning local buid ..."
  171. make NO_SDL=1 NO_SDL2=1 clean
  172. echo "Changing to autotools package directory ..."
  173. OLDDIR="$(pwd)"
  174. cd bin/dist-autotools/
  175. echo "Setting version in configure.ac ..."
  176. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_VERSION_MAJOR!!/${LIBOPENMPT_VERSION_MAJOR}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  177. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_VERSION_MINOR!!/${LIBOPENMPT_VERSION_MINOR}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  178. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_VERSION_PATCH!!/${LIBOPENMPT_VERSION_PATCH}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  179. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_VERSION_PREREL!!/${LIBOPENMPT_VERSION_PREREL}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  180. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_LTVER_CURRENT!!/${LIBOPENMPT_LTVER_CURRENT}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  181. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_LTVER_REVISION!!/${LIBOPENMPT_LTVER_CURRENT}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  182. cat configure.ac | sed "s/!!MPT_LIBOPENMPT_LTVER_AGE!!/${LIBOPENMPT_LTVER_AGE}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  183. echo " SemVer metadata "
  184. MPT_SEMVER_METADATA_PREFIX=
  185. if [ "${LIBOPENMPT_VERSION_PREREL}x" = "x" ] ; then
  186. MPT_SEMVER_METADATA_PREFIX=release
  187. else
  188. MPT_SEMVER_METADATA_PREFIX=r${BUILD_SVNVERSION}
  189. fi
  190. cat configure.ac | sed "s/!!MPT_SEMVER_METADATA_PREFIX!!/${MPT_SEMVER_METADATA_PREFIX}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  191. echo " SVNURL"
  192. cat configure.ac | sed "s/!!MPT_SVNURL!!/${BUILD_SVNURL}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  193. echo " SVNVERSION"
  194. cat configure.ac | sed "s/!!MPT_SVNVERSION!!/${BUILD_SVNVERSION}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  195. echo " SVNDATE"
  196. cat configure.ac | sed "s/!!MPT_SVNDATE!!/${BUILD_SVNDATE}/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  197. echo " PACKAGE"
  198. cat configure.ac | sed "s/!!MPT_PACKAGE!!/true/g" > configure.ac.tmp && mv configure.ac.tmp configure.ac
  199. echo "Generating 'Doxyfile.in' ..."
  200. ( cat libopenmpt/Doxyfile | grep -v '^PROJECT_NUMBER' | sed 's/INPUT += /INPUT += @top_srcdir@\//g' > Doxyfile.in ) && ( echo "PROJECT_NUMBER = @PACKAGE_VERSION@" >> Doxyfile.in ) && rm libopenmpt/Doxyfile
  201. echo "OUTPUT_DIRECTORY = doxygen-doc" >> Doxyfile.in
  202. echo "WARN_IF_DOC_ERROR = NO" >> Doxyfile.in
  203. echo "Running 'autoreconf -i' ..."
  204. autoreconf -i
  205. echo "Running './configure' ..."
  206. ./configure
  207. echo "Running 'make dist' ..."
  208. make dist
  209. echo "Running 'make distcheck' ..."
  210. #make distcheck
  211. (
  212. make distcheck 3>&1 1>&2 2>&3 | ( grep -v 'libtool: install: warning:' || true ) | ( grep -v 'libtool: warning: remember to run' || true ) | ( grep -v "libtool: warning: '.*la' has not been installed" || true )
  213. exit ${PIPESTATUS[0]}
  214. ) 3>&1 1>&2 2>&3
  215. echo "Running 'make' ..."
  216. make
  217. echo "Running 'make check' ..."
  218. make check
  219. echo "Building dist-autotools.tar ..."
  220. cd "$OLDDIR"
  221. MPT_LIBOPENMPT_VERSION=$(make NO_SDL=1 NO_SDL2=1 distversion-tarball)
  222. cd bin/dist-autotools
  223. rm -rf libopenmpt
  224. mkdir -p libopenmpt/src.autotools/$MPT_LIBOPENMPT_VERSION/
  225. cp *.tar.gz libopenmpt/src.autotools/$MPT_LIBOPENMPT_VERSION/
  226. tar -cv --numeric-owner --owner=0 --group=0 -f ../dist-autotools.tar libopenmpt
  227. cd ../..