ghc.SlackBuild 5.2 KB

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