Debug interfaces not compiled by default.
authorFlorian Pose <fp@igh-essen.com>
Fri, 13 Oct 2006 09:38:23 +0000
changeset 392 eaee3c8d6ae0
parent 391 7d67195702dd
child 393 9cfbb344adc0
Debug interfaces not compiled by default.
bootstrap
configure.ac
master/Kbuild
master/Makefile.am
master/device.c
master/device.h
master/globals.h
--- a/bootstrap	Fri Oct 13 09:05:45 2006 +0000
+++ b/bootstrap	Fri Oct 13 09:38:23 2006 +0000
@@ -3,5 +3,6 @@
 set -x
 mkdir -p autoconf
 aclocal -I autoconf
+autoheader
 automake --add-missing
 autoconf
--- a/configure.ac	Fri Oct 13 09:05:45 2006 +0000
+++ b/configure.ac	Fri Oct 13 09:38:23 2006 +0000
@@ -2,10 +2,13 @@
 # $Id$
 #------------------------------------------------------------------------------
 
+AC_PREREQ(2.59)
 AC_INIT([ethercat],[1.1],[fp@igh-essen.com])
 AC_CONFIG_AUX_DIR([autoconf])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-bzip2])
 AC_PREFIX_DEFAULT([/opt/etherlab])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-bzip2])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_SRCDIR([config.h.in])
 
 #------------------------------------------------------------------------------
 # Linux sources
@@ -49,11 +52,32 @@
 fi
 
 #------------------------------------------------------------------------------
+# Debug interface
+#------------------------------------------------------------------------------
+
+AC_ARG_ENABLE([debug-if],
+		AS_HELP_STRING([--enable-dbg-if],
+						[Create a debug interface for each master @<:@NO@:>@]),
+		[case "${enableval}" in
+			  yes) dbg=1
+				   AC_DEFINE([EC_DBG_IF], [1], [Debug interfaces enabled])
+				   ;;
+			  no)  dbg=0
+				   ;;
+			  *)   AC_MSG_ERROR([Invalid value for --enable-dbg-if])
+				   ;;
+		esac],
+		[dbg=0]
+)
+AM_CONDITIONAL(EC_DBG_IF, test "x$dbg" = x1)
+AC_SUBST([EC_DBG_IF],${dbg})
+
+#------------------------------------------------------------------------------
 
 AC_CONFIG_FILES([
-        Makefile 
-        master/Makefile 
-        devices/Makefile 
+        Makefile
+        master/Makefile
+        devices/Makefile
         script/Makefile
         include/Makefile
         examples/mini/Makefile
--- a/master/Kbuild	Fri Oct 13 09:05:45 2006 +0000
+++ b/master/Kbuild	Fri Oct 13 09:38:23 2006 +0000
@@ -38,7 +38,11 @@
 obj-m := ec_master.o
 
 ec_master-objs := module.o master.o device.o slave.o datagram.o \
-		domain.o mailbox.o ethernet.o debug.o fsm.o xmldev.o
+		domain.o mailbox.o ethernet.o fsm.o xmldev.o
+
+ifeq ($(EC_DBG_IF),1)
+	ec_master-objs += debug.o
+endif
 
 REV := $(shell if test -s $(src)/../svnrevision; then \
 		cat $(src)/../svnrevision; \
--- a/master/Makefile.am	Fri Oct 13 09:05:45 2006 +0000
+++ b/master/Makefile.am	Fri Oct 13 09:38:23 2006 +0000
@@ -52,7 +52,8 @@
 	xmldev.c xmldev.h
 
 all:
-	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
+	$(MAKE) -C "$(LINUX_SOURCE_DIR)" \
+		M="@abs_srcdir@" EC_DBG_IF="$(EC_DBG_IF)" modules
 
 clean-local:
 	$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
--- a/master/device.c	Fri Oct 13 09:05:45 2006 +0000
+++ b/master/device.c	Fri Oct 13 09:38:23 2006 +0000
@@ -71,14 +71,20 @@
     device->open = 0;
     device->link_state = 0; // down
 
+#ifdef EC_DBG_IF
     if (ec_debug_init(&device->dbg)) {
         EC_ERR("Failed to init debug device!\n");
         goto out_return;
     }
+#endif
 
     if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
         EC_ERR("Error allocating device socket buffer!\n");
+#ifdef EC_DBG_IF
         goto out_debug;
+#else
+        goto out_return;
+#endif
     }
 
     device->tx_skb->dev = net_dev;
@@ -92,8 +98,10 @@
 
     return 0;
 
+#ifdef EC_DBG_IF
  out_debug:
     ec_debug_clear(&device->dbg);
+#endif
  out_return:
     return -1;
 }
@@ -108,7 +116,9 @@
 {
     if (device->open) ec_device_close(device);
     if (device->tx_skb) dev_kfree_skb(device->tx_skb);
+#ifdef EC_DBG_IF
     ec_debug_clear(&device->dbg);
+#endif
 }
 
 /*****************************************************************************/
@@ -201,7 +211,9 @@
         ec_print_data(device->tx_skb->data + ETH_HLEN, size);
     }
 
+#ifdef EC_DBG_IF
     ec_debug_send(&device->dbg, device->tx_skb->data, ETH_HLEN + size);
+#endif
 
     // start sending
     device->dev->hard_start_xmit(device->tx_skb, device->dev);
@@ -243,7 +255,9 @@
                            data + ETH_HLEN, size - ETH_HLEN);
     }
 
+#ifdef EC_DBG_IF
     ec_debug_send(&device->dbg, data, size);
+#endif
 
     ec_master_receive_datagrams(device->master,
                                 data + ETH_HLEN,
--- a/master/device.h	Fri Oct 13 09:05:45 2006 +0000
+++ b/master/device.h	Fri Oct 13 09:38:23 2006 +0000
@@ -46,7 +46,10 @@
 #include "../include/ecrt.h"
 #include "../devices/ecdev.h"
 #include "globals.h"
+
+#ifdef EC_DBG_IF
 #include "debug.h"
+#endif
 
 /*****************************************************************************/
 
@@ -65,7 +68,9 @@
     ec_isr_t isr; /**< pointer to the device's interrupt service routine */
     struct module *module; /**< pointer to the device's owning module */
     uint8_t link_state; /**< device link state */
+#ifdef EC_DBG_IF
     ec_debug_t dbg; /**< debug device */
+#endif
 };
 
 /*****************************************************************************/
--- a/master/globals.h	Fri Oct 13 09:05:45 2006 +0000
+++ b/master/globals.h	Fri Oct 13 09:38:23 2006 +0000
@@ -43,6 +43,8 @@
 
 #include <linux/types.h>
 
+#include "../config.h"
+
 /******************************************************************************
  *  EtherCAT master
  *****************************************************************************/