ghc.SlackBuild 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/sh
  2. # Slackware build script for ghc
  3. # Copyright 2015 Mikko Värri, Finland
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. PRGNAM=ghc
  23. VERSION=${VERSION:-7.8.4}
  24. BUILD=${BUILD:-1}
  25. TAG=${TAG:-_SBo}
  26. if [ -z "$ARCH" ]; then
  27. case "$( uname -m )" in
  28. i?86) ARCH=i486 ;;
  29. arm*) ARCH=arm ;;
  30. *) ARCH=$( uname -m ) ;;
  31. esac
  32. fi
  33. CWD=$(pwd)
  34. TMP=${TMP:-/tmp/SBo}
  35. PKG=$TMP/package-$PRGNAM
  36. OUTPUT=${OUTPUT:-/tmp}
  37. if [ "$ARCH" = "i486" ]; then
  38. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  39. LIBDIRSUFFIX=""
  40. TARARCH=i386
  41. elif [ "$ARCH" = "i686" ]; then
  42. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  43. LIBDIRSUFFIX=""
  44. TARARCH=i386
  45. elif [ "$ARCH" = "x86_64" ]; then
  46. SLKCFLAGS="-O2 -fPIC"
  47. LIBDIRSUFFIX="64"
  48. TARARCH="x86_64"
  49. else
  50. printf "$ARCH is not supported...\n"
  51. exit 1
  52. fi
  53. set -e
  54. rm -rf $PKG
  55. mkdir -p $TMP $PKG $OUTPUT
  56. if [ "${BOOTSTRAP:-yes}" == "yes" ] ; then
  57. BOOTSTRAPDIR=$TMP/$PRGNAM-$VERSION-bootstrap
  58. rm -rf $BOOTSTRAPDIR
  59. cd $TMP
  60. rm -rf $PRGNAM-$VERSION
  61. tar xvf $CWD/$PRGNAM-$VERSION-$TARARCH-unknown-linux-deb7.tar.xz
  62. cd $PRGNAM-$VERSION
  63. chown -R root:root .
  64. find -L . \
  65. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  66. -o -perm 511 \) -exec chmod 755 {} \; -o \
  67. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  68. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  69. CFLAGS="$SLKCFLAGS" \
  70. CXXFLAGS="$SLKCFLAGS" \
  71. ./configure \
  72. --prefix=$BOOTSTRAPDIR/usr \
  73. --mandir=$BOOTSTRAPDIR/usr/man \
  74. --docdir=$BOOTSTRAPDIR/usr/doc/$PRGNAM-$VERSION \
  75. --libdir=$BOOTSTRAPDIR/usr/lib${LIBDIRSUFFIX}
  76. # GHC binary distributions are compiled in an environment where
  77. # libncurses is compiled as two separate libraries: libncurses and
  78. # libtinfo. Slackware has all the symbols of libtinfo in libncurses,
  79. # so we can soft link libtinfo to libncurses. But let's not do that
  80. # system wide. The link is needed both during build ('make install')
  81. # and during runtime (/usr/bin/ghc*).
  82. LIBTINFO_DIR=$BOOTSTRAPDIR/usr/lib$LIBDIRSUFFIX
  83. mkdir -p $LIBTINFO_DIR
  84. ln -s /lib$LIBDIRSUFFIX/libncurses.so.5 $LIBTINFO_DIR/libtinfo.so.5
  85. LD_LIBRARY_PATH=$LIBTINFO_DIR \
  86. make install
  87. sed -i -r -e "s|^exec |LD_LIBRARY_PATH=$LIBTINFO_DIR exec |" $BOOTSTRAPDIR/usr/bin/ghc{,-pkg}-$VERSION
  88. BOOTSTRAPGHC=$BOOTSTRAPDIR/usr/bin/ghc
  89. else
  90. BOOTSTRAPGHC=$( which ghc 2>/dev/null )
  91. fi
  92. cd $TMP
  93. rm -rf $PRGNAM-$VERSION
  94. tar xvf $CWD/$PRGNAM-$VERSION-src.tar.xz
  95. cd $PRGNAM-$VERSION
  96. chown -R root:root .
  97. find -L . \
  98. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  99. -o -perm 511 \) -exec chmod 755 {} \; -o \
  100. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  101. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  102. CFLAGS="$SLKCFLAGS" \
  103. CXXFLAGS="$SLKCFLAGS" \
  104. ./configure \
  105. --prefix=/usr \
  106. --mandir=/usr/man \
  107. --docdir=/usr/doc/$PRGNAM-$VERSION \
  108. --libdir=/usr/lib${LIBDIRSUFFIX} \
  109. --with-ghc=$BOOTSTRAPGHC
  110. make
  111. make install DESTDIR=$PKG
  112. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  113. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  114. find $PKG/usr/man -type f -exec gzip -9 {} \;
  115. cp -a LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
  116. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  117. mkdir -p $PKG/install
  118. cat $CWD/slack-desc > $PKG/install/slack-desc
  119. cd $PKG
  120. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}