dmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. # * SPDX-License-Identifier: GPL-3.0+
  26. # * License-Filename: LICENSE
  27. # */
  28. #
  29. # GNU / Linux is user-friendly. It's just particular who its friends are :)
  30. #
  31. # Only for GNU LINUX console:
  32. #
  33. # \033 ascii ESCape
  34. # \033[<NUM>G move to column <NUM> (linux console, xterm, not vt100)
  35. # \033[<NUM>C move <NUM> columns forward but only upto last column
  36. # \033[<NUM>D move <NUM> columns backward but only upto first column
  37. # \033[<NUM>A move <NUM> rows up
  38. # \033[<NUM>B move <NUM> rows down
  39. # \033[1m switch on bold
  40. # \033[31m switch on red
  41. # \033[32m switch on green
  42. # \033[33m switch on yellow
  43. # \033[m switch off color/bold
  44. # \017 exit alternate mode (xterm, vt100, linux console)
  45. # \033[10m exit alternate mode (linux console)
  46. # \015 carriage return (without newline)
  47. # Black 0;30 Dark Gray 1;30
  48. # Blue 0;34 Light Blue 1;34
  49. # Green 0;32 Light Green 1;32
  50. # Cyan 0;36 Light Cyan 1;36
  51. # Red 0;31 Light Red 1;31
  52. # Purple 0;35 Light Purple 1;35
  53. # Brown 0;33 Yellow 1;33
  54. # Light Gray 0;37 White 1;37
  55. #
  56. # normally 4 args to make should be oke. otherwise argv() to do.
  57. # add colors for enter/leave dir
  58. # if errors then run script to mailto or otherwise
  59. # if errors then run script to start emacs on the file
  60. # this cn run with GNU gawk and mawk on debian Linux
  61. rm -v -f dsmake.output
  62. rm -v -f dsmake.errors
  63. rm -v -f dsmake.warnings
  64. make $1 $2 $3 $4 2>&1 |
  65. awk '
  66. function toul() { print "\033[4m"; }
  67. function tobold() { print "\033[36m"; }
  68. function isentermakedir(thetext) { n = match(thetext, /[ ]Entering/); return n; }
  69. function isleavemakedir(thetext) { n = match(thetext, /[ ]Leaving/); return n; }
  70. function isgccerr(thetext) { n = match(thetext, /[ ]error:/); return n; }
  71. function isgccwarning(thetext) { n = match(thetext, /[ ]warning:/); return n; }
  72. BEGIN { tobold(); print "\033[34m"; print ":)" > "dsmake.output" }
  73. /^/ { 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; }
  74. END { print "end of make" > "dsmake.output"; print "\033[37m"; print "\033[10m"; }
  75. '
  76. # end.