Blame confdb/aclocal_libs.m4

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