numpy-legacy.SlackBuild 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/bin/sh
  2. # Slackware build script for the latest version of NumPy to include
  3. # the compatibility layer with numeric and numarray
  4. # Copyright 2011-2016 Serban Udrea <s.udrea@gsi.de>
  5. # All rights reserved.
  6. #
  7. # Redistribution and use of this script, with or without modification,
  8. # is 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
  14. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  17. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  21. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  22. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. # POSSIBILITY OF SUCH DAMAGE.
  24. # Written by Aleksandar Samardzic <asamardzic@gmail.com>
  25. # Updated up to 1.11.1 by Serban Udrea <S.Udrea@gsi.de>
  26. #
  27. # Added support for building with debugging symbols (S. Udrea)
  28. #
  29. # LIBDIRSUFFIX is now needed to set the proper path for
  30. # UMFPACK (S. Udrea)
  31. #
  32. # Since UMFPACK is not used anymore by scipy but by the optional package
  33. # scikit-umfpack, the configuration of this and the corresponding AMD library
  34. # is now optional. One has to set NO_UMFPACK to "no" to create the apropriate
  35. # configuration file before building numpy. (S. Udrea)
  36. #
  37. # Added support for newer versions of ATLAS (3.10.x) (S. Udrea)
  38. #
  39. # Added the possibility to force numpy to link to different kinds of the
  40. # ATLAS library (S. Udrea)
  41. PRGNAM="numpy-legacy"
  42. VERSION=${VERSION:-1.8.2}
  43. BUILD=${BUILD:-1}
  44. TAG=${TAG:-_SBo}
  45. TARBALL_NAME=numpy # This is actually what we are going to install
  46. if [ -z "$ARCH" ]; then
  47. case "$( uname -m )" in
  48. i?86) ARCH=i586 ;;
  49. arm*) ARCH=arm ;;
  50. *) ARCH=$( uname -m ) ;;
  51. esac
  52. fi
  53. if [ "$ARCH" = "i586" ]; then
  54. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  55. LIBDIRSUFFIX=""
  56. elif [ "$ARCH" = "i686" ]; then
  57. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  58. LIBDIRSUFFIX=""
  59. elif [ "$ARCH" = "x86_64" ]; then
  60. SLKCFLAGS="-O2 -fPIC"
  61. LIBDIRSUFFIX="64"
  62. else
  63. SLKCFLAGS="-O2"
  64. LIBDIRSUFFIX=""
  65. fi
  66. CWD=$(pwd)
  67. TMP=${TMP:-/tmp/SBo}
  68. PKG=${PKG:-$TMP/package-$PRGNAM}
  69. OUTPUT=${OUTPUT:-/tmp}
  70. set -e
  71. rm -rf $PKG
  72. mkdir -p $TMP $PKG $OUTPUT
  73. cd $TMP
  74. rm -rf $TARBALL_NAME-$VERSION
  75. tar xvf $CWD/$TARBALL_NAME-$VERSION.tar.gz
  76. cd $TARBALL_NAME-$VERSION
  77. chown -R root:root .
  78. find -L . \
  79. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  80. -exec chmod 755 {} \; -o \
  81. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  82. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  83. # Tell numpy about the new names of the ATLAS shared libraries. This doesn't
  84. # force compilation against ATLAS, just makes sure that numpy does not link
  85. # against the static libraries, in case ATLAS is chosen.
  86. #
  87. ATLAS_SHARED="${ATLAS_SHARED:-yes}"
  88. ATLAS_SHARED=$(echo "$ATLAS_SHARED"|cut -b 1|tr a-z A-Z)
  89. ATLAS_THREADS="${ATLAS_THREADS:-yes}"
  90. ATLAS_THREADS=$(echo "$ATLAS_THREADS"|cut -b 1|tr a-z A-Z)
  91. if [ "$ATLAS_SHARED" = "Y" ]; then
  92. if [ "$ATLAS_THREADS" = "Y" ]; then
  93. echo -e "[atlas]\natlas_libs = tatlas" >> site.cfg
  94. echo -e "lapack_libs = tatlas\nlapack_atlas = tatlas\n" >> site.cfg
  95. else
  96. echo -e "[atlas]\natlas_libs = satlas" >> site.cfg
  97. echo -e "lapack_libs = satlas\nlapack_atlas = satlas\n" >> site.cfg
  98. fi
  99. else
  100. if [ "$ATLAS_THREADS" = "Y" ]; then
  101. echo -e "[atlas]\natlas_libs = ptf77blas,ptcblas,atlas" >> site.cfg
  102. echo -e "lapack_libs = ptlapack\nlapack_atlas = ptlapack\n" >> site.cfg
  103. else
  104. echo -e "[atlas]\natlas_libs = f77blas,cblas,atlas" >> site.cfg
  105. echo -e "lapack_libs = lapack\nlapack_atlas = lapack\n" >> site.cfg
  106. fi
  107. fi
  108. NO_UMFPACK=${NO_UMFPACK:-yes}
  109. case "$NO_UMFPACK" in
  110. [yY]|[yY][eE][sS]) NO_UMFPACK="y" ;;
  111. *) NO_UMFPACK="" ;;
  112. esac
  113. if [ ! "$NO_UMFPACK" ]; then
  114. echo -e "[amd]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  115. echo -e "include_dirs = /usr/include/amd\namd_libs = amd\n" >> site.cfg
  116. echo -e "[umfpack]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  117. echo -e "include_dirs = /usr/include/umfpack\numfpack_libs = umfpack\n" \
  118. >> site.cfg
  119. fi
  120. DEBUG=${DEBUG:-no}
  121. case "$DEBUG" in
  122. [yY]|[yY][eE][sS]) DEBUG="y" ;;
  123. *) DEBUG="" ;;
  124. esac
  125. if [ ! "$DEBUG" ]; then
  126. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python setup.py install --root $PKG
  127. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  128. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  129. else
  130. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python setup.py build --debug
  131. python setup.py install --root $PKG
  132. fi
  133. mkdir -p $PKG/usr/doc/$TARBALL_NAME-$VERSION
  134. cp -a COMPATIBILITY DEV_README.txt LICENSE.txt README.txt THANKS.txt\
  135. $PKG/usr/doc/$TARBALL_NAME-$VERSION
  136. cat $CWD/${PRGNAM}.SlackBuild > \
  137. $PKG/usr/doc/$TARBALL_NAME-$VERSION/${PRGNAM}.SlackBuild
  138. find $PKG/usr/doc -type f -exec chmod 0644 {} \;
  139. mkdir -p $PKG/install
  140. cat $CWD/slack-desc > $PKG/install/slack-desc
  141. cd $PKG
  142. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}