chan-capi/create_config.sh

77 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
#
# create_config.sh
#
# Script to create config.h for compatibility with
# different asterisk versions.
#
# (C) 2005 Cytronics & Melware
# Armin Schindler <armin@melware.de>
#
CONFIGFILE="config.h"
rm -f "$CONFIGFILE"
if [ $# -lt 1 ]; then
echo >&2 "Missing argument"
exit 1
fi
INCLUDEDIR="$1/asterisk"
if [ ! -d "$INCLUDEDIR" ]; then
echo >&2 "Include directory '$INCLUDEDIR' does not exist"
exit 1
fi
echo "Checking Asterisk version..."
echo "/*" >$CONFIGFILE
echo " * automatically generated by $0 `date`" >>$CONFIGFILE
echo " */" >>$CONFIGFILE
echo >>$CONFIGFILE
echo "#ifndef CHAN_CAPI_CONFIG_H" >>$CONFIGFILE
echo "#define CHAN_CAPI_CONFIG_H" >>$CONFIGFILE
echo >>$CONFIGFILE
if grep -q "struct ast_channel_tech" $INCLUDEDIR/channel.h; then
echo "#define CC_AST_HAVE_TECH_PVT" >>$CONFIGFILE
echo " * found 'struct ast_channel_tech'"
else
echo "#undef CC_AST_HAVE_TECH_PVT" >>$CONFIGFILE
echo " * no 'struct ast_channel_tech', using old pvt"
fi
if grep -q "ast_dsp_process*needlock" $INCLUDEDIR/dsp.h; then
echo "#define CC_AST_DSP_PROCESS_NEEDLOCK" >>$CONFIGFILE
echo " * ast_dsp_process() needs 'needlock'"
else
echo "#undef CC_AST_DSP_PROCESS_NEEDLOCK" >>$CONFIGFILE
echo " * ast_dsp_process() without 'needlock'"
fi
if grep -q "struct ast_callerid" $INCLUDEDIR/channel.h; then
echo "#define CC_AST_CHANNEL_HAS_CID" >>$CONFIGFILE
echo " * found 'struct ast_callerid'"
else
echo "#undef CC_AST_CHANNEL_HAS_CID" >>$CONFIGFILE
echo " * no 'struct ast_callerid'"
fi
if grep -q "struct timeval delivery" $INCLUDEDIR/frame.h; then
echo "#define CC_AST_FRAME_HAS_TIMEVAL" >>$CONFIGFILE
echo " * found 'struct timeval delivery'"
else
echo "#undef CC_AST_FRAME_HAS_TIMEVAL" >>$CONFIGFILE
echo " * no 'struct timeval delivery'"
fi
echo "" >>$CONFIGFILE
echo "#endif /* CHAN_CAPI_CONFIG_H */" >>$CONFIGFILE
echo "" >>$CONFIGFILE
echo "config.h complete."
exit 0