1# GA_ARG_PARSE(ARG, VAR_LIBS, VAR_LDFLAGS, VAR_CPPFLAGS) 2# ------------------------------------------------------ 3# Parse whitespace-separated ARG into appropriate LIBS, LDFLAGS, and 4# CPPFLAGS variables. 5# some examples (not exhaustive): 6# $arg="/apps/mpi/hp/2.03.01.00/include/64 /apps/mpi/hp/2.03.01.00/lib/linux_amd64 -lmtmpi" 7# $arg="/usr/local" 8# $arg="-I/usr/local/include -L/usr/local/lib -lsomelib" 9# $arg="/usr/lib/mpich-shmem -lfmpich-shmem -lmpich-shmem -lpmpich-shmem" 10# $arg="/usr/lib/mpich-shmem/include /usr/lib/mpich-shmem/lib -lfmpich-shmem -lmpich-shmem -lpmpich-shmem" 11# $arg="/usr/local/lib64 /usr/local/include64" 12# 13# Special Cases: 14# -mkl[=arg] Intel compiler with special -mkl flag for headers and linking 15AC_DEFUN([GA_ARG_PARSE], 16[AC_COMPUTE_INT([ga_arg_parse_sizeof_voidp], [(long int) (sizeof (void*))]) 17for arg in $$1 ; do 18 AS_CASE([$arg], 19 [yes], [], 20 [no], [], 21 [-l*], [$2="$$2 $arg"], 22 [-L*], [$3="$$3 $arg"], 23 [-WL*], [$3="$$3 $arg"], 24 [-Wl*], [$3="$$3 $arg"], 25 [-I*], [$4="$$4 $arg"], 26 [*.a], [$2="$$2 $arg"], 27 [*.so], [$2="$$2 $arg"], 28 [*lib], [AS_IF([test -d $arg], [$3="$$3 -L$arg"], 29 [AC_MSG_WARN([$arg of $1 not parsed])])], 30 [*lib/], [AS_IF([test -d $arg], [$3="$$3 -L$arg"], 31 [AC_MSG_WARN([$arg of $1 not parsed])])], 32 [*lib64], [AS_IF([test -d $arg], [$3="$$3 -L$arg"], 33 [AC_MSG_WARN([$arg of $1 not parsed])])], 34 [*lib64/], [AS_IF([test -d $arg], [$3="$$3 -L$arg"], 35 [AC_MSG_WARN([$arg of $1 not parsed])])], 36 [*include], [AS_IF([test -d $arg], [$4="$$4 -I$arg"], 37 [AC_MSG_WARN([$arg of $1 not parsed])])], 38 [*include/], [AS_IF([test -d $arg], [$4="$$4 -I$arg"], 39 [AC_MSG_WARN([$arg of $1 not parsed])])], 40 [*include64], [AS_IF([test -d $arg], [$4="$$4 -I$arg"], 41 [AC_MSG_WARN([$arg of $1 not parsed])])], 42 [*include64/], [AS_IF([test -d $arg], [$4="$$4 -I$arg"], 43 [AC_MSG_WARN([$arg of $1 not parsed])])], 44 [-mkl*], [$2="$$2 $arg"], 45 [ga_arg_parse_ok=no]) 46# $arg didn't fit the most common cases 47# check for subdirectories e.g. lib,include 48 AS_IF([test "x$ga_arg_parse_ok" = xno], 49 [AS_IF([test "x$ga_arg_parse_sizeof_voidp" = x8], 50 [AS_IF([test -d $arg/lib64], [$3="$$3 -L$arg/lib64"; ga_arg_parse_ok=yes], 51 [test -d $arg/lib], [$3="$$3 -L$arg/lib"; ga_arg_parse_ok=yes]) 52 AS_IF([test -d $arg/include64],[$4="$$4 -I$arg/include64"; ga_arg_parse_ok=yes], 53 [test -d $arg/include], [$4="$$4 -I$arg/include"; ga_arg_parse_ok=yes])], 54 [AS_IF([test -d $arg/lib], [$3="$$3 -L$arg/lib"; ga_arg_parse_ok=yes]) 55 AS_IF([test -d $arg/include], [$4="$$4 -I$arg/include"; ga_arg_parse_ok=yes])])]) 56# $arg still unknown, look for "lib" and "include" anywhere... 57 AS_IF([test "x$ga_arg_parse_ok" = xno], 58 [AS_CASE([$arg], 59 [*lib*], [AS_IF([test -d $arg], [$3="$$3 -L$arg"; ga_arg_parse_ok=yes])], 60 [*include*],[AS_IF([test -d $arg], [$4="$$4 -I$arg"; ga_arg_parse_ok=yes])])]) 61# warn user that $arg fell through 62 AS_IF([test "x$ga_arg_parse_ok" = xno], 63 [AC_MSG_WARN([$arg of $1 not parsed])]) 64done])dnl 65