fp@365: #------------------------------------------------------------------------------
fp@365: # $Id$
fp@365: #------------------------------------------------------------------------------
fp@365:
fp@392: AC_PREREQ(2.59)
fp@490: AC_INIT([ethercat],[1.1.1],[fp@igh-essen.com])
fp@387: AC_CONFIG_AUX_DIR([autoconf])
fp@479: AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2])
fp@387: AC_PREFIX_DEFAULT([/opt/etherlab])
fp@392: AC_CONFIG_HEADERS([config.h])
fp@392: AC_CONFIG_SRCDIR([config.h.in])
fp@365:
fp@365: #------------------------------------------------------------------------------
fp@444: # Global
fp@444: #------------------------------------------------------------------------------
fp@444:
fp@444: branch=trunk
fp@444:
fp@444: AC_DEFINE_UNQUOTED(BRANCH, ["$branch"], [Subversion branch])
fp@444: AC_SUBST(BRANCH, [$branch])
fp@444:
fp@444: #------------------------------------------------------------------------------
fp@365: # Linux sources
fp@365: #------------------------------------------------------------------------------
fp@365:
fp@440: AC_ARG_WITH([linux-dir],
fp@365: AC_HELP_STRING(
fp@440: [--with-linux-dir=
],
fp@440: [Linux kernel sources @<:@running kernel@:>@]
fp@367: ),
fp@440: [
fp@440: sourcedir=[$withval]
fp@440: ],
fp@440: [
fp@440: version=[`uname -r`]
fp@440: modulesdir=/lib/modules/${version}
fp@440: if test \! -d ${modulesdir} || test \! -d ${modulesdir}/build; then
fp@440: echo
fp@477: AC_MSG_ERROR([Failed to find Linux sources. Use --with-linux-dir!])
fp@440: fi
fp@440: sourcedir=`cd ${modulesdir}/build && pwd -P`
fp@440: ]
fp@367: )
fp@365:
fp@440: AC_MSG_CHECKING([for Linux kernel sources])
fp@440:
fp@440: if test \! -r ${sourcedir}/.config; then
fp@477: echo
fp@477: AC_MSG_ERROR([No configured Linux kernel sources in $sourcedir])
fp@365: fi
fp@365:
fp@477: # Try to get kernel release string
fp@477: if test -r ${sourcedir}/.kernelrelease; then
fp@477: kernelrelease=`cat $sourcedir/.kernelrelease`
fp@477: elif test -r ${sourcedir}/include/linux/version.h; then
fp@477: hdr=$sourcedir/include/linux/version.h
fp@477: kernelrelease=`grep UTS_RELEASE $hdr | cut -d " " -f 3- | tr -d \"`
fp@477: fi
fp@477:
fp@477: if test -z "$kernelrelease"; then
fp@477: echo
fp@477: AC_MSG_ERROR([Failed to extract Linux kernel version!])
fp@477: fi
fp@477:
fp@477: # Extract three numbers from kernel release string
fp@477: linuxversion=`echo $kernelrelease | grep -oE [[0-9]]+\.[[0-9]]+\.[[0-9]]+`
fp@477:
fp@367: AC_SUBST(LINUX_SOURCE_DIR,[$sourcedir])
fp@477: AC_SUBST(LINUX_KERNEL_RELEASE,[$kernelrelease])
fp@477: AC_SUBST(LINUX_KERNEL_VERSION,[$linuxversion])
fp@477: AC_SUBST(LINUX_MOD_PATH,[/lib/modules/$kernelrelease/ethercat])
fp@477: AC_MSG_RESULT([$LINUX_SOURCE_DIR (Kernel $LINUX_KERNEL_RELEASE)])
fp@367:
fp@367: #------------------------------------------------------------------------------
fp@485: # 8139too Kernel
fp@485: #------------------------------------------------------------------------------
fp@485:
fp@485: AC_ARG_WITH([8139too-kernel],
fp@485: AC_HELP_STRING(
fp@485: [--with-8139too-kernel=],
fp@485: [8139too kernel (only if differing)]
fp@485: ),
fp@485: [
fp@485: kernel8139too=[$withval]
fp@485: ],
fp@485: [
fp@485: kernel8139too=$linuxversion
fp@485: ]
fp@485: )
fp@485:
fp@485: AC_MSG_CHECKING([for kernel for 8139too driver])
fp@485:
fp@485: kernels=`ls -1 devices/ | grep -oE "^8139too-.*-" | cut -d "-" -f 2 | uniq`
fp@485: found=0
fp@485: for k in $kernels; do
fp@485: if test "$kernel8139too" = "$k"; then
fp@485: found=1
fp@485: fi
fp@485: done
fp@485: if test $found -ne 1; then
fp@485: AC_MSG_ERROR([kernel $kernel8139too not available for 8139too driver!])
fp@485: fi
fp@485:
fp@485: AC_MSG_RESULT([$kernel8139too])
fp@485:
fp@485: #------------------------------------------------------------------------------
fp@485: # RTAI path (optional)
fp@485: #------------------------------------------------------------------------------
fp@485:
fp@485: AC_ARG_WITH([rtai-dir],
fp@485: AC_HELP_STRING(
fp@485: [--with-rtai-dir=],
fp@485: [RTAI path (only for RTAI examples)]
fp@485: ),
fp@485: [
fp@485: rtaidir=[$withval]
fp@485: ],
fp@485: [
fp@485: rtaidir=""
fp@485: ]
fp@485: )
fp@485:
fp@485: AC_MSG_CHECKING([for RTAI path])
fp@485:
fp@485: if test -z "${rtaidir}"; then
fp@485: AC_MSG_RESULT([not specified.])
fp@485: else
fp@485: if test \! -r ${rtaidir}/include/rtai.h; then
fp@485: AC_MSG_ERROR([no RTAI installation found in ${rtaidir}!])
fp@485: fi
fp@485: AC_MSG_RESULT([$rtaidir])
fp@485: AC_SUBST(RTAI_DIR,[$rtaidir])
fp@485: fi
fp@485:
fp@485: #------------------------------------------------------------------------------
fp@485: # MSR path (optional)
fp@485: #------------------------------------------------------------------------------
fp@485:
fp@485: AC_ARG_WITH([msr-dir],
fp@485: AC_HELP_STRING(
fp@485: [--with-msr-dir=],
fp@485: [MSR path (only for MSR example)]
fp@485: ),
fp@485: [
fp@485: msrdir=[$withval]
fp@485: ],
fp@485: [
fp@485: msrdir=""
fp@485: ]
fp@485: )
fp@485:
fp@485: AC_MSG_CHECKING([for MSR path])
fp@485:
fp@485: if test -z "${msrdir}"; then
fp@485: AC_MSG_RESULT([not specified.])
fp@485: else
fp@485: if test \! -r ${msrdir}/include/msr.h; then
fp@485: AC_MSG_ERROR([no MSR installation found in ${msrdir}!])
fp@485: fi
fp@485: AC_MSG_RESULT([$msrdir])
fp@485: AC_SUBST(MSR_DIR,[$msrdir])
fp@485: fi
fp@485:
fp@485: #------------------------------------------------------------------------------
fp@392: # Debug interface
fp@392: #------------------------------------------------------------------------------
fp@392:
fp@471: AC_ARG_ENABLE([dbg-if],
fp@440: AS_HELP_STRING([--enable-dbg-if],
fp@440: [Create a debug interface for each master @<:@NO@:>@]),
fp@440: [
fp@440: case "${enableval}" in
fp@440: yes) dbg=1
fp@440: AC_DEFINE([EC_DBG_IF], [1], [Debug interfaces enabled])
fp@440: ;;
fp@440: no) dbg=0
fp@440: ;;
fp@440: *) AC_MSG_ERROR([Invalid value for --enable-dbg-if])
fp@440: ;;
fp@440: esac
fp@440: ],
fp@440: [dbg=0]
fp@392: )
fp@440:
fp@392: AM_CONDITIONAL(EC_DBG_IF, test "x$dbg" = x1)
fp@392: AC_SUBST([EC_DBG_IF],${dbg})
fp@392:
fp@392: #------------------------------------------------------------------------------
fp@365:
fp@485: # Create config.kbuild
fp@485:
fp@485: echo configure: creating config.kbuild...
fp@485:
fp@485: cat > config.kbuild <