From 4be6fb9e4c58bd8e06ef77f7d09555037887181d Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Mon, 25 Sep 2006 10:24:44 +0000
Subject: [PATCH] EtherCAT master with Autotools.

---
 Makefile.am                              | 91 +++++++++++++++++++++++
 devices/{Makefile => Kbuild}             | 37 +---------
 devices/Makefile.am                      | 56 +++++++++++++++
 ethercat.conf.tmpl                       | 17 -----
 examples/mini/{Makefile => Kbuild}       | 40 ++---------
 examples/mini/Makefile.am                | 50 +++++++++++++
 examples/mini/kernel.conf.tmpl           | 12 ----
 examples/msr/Kbuild                      | 58 +++++++++++++++
 examples/msr/Makefile                    | 92 ------------------------
 examples/msr/{install.sh => Makefile.am} | 53 +++++---------
 examples/msr/kernel.conf.tmpl            | 15 ----
 examples/rtai/{Makefile => Kbuild}       | 36 +---------
 Makefile => examples/rtai/Makefile.am    | 52 +++-----------
 examples/rtai/kernel.conf.tmpl           | 12 ----
 master/{Makefile => Kbuild}              | 37 +---------
 master/Makefile.am                       | 66 +++++++++++++++++
 16 files changed, 356 insertions(+), 368 deletions(-)
 create mode 100644 Makefile.am
 rename devices/{Makefile => Kbuild} (71%)
 create mode 100644 devices/Makefile.am
 delete mode 100644 ethercat.conf.tmpl
 rename examples/mini/{Makefile => Kbuild} (69%)
 create mode 100644 examples/mini/Makefile.am
 delete mode 100644 examples/mini/kernel.conf.tmpl
 create mode 100644 examples/msr/Kbuild
 delete mode 100644 examples/msr/Makefile
 rename examples/msr/{install.sh => Makefile.am} (71%)
 mode change 100755 => 100644
 delete mode 100644 examples/msr/kernel.conf.tmpl
 rename examples/rtai/{Makefile => Kbuild} (66%)
 rename Makefile => examples/rtai/Makefile.am (65%)
 delete mode 100644 examples/rtai/kernel.conf.tmpl
 rename master/{Makefile => Kbuild} (72%)
 create mode 100644 master/Makefile.am

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 00000000..3ab1994a
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,91 @@
+#------------------------------------------------------------------------------
+#
+#  Makefile.am
+#
+#  IgH EtherCAT master
+#
+#  $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.
+#
+#------------------------------------------------------------------------------
+
+SUBDIRS = master/ devices/
+
+initdir = $(sysconfdir)/init.d
+sysdir = $(sysconfdir)/sysconfig
+
+include_HEADERS = include/ecdb.h include/ecrt.h
+noinst_SCRIPTS = script/lsec.pl script/ethercat.sh script/sysconfig
+
+MINI_FILES = \
+	examples/mini/Kbuild \
+	examples/mini/Makefile.am \
+	examples/mini/Makefile.in \
+	examples/mini/mini.c
+
+RTAI_FILES = \
+	examples/rtai/Kbuild \
+	examples/rtai/Makefile.am \
+	examples/rtai/Makefile.in \
+	examples/rtai/rtai_sample.c
+
+MSR_FILES = \
+	examples/msr/Kbuild \
+	examples/msr/libm.o_shipped \
+	examples/msr/Makefile.am \
+	examples/msr/Makefile.in \
+	examples/msr/msr_load \
+	examples/msr/msr_param.h \
+	examples/msr/msr_sample.c \
+	examples/msr/msrserv.pl \
+	examples/msr/msr_unload
+
+EXTRA_DIST = $(noinst_SCRIPTS) $(MINI_FILES) $(RTAI_FILES) $(MSR_FILES)
+
+install-data-local:
+	$(mkinstalldirs) $(bindir)
+	$(mkinstalldirs) $(initdir)
+	$(mkinstalldirs) $(sysdir)
+	$(INSTALL_SCRIPT) $(srcdir)/script/lsec.pl $(bindir)/lsec
+	$(INSTALL_SCRIPT) $(srcdir)/script/ethercat.sh $(initdir)/ethercat
+	$(INSTALL_DATA) $(srcdir)/script/sysconfig $(sysdir)/ethercat
+
+uninstall-local:
+	rm -rf $(LINUX_MODULES_DIR)/ethercat
+	rm $(bindir)/lsec
+	rm $(initdir)/ethercat
+	rm $(sysdir)/ethercat
+
+doc:
+	doxygen Doxyfile
+
+cleandoc:
+	@rm -rf documentation
+
+#------------------------------------------------------------------------------
diff --git a/devices/Makefile b/devices/Kbuild
similarity index 71%
rename from devices/Makefile
rename to devices/Kbuild
index eac889ad..edad4e7a 100644
--- a/devices/Makefile
+++ b/devices/Kbuild
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------
 #
