Autotools "--with-linux" switch; "mydist" target
authorFlorian Pose <fp@igh-essen.com>
Mon, 25 Sep 2006 14:13:23 +0000
changeset 367 e85e3143dc8d
parent 366 148ac5ef18ae
child 368 5526520f323f
Autotools "--with-linux" switch; "mydist" target
Makefile.am
configure.ac
devices/Makefile.am
examples/mini/Makefile.am
examples/msr/Makefile.am
examples/rtai/Makefile.am
master/Makefile.am
--- a/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -68,6 +68,9 @@
 
 EXTRA_DIST = $(noinst_SCRIPTS) $(MINI_FILES) $(RTAI_FILES) $(MSR_FILES)
 
+mydist:
+	$(MAKE) dist distdir=$(PACKAGE)-$(VERSION)-r`svnversion $(srcdir)`
+
 dist-hook:
 	if which svnversion >/dev/null 2>&1; then \
 		svnversion $(srcdir) 2>/dev/null >$(distdir)/svnrevision; \
@@ -80,6 +83,7 @@
 	$(INSTALL_SCRIPT) $(srcdir)/script/lsec.pl $(bindir)/lsec
 	$(INSTALL_SCRIPT) $(srcdir)/script/ethercat.sh $(initdir)/ethercat
 	$(INSTALL_DATA) $(srcdir)/script/sysconfig $(sysdir)/ethercat
+	$(DEPMOD) $(LINUX_KERNEL_VERSION)
 
 uninstall-local:
 	rm -rf $(LINUX_MODULES_DIR)/ethercat
--- a/configure.ac	Mon Sep 25 12:11:05 2006 +0000
+++ b/configure.ac	Mon Sep 25 14:13:23 2006 +0000
@@ -14,27 +14,42 @@
 # Linux sources
 #------------------------------------------------------------------------------
 
-AC_ARG_WITH([linux-dir],
+AC_ARG_WITH([linux],
     AC_HELP_STRING(
-        [--with-linux-dir=<linux-dir>],
-        [Linux source directory @<:@/lib/modules/<kernelversion>/build@:>@]),
+        [--with-linux=<version>],
+        [Linux kernel version @<:@running kernel@:>@]
+    ),
     [ ],
-    [
-	modulesdir=/lib/modules/`uname -r`
-        withval=${modulesdir}/build
-    ])
+    [version=`uname -r`]
+)
 
-AC_MSG_CHECKING([for Linux source tree])
-
-if test \! -r ${withval}/Makefile; then
+AC_MSG_CHECKING([for Linux kernel])
+modulesdir=/lib/modules/${version}
+if test \! -d ${modulesdir} || test \! -d ${modulesdir}/build; then
    echo
-   AC_MSG_ERROR([No Linux kernel tree in $withval])
+   AC_MSG_ERROR([Invalid modules directory ${modulesdir}])
+fi
+sourcedir=`cd ${modulesdir}/build && pwd -P`
+if test \! -r ${sourcedir}/Makefile; then
+   echo
+   AC_MSG_ERROR([No Linux kernel tree in $sourcedir])
 fi
 
-AC_SUBST(LINUX_DIR,[$withval])
+AC_SUBST(LINUX_KERNEL_VERSION,[$version])
+AC_SUBST(LINUX_SOURCE_DIR,[$sourcedir])
 AC_SUBST(LINUX_MODULES_DIR,[$modulesdir])
 
-AC_MSG_RESULT($LINUX_DIR)
+AC_MSG_RESULT($LINUX_KERNEL_VERSION)
+
+#------------------------------------------------------------------------------
+# Depmod
+#------------------------------------------------------------------------------
+
+AC_PATH_PROG([DEPMOD], [depmod],, [$PATH:/sbin:/usr/sbin:/usr/local/sbin])
+
+if test -z "$DEPMOD"; then
+   AC_MSG_WARN([depmod was not found!]);
+fi
 
 #------------------------------------------------------------------------------
 
--- a/devices/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/devices/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -44,13 +44,13 @@
 ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
 all:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
 
 clean-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
 
 install-data-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
 		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
--- a/examples/mini/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/examples/mini/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -38,13 +38,13 @@
 ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
 all:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
 
 clean-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
 
 install-data-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
 		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
--- a/examples/msr/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/examples/msr/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -45,13 +45,13 @@
 ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
 all:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
 
 clean-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
 
 install-data-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
 		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
--- a/examples/rtai/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/examples/rtai/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -40,13 +40,13 @@
 ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
 all:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
 
 clean-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
 
 install-data-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
 		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------
--- a/master/Makefile.am	Mon Sep 25 12:11:05 2006 +0000
+++ b/master/Makefile.am	Mon Sep 25 14:13:23 2006 +0000
@@ -54,13 +54,13 @@
 ABSSRCDIR = `cd $(srcdir) && pwd -P`
 
 all:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
 
 clean-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" clean
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
 
 install-data-local:
-	$(MAKE) -C "$(LINUX_DIR)" M="$(ABSSRCDIR)" \
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
 		INSTALL_MOD_DIR="ethercat" modules_install
 
 #------------------------------------------------------------------------------