1AC_INIT(configure.in)
2
3AM_CONFIG_HEADER(config.h)
4AM_INIT_AUTOMAKE(pptp,0.8.5)
5
6AC_LANG_C
7AC_PROG_CC
8AM_PROG_LIBTOOL
9
10AC_DEFINE(PPPD_VERSION,[],"PPPD version")
11AC_DEFINE(KERNELVERSION,[],"kernel version")
12
13CFLAGS="${CFLAGS:=}"
14
15dnl check linux headers
16AC_MSG_CHECKING([for linux kernel herders])
17if test -n "${KDIR}"; then
18    if test -f ${KDIR}/include/linux/version.h; then 
19	header=${KDIR}/include
20    else
21	AC_MSG_RESULT(not found)
22	AC_MSG_ERROR(Could not find linux kernel headers)
23    fi
24else
25    kernel=`uname -r`
26    if test -f /usr/src/linux/include/linux/version.h; then
27	header=/usr/src/linux/include
28    elif test -f /lib/modules/${kernel}/build/include/linux/version.h; then 
29	header=/lib/modules/${kernel}/build/include
30    else
31	AC_MSG_RESULT(not found)
32	AC_MSG_ERROR(Could not find linux kernel headers)
33    fi
34fi
35VERSION=$(cat ${header/include}Makefile | grep '^VERSION = ' | awk '{print $3}')
36PATCHLEVEL=$(cat ${header/include}Makefile | grep '^PATCHLEVEL = ' | awk '{print $3}')
37SUBLEVEL=$(cat ${header/include}Makefile | grep '^SUBLEVEL = ' | awk '{print $3}')
38EXTRAVERSION=$(cat ${header/include}Makefile | grep '^EXTRAVERSION = ' | awk '{print $3}')
39KERNELVERSION=$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION
40AC_MSG_RESULT(found ($KERNELVERSION at ${header/include}))
41AC_DEFINE_UNQUOTED(KERNELVERSION,"$KERNELVERSION")
42
43
44CFLAGS="${CFLAGS} -I. -I${header}"
45
46AC_MSG_CHECKING([for pppd])
47pppd=`which pppd 2>&1`
48if test $? -eq 1; then
49    pppd=""
50    for path in /usr/sbin /usr/local/sbin /usr/bin /usr/local/bin /sbin; do
51	if test -x ${path}/pppd; then
52	    pppd=${path}/pppd
53	    break;
54        fi
55    done
56fi
57
58if test -z "${pppd}"; then
59    AC_MSG_RESULT(not found)
60    AC_MSG_ERROR(Could not find pppd)
61fi    
62pppd_ver=`${pppd} --version 2>&1 | grep version | sed 's/pppd version //'`
63AC_MSG_RESULT($pppd ($pppd_ver))
64AC_DEFINE_UNQUOTED(PPPD_VERSION,"${pppd_ver}")
65
66echo '==============================================================================='
67
68echo 'Configuration chosen:'
69echo    '   PPPD:              '${pppd_ver}
70echo    '   linux kernel :     '$KERNELVERSION at ${header/include}
71
72AC_OUTPUT(Makefile src/Makefile)
73