Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 102 lines (87 sloc) 2.93 kb
3c3c591 @stefanocasazza clean history
authored
1 ####################################################################################
2 # ULib.m4 - Example autoconf macro showing how to find ULib library and header files
3 ####################################################################################
4
5 dnl @synopsis AC_ULIB
6 dnl
7 dnl This macro tries to find the ULib library and header files.
8 dnl
9 dnl We define the following configure script flags:
10 dnl
11 dnl --with-ulib: Give prefix for both library and headers, and try to guess subdirectory names for each.
12 dnl
13 dnl --with-ulib-lib: Similar to --with-ulib, but for library only.
14 dnl --with-ulib-include: Similar to --with-ulib, but for headers only.
15
16 AC_DEFUN([AC_ULIB],[
17 AC_CACHE_CHECK([for ULib library stuff], ac_cv_ulib,
18 [ # Set up configure script macros
19 AC_ARG_WITH(ulib,
20 [ --with-ulib=<path> path containing ULib header and library subdirs],
21 [ULIB_lib_check="$with_ulib/lib $with_ulib/lib/ulib"
22 ULIB_inc_check="$with_ulib/include $with_ulib/include/ulib"],
23 [ULIB_lib_check="/usr/local/ulib/lib /usr/local/lib/ulib /opt/ulib/lib /usr/lib/ulib /usr/local/lib /usr/lib"
24 ULIB_inc_check="/usr/local/ulib/include /usr/local/include/ulib /opt/ulib/include /usr/local/include/ulib /usr/local/include /usr/include/ulib /usr/include"])
25 AC_ARG_WITH(ulib-lib,
26 [ --with-ulib-lib=<path> directory path of ULib library],
27 [ULIB_lib_check="$with_ulib_lib $with_ulib_lib/lib $with_ulib_lib/lib/ulib"])
28 AC_ARG_WITH(ulib-include,
29 [ --with-ulib-include=<path> directory path of ULib headers],
30 [ULIB_inc_check="$with_ulib_include $with_ulib_include/include $with_ulib_include/include/ulib"])
31
32 #
33 # Look for ULib library
34 #
35 ULIB_libdir=
36 for dir in $ULIB_lib_check
37 do
38 if test -d "$dir" && \
39 ( test -f "$dir/libulib.so" ||
40 test -f "$dir/libulib.a" )
41 then
42 ULIB_libdir=$dir
43 break
44 fi
45 done
46
47 if test -z "$ULIB_libdir"
48 then
49 AC_MSG_ERROR([Didn't find the ULib library dir in '$ULIB_lib_check'])
50 fi
51
52 case "$ULIB_libdir" in
53 /* ) ;;
54 * ) AC_MSG_ERROR([The ULib library directory ($ULIB_libdir) must be an absolute path.]) ;;
55 esac
56
57 AC_MSG_RESULT([lib in $ULIB_libdir])
58
59 case "$ULIB_libdir" in
60 /usr/lib) ;;
61 *) LDFLAGS="$LDFLAGS -L${ULIB_libdir}" ;;
62 esac
63
64 #
65 # Look for ULib headers
66 #
67 AC_MSG_CHECKING([for ULib header directory])
68 ULIB_incdir=
69 for dir in $ULIB_inc_check
70 do
71 if test -d "$dir" && test -f "$dir/all.h"
72 then
73 ULIB_incdir=$dir
74 break
75 fi
76 done
77
78 if test -z "$ULIB_incdir"
79 then
80 AC_MSG_ERROR([Didn't find the ULib header dir in '$ULIB_inc_check'])
81 fi
82
83 case "$ULIB_incdir" in
84 /* ) ;;
85 * ) AC_MSG_ERROR([The ULib header directory ($ULIB_incdir) must be an absolute path.]) ;;
86 esac
87
88 AC_MSG_RESULT([$ULIB_incdir])
89
90 CPPFLAGS="$CPPFLAGS -I${ULIB_incdir}"
91
92 AC_MSG_CHECKING([that we can build ULib programs])
93 AC_COMPILE_IFELSE(
94 [AC_LANG_PROGRAM([#include <all.h>],
95 [UString s; s.c_str();])],
96 ac_cv_ulib=yes,
97 AC_MSG_ERROR(no))
98 ])
99 ])
100 dnl End ULIB
101
Something went wrong with that request. Please try again.