#!/bin/sh

input=links.raw
output=links

if [ ! -f ../include/conf.h ]; then
    echo " "
    echo "Sorry, ../include/conf.h does not exist.  Please create it (check"
    echo "../INSTALL for information on how to do so) and try again."
    echo " "
    exit 1
fi

bnews=`grep "^#define BNEWS" ../include/conf.h`
cnews=`grep "^#define CNEWS" ../include/conf.h`
inn=`grep "^#define INN" ../include/conf.h`

if [ \( -n "$bnews" -a -n "$cnews" \) -o \
	\( -n "$bnews" -a -n "$inn" \) -o \
	\( -n "$cnews" -a -n "$inn" \) ]; then
    echo " "
    echo "Sorry, you can only define one type of news system (BNEWS, CNEWS,"
    echo "or INN) in ../include/conf.h.  Please fix this and try again."
    echo " "
    exit 1
fi

if [ -n "$bnews" ]; then
    sed -e "s/#BNEWS //; /#CNEWS /d; /#INN /d" < $input > $output
elif [ -n "$cnews" ]; then
    sed -e "/#BNEWS /d; s/#CNEWS //; /#INN /d" < $input > $output
elif [ -n "$inn" ]; then
    sed -e "/#BNEWS /d; /#CNEWS /d; s/#INN //" < $input > $output
else
    echo " "
    echo "Sorry, you have not defined any type of news system (BNEWS, CNEWS,"
    echo "or INN) in ../include/conf.h.  Please fix this and try again."
    echo " "
    exit 1
fi
