Commit 2dea04704ac1970b3a0f072555cd42d9d02caf0e

Con Kolivas 2013-04-18T12:49:31

Merge branch 'master' of github.com:ckolivas/cgminer

diff --git a/Makefile.am b/Makefile.am
index c9070b2..2417fbe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,6 +33,8 @@ else
 cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@ @LIBUSB_CFLAGS@ @LIBCURL_CFLAGS@
 endif
 
+cgminer_CPPFLAGS += $(ADL_CPPFLAGS)
+
 # common sources
 cgminer_SOURCES := cgminer.c
 
diff --git a/autogen.sh b/autogen.sh
index e922cfc..8bb94c3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,17 +1,11 @@
 #!/bin/sh
-cwd="$PWD"
 bs_dir="$(dirname $(readlink -f $0))"
 rm -rf "${bs_dir}"/autom4te.cache
 rm -f "${bs_dir}"/aclocal.m4 "${bs_dir}"/ltmain.sh
 
 echo 'Running autoreconf -if...'
-autoreconf -if || exit 1
+autoreconf -if ${AC_FLAGS} "${bs_dir}" || exit 1
 if test -z "$NOCONFIGURE" ; then
 	echo 'Configuring...'
-	cd "${bs_dir}" &> /dev/null
-	test "$?" = "0" || e=1
-	test "$cwd" != "$bs_dir" && cd "$bs_dir" &> /dev/null
-	./configure $@
-	test "$e" = "1" && exit 1
-	cd "$cwd"
+	"$bs_dir"/configure "$@"
 fi
diff --git a/ccan/Makefile.am b/ccan/Makefile.am
index 1514f6f..a667df3 100644
--- a/ccan/Makefile.am
+++ b/ccan/Makefile.am
@@ -1,3 +1,4 @@
 noinst_LIBRARIES	= libccan.a
 
 libccan_a_SOURCES	= compiler/compiler.h opt/helpers.c opt/opt.c opt/opt.h opt/parse.c opt/private.h opt/usage.c typesafe_cb/typesafe_cb.h
+libccan_a_CPPFLAGS	= -I$(top_srcdir)
diff --git a/configure.ac b/configure.ac
index c7bd873..6c2b3c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,13 @@ if test "x$have_win32" != xtrue; then
 	fi
 fi
 
+have_cgminer_sdk=false
+if test -n "$CGMINER_SDK"; then
+	have_cgminer_sdk=true
+	CPPFLAGS="-I$CGMINER_SDK/include $CPPFLAGS"
+	LDFLAGS="-L$CGMINER_SDK/lib/$target $LDFLAGS"
+fi
+
 cpumining="no"
 
 AC_ARG_ENABLE([cpumining],,[cpumining=$enableval]	)
@@ -186,7 +193,11 @@ scrypt="no"
 
 if test "$found_opencl" = 1; then
 	if test "x$adl" != xno; then
-		AC_CHECK_FILE([${ADL_SDK:-ADL_SDK}/adl_sdk.h], have_adl=true, have_adl=false,)
+		ADL_CPPFLAGS=
+		AC_CHECK_FILE([$srcdir/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$srcdir], have_adl=false,)
+		if test x$have_adl+$have_cgminer_sdk = xfalse+true; then
+			AC_CHECK_FILE([$CGMINER_SDK/include/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$CGMINER_SDK/include], have_adl=false,)
+		fi
 		if test x$have_adl = xtrue
 		then
 			AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found])
@@ -386,6 +397,16 @@ AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
 
 PKG_PROG_PKG_CONFIG()
 
+if test "x$have_cgminer_sdk" = "xtrue"; then
+	if test "x$have_x86_64" = xtrue; then
+		ARCH_DIR=x86_64
+	else
+		ARCH_DIR=x86
+	fi
+	PKG_CONFIG="${PKG_CONFIG:-pkg-config} --define-variable=arch=$ARCH_DIR --define-variable=target=$target --define-variable=cgminersdkdir=$CGMINER_SDK"
+	PKG_CONFIG_PATH="$CGMINER_SDK/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
+fi
+
 if test "x$ztex$modminer$bitforce$bflsc" != xnononono; then
   case $target in
     *-*-freebsd*)
@@ -475,6 +496,7 @@ AC_SUBST(WS2_LIBS)
 AC_SUBST(MATH_LIBS)
 AC_SUBST(UDEV_LIBS)
 AC_SUBST(YASM_FMT)
+AC_SUBST(ADL_CPPFLAGS)
 
 AC_CONFIG_FILES([
 	Makefile