dmake 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh -x
  2. # helper script to run make using GNU AWK with colorizing in development.
  3. #
  4. # /*
  5. # *
  6. # * This program is free software: you can redistribute it and/or modify
  7. # * it under the terms of the GNU General Public License as published by
  8. # * the Free Software Foundation, either version 3 of the License, or
  9. # * (at your option) any later version.
  10. # *
  11. # * This program is distributed in the hope that it will be useful,
  12. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # * GNU General Public License for more details.
  15. # *
  16. # * You should have received a copy of the GNU General Public License
  17. # * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # *
  19. # * The four essential freedoms with GNU GPL software:
  20. # * The freedom to run the program, for any purpose
  21. # * The freedom to study how the program works, and change it to make it do what you wish
  22. # * The freedom to redistribute copies so you can help others
  23. # * The freedom to distribute copies of your modified versions to others
  24. # */
  25. #
  26. # GNU / Linux is user-friendly. It's just particular who its friends are :)
  27. #
  28. # Only for GNU LINUX console:
  29. #
  30. # \033 ascii ESCape
  31. # \033[<NUM>G move to column <NUM> (linux console, xterm, not vt100)
  32. # \033[<NUM>C move <NUM> columns forward but only upto last column
  33. # \033[<NUM>D move <NUM> columns backward but only upto first column
  34. # \033[<NUM>A move <NUM> rows up
  35. # \033[<NUM>B move <NUM> rows down
  36. # \033[1m switch on bold
  37. # \033[31m switch on red
  38. # \033[32m switch on green
  39. # \033[33m switch on yellow
  40. # \033[m switch off color/bold
  41. # \017 exit alternate mode (xterm, vt100, linux console)
  42. # \033[10m exit alternate mode (linux console)
  43. # \015 carriage return (without newline)
  44. # Black 0;30 Dark Gray 1;30
  45. # Blue 0;34 Light Blue 1;34
  46. # Green 0;32 Light Green 1;32
  47. # Cyan 0;36 Light Cyan 1;36
  48. # Red 0;31 Light Red 1;31
  49. # Purple 0;35 Light Purple 1;35
  50. # Brown 0;33 Yellow 1;33
  51. # Light Gray 0;37 White 1;37
  52. #
  53. # normally 4 args to make should be oke. otherwise argv() to do.
  54. # add colors for enter/leave dir
  55. # if errors then run script to mailto or otherwise
  56. # if errors then run script to start emacs on the file
  57. rm -v -f dsmake.output
  58. rm -v -f dsmake.errors
  59. rm -v -f dsmake.warnings
  60. make $1 $2 $3 $4 2>&1 |
  61. gawk '
  62. function toul() { print "\033[4m"; }
  63. function tobold() { print "\033[36m"; }
  64. function isentermakedir(thetext) { n = match(thetext, /[ ]Entering/); return n; }
  65. function isleavemakedir(thetext) { n = match(thetext, /[ ]Leaving/); return n; }
  66. function isgccerr(thetext) { n = match(thetext, /[ ]error:/); return n; }
  67. function isgccwarning(thetext) { n = match(thetext, /[ ]warning:/); return n; }
  68. BEGIN { tobold(); print "\033[34m"; > "dsmake.output" }
  69. /^/ { print $0 > "dsmake.output"; print "\033[34m"; if(isgccerr($0)) { print "\033[31m"; print $0 > "dsmake.errors"; } ; if(isgccwarning($0)) { print "\033[35m"; print $0 > "dsmake.warnings" } ; print $0; next; }
  70. END { print "end of make" > "dsmake.output"; print "\033[37m"; print "\033[10m"; }
  71. '
  72. # end.