aboutsummaryrefslogtreecommitdiff
path: root/gen_license_include.sh
blob: af41415aa19763beda255353dbfdc746153f504e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

set -e

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

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

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/\(.*\)/\"\1\\n\" \\/g' >>${OUTFILE}
echo '""' >>${OUTFILE}
echo "\n" >>${OUTFILE}
echo '#endif'  >>${OUTFILE}