makepack 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. #
  3. # Shell script to make a FPC .tar package for Linux
  4. # Copyright 1996-2004 Michael Van Canneyt and Peter Vreman
  5. #
  6. set -e
  7. # Retrieve current system info by calling FPC. We need
  8. # to use the | head -n1 to fix a bug in fpc 1.9.4 and earlier
  9. # that uses exitcode 1 also when printing info resulting in
  10. # fpc binary to print an error line (PFV)
  11. SOURCECPU=`fpc -iSP | head -n1`
  12. SOURCEOS=`fpc -iSO | head -n1`
  13. if [ $# -ne 0 ]; then
  14. if [ $# -ne 2 ]; then
  15. echo "Usage: makepack [<cpu> <os>]"
  16. exit 1
  17. fi
  18. TARGETCPU=$1
  19. TARGETOS=$2
  20. else
  21. TARGETCPU=$SOURCECPU
  22. TARGETOS=$SOURCEOS
  23. fi
  24. FULLTARGET=$TARGETCPU-$TARGETOS
  25. if [ "$TARGETCPU" != "$SOURCECPU" ] || [ "$TARGETOS" != "$SOURCEOS" ]; then
  26. CROSS="cross"
  27. fi
  28. unset FPCDIR
  29. # Goto the toplevel if necessary
  30. [ -d install ] || cd ..
  31. # Build everything using the makefiles
  32. make distclean CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
  33. make ${CROSS}zipinstall CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS SNAPSHOT=1
  34. if [ $? != 0 ]; then
  35. echo "Failed to make distribution archive."
  36. exit 1
  37. fi
  38. # Retrieve version info before it gets cleaned below
  39. VERSION=`cd compiler && ./utils/fpc -iV`
  40. if [ "$CROSS" == "" ]; then
  41. make docs
  42. if [ $? != 0 ]; then
  43. echo "Failed to make documentation archive."
  44. exit 1
  45. fi
  46. make sourcezip
  47. if [ $? != 0 ]; then
  48. echo "Failed to make source archive."
  49. exit 1
  50. fi
  51. make docsrc
  52. if [ $? != 0 ]; then
  53. echo Failed to make documentation source archive.
  54. exit 1
  55. fi
  56. make demozip
  57. if [ $? != 0 ]; then
  58. echo Failed to make demo source archive.
  59. exit 1
  60. fi
  61. fi
  62. # Build filename
  63. if [ "$CROSS" == "" ]; then
  64. TARNAME=fpc-$VERSION.$FULLTARGET.tar
  65. else
  66. TARNAME=fpc-$FULLTARGET-$VERSION.$SOURCECPU-$SOURCEOS.tar
  67. fi
  68. BINARYTAR=binary-$FULLTARGET.tar
  69. SOURCES=`/bin/ls *src.tar.gz`
  70. FILES=`/bin/ls *linux.tar.gz`
  71. RELFILES="binary.$FULLTARGET.tar sources.tar demo.tar.gz docs.tar.gz install.sh"
  72. echo "Creating $BINARYTAR"
  73. tar cf $BINARYTAR $FILES
  74. if [ $? != 0 ]; then
  75. echo "Failed to create $BINARYTAR"
  76. exit 1
  77. fi
  78. echo "Creating sources.tar"
  79. tar cf sources.tar $SOURCES
  80. if [ $? != 0 ]; then
  81. echo "Failed to create sources.tar"
  82. exit 1
  83. fi
  84. echo "Copying install.sh"
  85. sed s+%version%+$VERSION+ install/install.sh > install.sh
  86. chmod 755 install.sh
  87. echo "Creating $TARNAME"
  88. tar cf $TARNAME $RELFILES
  89. if [ $? != 0 ]; then
  90. echo "Failed to create $TARNAME"
  91. exit 1
  92. fi