avogadrolibs.SlackBuild 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/bash
  2. # Slackware build script for avogadrolibs
  3. # Copyright 2020-2022 Giancarlo Dessì, Cagliari, IT
  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. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=avogadrolibs
  24. VERSION=${VERSION:-1.95.1}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. MVERSION=${MVERSION:-1.0.0}
  29. CVERSION=${CVERSION:-1.0.1}
  30. if [ -z "$ARCH" ]; then
  31. case "$( uname -m )" in
  32. i?86) ARCH=i586 ;;
  33. arm*) ARCH=arm ;;
  34. *) ARCH=$( uname -m ) ;;
  35. esac
  36. fi
  37. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  38. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  39. exit 0
  40. fi
  41. #These are features which are disabled by default
  42. USEHDF5="" ; [ "${HDF5:-no}" = "yes" ] && USEHDF5="-DUSE_HDF5=ON"
  43. USEPYTHON="" ; [ "${PYTHON:-no}" = "yes" ] && USEPYTHON="-DUSE_PYTHON=ON"
  44. #These are features which are enabled by default
  45. USELIBMSYM="" ; [ "${LIBMSYM:-yes}" = "no" ] && USELIBMSYM="-DUSE_LIBMSYM=OFF"
  46. USESPGLIB="-DSPGLIB_INCLUDE_DIR=/usr/include/spglib" ; [ "${SPGLIB:-yes}" = "no" ] && \
  47. USESPGLIB="-DUSE_SPGLIB=OFF"
  48. USEMMTF="" ; [ "${MMTF:-yes}" = "no" ] && USEMMTF="-DUSE_MMTF=OFF"
  49. TMP=${TMP:-/tmp/SBo}
  50. PKG=$TMP/package-$PRGNAM
  51. OUTPUT=${OUTPUT:-/tmp}
  52. if [ "$ARCH" = "i586" ]; then
  53. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  54. LIBDIRSUFFIX=""
  55. elif [ "$ARCH" = "i686" ]; then
  56. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  57. LIBDIRSUFFIX=""
  58. elif [ "$ARCH" = "x86_64" ]; then
  59. SLKCFLAGS="-O2 -fPIC"
  60. LIBDIRSUFFIX="64"
  61. else
  62. SLKCFLAGS="-O2"
  63. LIBDIRSUFFIX=""
  64. fi
  65. set -e
  66. rm -rf $PKG
  67. mkdir -p $TMP $PKG $OUTPUT
  68. cd $TMP
  69. rm -rf $PRGNAM-$VERSION molecules crystals avogadrogenerators
  70. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  71. # Following archives must be unpacked in /tmp since the build process
  72. # searches them as parallel directories and tries to connect to github
  73. # if not found
  74. tar xvf $CWD/molecules-$MVERSION.tar.gz
  75. tar xvf $CWD/crystals-$CVERSION.tar.gz
  76. mv molecules-$MVERSION molecules
  77. mv crystals-$CVERSION crystals
  78. if [ "${PYTHON}" = "yes" ]; then
  79. tar xvf $CWD/avogadrogenerators.tar.gz
  80. fi
  81. # Now we can change directory to $PRGNAM-$VERSION
  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 \
  86. -o -perm 511 \) -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. # fix issues that generate cmake warnings
  90. patch -p1 < $CWD/fix_cmake-find-package.diff
  91. mkdir -p build
  92. cd build
  93. cmake \
  94. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  95. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  96. -DCMAKE_INSTALL_PREFIX=/usr \
  97. -DCMAKE_BUILD_TYPE=Release \
  98. -DCMAKE_POLICY_DEFAULT_CMP0072=NEW \
  99. -DENABLE_TESTING=OFF \
  100. -DENABLE_TRANSLATIONS=ON \
  101. $USEHDF5 \
  102. $USEPYTHON \
  103. $USELIBMSYM \
  104. $USESPGLIB \
  105. $USEMMTF \
  106. ..
  107. make
  108. make install DESTDIR=$PKG
  109. cd ..
  110. rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la
  111. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  112. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  113. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  114. cp -a *.md LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
  115. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  116. # Remove doc files installed by make install in /usr/share/doc/AvogadroLibs that are redundant
  117. rm -rf $PKG/usr/share/doc
  118. mkdir -p $PKG/install
  119. cat $CWD/slack-desc > $PKG/install/slack-desc
  120. cd $PKG
  121. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE