mk_cfgrpt.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. # Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
  3. #
  4. # Permission to use, copy, modify, and/or distribute this software for any
  5. # purpose with or without fee is hereby granted, provided that the above
  6. # copyright notice and this permission notice appear in all copies.
  7. #
  8. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  9. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  10. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  13. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  14. # PERFORMANCE OF THIS SOFTWARE.
  15. #
  16. # This script embeds config.report into src/bin/cfgrpt/config_report.cc
  17. # Called by configure
  18. #
  19. report_file="$1"
  20. dest="$2"
  21. if [ -z ${report_file} ]
  22. then
  23. echo "ERROR mk_cfgrpt.sh - input report: $report_file does not exist"
  24. exit -1
  25. fi
  26. # Initializes
  27. cat /dev/null > $dest
  28. if [ $? -ne 0 ]
  29. then
  30. echo "ERROR mk_cfgrpt.sh - cannot create config output file: $dest"
  31. exit -1
  32. fi
  33. # Header
  34. cat >> $dest << END
  35. // config_report.cc. Generated from config.report by tools/mk_cfgrpt.sh
  36. namespace isc {
  37. namespace detail {
  38. extern const char* const config_report[] = {
  39. END
  40. # Body: escape '\'s and '"'s, preprend ' ";;;; ' and append '",'
  41. sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/ ";;;; /' -e 's/$/",/' \
  42. < $report_file >> $dest
  43. # Trailer
  44. cat >> $dest <<END
  45. ""
  46. };
  47. }
  48. }
  49. END