mk_cfgrpt.sh 1.05 KB
Newer Older
1
#!/bin/sh
2
# Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
3
#
4 5 6
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 8 9 10 11
#
# This script embeds config.report into src/bin/cfgrpt/config_report.cc
# Called by configure
#

12 13
report_file="$1"
dest="$2"
14 15 16 17 18 19

if [ -z ${report_file} ]
then
    echo "ERROR mk_cfgrpt.sh - input report: $report_file does not exist"
    exit -1
fi
20 21

# Initializes
22 23 24 25 26 27
cat /dev/null > $dest
if [ $? -ne 0 ]
then
    echo "ERROR mk_cfgrpt.sh - cannot create config output file: $dest"
    exit -1
fi
28 29 30

# Header
cat >> $dest << END
31
// config_report.cc. Generated from config.report by tools/mk_cfgrpt.sh
32 33 34 35 36 37 38 39 40

namespace isc {
namespace detail {

extern const char* const config_report[] = {
END

# Body: escape '\'s and '"'s, preprend '    ";;;; ' and append '",'
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/    ";;;; /' -e 's/$/",/' \
41
    < $report_file >> $dest
42 43 44 45 46 47 48 49 50

# Trailer
cat >> $dest <<END
    ""
};

}
}
END