slatec.SlackBuild 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. # Slackware build script for slatec
  3. # Written by Pablo Santamaria (pablosantamaria@gmail.com)
  4. PRGNAM=slatec
  5. VERSION=${VERSION:-4.1}
  6. BUILD=${BUILD:-1}
  7. TAG=${TAG:-_SBo}
  8. SRCVERSION=${VERSION}-4
  9. if [ -z "$ARCH" ]; then
  10. case "$( uname -m )" in
  11. i?86) ARCH=i486 ;;
  12. arm*) ARCH=arm ;;
  13. *) ARCH=$( uname -m ) ;;
  14. esac
  15. fi
  16. CWD=$(pwd)
  17. TMP=${TMP:-/tmp/SBo}
  18. PKG=$TMP/package-$PRGNAM
  19. OUTPUT=${OUTPUT:-/tmp}
  20. if [ "$ARCH" = "i486" ]; then
  21. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  22. LIBDIRSUFFIX=""
  23. elif [ "$ARCH" = "i686" ]; then
  24. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  25. LIBDIRSUFFIX=""
  26. elif [ "$ARCH" = "x86_64" ]; then
  27. SLKCFLAGS="-O2 -fPIC"
  28. LIBDIRSUFFIX="64"
  29. else
  30. SLKCFLAGS="-O2"
  31. LIBDIRSUFFIX=""
  32. fi
  33. set -e
  34. rm -rf $PKG
  35. mkdir -p $TMP $PKG $OUTPUT
  36. cd $TMP
  37. rm -rf ${PRGNAM}_$SRCVERSION
  38. tar xvf $CWD/${PRGNAM}_${SRCVERSION}.tar.gz
  39. cd $PRGNAM-$VERSION
  40. chown -R root:root .
  41. find -L . \
  42. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  43. -exec chmod 755 {} \; -o \
  44. \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  45. -exec chmod 644 {} \;
  46. # Compile static and dynamic library.
  47. v1=$(echo $VERSION | cut -d. -f1)
  48. v2=$VERSION
  49. make MA_N=${v1} MI_N=${v2} OPT="$SLKCFLAGS -std=legacy" F77="gfortran" CC="gcc"
  50. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
  51. cp -a libslatec.a $PKG/usr/lib${LIBDIRSUFFIX}
  52. cp -a libslatec.so.$v2 $PKG/usr/lib${LIBDIRSUFFIX}
  53. ( cd $PKG/usr/lib${LIBDIRSUFFIX}
  54. ln -s libslatec.so.$v2 libslatec.so.$v1
  55. ln -s libslatec.so.$v2 libslatec.so
  56. )
  57. # Create manpages.
  58. mkdir -p $PKG/usr/man/man3
  59. for f in $(find -name "*.f") ; do
  60. sed -f $CWD/makedoc.sed $f > $PKG/usr/man/man3/$(basename $f .f).3
  61. done
  62. # Let's not overwrite manpages that are already on the system
  63. for i in \
  64. acosh asinh atanh cacos cacosh carg casin casinh catan catanh cbrt ccosh \
  65. clog10 csinh ctan ctanh des erf erfc gamma rand ; do
  66. mv $PKG/usr/man/man3/$i.3 $PKG/usr/man/man3/$i-slatec.3 ;
  67. done
  68. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  69. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  70. ( cd $PKG/usr/man
  71. find . -type f -exec gzip -9 {} \;
  72. for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  73. )
  74. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  75. cp -a readme $PKG/usr/doc/$PRGNAM-$VERSION
  76. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  77. mkdir -p $PKG/install
  78. cat $CWD/slack-desc > $PKG/install/slack-desc
  79. cd $PKG
  80. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}