1 2dnl PAC_SET_HEADER_LIB_PATH(with_option,[default_path]) 3dnl This macro looks for the --with-xxx=, --with-xxx-include and --with-xxx-lib= 4dnl options and sets the library and include paths. 5dnl 6dnl TODO as written, this macro cannot handle a "with_option" arg that has "-" 7dnl characters in it. Use AS_TR_SH (and possibly AS_VAR_* macros) to handle 8dnl this case if it ever arises. 9AC_DEFUN([PAC_SET_HEADER_LIB_PATH],[ 10 AC_ARG_WITH([$1], 11 [AC_HELP_STRING([--with-$1=PATH], 12 [specify path where $1 include directory and lib directory can be found])], 13 14 [AS_CASE(["$withval"], 15 [yes|no|''], 16 [AC_MSG_WARN([--with[out]-$1=PATH expects a valid PATH]) 17 with_$1=""])], 18 [with_$1=$2]) 19 AC_ARG_WITH([$1-include], 20 [AC_HELP_STRING([--with-$1-include=PATH], 21 [specify path where $1 include directory can be found])], 22 [AS_CASE(["$withval"], 23 [yes|no|''], 24 [AC_MSG_WARN([--with[out]-$1-include=PATH expects a valid PATH]) 25 with_$1_include=""])], 26 []) 27 AC_ARG_WITH([$1-lib], 28 [AC_HELP_STRING([--with-$1-lib=PATH], 29 [specify path where $1 lib directory can be found])], 30 [AS_CASE(["$withval"], 31 [yes|no|''], 32 [AC_MSG_WARN([--with[out]-$1-lib=PATH expects a valid PATH]) 33 with_$1_lib=""])], 34 []) 35 36 # The args have been sanitized into empty/non-empty values above. 37 # Now append -I/-L args to CPPFLAGS/LDFLAGS, with more specific options 38 # taking priority 39 40 AS_IF([test -n "${with_$1_include}"], 41 [PAC_APPEND_FLAG([-I${with_$1_include}],[CPPFLAGS]) 42 PAC_APPEND_FLAG([-I${with_$1_include}],[WRAPPER_CPPFLAGS])], 43 [AS_IF([test -n "${with_$1}"], 44 [PAC_APPEND_FLAG([-I${with_$1}/include],[CPPFLAGS]) 45 PAC_APPEND_FLAG([-I${with_$1}/include],[WRAPPER_CPPFLAGS])])]) 46 47 AS_IF([test -n "${with_$1_lib}"], 48 [PAC_APPEND_FLAG([-L${with_$1_lib}],[LDFLAGS]) 49 PAC_APPEND_FLAG([-L${with_$1_lib}],[WRAPPER_LDFLAGS])], 50 [AS_IF([test -n "${with_$1}"], 51 dnl is adding lib64 by default really the right thing to do? What if 52 dnl we are on a 32-bit host that happens to have both lib dirs available? 53 [PAC_APPEND_FLAG([-L${with_$1}/lib64],[LDFLAGS]) 54 PAC_APPEND_FLAG([-L${with_$1}/lib64],[WRAPPER_LDFLAGS]) 55 PAC_APPEND_FLAG([-L${with_$1}/lib],[LDFLAGS]) 56 PAC_APPEND_FLAG([-L${with_$1}/lib],[WRAPPER_LDFLAGS])])]) 57]) 58 59 60dnl PAC_CHECK_HEADER_LIB(header.h, libname, function, action-if-yes, action-if-no) 61dnl This macro checks for a header and lib. It is assumed that the 62dnl user can specify a path to the includes and libs using --with-xxx=. 63dnl The xxx is specified in the "with_option" parameter. 64dnl 65dnl NOTE: This macro expects a corresponding PAC_SET_HEADER_LIB_PATH 66dnl macro (or equivalent logic) to be used before this macro is used. 67AC_DEFUN([PAC_CHECK_HEADER_LIB],[ 68 failure=no 69 AC_CHECK_HEADER([$1],,failure=yes) 70 AC_CHECK_LIB($2,$3,,failure=yes) 71 if test "$failure" = "no" ; then 72 $4 73 else 74 $5 75 fi 76]) 77 78dnl PAC_CHECK_HEADER_LIB_FATAL(with_option, header.h, libname, function) 79dnl Similar to PAC_CHECK_HEADER_LIB, but errors out on failure 80AC_DEFUN([PAC_CHECK_HEADER_LIB_FATAL],[ 81 PAC_CHECK_HEADER_LIB($2,$3,$4,success=yes,success=no) 82 if test "$success" = "no" ; then 83 AC_MSG_ERROR(['$2 or lib$3 library not found. Did you specify --with-$1= or --with-$1-include= or --with-$1-lib=?']) 84 fi 85]) 86 87dnl PAC_CHECK_PREFIX(with_option,prefixvar) 88AC_DEFUN([PAC_CHECK_PREFIX],[ 89 AC_ARG_WITH([$1-prefix], 90 [AS_HELP_STRING([[--with-$1-prefix[=DIR]]], [use the $1 91 library installed in DIR, rather than the 92 one included in the distribution. Pass 93 "embedded" to force usage of the included 94 $1 source.])], 95 [if test "$withval" = "system" ; then 96 : 97 elif test "$withval" = "embedded" ; then 98 : 99 else 100 PAC_APPEND_FLAG([-I${with_$1_prefix}/include],[CPPFLAGS]) 101 if test -d "${with_$1_prefix}/lib64" ; then 102 PAC_APPEND_FLAG([-L${with_$1_prefix}/lib64],[LDFLAGS]) 103 fi 104 PAC_APPEND_FLAG([-L${with_$1_prefix}/lib],[LDFLAGS]) 105 fi 106 ], 107 [with_$1_prefix="embedded"]) 108 ] 109) 110