mk.sh 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # eecc - Eclectic Engineer's Control Center
  3. # See LICENSE file for copyright and license details.
  4. tmp=$(mktemp)
  5. sed -e 's/ = /=/' < config.mk > $tmp
  6. . $tmp
  7. rm -f $tmp
  8. bindir=${DESTDIR}${PREFIX}/bin
  9. list_of_bins() {
  10. echo bin/eeabrt
  11. echo bin/eeget
  12. echo bin/eeiam
  13. echo bin/eeln
  14. echo bin/eemk
  15. echo bin/eepush
  16. echo bin/eerevert
  17. echo bin/eewatch
  18. echo bin/eewww
  19. }
  20. list_of_installed_bins() {
  21. list_of_bins | sed -e "s/bin/$(sed -e 's/\//\\\//g' <<<$bindir)/"
  22. }
  23. die() {
  24. for l in "$@"; do echo "$l" >&2; done
  25. exit 9
  26. }
  27. clean() {
  28. test -f built.list && {
  29. cat built.list | xargs rm -f
  30. rm -f built.list
  31. } || :
  32. }
  33. dist() {
  34. local dirname=eecc-${VERSION}
  35. mkdir -p $dirname
  36. cp -R bin \
  37. config.mk \
  38. Makefile \
  39. README \
  40. LICENSE \
  41. setup \
  42. test \
  43. utils \
  44. $dirname
  45. tar -cf $dirname.tar $dirname
  46. gzip $dirname.tar
  47. rm -rf $dirname
  48. echo $dirname.tar.gz >> built.list
  49. }
  50. install() {
  51. mkdir -p $bindir
  52. list_of_bins | xargs cp -vrt $bindir
  53. list_of_installed_bins | xargs chmod 755
  54. test -f .autoclean && clean || :
  55. }
  56. eecc() {
  57. ffoom init_path >& /dev/null \
  58. || die "-----" \
  59. "fastfood not installed or ffoom is not available for $(id -un)." \
  60. "In the latter case try running (only) \`make\` under normal" \
  61. "user and repeating the \`make install\` again." \
  62. "-----"
  63. local ffoo_init=$(ffoom init_path)
  64. local srcpath dstpath
  65. find -type f -name '*.in' \
  66. | while read srcpath;
  67. do
  68. dstpath=${srcpath%.in}
  69. perl -pe "s|__FFOO_INIT__|$ffoo_init|;
  70. s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
  71. s|__VERSION__|$VERSION|;" < $srcpath > $dstpath
  72. echo $dstpath >> built.list
  73. done
  74. }
  75. run_test() {
  76. pushd test
  77. find -maxdepth 1 -type f \! -name '*.in' | while read test;
  78. do
  79. chmod 0755 $test
  80. $test || exit $?
  81. done
  82. popd
  83. }
  84. uninstall() {
  85. list_of_installed_bins | xargs rm -f
  86. }
  87. case $1 in
  88. clean|dist|install|install_manpages|manpages|eecc|uninstall)
  89. $1
  90. ;;
  91. test)
  92. run_test
  93. ;;
  94. *)
  95. echo "usage: $(basename $0) clean|dist|install|eecc|test|uninstall" >&2
  96. esac