mk.sh 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/eedmenu
  12. echo bin/eeget
  13. echo bin/eeiam
  14. echo bin/eeini
  15. echo bin/eeip
  16. echo bin/eeln
  17. echo bin/eepush
  18. echo bin/eerevert
  19. echo bin/eewatch
  20. echo bin/eewww
  21. }
  22. list_of_installed_bins() {
  23. list_of_bins | sed -e "s/bin/$(sed -e 's/\//\\\//g' <<<$bindir)/"
  24. }
  25. die() {
  26. for l in "$@"; do echo "$l" >&2; done
  27. exit 9
  28. }
  29. build1() {
  30. local srcpath dstpath
  31. srcpath=$1
  32. dstpath=${srcpath%.in}
  33. perl -pe "
  34. s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
  35. s|__VERSION__|$VERSION|;
  36. " < $srcpath > $dstpath
  37. echo $dstpath >> built.list
  38. }
  39. build() {
  40. local srcpath
  41. find -type f -name '*.in' \
  42. | while read srcpath;
  43. do
  44. build1 "$srcpath"
  45. done
  46. }
  47. clean() {
  48. test -f built.list && {
  49. cat built.list | xargs rm -f
  50. rm -f built.list
  51. } || :
  52. }
  53. dist() {
  54. local dirname=eecc-${VERSION}
  55. mkdir -p $dirname
  56. cp -R bin \
  57. config.mk \
  58. Makefile \
  59. README \
  60. LICENSE \
  61. setup \
  62. test \
  63. utils \
  64. $dirname
  65. tar -cf $dirname.tar $dirname
  66. gzip $dirname.tar
  67. rm -rf $dirname
  68. echo $dirname.tar.gz >> built.list
  69. }
  70. install() {
  71. mkdir -vp $bindir
  72. list_of_bins | xargs cp -vrt $bindir
  73. list_of_installed_bins | xargs chmod -v 755
  74. test -f .autoclean && clean || :
  75. }
  76. run_test() {
  77. pushd test
  78. find -maxdepth 1 -type f \! -name '*.in' | while read test;
  79. do
  80. chmod 0755 $test
  81. $test || exit $?
  82. done
  83. popd
  84. }
  85. uninstall() {
  86. list_of_installed_bins | xargs rm -vf
  87. }
  88. case $1 in
  89. build|clean|dist|install|install_manpages|manpages|uninstall)
  90. $1
  91. ;;
  92. test)
  93. run_test
  94. ;;
  95. *)
  96. echo "usage: $(basename $0) build|clean|dist|install|test|uninstall" >&2
  97. esac