numpy.SlackBuild 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/bin/bash
  2. # Slackware build script for NumPy
  3. # Copyright 2011-2018 Serban Udrea <s.udrea@gsi.de>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification,
  7. # is 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
  13. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  16. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  18. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  19. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  20. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  21. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  22. # POSSIBILITY OF SUCH DAMAGE.
  23. # Written by Aleksandar Samardzic <asamardzic@gmail.com>
  24. # Updated up to 1.14.3 by Serban Udrea <S.Udrea@gsi.de>
  25. #
  26. # Added support for building with debugging symbols (S. Udrea)
  27. #
  28. # LIBDIRSUFFIX is now needed to set the proper path for
  29. # UMFPACK (S. Udrea)
  30. #
  31. # Since UMFPACK is not used anymore by scipy but by the optional package
  32. # scikit-umfpack, the configuration of this and the corresponding AMD library
  33. # is now optional. One has to set NO_UMFPACK to "no" to create the apropriate
  34. # configuration file before building numpy. (S. Udrea)
  35. #
  36. # Added the possibility to force numpy to link to different kinds of the
  37. # ATLAS library (S. Udrea)
  38. #
  39. # Thanks go to Pedro Ribeiro Mendes Júnior for help with the upgrade to 1.14.3.
  40. cd $(dirname $0) ; CWD=$(pwd)
  41. PRGNAM=numpy
  42. VERSION=${VERSION:-1.14.3}
  43. BUILD=${BUILD:-1}
  44. TAG=${TAG:-_SBo}
  45. PKGTYPE=${PKGTYPE:-tgz}
  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. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  67. # the name of the created package would be, and then exit. This information
  68. # could be useful to other scripts.
  69. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  70. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  71. exit 0
  72. fi
  73. TMP=${TMP:-/tmp/SBo}
  74. PKG=${PKG:-$TMP/package-$PRGNAM}
  75. OUTPUT=${OUTPUT:-/tmp}
  76. set -e
  77. rm -rf $PKG
  78. mkdir -p $TMP $PKG $OUTPUT
  79. cd $TMP
  80. rm -rf $PRGNAM-$VERSION
  81. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  82. cd $PRGNAM-$VERSION
  83. chown -R root:root .
  84. find -L . \
  85. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  86. -exec chmod 755 {} \; -o \
  87. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  88. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  89. # You may want to force numpy to link against a special kind of ATLAS
  90. #
  91. ATLAS_SHARED="${ATLAS_SHARED:-yes}"
  92. ATLAS_SHARED=$(echo "$ATLAS_SHARED"|cut -b 1|tr a-z A-Z)
  93. ATLAS_NO_THREADS="${ATLAS_NO_THREADS:-no}"
  94. ATLAS_NO_THREADS=$(echo "$ATLAS_NO_THREADS"|cut -b 1|tr a-z A-Z)
  95. if [ "$ATLAS_SHARED" = "Y" ]; then
  96. if [ "$ATLAS_NO_THREADS" = "Y" ]; then
  97. echo -e "[atlas]\natlas_libs = satlas" >> site.cfg
  98. echo -e "lapack_libs = satlas\nlapack_atlas = satlas\n" >> site.cfg
  99. fi
  100. else
  101. if [ "$ATLAS_NO_THREADS" = "Y" ]; then
  102. echo -e "[atlas]\natlas_libs = f77blas,cblas,atlas" >> site.cfg
  103. echo -e "lapack_libs = lapack\nlapack_atlas = lapack\n" >> site.cfg
  104. else
  105. echo -e "[atlas]\natlas_libs = ptf77blas,ptcblas,atlas" >> site.cfg
  106. echo -e "lapack_libs = ptlapack\nlapack_atlas = ptlapack\n" >> site.cfg
  107. fi
  108. fi
  109. NO_UMFPACK=${NO_UMFPACK:-yes}
  110. case "$NO_UMFPACK" in
  111. [yY]|[yY][eE][sS]) NO_UMFPACK="y" ;;
  112. *) NO_UMFPACK="" ;;
  113. esac
  114. if [ ! "$NO_UMFPACK" ]; then
  115. echo -e "[amd]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  116. echo -e "include_dirs = /usr/include/amd\namd_libs = amd\n" >> site.cfg
  117. echo -e "[umfpack]\nlibrary_dirs = /usr/lib${LIBDIRSUFFIX}" >> site.cfg
  118. echo -e "include_dirs = /usr/include/umfpack\numfpack_libs = umfpack\n" \
  119. >> site.cfg
  120. fi
  121. DEBUG=${DEBUG:-no}
  122. case "$DEBUG" in
  123. [yY]|[yY][eE][sS]) DEBUG="y" ;;
  124. *) DEBUG="" ;;
  125. esac
  126. if [ ! "$DEBUG" ]; then
  127. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python setup.py install --root $PKG
  128. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  129. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  130. else
  131. NPY_RELAXED_STRIDES_CHECKING=${NPY_RSC:-1} python setup.py build --debug
  132. python setup.py install --root $PKG
  133. fi
  134. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  135. cp -a LICENSE.txt THANKS.txt INSTALL.rst.txt PKG-INFO \
  136. $PKG/usr/doc/$PRGNAM-$VERSION
  137. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$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