package.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #!/bin/sh
  2. #
  3. # Because nobody's perfect.. ;-)
  4. #
  5. ################################################################################
  6. function usage {
  7. echo "usage: $0 [-b win32 | macos | psp | linux-i686 | linux-amd64]"
  8. echo
  9. echo " -b Builds a binary distribution for the specified arch."
  10. echo " -h Displays this help text."
  11. exit 0
  12. }
  13. #
  14. # createpspzip
  15. #
  16. function createpspzip {
  17. #
  18. # Create the binary package.
  19. #
  20. $SEVENZIP a -tzip dist/$TARGET-psp.zip \
  21. $BINARY_DEPS $DOCS EBOOT.PBP $PADCONFIG
  22. }
  23. #
  24. # createzip /path/to/SDL.dll
  25. #
  26. function createzip {
  27. WINDIB_BAT="windib.bat"
  28. #
  29. # Copy SDL here temporarily.
  30. #
  31. cp -f $1 SDL.dll &&
  32. #
  33. # Generate a suitable windib.bat
  34. #
  35. echo "set SDL_VIDEODRIVER=windib" > $WINDIB_BAT &&
  36. echo "start $TARGET.exe" >> $WINDIB_BAT &&
  37. #
  38. # Create the binary package.
  39. #
  40. $SEVENZIP a -tzip dist/$TARGET.zip \
  41. $BINARY_DEPS $DOCS $TARGET.exe SDL.dll $WINDIB_BAT &&
  42. #
  43. # Remove SDL, and the bat file.
  44. #
  45. rm -f SDL.dll $WINDIB_BAT
  46. }
  47. #
  48. # createtbz tar-name-ext [extra-binary]
  49. #
  50. function createtbz {
  51. #
  52. # create temporary directory
  53. #
  54. mkdir -p dist/$TARGET/docs &&
  55. #
  56. # copy binaries into it
  57. #
  58. cp -f --dereference $BINARY_DEPS $TARGET $2 dist/$TARGET &&
  59. #
  60. # copy docs over
  61. #
  62. cp -f --dereference $DOCS dist/$TARGET/docs &&
  63. #
  64. # tar it up
  65. #
  66. tar -C dist -jcvf dist/$TARGET-$1.tar.bz2 $TARGET &&
  67. #
  68. # now delete temporary dir
  69. #
  70. rm -rf dist/$TARGET
  71. }
  72. #
  73. # in case of error; breakout CODE
  74. #
  75. function breakout {
  76. echo "Error $1 occured during packaging, aborted."
  77. exit $1
  78. }
  79. #
  80. # The basename for the source and binary packages.
  81. #
  82. TARGET=`grep TARGET Makefile.in | sed "s/ //g" | cut -d "=" -f 2`
  83. if [ "$TARGET" == "" ]; then
  84. breakout 1
  85. fi
  86. if [ "$1" == "-h" ]; then
  87. usage
  88. fi
  89. #
  90. # MegaZeux source AND binary distributions depend on these
  91. # files being here. Update this list carefully; things that
  92. # are in source but NOT the binary package should be in
  93. # build deps below.
  94. #
  95. BINARY_DEPS="smzx.pal mzx_ascii.chr mzx_blank.chr mzx_default.chr \
  96. mzx_help.fil mzx_smzx.chr mzx_edit.chr config.txt"
  97. #
  98. # Documents that the binary zip should contain (pathname will be stored too).
  99. #
  100. DOCS="docs/COPYING.DOC docs/changelog.txt docs/port.txt docs/macro.txt"
  101. #
  102. # Name of the PSP's Pad Configuration mapping file.
  103. #
  104. PADCONFIG="pad.config"
  105. #
  106. # MegaZeux's build system dependencies; these are packaged in
  107. # addition to binary deps above to complete the source package.
  108. #
  109. BUILD_DEPS="config.sh Makefile Makefile.in package.sh $PADCONFIG macosx.zip"
  110. #
  111. # These directories are purely for source distributions.
  112. #
  113. SUBDIRS="arch contrib debian docs"
  114. #
  115. # What we actually care about; the complete sources to MegaZeux. Try to
  116. # extract crap Exo's left in the wrong place. Feel free to update this.
  117. #
  118. SRC="src/*.c src/*.cpp src/*.h src/Makefile src/old src/utils"
  119. #
  120. # Name of the 7zip extractor. On Windows, this is '7za.exe'. On Linux, this is
  121. # _usually_ '7za', but if you're using a compatible replacement, change this
  122. # here. Only affects Windows binary distributions and PSP binary distributions,
  123. # otherwise GNU tar is used instead.
  124. #
  125. SEVENZIP="7za"
  126. #
  127. # Do source package.
  128. #
  129. ################################################################################
  130. echo "Generating source package for $TARGET.."
  131. #
  132. # dist cannot safely exist prior to starting.
  133. #
  134. if [ -d dist ]; then
  135. echo "Destroying dist/.."
  136. rm -rf dist
  137. fi
  138. mkdir -p dist/$TARGET/src &&
  139. cp -pv $BINARY_DEPS $BUILD_DEPS dist/$TARGET &&
  140. cp -pvr $SUBDIRS dist/$TARGET &&
  141. cp -pvr $SRC dist/$TARGET/src &&
  142. # hack for gdm2s3m & libmodplug & misc
  143. rm -f dist/$TARGET/contrib/gdm2s3m/src/{*.a,*.o} &&
  144. rm -f dist/$TARGET/contrib/libmodplug/src/{*.a,*.o} &&
  145. rm -f dist/$TARGET/src/utils/*.o dist/$TARGET/src/utils/txt2hlp{,.exe} &&
  146. rm -f dist/$TARGET/src/utils/txt2hlp.dbg{,.exe} &&
  147. # hack for "dist" makefile
  148. cp dist/$TARGET/arch/Makefile.dist dist/$TARGET/Makefile.platform
  149. if [ "$?" != "0" ]; then
  150. breakout 2
  151. fi
  152. rm -f dist/$TARGET/src/config.h
  153. echo "Creating source (${TARGET}src.tar.bz2).."
  154. cd dist
  155. tar --exclude CVS --exclude .cvsignore -jcvf ${TARGET}src.tar.bz2 $TARGET
  156. cd ..
  157. if [ "$?" != "0" ]; then
  158. breakout 3
  159. fi
  160. rm -rf dist/$TARGET
  161. echo Built source distribution successfully!
  162. #
  163. # no binary package is required
  164. #
  165. if [ "$1" != "-b" ]; then
  166. echo "Skipping binary package build."
  167. exit 0
  168. fi
  169. #
  170. # Do binary package.
  171. #
  172. ################################################################################
  173. echo "Generating binary package for $2.."
  174. #
  175. # PSP, using ZIP compression via 7ZIP compressor (add pad config)
  176. #
  177. if [ "$2" = "psp" ]; then
  178. createpspzip
  179. exit
  180. fi
  181. #
  182. # Windows, using ZIP compression via 7ZIP compressor
  183. #
  184. if [ "$2" = "win32" ]; then
  185. LIBSDL="`sdl-config --prefix`/bin/SDL.dll"
  186. createzip $LIBSDL
  187. exit
  188. fi
  189. #
  190. # MacOS X, using tar.bz2 compression.
  191. #
  192. if [ "$2" = "macos" ]; then
  193. LIBSDL="~/dev/lib/libSDL-1.2.0.dylib" # burst or beige's mac
  194. createtbz osx-ppc $LIBSDL
  195. exit
  196. fi
  197. #
  198. # Linux/i686, using tar.bz2 compression (NO SDL)
  199. #
  200. if [ "$2" = "linux-i686" ]; then
  201. createtbz linux-i686
  202. exit
  203. fi
  204. #
  205. # Linux/amd64, using tar.bz2 compression (NO SDL)
  206. #
  207. if [ "$2" = "linux-amd64" ]; then
  208. createtbz linux-amd64
  209. exit
  210. fi
  211. #
  212. # Unknown binary arch
  213. #
  214. echo "Unknown binary architecture.."
  215. echo
  216. usage