# Process this file with autoconf to produce a configure script.
# File: components/infiniband/configure.in
# CVS: $Id$

AC_INIT


# looking for infiniband ibumad packages header file and library
AC_ARG_WITH(infiniband_ibumad_dir,
			[  --with-infiniband_ibumad_dir=<path>  Specify path to InfiniBand ibumad root directory ],
			[case "$with_infiniband_ibumad_dir" in 
			yes|''|no) AC_MSG_ERROR([--with-infiniband_ibumad_dir requires a path]) ;;
			*) infiniband_ibumad_dir=$with_infiniband_ibumad_dir ;;
			esac],
			[infiniband_ibumad_dir="/usr/include/infiniband"])

CFLAGS="$CFLAGS -I$infiniband_ibumad_dir/include"
AC_CHECK_HEADERS([infiniband/umad.h],
				 [AC_DEFINE([HAVE_INFINIBAND_H], [1], [infiniband header] )],
				 [AC_MSG_ERROR([umad.h not found. See --with-infiniband_ibumad_dir ])],
				 [#include <infiniband/umad.h>])
				 
LDFLAGS="$LDFLAGS -L$infiniband_ibumad_dir/lib64 -libumad"
AC_CHECK_LIB([ibumad],
			 [umad_init],
			 [],
			 [AC_MSG_ERROR([libibumad.a is needed for the PAPI infiniband component])])


# looking for infiniband ibmad packages header file and library
AC_ARG_WITH(infiniband_ibmad_dir,
			[  --with-infiniband_ibmad_dir=<path>  Specify path to InfiniBand ibmad root directory ],
			[case "$with_infiniband_ibmad_dir" in 
			yes|''|no) AC_MSG_ERROR([--with-infiniband_ibmad_dir requires a path]) ;;
			*) infiniband_ibmad_dir=$with_infiniband_ibmad_dir ;;
			esac],
			[infiniband_ibmad_dir="/usr/include/infiniband"])

CFLAGS="$CFLAGS -I$infiniband_ibmad_dir/include"
AC_CHECK_HEADERS([infiniband/mad.h],
				 [AC_DEFINE([HAVE_INFINIBAND_H], [1], [infiniband header] )],
				 [AC_MSG_ERROR([mad.h not found. See --with-infiniband_ibmad_dir ])],
				 [#include <infiniband/mad.h>])

LDFLAGS="$LDFLAGS -L$infiniband_ibmad_dir/lib64 -libmad -L$infiniband_ibumad_dir/lib64 -libumad"
AC_CHECK_LIB([ibmad],
			 [madrpc_init],
			 [],
			 [AC_MSG_ERROR([libibmad.a is needed for the PAPI infiniband component])])


AC_SUBST(infiniband_ibmad_dir)
AC_SUBST(infiniband_ibumad_dir)
## AC_SUBST(infiniband_libdir)
AC_CONFIG_FILES([Makefile.infiniband_umad])

AC_OUTPUT
