# Process this file with autoconf to produce a configure script.
# File: components/libmsr/configure.in

AC_INIT

AC_ARG_WITH(libmsr_incdir,
           [  --with-libmsr-incdir=<path>         Specify directory of libmsr header files (libmsr.h) in a specific location ],
           [libmsr_incdir=$withval])
AC_ARG_WITH(libmsr_libdir,
           [  --with-libmsr-libdir=<path>         Specify directory of libmsr library (libmsr.a or libmsr.so) in a specific location ],
           [libmsr_libdir=$withval])

if test "x$libmsr_libdir" != "x"; then
    LIBS="-L$libmsr_libdir"
    libmsr_dotest=1
fi
if test "x$libmsr_incdir" != "x"; then
    CPPFLAGS="-I$libmsr_incdir"
    libmsr_dotest=1
fi

CFLAGS="$CFLAGS -I$libmsr_incdir"
AC_CHECK_HEADER( [msr/msr_rapl.h], [], [AC_MSG_ERROR([libmsr component: msr/msr_rapl.h not found: use configure flags to set the path ])], )
LDFLAGS="$LDFLAGS -L$libmsr_libdir -Wl,-rpath,$libmsr_libdir" 
AC_CHECK_LIB( [msr], [init_msr], [], [AC_MSG_ERROR([libmsr component: libmsr.so not found: use configure flags to set the path])] )
LIBMSR_INCDIR=$libmsr_incdir
LIBMSR_LIBDIR=$libmsr_libdir

AC_CONFIG_FILES([Makefile.libmsr])
AC_SUBST(LIBMSR_INCDIR)
AC_SUBST(LIBMSR_LIBDIR)
AC_SUBST(CUDA_DIR)
AC_OUTPUT
