1#!/usr/bin/env bash
2
3if [[ "" == "$2" ]]
4then
5    echo "Usage: $0 <in-file> <out-file>"
6    exit 1
7fi
8
9if [ ! -f "$1" ]
10then
11    echo "Error: Can't find input file $1..."
12    exit 2
13fi
14
15DATE=`/usr/bin/env date`
16BASE=`basename $2`
17BASE=`echo ${BASE} | tr "[:lower:]" "[:upper:]"`
18BASE=`echo ${BASE} | sed -e "s/\\./_/"`
19PROTECT="_${BASE}"
20
21echo "/* Auto-generated from $1 on ${DATE} */" > $2
22echo "#ifndef ${PROTECT}" >> $2
23echo "#define ${PROTECT}" >> $2
24sed -e '/^#/d' -e '/^$$/d' -e '/# Makefile only$$/d' -e 's/^/#define /' -e 's/=/ /' $1 >> $2
25echo "#endif" >> $2
26