makepack 3.9 KB

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