-#  Makefile
+#  Kbuild
 #
 #  IgH EtherCAT master device modules
 #
@@ -35,11 +35,6 @@
 #
 #------------------------------------------------------------------------------
 
-#------------------------------------------------------------------------------
-#  kbuild section
-
-ifneq ($(KERNELRELEASE),)
-
 obj-m := ec_8139too.o
 
 ec_8139too-objs := 8139too.o
@@ -49,33 +44,3 @@ REV := $(shell svnversion $(src) 2>/dev/null || echo "unknown")
 EXTRA_CFLAGS = -DEC_REV=$(REV) -DEC_USER=$(USER)
 
 #------------------------------------------------------------------------------
-#  default section
-
-else
-
-ifneq ($(wildcard ../ethercat.conf),)
-include ../ethercat.conf
-else
-KERNEL := $(shell uname -r)
-endif
-
-KERNEL_DIR := /lib/modules/$(KERNEL)/build
-CURRENT_DIR := $(shell pwd)
-INSTALL_MOD_DIR := ethercat/devices
-
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) modules
-
-install: modules_install
-
-modules_install:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) \
-		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
-
-clean:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-	@rm -f Modules.symvers
-
-#------------------------------------------------------------------------------
-
-endif
diff --git a/devices/Makefile.am b/devices/Makefile.am
new file mode 100644
index 00000000..8008898d
--- /dev/null
+++ b/devices/Makefile.am
@@ -0,0 +1,56 @@
+#------------------------------------------------------------------------------
+#
+#  Makefile.am
+#
+#  IgH EtherCAT master module
+#
+#  $Id: Makefile 545 2006-09-19 13:28:40Z fp $
+#
+#  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.
+#
+#------------------------------------------------------------------------------
+
+EXTRA_DIST = \
+	Kbuild \
+	ecdev.h \
+	8139too.c \
+	original_8139too.c
+
+ABSSRCDIR = `cd $(srcdir) && pwd -P`
+
+all:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+
+clean-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+
+install-data-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+		INSTALL_MOD_DIR="ethercat" modules_install
+
+#------------------------------------------------------------------------------
diff --git a/ethercat.conf.tmpl b/ethercat.conf.tmpl
deleted file mode 100644
index 5ce7e6ad..00000000
--- a/ethercat.conf.tmpl
+++ /dev/null
@@ -1,17 +0,0 @@
-#------------------------------------------------------------------------------
-#
-#  EtherCAT configuration file
-#
-#  $Id$
-#
-#  This file is a versioned template configuration. Copy it to "ethercat.conf"
-#  (which is ignored by Subversion) and adjust it to your needs.
-#
-#------------------------------------------------------------------------------
-
-#
-# The kernel to compile the EtherCAT sources against
-#
-KERNEL := $(shell uname -r)
-
-#------------------------------------------------------------------------------
diff --git a/examples/mini/Makefile b/examples/mini/Kbuild
similarity index 69%
rename from examples/mini/Makefile
rename to examples/mini/Kbuild
index c9131015..6162938c 100644
--- a/examples/mini/Makefile
+++ b/examples/mini/Kbuild
@@ -1,8 +1,6 @@
-#----------------------------------------------------------------
+#------------------------------------------------------------------------------
 #
-#  Makefile
-#
-#  Minimal EtherCAT module.
+#  Kbuild
 #
 #  $Id$
 #
@@ -33,40 +31,10 @@
 #  standard) as the (only) precondition to have the right to use EtherCAT
 #  Technology, IP and trade marks.
 #
-#----------------------------------------------------------------
-
-ifneq ($(KERNELRELEASE),)
-
-#----------------------------------------------------------------
-#  kbuild section
-#----------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 obj-m := ec_mini.o
 
 ec_mini-objs := mini.o
 
-#----------------------------------------------------------------
-
-else
-
-#----------------------------------------------------------------
-#  default section
-#----------------------------------------------------------------
-
-ifneq ($(wildcard kernel.conf),)
-include kernel.conf
-else
-KERNEL_DIR := /lib/modules/$(shell uname -r)/build
-endif
-
-CURRENT_DIR := $(shell pwd)
-
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR)
-
-clean:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-
-#----------------------------------------------------------------
-
-endif
+#------------------------------------------------------------------------------
diff --git a/examples/mini/Makefile.am b/examples/mini/Makefile.am
new file mode 100644
index 00000000..c3427955
--- /dev/null
+++ b/examples/mini/Makefile.am
@@ -0,0 +1,50 @@
+#------------------------------------------------------------------------------
+#
+#  Makefile.am
+#
+#  IgH EtherCAT master module
+#
+#  $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.
+#
+#------------------------------------------------------------------------------
+
+ABSSRCDIR = `cd $(srcdir) && pwd -P`
+
+all:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+
+clean-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+
+install-data-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+		INSTALL_MOD_DIR="ethercat" modules_install
+
+#------------------------------------------------------------------------------
diff --git a/examples/mini/kernel.conf.tmpl b/examples/mini/kernel.conf.tmpl
deleted file mode 100644
index 9a0ac049..00000000
--- a/examples/mini/kernel.conf.tmpl
+++ /dev/null
@@ -1,12 +0,0 @@
-#------------------------------------------------------------------------------
-#
-#  Kernel configuration file for EtherCAT mini sample
-#
-#  $Id$
-#
-#  This file is a versioned template configuration. Copy it to "kernel.conf"
-#  (which is ignored by Subversion) and adjust it to your needs.
-#
-#------------------------------------------------------------------------------
-
-KERNELDIR := /lib/modules/$(shell uname -r)/build
diff --git a/examples/msr/Kbuild b/examples/msr/Kbuild
new file mode 100644
index 00000000..c62652c7
--- /dev/null
+++ b/examples/msr/Kbuild
@@ -0,0 +1,58 @@
+#------------------------------------------------------------------------------
+#
+#  Kbuild
+#
+#  $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.
+#
+#------------------------------------------------------------------------------
+
+MODULE := ec_msr_sample
+
+obj-m := $(MODULE).o
+
+$(MODULE)-objs := msr_sample.o \
+                        rt_lib/msr-core/msr_lists.o \
+                        rt_lib/msr-core/msr_main.o \
+                        rt_lib/msr-core/msr_charbuf.o \
+                        rt_lib/msr-core/msr_reg.o \
+                        rt_lib/msr-core/msr_interpreter.o \
+                        rt_lib/msr-core/msr_messages.o \
+                        rt_lib/msr-core/msr_proc.o \
+                        rt_lib/msr-core/msr_error_reg.o \
+                        rt_lib/msr-utils/msr_utils.o \
+                        rt_lib/msr-utils/msr_time.o \
+                        rt_lib/msr-math/msr_base64.o \
+                        rt_lib/msr-math/msr_hex_bin.o \
+                        libm.o
+
+EXTRA_CFLAGS := -I$(src)/rt_lib/msr-include -I/usr/realtime/include \
+                -D_SIMULATION -mhard-float
+
+#------------------------------------------------------------------------------
diff --git a/examples/msr/Makefile b/examples/msr/Makefile
deleted file mode 100644
index d84adf8e..00000000
--- a/examples/msr/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-#------------------------------------------------------------------------------
-#
-#  Makefile
-#
-#  Sample module for use with IgH MSR library.
-#
-#  $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.
-#
-#------------------------------------------------------------------------------
-
-MODULE := ec_msr_sample
-
-#------------------------------------------------------------------------------
-#  kbuild section
-#------------------------------------------------------------------------------
-
-ifneq ($(KERNELRELEASE),)
-
-obj-m := $(MODULE).o
-
-$(MODULE)-objs := msr_sample.o \
-			rt_lib/msr-core/msr_lists.o \
-			rt_lib/msr-core/msr_main.o \
-			rt_lib/msr-core/msr_charbuf.o \
-			rt_lib/msr-core/msr_reg.o \
-			rt_lib/msr-core/msr_interpreter.o \
-			rt_lib/msr-core/msr_messages.o \
-			rt_lib/msr-core/msr_proc.o \
-			rt_lib/msr-core/msr_error_reg.o \
-			rt_lib/msr-utils/msr_utils.o \
-			rt_lib/msr-utils/msr_time.o \
-			rt_lib/msr-math/msr_base64.o \
-			rt_lib/msr-math/msr_hex_bin.o \
-			libm.o
-
-EXTRA_CFLAGS := -I$(src)/rt_lib/msr-include -I/usr/realtime/include \
-		-D_SIMULATION -mhard-float
-
-#------------------------------------------------------------------------------
-#  default section
-#------------------------------------------------------------------------------
-
-else
-
-ifneq ($(wildcard kernel.conf),)
-include kernel.conf
-else
-KERNEL := $(shell uname -r)
-endif
-
-KERNEL_DIR := /lib/modules/$(KERNEL)/build
-CURRENT_DIR := $(shell pwd)
-
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR)
-
-clean:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-
-install:
-	@./install.sh $(MODULE) $(KERNEL)
-
-endif
-
-#------------------------------------------------------------------------------
diff --git a/examples/msr/install.sh b/examples/msr/Makefile.am
old mode 100755
new mode 100644
similarity index 71%
rename from examples/msr/install.sh
rename to examples/msr/Makefile.am
index 6b438ac0..fb32a16d
--- a/examples/msr/install.sh
+++ b/examples/msr/Makefile.am
@@ -1,8 +1,8 @@
-#!/bin/sh
-
 #------------------------------------------------------------------------------
 #
-#  Realtime module install script
+#  Makefile.am
+#
+#  IgH EtherCAT master module
 #
 #  $Id$
 #
@@ -35,42 +35,23 @@
 #
 #------------------------------------------------------------------------------
 
-# Fetch parameters
-
-if [ $# -ne 2 ]; then
-    echo "Usage: $0 <MODULENAME> <KERNEL>"
-    exit 1
-fi
-
-MODULENAME=$1
-KERNEL=$2
-
-MODULESDIR=/lib/modules/$KERNEL/kernel/drivers/rt
-
-echo "Realtime installer"
-echo "  target: $MODULENAME"
-echo "  kernel: $KERNEL"
-
-# Create target directory
-
-if [ ! -d $MODULESDIR ]; then
-    echo "  creating $MODULESDIR..."
-    mkdir $MODULESDIR || exit 1
-fi
-
-# Install files
-
-echo "  installing $MODULENAME..."
-if ! cp $MODULENAME.ko $MODULESDIR/$MODULENAME.ko; then exit 1; fi
+EXTRA_DIST = \
+	Kbuild \
+	msr_sample.c msr_param.h \
+	libm.o_shipped \
+	msr_load msr_unload \
+	msrserv.pl
 
-# Calculate dependencies
+ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
-echo "  building module dependencies..."
-depmod
+all:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
 
-# Finish
+clean-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
 
-echo "done."
-exit 0
+install-data-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
diff --git a/examples/msr/kernel.conf.tmpl b/examples/msr/kernel.conf.tmpl
deleted file mode 100644
index 31164da2..00000000
--- a/examples/msr/kernel.conf.tmpl
+++ /dev/null
@@ -1,15 +0,0 @@
-#------------------------------------------------------------------------------
-#
-#  Configuration file for MSR realtime modules
-#
-#  $Id$
-#
-#  This file is a versioned template configuration. Copy it to "kernel.conf"
-#  (which is ignored by Subversion) and adjust it to your needs.
-#
-#------------------------------------------------------------------------------
-
-# Kernel sources for module compilation
-KERNEL := $(shell uname -r)
-
-#------------------------------------------------------------------------------
diff --git a/examples/rtai/Makefile b/examples/rtai/Kbuild
similarity index 66%
rename from examples/rtai/Makefile
rename to examples/rtai/Kbuild
index 66b5ff82..40b09cef 100644
--- a/examples/rtai/Makefile
+++ b/examples/rtai/Kbuild
@@ -1,8 +1,6 @@
 #------------------------------------------------------------------------------
 #
-#  Makefile
-#
-#  RTAI sample module for the IgH EtherCAT master.
+#  Kbuild
 #
 #  $Id$
 #
@@ -35,40 +33,8 @@
 #
 #------------------------------------------------------------------------------
 
-ifneq ($(KERNELRELEASE),)
-
-#------------------------------------------------------------------------------
-#  kbuild section
-#------------------------------------------------------------------------------
-
 obj-m := ec_rtai_sample.o
 
 ec_rtai_sample-objs := rtai_sample.o
 
-EXTRA_CFLAGS := -I/usr/realtime/include -mhard-float
-
-#------------------------------------------------------------------------------
-
-else
-
 #------------------------------------------------------------------------------
-#  default section
-#------------------------------------------------------------------------------
-
-ifneq ($(wildcard kernel.conf),)
-include kernel.conf
-else
-KERNEL_DIR := /lib/modules/$(shell uname -r)/build
-endif
-
-CURRENT_DIR := $(shell pwd)
-
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR)
-
-clean:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-
-#------------------------------------------------------------------------------
-
-endif
diff --git a/Makefile b/examples/rtai/Makefile.am
similarity index 65%
rename from Makefile
rename to examples/rtai/Makefile.am
index 704acd01..f00511f3 100644
--- a/Makefile
+++ b/examples/rtai/Makefile.am
@@ -1,8 +1,8 @@
 #------------------------------------------------------------------------------
 #
-#  Makefile
+#  Makefile.am
 #
