aboutsummaryrefslogtreecommitdiff
path: root/gen_license_include.sh
blob: 16de0b2fea106356ad08bd60e442de6b8cb426ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

set -e

LICENSE="$(dirname $0)/COPYING"
OUTFILE="$(dirname $0)/src/license.h"

echo "$(basename $0): generating ${OUTFILE} from ${LICENSE}"

echo -n >${OUTFILE}
echo '/*' >>${OUTFILE}
echo " * File: ${OUTFILE}" >>${OUTFILE}
echo " * Generated by: $(basename $0) [user: $(id -nu)]" >>${OUTFILE}
echo ' *' >>${OUTFILE}
echo " * Autogenerated license pre-processor macro from ${LICENSE}" >>${OUTFILE}
echo ' * Remember to use std::wstring instead of std::string' >>${OUTFILE}
echo ' *   for ALL_LICENSES (contains non-ASCII characters).' >>${OUTFILE}
echo ' */' >>${OUTFILE}
echo '#ifndef LICENSE_H' >>${OUTFILE}
echo '#define LICENSE_H 1' >>${OUTFILE}
echo "\n" >>${OUTFILE}
echo '#define ALL_LICENSES  \' >>${OUTFILE}
# first sed will escape all existing double quotes
# second sed will C-ify the text
cat "${LICENSE}" | sed 's/\"/\\"/g' | sed 's/\(.*\)/L\"\1\\n\" \\/g' >>${OUTFILE}
echo 'L""' >>${OUTFILE}
echo "\n" >>${OUTFILE}
echo '#endif'  >>${OUTFILE}