Improved autotools, added config.kbuild, --with-msr-dir, --with-rtai-dir, --with-8139too-kernel.
authorFlorian Pose <fp@igh-essen.com>
Mon, 06 Nov 2006 16:27:40 +0000
changeset 485 8354ddf38481
parent 484 9fde4a17b820
child 486 7313ed820882
Improved autotools, added config.kbuild, --with-msr-dir, --with-rtai-dir, --with-8139too-kernel.
Kbuild
Makefile.am
configure.ac
devices/Kbuild
devices/Makefile.am
examples/mini/Kbuild
examples/msr/Kbuild
examples/rtai/Kbuild
examples/rtai/Makefile.am
master/Kbuild
master/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -0,0 +1,36 @@
+#------------------------------------------------------------------------------
+#
+#  $Id$
+#
+#  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
+#
+#  This file is part of the IgH EtherCAT Master.
+#
+#  The IgH EtherCAT Master is free software; you can redistribute it
+#  and/or modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2 of the
+#  License, or (at your option) any later version.
+#
+#  The IgH EtherCAT Master is distributed in the hope that it will be
+#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the IgH EtherCAT Master; if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#  The right to use EtherCAT Technology is granted and comes free of
+#  charge under condition of compatibility of product made by
+#  Licensee. People intending to distribute/sell products based on the
+#  code, have to sign an agreement to guarantee that products using
+#  software based on IgH EtherCAT master stay compatible with the actual
+#  EtherCAT specification (which are released themselves as an open
+#  standard) as the (only) precondition to have the right to use EtherCAT
+#  Technology, IP and trade marks.
+#
+#------------------------------------------------------------------------------
+
+obj-m := master/ devices/
+
+#------------------------------------------------------------------------------
--- a/Makefile.am	Mon Nov 06 14:22:35 2006 +0000
+++ b/Makefile.am	Mon Nov 06 16:27:40 2006 +0000
@@ -43,6 +43,9 @@
 	globals.h \
 	LICENSE
 
+modules:
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
+
 modules_install:
 	$(MAKE) -C master modules_install
 	$(MAKE) -C devices modules_install
@@ -66,6 +69,7 @@
 		config.h.in \
 		config.log \
 		config.status \
+		config.kbuild \
 		configure.in \
 		configure \
 		Makefile \
--- a/configure.ac	Mon Nov 06 14:22:35 2006 +0000
+++ b/configure.ac	Mon Nov 06 16:27:40 2006 +0000
@@ -72,6 +72,96 @@
 AC_MSG_RESULT([$LINUX_SOURCE_DIR (Kernel $LINUX_KERNEL_RELEASE)])
 
 #------------------------------------------------------------------------------
+# 8139too Kernel
+#------------------------------------------------------------------------------
+
+AC_ARG_WITH([8139too-kernel],
+    AC_HELP_STRING(
+        [--with-8139too-kernel=<X.Y.Z>],
+        [8139too kernel (only if differing)]
+    ),
+    [
+        kernel8139too=[$withval]
+    ],
+    [
+        kernel8139too=$linuxversion
+    ]
+)
+
+AC_MSG_CHECKING([for kernel for 8139too driver])
+
+kernels=`ls -1 devices/ | grep -oE "^8139too-.*-" | cut -d "-" -f 2 | uniq`
+found=0
+for k in $kernels; do
+    if test "$kernel8139too" = "$k"; then
+        found=1
+    fi
+done
+if test $found -ne 1; then
+    AC_MSG_ERROR([kernel $kernel8139too not available for 8139too driver!])
+fi
+
+AC_MSG_RESULT([$kernel8139too])
+
+#------------------------------------------------------------------------------
+# RTAI path (optional)
+#------------------------------------------------------------------------------
+
+AC_ARG_WITH([rtai-dir],
+    AC_HELP_STRING(
+        [--with-rtai-dir=<DIR>],
+        [RTAI path (only for RTAI examples)]
+    ),
+    [
+        rtaidir=[$withval]
+    ],
+    [
+        rtaidir=""
+    ]
+)
+
+AC_MSG_CHECKING([for RTAI path])
+
+if test -z "${rtaidir}"; then
+    AC_MSG_RESULT([not specified.])
+else
+    if test \! -r ${rtaidir}/include/rtai.h; then
+        AC_MSG_ERROR([no RTAI installation found in ${rtaidir}!])
+    fi
+    AC_MSG_RESULT([$rtaidir])
+    AC_SUBST(RTAI_DIR,[$rtaidir])
+fi
+
+#------------------------------------------------------------------------------
+# MSR path (optional)
+#------------------------------------------------------------------------------
+
+AC_ARG_WITH([msr-dir],
+    AC_HELP_STRING(
+        [--with-msr-dir=<DIR>],
+        [MSR path (only for MSR example)]
+    ),
+    [
+        msrdir=[$withval]
+    ],
+    [
+        msrdir=""
+    ]
+)
+
+AC_MSG_CHECKING([for MSR path])
+
+if test -z "${msrdir}"; then
+    AC_MSG_RESULT([not specified.])
+else
+    if test \! -r ${msrdir}/include/msr.h; then
+        AC_MSG_ERROR([no MSR installation found in ${msrdir}!])
+    fi
+    AC_MSG_RESULT([$msrdir])
+    AC_SUBST(MSR_DIR,[$msrdir])
+fi
+
+#------------------------------------------------------------------------------
 # Debug interface
 #------------------------------------------------------------------------------
 
@@ -97,6 +187,20 @@
 
 #------------------------------------------------------------------------------
 
