diff options
| author | Antonin Descampe <antonin@gmail.com> | 2011-08-15 13:25:58 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2011-08-15 13:25:58 +0000 |
| commit | 61e0ed6a964bf068a26a072298f5e0a3664461f0 (patch) | |
| tree | 255ce7610b77587e42feba60f946d1a6fdcd9f22 /m4 | |
| parent | 9c7899372b0dd76aa6ef92eeb7a414ddcf71afbe (diff) | |
backport r868 to openjpeg-1.5 branch
Diffstat (limited to 'm4')
| -rw-r--r-- | m4/opj_check_lib.m4 | 112 |
1 files changed, 92 insertions, 20 deletions
diff --git a/m4/opj_check_lib.m4 b/m4/opj_check_lib.m4 index e401f8e1..a92d2622 100644 --- a/m4/opj_check_lib.m4 +++ b/m4/opj_check_lib.m4 @@ -3,12 +3,12 @@ dnl That code is public domain and can be freely used or copied. dnl Macro that check if a library is in a specified directory. -dnl Usage: OPJ_CHECK_LIB(prefix, header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Usage: OPJ_CHECK_LIB_WITH_PREFIX(prefix, header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl Call AC_SUBST(THELIB_CFLAGS) dnl Call AC_SUBST(THELIB_LIBS) dnl where THELIB is the uppercase value of 'lib' -AC_DEFUN([OPJ_CHECK_LIB], +AC_DEFUN([OPJ_CHECK_LIB_WITH_PREFIX], [ m4_pushdef([UP], m4_toupper([$3])) @@ -21,36 +21,108 @@ __opj_func=$4 __opj_have_dep="no" save_CPPFLAGS=${CPPFLAGS} -CPPFLAGS="${CPPFLAGS} -I${__opj_prefix}/include" -AC_CHECK_HEADER([${__opj_header}], [__opj_have_dep="yes"], [__opj_have_dep="no"]) -CPPFLAGS=${save_CPPFLAGS} +save_LDFLAGS=${LDFLAGS} +save_LIBS=${LIBS} -if test "x${__opj_have_dep}" = "xyes" ; then - save_LDFLAGS=${LDFLAGS} +if test "x${__opj_prefix}" = "x" ; then + CPPFLAGS="${CPPFLAGS} $UP[_CFLAGS]" + LDFLAGS="${LDFLAGS} $UP[_LIBS]" +else + CPPFLAGS="${CPPFLAGS} -I${__opj_prefix}/include" LDFLAGS="${LDFLAGS} -L${__opj_prefix}/lib" - AC_CHECK_LIB([${__opj_lib}], - [${__opj_func}], - [__opj_have_dep="yes"], - [__opj_have_dep="no"]) - LDFLAGS=${save_LDFLAGS} + LIBS="${LIBS} -l${__opj_lib}" +fi + +AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <${__opj_header}> + ]], + [[ +${__opj_func}(); + ]])], + [__opj_have_dep="yes"], + [__opj_have_dep="no"]) + +CPPFLAGS=${save_CPPFLAGS} +LDFLAGS=${save_LDFLAGS} +LIBS=${save_LIBS} + +if test "x${__opj_prefix}" = "x" ; then + AC_MSG_CHECKING([whether ]UP[ library is available in standard or predefined directories]) +else + AC_MSG_CHECKING([whether ]UP[ library is available in ${__opj_prefix}]) fi +AC_MSG_RESULT([${__opj_have_dep}]) -if test "x${__opj_have_dep}" = "xyes" ; then - if ! test "x$1" = "x/usr" ; then +if test "x${__opj_have_dep}" = "xyes" && ! test "x${__opj_prefix}" = "x"; then + if test "x${UP[]_CFLAGS}" = "x" ; then UP[]_CFLAGS="-I${__opj_prefix}/include" - UP[]_LIBS="-L${__opj_prefix}/lib" fi - UP[]_LIBS="${UP[]_LIBS} -l${__opj_lib}" + if test "x${UP[]_LIBS}" = "x" ; then + UP[]_LIBS="-L${__opj_prefix}/lib -l${__opj_lib}" + fi +fi + +AS_IF([test "x${__opj_have_dep}" = "xyes"], [$5], [$6]) + +m4_popdef([UP]) +m4_popdef([DOWN]) + +]) + +dnl Macro that check if a library is in a set of directories. + +dnl Usage: OPJ_CHECK_LIB(header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) + +AC_DEFUN([OPJ_CHECK_LIB], +[ + +m4_pushdef([UP], m4_toupper([$2])) + +__opj_have_dep="no" + +OPJ_CHECK_LIB_WITH_PREFIX([], + [$1], + [$2], + [$3], + [__opj_have_dep="yes"], + [__opj_have_dep="no"]) + +if ! test "x${__opj_have_dep}" = "xyes" ; then + OPJ_CHECK_LIB_WITH_PREFIX([/usr], + [$1], + [$2], + [$3], + [__opj_have_dep="yes"], + [__opj_have_dep="no"]) fi -AC_ARG_VAR(UP[_CFLAGS], [preprocessor flags for lib$3]) +if ! test "x${__opj_have_dep}" = "xyes" ; then + OPJ_CHECK_LIB_WITH_PREFIX([/usr/local], + [$1], + [$2], + [$3], + [__opj_have_dep="yes"], + [__opj_have_dep="no"]) +fi + +if ! test "x${__opj_have_dep}" = "xyes" ; then + OPJ_CHECK_LIB_WITH_PREFIX([/opt/local], + [$1], + [$2], + [$3], + [__opj_have_dep="yes"], + [__opj_have_dep="no"]) +fi + +AC_ARG_VAR(UP[_CFLAGS], [preprocessor flags for lib$2]) AC_SUBST(UP[_CFLAGS]) -AC_ARG_VAR(UP[_LIBS], [linker flags for lib$3]) +AC_ARG_VAR(UP[_LIBS], [linker flags for lib$2]) AC_SUBST(UP[_LIBS]) -AS_IF([test "x${__opj_have_dep}" = "xyes"], [$5], [$6]) +AS_IF([test "x${__opj_have_dep}" = "xyes"], [$4], [$5]) m4_popdef([UP]) -m4_popdef([DOWN]) ]) |
