mk.sh 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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/eemk
  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_INIT__|$ffoo_init|;
  35. s|__FFOO_INI_PATH__|$FFOO_INI_PATH_GLOBAL:\\\$HOME/$FFOO_INI_PATH_USER|;
  36. s|__VERSION__|$VERSION|;
  37. " < $srcpath > $dstpath
  38. echo $dstpath >> built.list
  39. }
  40. build() {
  41. ffoom init_path >& /dev/null \
  42. || die "-----" \
  43. "fastfoo not installed or ffoom is not available for $(id -un)." \
  44. "In the latter case try running (only) \`make\` under normal" \
  45. "user and repeating the \`make install\` again." \
  46. "-----"
  47. local ffoo_init=$(ffoom init_path)
  48. local srcpath
  49. find -type f -name '*.in' \
  50. | while read srcpath;
  51. do
  52. build1 "$srcpath"
  53. done
  54. }
  55. clean() {
  56. test -f built.list && {
  57. cat built.list | xargs rm -f
  58. rm -f built.list
  59. } || :
  60. }
  61. dist() {
  62. local dirname=eecc-${VERSION}
  63. mkdir -p $dirname
  64. cp -R bin \
  65. config.mk \
  66. Makefile \
  67. README \
  68. LICENSE \
  69. setup \
  70. test \
  71. utils \
  72. $dirname
  73. tar -cf $dirname.tar $dirname
  74. gzip $dirname.tar
  75. rm -rf $dirname
  76. echo $dirname.tar.gz >> built.list
  77. }
  78. install() {
  79. mkdir -vp $bindir
  80. list_of_bins | xargs cp -vrt $bindir
  81. list_of_installed_bins | xargs chmod -v 755
  82. test -f .autoclean && clean || :
  83. }
  84. run_test() {
  85. pushd test
  86. find -maxdepth 1 -type f \! -name '*.in' | while read test;
  87. do
  88. chmod 0755 $test
  89. $test || exit $?
  90. done
  91. popd
  92. }
  93. uninstall() {
  94. list_of_installed_bins | xargs rm -vf
  95. }
  96. case $1 in
  97. build|clean|dist|install|install_manpages|manpages|uninstall)
  98. $1
  99. ;;
  100. test)
  101. run_test
  102. ;;
  103. *)
  104. echo "usage: $(basename $0) build|clean|dist|install|test|uninstall" >&2
  105. esac