1 dnl Copyright (C) 2011 Vincent Torri <vtorri at univ-evry dot fr>
2 dnl That code is public domain and can be freely used or copied.
4 dnl Macro that check if a library is in a specified directory.
6 dnl Usage: OPJ_CHECK_LIB_WITH_PREFIX(prefix, header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7 dnl Call AC_SUBST(THELIB_CFLAGS)
8 dnl Call AC_SUBST(THELIB_LIBS)
9 dnl where THELIB is the uppercase value of 'lib'
11 AC_DEFUN([OPJ_CHECK_LIB_WITH_PREFIX],
14 m4_pushdef([UP], m4_toupper([$3]))
15 m4_pushdef([DOWN], m4_tolower([$3]))
23 save_CPPFLAGS=${CPPFLAGS}
24 save_LDFLAGS=${LDFLAGS}
27 if test "x${__opj_prefix}" = "x" ; then
28 CPPFLAGS="${CPPFLAGS} $UP[_CFLAGS]"
29 LDFLAGS="${LDFLAGS} $UP[_LIBS]"
31 CPPFLAGS="${CPPFLAGS} -I${__opj_prefix}/include"
32 LDFLAGS="${LDFLAGS} -L${__opj_prefix}/lib"
33 LIBS="${LIBS} -l${__opj_lib}"
39 #include <${__opj_header}>
44 [__opj_have_dep="yes"],
45 [__opj_have_dep="no"])
47 CPPFLAGS=${save_CPPFLAGS}
48 LDFLAGS=${save_LDFLAGS}
51 if test "x${__opj_prefix}" = "x" ; then
52 AC_MSG_CHECKING([whether ]UP[ library is available in standard or predefined directories])
54 AC_MSG_CHECKING([whether ]UP[ library is available in ${__opj_prefix}])
56 AC_MSG_RESULT([${__opj_have_dep}])
58 if test "x${__opj_have_dep}" = "xyes" && ! test "x${__opj_prefix}" = "x"; then
59 if test "x${UP[]_CFLAGS}" = "x" ; then
60 UP[]_CFLAGS="-I${__opj_prefix}/include"
62 if test "x${UP[]_LIBS}" = "x" ; then
63 UP[]_LIBS="-L${__opj_prefix}/lib -l${__opj_lib}"
67 AS_IF([test "x${__opj_have_dep}" = "xyes"], [$5], [$6])
74 dnl Macro that check if a library is in a set of directories.
76 dnl Usage: OPJ_CHECK_LIB(header, lib, func [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
78 AC_DEFUN([OPJ_CHECK_LIB],
81 m4_pushdef([UP], m4_toupper([$2]))
85 OPJ_CHECK_LIB_WITH_PREFIX([],
89 [__opj_have_dep="yes"],
90 [__opj_have_dep="no"])
92 if ! test "x${__opj_have_dep}" = "xyes" ; then
93 OPJ_CHECK_LIB_WITH_PREFIX([/usr],
97 [__opj_have_dep="yes"],
98 [__opj_have_dep="no"])
101 if ! test "x${__opj_have_dep}" = "xyes" ; then
102 OPJ_CHECK_LIB_WITH_PREFIX([/usr/local],
106 [__opj_have_dep="yes"],
107 [__opj_have_dep="no"])
110 if ! test "x${__opj_have_dep}" = "xyes" ; then
111 OPJ_CHECK_LIB_WITH_PREFIX([/opt/local],
115 [__opj_have_dep="yes"],
116 [__opj_have_dep="no"])
119 AC_ARG_VAR(UP[_CFLAGS], [preprocessor flags for lib$2])
120 AC_SUBST(UP[_CFLAGS])
121 AC_ARG_VAR(UP[_LIBS], [linker flags for lib$2])
124 AS_IF([test "x${__opj_have_dep}" = "xyes"], [$4], [$5])