makepack 3.6 KB

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