Blame confdb/aclocal_libs.m4

Packit 0848f5
Packit 0848f5
dnl PAC_SET_HEADER_LIB_PATH(with_option,[default_path])
Packit 0848f5
dnl This macro looks for the --with-xxx=, --with-xxx-include and --with-xxx-lib=
Packit 0848f5
dnl options and sets the library and include paths.
Packit 0848f5
dnl
Packit 0848f5
dnl TODO as written, this macro cannot handle a "with_option" arg that has "-"
Packit 0848f5
dnl characters in it.  Use AS_TR_SH (and possibly AS_VAR_* macros) to handle
Packit 0848f5
dnl this case if it ever arises.
Packit 0848f5
AC_DEFUN([PAC_SET_HEADER_LIB_PATH],[
Packit 0848f5
    AC_ARG_WITH([$1],
Packit 0848f5
                [AC_HELP_STRING([--with-$1=PATH],
Packit 0848f5
                                [specify path where $1 include directory and lib directory can be found])],
Packit 0848f5
Packit 0848f5
                [AS_CASE(["$withval"],
Packit 0848f5
                         [yes|no|''],
Packit 0848f5
                         [AC_MSG_WARN([--with[out]-$1=PATH expects a valid PATH])
Packit 0848f5
                          with_$1=""])],
Packit 0848f5
                [with_$1=$2])
Packit 0848f5
    AC_ARG_WITH([$1-include],
Packit 0848f5
                [AC_HELP_STRING([--with-$1-include=PATH],
Packit 0848f5
                                [specify path where $1 include directory can be found])],
Packit 0848f5
                [AS_CASE(["$withval"],
Packit 0848f5
                         [yes|no|''],
Packit 0848f5
                         [AC_MSG_WARN([--with[out]-$1-include=PATH expects a valid PATH])
Packit 0848f5
                          with_$1_include=""])],
Packit 0848f5
                [])
Packit 0848f5
    AC_ARG_WITH([$1-lib],
Packit 0848f5
                [AC_HELP_STRING([--with-$1-lib=PATH],
Packit 0848f5
                                [specify path where $1 lib directory can be found])],
Packit 0848f5
                [AS_CASE(["$withval"],
Packit 0848f5
                         [yes|no|''],
Packit 0848f5
                         [AC_MSG_WARN([--with[out]-$1-lib=PATH expects a valid PATH])
Packit 0848f5
                          with_$1_lib=""])],
Packit 0848f5
                [])
Packit 0848f5
Packit 0848f5
    # The args have been sanitized into empty/non-empty values above.
Packit 0848f5
    # Now append -I/-L args to CPPFLAGS/LDFLAGS, with more specific options
Packit 0848f5
    # taking priority
Packit 0848f5
Packit 0848f5
    AS_IF([test -n "${with_$1_include}"],
Packit 0848f5
          [PAC_APPEND_FLAG([-I${with_$1_include}],[CPPFLAGS])],
Packit 0848f5
          [AS_IF([test -n "${with_$1}"],
Packit 0848f5
                 [PAC_APPEND_FLAG([-I${with_$1}/include],[CPPFLAGS])])])
Packit 0848f5
Packit 0848f5
    AS_IF([test -n "${with_$1_lib}"],
Packit 0848f5
          [PAC_APPEND_FLAG([-L${with_$1_lib}],[LDFLAGS])],
Packit 0848f5
          [AS_IF([test -n "${with_$1}"],
Packit 0848f5
                 dnl is adding lib64 by default really the right thing to do?  What if
Packit 0848f5
                 dnl we are on a 32-bit host that happens to have both lib dirs available?
Packit 0848f5
                 [PAC_APPEND_FLAG([-L${with_$1}/lib],[LDFLAGS])
Packit 0848f5
                  AS_IF([test -d "${with_$1}/lib64"],
Packit 0848f5
		        [PAC_APPEND_FLAG([-L${with_$1}/lib64],[LDFLAGS])])
Packit 0848f5
                 ])
Packit 0848f5
          ])
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
Packit 0848f5
dnl PAC_CHECK_HEADER_LIB(header.h, libname, function, action-if-yes, action-if-no)
Packit 0848f5
dnl This macro checks for a header and lib.  It is assumed that the
Packit 0848f5
dnl user can specify a path to the includes and libs using --with-xxx=.
Packit 0848f5
dnl The xxx is specified in the "with_option" parameter.
Packit 0848f5
dnl
Packit 0848f5
dnl NOTE: This macro expects a corresponding PAC_SET_HEADER_LIB_PATH
Packit 0848f5
dnl macro (or equivalent logic) to be used before this macro is used.
Packit 0848f5
AC_DEFUN([PAC_CHECK_HEADER_LIB],[
Packit 0848f5
    failure=no
Packit 0848f5
    AC_CHECK_HEADER([$1],,failure=yes)
Packit 0848f5
    AC_CHECK_LIB($2,$3,,failure=yes)
Packit 0848f5
    if test "$failure" = "no" ; then
Packit 0848f5
       $4
Packit 0848f5
    else
Packit 0848f5
       $5
Packit 0848f5
    fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_CHECK_HEADER_LIB_FATAL(with_option, header.h, libname, function)
Packit 0848f5
dnl Similar to PAC_CHECK_HEADER_LIB, but errors out on failure
Packit 0848f5
AC_DEFUN([PAC_CHECK_HEADER_LIB_FATAL],[
Packit 0848f5
	PAC_CHECK_HEADER_LIB($2,$3,$4,success=yes,success=no)
Packit 0848f5
	if test "$success" = "no" ; then
Packit 0848f5
	   AC_MSG_ERROR(['$2 or lib$3 library not found. Did you specify --with-$1= or --with-$1-include= or --with-$1-lib=?'])
Packit 0848f5
	fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_CHECK_PREFIX(with_option,prefixvar)
Packit 0848f5
AC_DEFUN([PAC_CHECK_PREFIX],[
Packit 0848f5
	AC_ARG_WITH([$1-prefix],
Packit 0848f5
            [AS_HELP_STRING([[--with-$1-prefix[=DIR]]], [use the $1
Packit 0848f5
                            library installed in DIR, rather than the
Packit 0848f5
                            one included in the distribution.  Pass
Packit 0848f5
                            "embedded" to force usage of the included
Packit 0848f5
                            $1 source.])],
Packit 0848f5
            [if test "$withval" = "system" ; then
Packit 0848f5
                 :
Packit 0848f5
             elif test "$withval" = "embedded" ; then
Packit 0848f5
                 :
Packit 0848f5
             else
Packit 0848f5
                 PAC_APPEND_FLAG([-I${with_$1_prefix}/include],[CPPFLAGS])
Packit 0848f5
                 if test -d "${with_$1_prefix}/lib64" ; then
Packit 0848f5
                     PAC_APPEND_FLAG([-L${with_$1_prefix}/lib64],[LDFLAGS])
Packit 0848f5
                 fi
Packit 0848f5
                 PAC_APPEND_FLAG([-L${with_$1_prefix}/lib],[LDFLAGS])
Packit 0848f5
             fi
Packit 0848f5
             ],
Packit 0848f5
            [with_$1_prefix="embedded"])
Packit 0848f5
	]
Packit 0848f5
)