makepack 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/usr/bin/env bash
  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. # Set this to "yes" if you want to force making the documentation.
  8. # if it is not equal to yes, the documentation is assumed present in a file docs.tar.gz
  9. MAKEDOCS=no
  10. # Al
  11. unset FPCDIR
  12. # Goto the toplevel if necessary
  13. [ -d install ] || cd ..
  14. # Retrieve version from compiler/Makefile.fpc
  15. VERSION=`grep '^version' compiler/Makefile.fpc | sed 's+[^=]*= *\(.*\)+\1+'`
  16. # Retrieve current system info by calling FPC. We need
  17. # to use the | head -n1 to fix a bug in fpc 1.9.4 and earlier
  18. # that uses exitcode 1 also when printing info resulting in
  19. # fpc binary to print an error line (PFV)
  20. SOURCECPU=`fpc -iSP | head -n1`
  21. SOURCEOS=`fpc -iSO | head -n1`
  22. # retrieve real OS.
  23. HOSTARCH=`uname -p | tr "[:upper:]" "[:lower:]"`
  24. HOSTOS=`uname -s | tr "[:upper:]" "[:lower:]"`
  25. MAKE=make
  26. case "$HOSTOS" in
  27. *BSD*) MAKE=gmake
  28. ;;
  29. *bsd*) MAKE=gmake
  30. ;;
  31. esac
  32. if [ $# -ne 0 ]; then
  33. if [ $# -ne 1 ]; then
  34. echo "Usage: makepack [<cpu>-<os>]"
  35. exit 1
  36. fi
  37. TARGETCPU=`echo $1 | sed 's+\([^-]*\)-.*+\1+'`
  38. TARGETOS=`echo $1 | sed 's+[^-]*-\(.*\)+\1+'`
  39. else
  40. TARGETCPU=$SOURCECPU
  41. TARGETOS=$SOURCEOS
  42. fi
  43. FULLTARGET=$TARGETCPU-$TARGETOS
  44. FULLSOURCE=$SOURCECPU-$SOURCEOS
  45. echo "FPC Source: $FULLSOURCE"
  46. echo "FPC Target: $FULLTARGET"
  47. if [ "$FULLTARGET" != "$FULLSOURCE" ]; then
  48. CROSS="cross"
  49. CROSSPREFIX=$FULLTARGET-
  50. else
  51. CROSS=
  52. CROSSPREFIX=
  53. fi
  54. # Build everything using the makefiles
  55. ${MAKE} distclean CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
  56. ${MAKE} ${CROSS}zipinstall CPU_TARGET=$TARGETCPU OS_TARGET=$TARGETOS
  57. if [ $? != 0 ]; then
  58. echo "Failed to make distribution archive."
  59. exit 1
  60. fi
  61. if [ "$CROSS" = "" ]; then
  62. if [ ! -f docs.tar.gz ]; then
  63. if [ "$MAKEDOCS" != "yes" ]; then
  64. echo "No documentation available. Please copy the file docs.tar.gz to this directory."
  65. exit 1
  66. else
  67. ${MAKE} makepackdocs
  68. if [ $? != 0 ]; then
  69. echo "Failed to make documentation archive."
  70. exit 1
  71. fi
  72. fi
  73. fi
  74. ${MAKE} sourcezip
  75. if [ $? != 0 ]; then
  76. echo "Failed to make source archive."
  77. exit 1
  78. fi
  79. ${MAKE} docsrc
  80. if [ $? != 0 ]; then
  81. echo "Failed to make documentation source archive."
  82. exit 1
  83. fi
  84. ${MAKE} demozip
  85. if [ $? != 0 ]; then
  86. echo "Failed to make demo source archive."
  87. exit 1
  88. fi
  89. fi
  90. # binary.*.tar
  91. BINARYTAR=${CROSSPREFIX}binary.$FULLTARGET.tar
  92. echo "Creating $BINARYTAR"
  93. BINPACKAGES="base ide units utils"
  94. BINFILES=
  95. for p in $BINPACKAGES; do
  96. BINFILES="$BINFILES ${CROSSPREFIX}$p*.$FULLSOURCE.tar.gz"
  97. done
  98. tar cf $BINARYTAR $BINFILES
  99. if [ $? != 0 ]; then
  100. echo "Failed to create $BINARYTAR"
  101. exit 1
  102. fi
  103. # sources.tar
  104. echo "Creating sources.tar"
  105. tar cf sources.tar *.source.tar.gz
  106. if [ $? != 0 ]; then
  107. echo "Failed to create sources.tar"
  108. exit 1
  109. fi
  110. # install.sh
  111. echo "Copying install.sh"
  112. sed s+%version%+$VERSION+ install/install.sh > install.sh
  113. chmod 755 install.sh
  114. # Files to be added to the .tar
  115. RELFILES="$BINARYTAR sources.tar demo.tar.gz docs.tar.gz install.sh"
  116. TARNAME=${CROSSPREFIX}fpc-$VERSION.$FULLSOURCE.tar
  117. echo "Creating $TARNAME"
  118. tar cf $TARNAME $RELFILES
  119. if [ $? != 0 ]; then
  120. echo "Failed to create $TARNAME"
  121. exit 1
  122. fi