makepack 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. # Al
  8. unset FPCDIR
  9. # Goto the toplevel if necessary
  10. [ -d install ] || cd ..
  11. # Retrieve version from compiler/Makefile.fpc
  12. VERSION=`grep '^version' compiler/Makefile.fpc | sed 's+[^=]*= *\(.*\)+\1+'`
  13. # Retrieve current system info by calling FPC. We need
  14. # to use the | head -n1 to fix a bug in fpc 1.9.4 and earlier
  15. # that uses exitcode 1 also when printing info resulting in
  16. # fpc binary to print an error line (PFV)
  17. SOURCECPU=`fpc -iSP | head -n1`
  18. SOURCEOS=`fpc -iSO | head -n1`
  19. if [ $# -ne 0 ]; then
  20. if [ $# -ne 1 ]; then
  21. echo "Usage: makepack [<cpu>-<os>]"
  22. exit 1
  23. fi
  24. TARGETCPU=`echo $1 | sed 's+\([^-]*\)-.*+\1+'`
  25. TARGETOS=`echo $1 | sed 's+[^-]*-\(.*\)+\1+'`
  26. else
  27. TARGETCPU=$SOURCECPU
  28. TARGETOS=$SOURCEOS
  29. fi
  30. FULLTARGET=$TARGETCPU-$TARGETOS
  31. FULLSOURCE=$SOURCECPU-$SOURCEOS
  32. echo "FPC Source: $FULLSOURCE"
  33. echo "FPC Target: $FULLTARGET"
  34. if [ "$FULLTARGET" != "$FULLSOURCE" ]; then
  35. CROSS="cross"
  36. CROSSPREFIX=$FULLTARGET-
  37. else
  38. CROSS=
  39. CROSSPREFIX=
  40. fi
  41. # Build everything using the makefiles
  42. make distclean CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
  43. make ${CROSS}zipinstall CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
  44. if [ $? != 0 ]; then
  45. echo "Failed to make distribution archive."
  46. exit 1
  47. fi
  48. if [ "$CROSS" == "" ]; then
  49. make makepackdocs
  50. if [ $? != 0 ]; then
  51. echo "Failed to make documentation archive."
  52. exit 1
  53. fi
  54. make sourcezip
  55. if [ $? != 0 ]; then
  56. echo "Failed to make source archive."
  57. exit 1
  58. fi
  59. make docsrc
  60. if [ $? != 0 ]; then
  61. echo "Failed to make documentation source archive."
  62. exit 1
  63. fi
  64. make demozip
  65. if [ $? != 0 ]; then
  66. echo "Failed to make demo source archive."
  67. exit 1
  68. fi
  69. fi
  70. # binary.*.tar
  71. BINARYTAR=${CROSSPREFIX}binary.$FULLTARGET.tar
  72. echo "Creating $BINARYTAR"
  73. BINPACKAGES="base ide units utils"
  74. BINFILES=
  75. for p in $BINPACKAGES; do
  76. BINFILES="$BINFILES ${CROSSPREFIX}$p*.$FULLSOURCE.tar.gz"
  77. done
  78. tar cf $BINARYTAR $BINFILES
  79. if [ $? != 0 ]; then
  80. echo "Failed to create $BINARYTAR"
  81. exit 1
  82. fi
  83. # sources.tar
  84. echo "Creating sources.tar"
  85. tar cf sources.tar *.source.tar.gz
  86. if [ $? != 0 ]; then
  87. echo "Failed to create sources.tar"
  88. exit 1
  89. fi
  90. # install.sh
  91. echo "Copying install.sh"
  92. sed s+%version%+$VERSION+ install/install.sh > install.sh
  93. chmod 755 install.sh
  94. # Files to be added to the .tar
  95. RELFILES="$BINARYTAR sources.tar demo.tar.gz docs.tar.gz install.sh"
  96. TARNAME=${CROSSPREFIX}fpc-$VERSION.$FULLSOURCE.tar
  97. echo "Creating $TARNAME"
  98. tar cf $TARNAME $RELFILES
  99. if [ $? != 0 ]; then
  100. echo "Failed to create $TARNAME"
  101. exit 1
  102. fi