Description: Enable MMX support in the DAHDI EC for most i386 CPUs
Author: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Bug: http://bugs.digium.com/view.php?id=13500

Enable MMX support if safe on the target CPU type (on most i386 systems,
not on x86_64). The OSLEC patch will build the module 'echo' with MMX
support if DAHDI_USE_MMX from here is defined.

Patch dahdi_mmx_auto.diff from http://bugs.digium.com/view.php?id=13500
This specific part of the fix has been rejected by upstream, as non of
the echo cancellers included there uses MMX.

See also http://bugs.debian.org/593438 before re-adding it.

--- a/drivers/dahdi/Kbuild
+++ b/drivers/dahdi/Kbuild
@@ -134,3 +134,25 @@ $(obj)/makefw: $(src)/makefw.c
 	$(HOSTCC) -o $@ $^
 
 clean-files	:= radfw.h tor2fw.h
+
+# set CONFIG_DAHDI_MMX for a number of CPU types.
+DAHDI_MMX_AUTO=yes
+DAHDI_USE_MMX=
+DAHDI_MMX_WHITELIST_x86_32 = M586MMX M686 MPENTIUMII MPENTIUMIII MPENTIUMM \
+			   MPENTIUM4 MVIAC3_2 MVIAC3_2 MK7 MK8
+
+DAHDI_MMX_WHITELIST_x86_64 =
+
+# A list of configuration variables to test: CONFIG_M686 , etc.
+DAHDI_MMX_CONFIG_VARS := $(DAHDI_MMX_WHITELIST_$(DAHDI_ARCH):%=CONFIG_%)
+
+# expand them:
+DAHDI_MMX_CONFIG_VALS := $(strip  $(foreach var,$(DAHDI_MMX_CONFIG_VARS),$(var))  )
+ifneq (,$(DAHDI_MMX_AUTO))
+  ifneq (,$(DAHDI_MMX_CONFIG_VALS))
+    DAHDI_USE_MMX=yes
+    CFLAGS_zaptel-base.o += -DCONFIG_DAHDI_MMX
+  endif
+endif
+
+export DAHDI_USE_MMX
