c_count.SlackBuild 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # Slackware build script for c_count
  3. # Written by B. Watson (urchlay@slackware.uk)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. # sloccount conflict is because both packages install /usr/bin/c_count.
  6. # Upstream for c_count is aware of this but refuses to change (because
  7. # his package is older). No idea if sloccount upstream knows or cares
  8. # (it's been decades, so the problem isn't going to get solved). So
  9. # install as C_count by default. Annnoyingly enough, there's no man
  10. # page for sloccount's c_count, and our man command is case-insensitive
  11. # by default, so "man c_count" will show the man page for C_count since
  12. # there isn't one for sloccount c_count. Confusing. Hopefully whoever
  13. # this happens to, figures it out pretty quick.
  14. cd $(dirname $0) ; CWD=$(pwd)
  15. PRGNAM=c_count
  16. VERSION=${VERSION:-7.22}
  17. BUILD=${BUILD:-1}
  18. TAG=${TAG:-_SBo}
  19. PKGTYPE=${PKGTYPE:-tgz}
  20. if [ -z "$ARCH" ]; then
  21. case "$( uname -m )" in
  22. i?86) ARCH=i586 ;;
  23. arm*) ARCH=arm ;;
  24. *) ARCH=$( uname -m ) ;;
  25. esac
  26. fi
  27. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  28. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  29. exit 0
  30. fi
  31. TMP=${TMP:-/tmp/SBo}
  32. PKG=$TMP/package-$PRGNAM
  33. OUTPUT=${OUTPUT:-/tmp}
  34. if [ "$ARCH" = "i586" ]; then
  35. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  36. LIBDIRSUFFIX=""
  37. elif [ "$ARCH" = "i686" ]; then
  38. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  39. LIBDIRSUFFIX=""
  40. elif [ "$ARCH" = "x86_64" ]; then
  41. SLKCFLAGS="-O2 -fPIC"
  42. LIBDIRSUFFIX="64"
  43. else
  44. SLKCFLAGS="-O2"
  45. LIBDIRSUFFIX=""
  46. fi
  47. set -e
  48. rm -rf $PKG
  49. mkdir -p $TMP $PKG $OUTPUT
  50. cd $TMP
  51. rm -rf $PRGNAM-$VERSION
  52. tar xvf $CWD/$PRGNAM-$VERSION.tgz
  53. cd $PRGNAM-$VERSION
  54. chown -R root:root .
  55. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  56. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  57. # Avoid sloccount conflict. --program-transform-name fixes the
  58. # filenames but not the file contents, hence the sed stuff.
  59. if [ "${LOWERCASE:-no}" = "no" ]; then
  60. PTN="--program-transform-name='s/^c/C/'"
  61. sed -i '/"[^"]*c_count/s,c_count,C_count,g' $PRGNAM.c
  62. sed -i 's,c_count,C_count,g' $PRGNAM.1
  63. BIN="C_count"
  64. else
  65. BIN="c_count"
  66. fi
  67. CFLAGS="$SLKCFLAGS" \
  68. CXXFLAGS="$SLKCFLAGS" \
  69. ./configure \
  70. $PTN \
  71. --prefix=/usr \
  72. --libdir=/usr/lib${LIBDIRSUFFIX} \
  73. --sysconfdir=/etc \
  74. --localstatedir=/var \
  75. --mandir=/usr/man \
  76. --disable-static \
  77. --build=$ARCH-slackware-linux
  78. make
  79. strip $PRGNAM
  80. make install DESTDIR=$PKG
  81. gzip $PKG/usr/man/man*/*
  82. PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
  83. mkdir -p $PKGDOC
  84. cp -a CHANGES COPYING README $PKGDOC
  85. cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
  86. mkdir -p $PKG/install
  87. sed "s,@BIN@,$BIN,g" < $CWD/slack-desc > $PKG/install/slack-desc
  88. cd $PKG
  89. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE