GMT.SlackBuild 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/bash
  2. # Slackware build script for GMT (Generic Mapping Tools)
  3. # Copyright (c) 2016 Cristiano Urban, Gonars, Italy
  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=GMT
  24. SRCNAM=gmt
  25. VERSION=${VERSION:-6.3.0}
  26. BUILD=${BUILD:-1}
  27. TAG=${TAG:-_SBo}
  28. PKGTYPE=${PKGTYPE:-tgz}
  29. GSHHG=gshhg
  30. GSHHG_VERSION=${GSHHG_VERSION:-2.3.7}
  31. DCW=dcw
  32. DCW_VERSION=${DCW_VERSION:-2.1.0}
  33. if [ -z "$ARCH" ]; then
  34. case "$( uname -m )" in
  35. i?86) ARCH=i586 ;;
  36. arm*) ARCH=arm ;;
  37. *) ARCH=$( uname -m ) ;;
  38. esac
  39. fi
  40. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  41. # the name of the created package would be, and then exit. This information
  42. # could be useful to other scripts.
  43. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  44. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  45. exit 0
  46. fi
  47. TMP=${TMP:-/tmp/SBo}
  48. PKG=$TMP/package-$PRGNAM
  49. OUTPUT=${OUTPUT:-/tmp}
  50. if [ "$ARCH" = "i586" ]; then
  51. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  52. LIBDIRSUFFIX=""
  53. elif [ "$ARCH" = "i686" ]; then
  54. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  55. LIBDIRSUFFIX=""
  56. elif [ "$ARCH" = "x86_64" ]; then
  57. SLKCFLAGS="-O2 -fPIC"
  58. LIBDIRSUFFIX="64"
  59. else
  60. SLKCFLAGS="-O2"
  61. LIBDIRSUFFIX=""
  62. fi
  63. set -e
  64. rm -rf $PKG
  65. mkdir -p $TMP $PKG $OUTPUT
  66. cd $TMP
  67. rm -rf $SRCNAM-$VERSION $GSHHG-$SRCNAM-$GSHHG_VERSION $DCW-$SRCNAM-$DCW_VERSION
  68. tar xvf $CWD/$SRCNAM-$VERSION*.tar.gz
  69. tar xvf $CWD/$GSHHG-$SRCNAM-$GSHHG_VERSION.tar.gz
  70. tar xvf $CWD/$DCW-$SRCNAM-$DCW_VERSION.tar.gz
  71. mkdir -p $PKG/usr/share/$SRCNAM/gshhg
  72. mkdir -p $PKG/usr/share/$SRCNAM/dcw
  73. cp -r $GSHHG-$SRCNAM-$GSHHG_VERSION/* $PKG/usr/share/$SRCNAM/gshhg
  74. cp -r $DCW-$SRCNAM-$DCW_VERSION/* $PKG/usr/share/$SRCNAM/dcw
  75. cd $SRCNAM-$VERSION
  76. chown -R root:root .
  77. find -L . \
  78. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  79. -o -perm 511 \) -exec chmod 755 {} \; -o \
  80. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  81. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  82. if [ "${SHEWCHUK:-no}" = "yes" ]; then
  83. LICFLAG="no"
  84. else
  85. LICFLAG="GPL"
  86. fi
  87. mkdir -p build
  88. cd build
  89. cmake \
  90. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  91. -DCMAKE_INSTALL_PREFIX=/usr \
  92. -DLIB_SUFFIX=${LIBDIRSUFFIX} \
  93. -DGMT_DATADIR=share/$SRCNAM \
  94. -DGMT_DOCDIR=doc/$PRGNAM-$VERSION \
  95. -DGMT_MANDIR=man \
  96. -DGSHHG_ROOT=$PKG/usr/share/$SRCNAM/gshhg \
  97. -DDCW_ROOT=$PKG/usr/share/$SRCNAM/dcw \
  98. -DCOPY_GSHHG=true \
  99. -DCOPY_DCW=true \
  100. -DGMT_INSTALL_MODULE_LINKS=true \
  101. -DLICENSE_RESTRICTED=$LICFLAG \
  102. -DCMAKE_BUILD_TYPE=Release ..
  103. make all
  104. make docs_man
  105. make docs_html
  106. make install DESTDIR=$PKG
  107. cd ..
  108. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  109. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  110. find $PKG/usr/man -type f -exec gzip -9 {} \;
  111. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  112. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  113. cp -a BUILDING.md INSTALL.md LICENSE.TXT README.md $PKG/usr/doc/$PRGNAM-$VERSION
  114. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  115. mkdir -p $PKG/install
  116. cat $CWD/slack-desc > $PKG/install/slack-desc
  117. cd $PKG
  118. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE