mk_cfgrpt.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
  3. #
  4. # This Source Code Form is subject to the terms of the Mozilla Public
  5. # License, v. 2.0. If a copy of the MPL was not distributed with this
  6. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. #
  8. # This script embeds config.report into src/bin/cfgrpt/config_report.cc
  9. # Called by configure
  10. #
  11. report_file="$1"
  12. dest="$2"
  13. if [ -z ${report_file} ]
  14. then
  15. echo "ERROR mk_cfgrpt.sh - input report: $report_file does not exist"
  16. exit -1
  17. fi
  18. # Initializes
  19. cat /dev/null > $dest
  20. if [ $? -ne 0 ]
  21. then
  22. echo "ERROR mk_cfgrpt.sh - cannot create config output file: $dest"
  23. exit -1
  24. fi
  25. # Header
  26. cat >> $dest << END
  27. // config_report.cc. Generated from config.report by tools/mk_cfgrpt.sh
  28. namespace isc {
  29. namespace detail {
  30. extern const char* const config_report[] = {
  31. END
  32. # Body: escape '\'s and '"'s, preprend ' ";;;; ' and append '",'
  33. sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/ ";;;; /' -e 's/$/",/' \
  34. < $report_file >> $dest
  35. # Trailer
  36. cat >> $dest <<END
  37. ""
  38. };
  39. }
  40. }
  41. END