Browse Source

configure: Deduplicate Linux i2c-dev.h checks for KnCMiner drivers

Luke Dashjr 11 years ago
parent
commit
5feff7bb77
1 changed files with 21 additions and 42 deletions
  1. 21 42
      configure.ac

+ 21 - 42
configure.ac

@@ -124,6 +124,7 @@ has_asic=no
 need_binloader=no
 need_dynclock=no
 need_gc3355=no
+need_linux_i2c_dev=no
 need_lowl_vcom=no
 need_lowlevel=no
 need_lowl_ftdi=no
@@ -600,20 +601,7 @@ AC_ARG_ENABLE([knc],
 	[knc=$ddno]
 	)
 if test "x$knc" = xyes; then
-	AC_CHECK_HEADERS([linux/i2c-dev-user.h])
-	AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[
-		AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools/libi2c-dev (NOT linux headers) is required for knc driver])
-	],[
-		#include <stddef.h>
-		#ifdef HAVE_LINUX_I2C_DEV_USER_H
-		#include <linux/i2c-dev-user.h>
-		#else
-		#ifdef NEED_LINUX_I2C_H
-		#include <linux/i2c.h>
-		#endif
-		#include <linux/i2c-dev.h>
-		#endif
-	])
+	need_linux_i2c_dev=yes
 	AC_DEFINE([USE_KNC], [1], [Defined to 1 if KnC support is wanted])
 	need_lowl_spi=yes
 fi
@@ -631,20 +619,7 @@ if test "x$kncasic" != xno && test "x$kncasic" != xauto; then
 		kncasic_controller=BBB
 	fi
 	kncasic=yes
-	AC_CHECK_HEADERS([linux/i2c-dev-user.h])
-	AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[
-		AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools/libi2c-dev (NOT linux headers) is required for knc driver])
-	],[
-		#include <stddef.h>
-		#ifdef HAVE_LINUX_I2C_DEV_USER_H
-		#include <linux/i2c-dev-user.h>
-		#else
-		#ifdef NEED_LINUX_I2C_H
-		#include <linux/i2c.h>
-		#endif
-		#include <linux/i2c-dev.h>
-		#endif
-	])
+	need_linux_i2c_dev=yes
 	AC_DEFINE([USE_KNCASIC], [1], [Defined to 1 if KnC gen 2 support is wanted])
 	AC_DEFINE_UNQUOTED([CONTROLLER_BOARD_$titan_controller],[1])
 	AH_TEMPLATE([CONTROLLER_BOARD_BACKPLANE])
@@ -843,20 +818,7 @@ if test "x$titan" != xno && test "x$titan" != xauto; then
 	if test "x$scrypt" = "xno"; then
 		AC_MSG_ERROR([You explicitly enabled KnC Titan, but did not enable scrypt])
 	fi
-	AC_CHECK_HEADERS([linux/i2c-dev-user.h])
-	AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[
-		AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools/libi2c-dev (NOT linux headers) is required for titan driver])
-	],[
-		#include <stddef.h>
-		#ifdef HAVE_LINUX_I2C_DEV_USER_H
-		#include <linux/i2c-dev-user.h>
-		#else
-		#ifdef NEED_LINUX_I2C_H
-		#include <linux/i2c.h>
-		#endif
-		#include <linux/i2c-dev.h>
-		#endif
-	])
+	need_linux_i2c_dev=yes
 	AC_DEFINE([USE_TITAN], [1], [Defined to 1 if KnC Titan support is wanted])
 	AC_DEFINE_UNQUOTED([CONTROLLER_BOARD_$titan_controller],[1])
 	AH_TEMPLATE([CONTROLLER_BOARD_BACKPLANE])
@@ -1390,6 +1352,23 @@ if test x$need_lowlevel = xyes; then
 	AC_DEFINE([HAVE_BFG_LOWLEVEL], [1], [Defined to 1 if lowlevel drivers are being used])
 fi
 
+if test x$need_linux_i2c_dev = xyes; then
+	AC_CHECK_HEADERS([linux/i2c-dev-user.h])
+	AC_CHECK_DECL([i2c_smbus_read_word_data],[true],[
+		AC_MSG_ERROR([linux/i2c-dev.h header from i2c-tools/libi2c-dev (NOT linux headers) is required for KnCMiner drivers])
+	],[
+		#include <stddef.h>
+		#ifdef HAVE_LINUX_I2C_DEV_USER_H
+		#include <linux/i2c-dev-user.h>
+		#else
+		#ifdef NEED_LINUX_I2C_H
+		#include <linux/i2c.h>
+		#endif
+		#include <linux/i2c-dev.h>
+		#endif
+	])
+fi
+
 
 curses="auto"