mk.sh 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/eeln
  16. echo bin/eepush
  17. echo bin/eerevert
  18. echo bin/eewatch
  19. echo bin/eewww
  20. }
  21. list_of_installed_bins() {
  22. list_of_bins | sed -e "s/bin/$(sed -e 's/\//\\\//g' <<<$bindir)/"
  23. }
  24. die() {
  25. for l in "$@"; do echo "$l" >&2; done
  26. exit 9
  27. }
  28. build1() {
  29. local srcpath dstpath
  30. srcpath=$1
  31. dstpath=${srcpath%.in}
  32. perl -pe "
  33. s|__FFOO_INIT__|$ffoo_init|;
  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. ffoom init_path >& /dev/null \
  41. || die "-----" \
  42. "fastfoo not installed or ffoom is not available for $(id -un)." \
  43. "In the latter case try running (only) \`make\` under normal" \
  44. "user and repeating the \`make install\` again." \
  45. "-----"
  46. local ffoo_init=$(ffoom init_path)
  47. local srcpath
  48. find -type f -name '*.in' \
  49. | while read srcpath;
  50. do
  51. build1 "$srcpath"
  52. done
  53. }
  54. clean() {
  55. test -f built.list && {
  56. cat built.list | xargs rm -f
  57. rm -f built.list
  58. } || :
  59. }
  60. dist() {
  61. local dirname=eecc-${VERSION}
  62. mkdir -p $dirname
  63. cp -R bin \
  64. config.mk \
  65. Makefile \
  66. README \
  67. LICENSE \
  68. setup \
  69. test \
  70. utils \
  71. $dirname
  72. tar -cf $dirname.tar $dirname
  73. gzip $dirname.tar
  74. rm -rf $dirname
  75. echo $dirname.tar.gz >> built.list
  76. }
  77. install() {
  78. mkdir -vp $bindir
  79. list_of_bins | xargs cp -vrt $bindir
  80. list_of_installed_bins | xargs chmod -v 755
  81. test -f .autoclean && clean || :
  82. }
  83. run_test() {
  84. pushd test
  85. find -maxdepth 1 -type f \! -name '*.in' | while read test;
  86. do
  87. chmod 0755 $test
  88. $test || exit $?
  89. done
  90. popd
  91. }
  92. uninstall() {
  93. list_of_installed_bins | xargs rm -vf
  94. }
  95. case $1 in
  96. build|clean|dist|install|install_manpages|manpages|uninstall)
  97. $1
  98. ;;
  99. test)
  100. run_test
  101. ;;
  102. *)
  103. echo "usage: $(basename $0) build|clean|dist|install|test|uninstall" >&2
  104. esac