+# Create config.kbuild
+
+echo configure: creating config.kbuild...
+
+cat > config.kbuild <<EOF
+# config.kbuild - created by configure
+EC_DBG_IF := ${dbg}
+EC_8139TOO_KERNEL := ${kernel8139too}
+EC_RTAI_DIR := "${rtaidir}"
+EC_MSR_DIR := "${msrdir}"
+EOF
+
+#------------------------------------------------------------------------------
+
 AC_CONFIG_FILES([
         Makefile
         master/Makefile
--- a/devices/Kbuild	Mon Nov 06 14:22:35 2006 +0000
+++ b/devices/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -31,11 +31,13 @@
 #
 #------------------------------------------------------------------------------
 
-EC_MOD_KERNEL := $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
+include $(src)/../config.kbuild
+
+EC_8139TOO_OBJ = 8139too-$(EC_8139TOO_KERNEL)-ethercat.o
 
 obj-m := ec_8139too.o
 
-ec_8139too-objs := 8139too-$(EC_MOD_KERNEL)-ethercat.o
+ec_8139too-objs := $(EC_8139TOO_OBJ)
 
 REV := $(shell if test -s $(src)/../svnrevision; then \
 		cat $(src)/../svnrevision; \
@@ -43,6 +45,6 @@
 		svnversion $(src)/.. 2>/dev/null || echo "unknown"; \
 	fi)
 
-CFLAGS_8139too-$(EC_MOD_KERNEL)-ethercat.o = -DSVNREV=$(REV)
+CFLAGS_$(EC_8139TOO_OBJ) = -DSVNREV=$(REV)
 
 #------------------------------------------------------------------------------
--- a/devices/Makefile.am	Mon Nov 06 14:22:35 2006 +0000
+++ b/devices/Makefile.am	Mon Nov 06 16:27:40 2006 +0000
@@ -39,15 +39,13 @@
 	8139too-2.6.17-ethercat.c \
 	8139too-2.6.17-orig.c
 
-all-local:
-	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
+modules:
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_top_srcdir@" modules
+
+modules_install:
+	cp $(srcdir)/ec_8139too.ko $(DESTDIR)$(LINUX_MOD_PATH)
 
 clean-local:
 	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
 
-install-data-local: modules_install
-
-modules_install:
-	cp $(srcdir)/ec_8139too.ko $(DESTDIR)$(LINUX_MOD_PATH)
-
 #------------------------------------------------------------------------------
--- a/examples/mini/Kbuild	Mon Nov 06 14:22:35 2006 +0000
+++ b/examples/mini/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -1,7 +1,5 @@
 #------------------------------------------------------------------------------
 #
-#  Kbuild
-#
 #  $Id$
 #
 #  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
--- a/examples/msr/Kbuild	Mon Nov 06 14:22:35 2006 +0000
+++ b/examples/msr/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -1,7 +1,5 @@
 #------------------------------------------------------------------------------
 #
-#  Kbuild
-#
 #  $Id$
 #
 #  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
@@ -33,6 +31,8 @@
 #
 #------------------------------------------------------------------------------
 
+include $(src)/../../config.kbuild
+
 MODULE := ec_msr_sample
 
 obj-m := $(MODULE).o
@@ -52,7 +52,7 @@
                         rt_lib/msr-math/msr_hex_bin.o \
                         libm.o
 
-EXTRA_CFLAGS := -I$(src)/rt_lib/msr-include -I/usr/realtime/include \
+EXTRA_CFLAGS := -I$(EC_MSR_DIR)/include -I$(EC_RTAI_DIR)/include \
                 -D_SIMULATION -mhard-float
 
 #------------------------------------------------------------------------------
--- a/examples/rtai/Kbuild	Mon Nov 06 14:22:35 2006 +0000
+++ b/examples/rtai/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -31,10 +31,12 @@
 #
 #------------------------------------------------------------------------------
 
+include $(src)/../../config.kbuild
+
 obj-m := ec_rtai_sample.o
 
 ec_rtai_sample-objs := rtai_sample.o
 
-EXTRA_CFLAGS := -I/usr/realtime/include
+EXTRA_CFLAGS := -I$(EC_RTAI_DIR)/include
 
 #------------------------------------------------------------------------------
--- a/examples/rtai/Makefile.am	Mon Nov 06 14:22:35 2006 +0000
+++ b/examples/rtai/Makefile.am	Mon Nov 06 16:27:40 2006 +0000
@@ -1,7 +1,5 @@
 #------------------------------------------------------------------------------
 #
-#  Makefile.am
-#
 #  IgH EtherCAT master module
 #
 #  $Id$
--- a/master/Kbuild	Mon Nov 06 14:22:35 2006 +0000
+++ b/master/Kbuild	Mon Nov 06 16:27:40 2006 +0000
@@ -31,6 +31,8 @@
 #
 #------------------------------------------------------------------------------
 
+include $(src)/../config.kbuild
+
 obj-m := ec_master.o
 
 ec_master-objs := module.o master.o device.o slave.o datagram.o \
--- a/master/Makefile.am	Mon Nov 06 14:22:35 2006 +0000
+++ b/master/Makefile.am	Mon Nov 06 16:27:40 2006 +0000
@@ -51,16 +51,13 @@
 	slave.c slave.h \
 	xmldev.c xmldev.h
 
-all-local:
-	$(MAKE) -C "$(LINUX_SOURCE_DIR)" \
-		M="@abs_srcdir@" EC_DBG_IF="$(EC_DBG_IF)" modules
+modules:
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_top_srcdir@" modules
+
+modules_install:
+	cp $(srcdir)/ec_master.ko $(DESTDIR)$(LINUX_MOD_PATH)
 
 clean-local:
 	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
 
-install-data-local: modules_install
-
-modules_install:
-	cp $(srcdir)/ec_master.ko $(DESTDIR)$(LINUX_MOD_PATH)
-
 #------------------------------------------------------------------------------