-#  IgH EtherCAT master
+#  IgH EtherCAT master module
 #
 #  $Id$
 #
@@ -35,48 +35,18 @@
 #
 #------------------------------------------------------------------------------
 
-#------------------------------------------------------------------------------
-#  kbuild section
-
-ifneq ($(KERNELRELEASE),)
-
-obj-m := master/ devices/
-
-#------------------------------------------------------------------------------
-#  default section
-
-else
+EXTRA_DIST = Kbuild rtai_sample.c
 
-ifneq ($(wildcard ethercat.conf),)
-include ethercat.conf
-else
-KERNEL := $(shell uname -r)
-endif
+ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
-KERNEL_DIR := /lib/modules/$(KERNEL)/build
-CURRENT_DIR := $(shell pwd)
-INSTALL_MOD_DIR := ethercat
+all:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
 
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) modules
+clean-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
 
-install: modules_install
-	@script/install.sh $(KERNEL)
-
-modules_install:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) \
-		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
-
-clean: cleandoc
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-	@rm -f Modules.symvers
-
-doc:
-	doxygen Doxyfile
-
-cleandoc:
-	@rm -rf doc
+install-data-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
-
-endif
diff --git a/examples/rtai/kernel.conf.tmpl b/examples/rtai/kernel.conf.tmpl
deleted file mode 100644
index c5c2cc2f..00000000
--- a/examples/rtai/kernel.conf.tmpl
+++ /dev/null
@@ -1,12 +0,0 @@
-#------------------------------------------------------------------------------
-#
-#  Kernel configuration file for RTAI sample.
-#
-#  $Id$
-#
-#  This file is a versioned template configuration. Copy it to "kernel.conf"
-#  (which is ignored by Subversion) and adjust it to your needs.
-#
-#------------------------------------------------------------------------------
-
-KERNELDIR := /lib/modules/$(shell uname -r)/build
diff --git a/master/Makefile b/master/Kbuild
similarity index 72%
rename from master/Makefile
rename to master/Kbuild
index ef5d2d2e..51d18a8f 100644
--- a/master/Makefile
+++ b/master/Kbuild
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------
 #
-#  Makefile
+#  Kbuild
 #
 #  IgH EtherCAT master module
 #
@@ -35,11 +35,6 @@
 #
 #------------------------------------------------------------------------------
 
-#------------------------------------------------------------------------------
-#  kbuild section
-
-ifneq ($(KERNELRELEASE),)
-
 obj-m := ec_master.o
 
 ec_master-objs := module.o master.o device.o slave.o datagram.o \
@@ -50,33 +45,3 @@ REV := $(shell svnversion $(src) 2>/dev/null || echo "unknown")
 EXTRA_CFLAGS := -DSVNREV=$(REV) -DUSER=$(USER)
 
 #------------------------------------------------------------------------------
-#  default section
-
-else
-
-ifneq ($(wildcard ../ethercat.conf),)
-include ../ethercat.conf
-else
-KERNEL := $(shell uname -r)
-endif
-
-KERNEL_DIR := /lib/modules/$(KERNEL)/build
-CURRENT_DIR := $(shell pwd)
-INSTALL_MOD_DIR := ethercat/master
-
-modules:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) modules
-
-install: modules_install
-
-modules_install:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) \
-		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
-
-clean:
-	$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
-	@rm -f Modules.symvers
-
-#------------------------------------------------------------------------------
-
-endif
diff --git a/master/Makefile.am b/master/Makefile.am
new file mode 100644
index 00000000..ff8e6bcb
--- /dev/null
+++ b/master/Makefile.am
@@ -0,0 +1,66 @@
+#------------------------------------------------------------------------------
+#
+#  Makefile.am
+#
+#  IgH EtherCAT master module
+#
+#  $Id: Makefile 545 2006-09-19 13:28:40Z fp $
+#
+#  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.
+#
+#------------------------------------------------------------------------------
+
+EXTRA_DIST = \
+	Kbuild \
+	datagram.c datagram.h \
+	debug.c	debug.h \
+	device.c device.h \
+	domain.c domain.h \
+	doxygen.c \
+	ethernet.c ethernet.h \
+	fsm.c fsm.h \
+	globals.h \
+	mailbox.c mailbox.h \
+	master.c master.h \
+	module.c \
+	slave.c slave.h \
+	xmldev.c xmldev.h
+
+ABSSRCDIR = `cd $(srcdir) && pwd -P`
+
+all:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+
+clean-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+
+install-data-local:
+	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+		INSTALL_MOD_DIR="ethercat" modules_install
+
+#------------------------------------------------------------------------------
-- 
GitLab