factorize m4 macros and add one to set X extensions
[free-sw/xcb/libxcb] / acinclude.m4
1 dnl Detection and configuration of the visibility feature of gcc
2 dnl Vincent Torri 2006-02-11
3 dnl
4 dnl XCB_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
5 dnl Check the visibility feature of gcc
6 dnl
7 AC_DEFUN([XCB_CHECK_VISIBILITY],
8 [
9 AC_MSG_CHECKING([whether ${CC} supports symbol visibility])
10
11 save_CFLAGS=${CFLAGS}
12 CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
13 AC_COMPILE_IFELSE(
14    [AC_LANG_PROGRAM(
15       [[
16 #pragma GCC visibility push(hidden)
17 extern void f(int);
18 #pragma GCC visibility pop
19       ]],
20       [[]]
21     )],
22    [AC_DEFINE(
23        GCC_HAS_VISIBILITY,
24        [],
25        [Defined if GCC supports the visibility feature])
26     m4_if([$1], [], [:], [$1])
27     AC_MSG_RESULT(yes)],
28    [m4_if([$2], [], [:], [$2])
29     AC_MSG_RESULT(no)])
30
31 CFLAGS=${save_CFLAGS}
32 ])
33
34 dnl Configure script for doxygen
35 dnl Vincent Torri 2006-05-11
36 dnl
37 dnl XCB_CHECK_DOXYGEN([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
38 dnl Test for the doxygen program, and define BUILD_DOCS and DOXYGEN.
39 dnl
40 AC_DEFUN([XCB_CHECK_DOXYGEN],
41 [
42 DOXYGEN="doxygen"
43
44 dnl
45 dnl Disable the build of the documentation
46 dnl
47 AC_ARG_ENABLE(
48    [build_docs],
49    AC_HELP_STRING(
50       [--disable-build-docs],
51       [Disable the build of the documentation]),
52    [if test x"$enableval" != x"yes" ; then
53        enable_build_docs="no"
54     else
55        enable_build_docs="yes"
56     fi],
57    [enable_build_docs="yes"])
58
59 if test "$enable_build_docs" = "no" ; then
60     BUILD_DOCS=no
61 else
62 dnl
63 dnl Get the prefix where doxygen is installed.
64 dnl
65 AC_ARG_WITH(
66    [doxygen],
67    AC_HELP_STRING(
68       [--with-doxygen=FILE],
69       [doxygen program to use (eg /usr/bin/doxygen)]),
70    dnl
71    dnl Check the given doxygen program.
72    dnl
73    [DOXYGEN=${withval}
74     AC_CHECK_PROG(
75        [BUILD_DOCS],
76        [${DOXYGEN}],
77        [yes],
78        [no])
79     if test $BUILD_DOCS = no; then
80        echo "WARNING:"
81        echo "The doxygen program you specified:"
82        echo "$DOXYGEN"
83        echo "was not found.  Please check the path and make sure "
84        echo "the program exists and is executable."
85        AC_MSG_WARN(
86           [Warning: no doxygen detected. Documentation will not be built])
87     fi],
88    [AC_CHECK_PROG(
89        [BUILD_DOCS],
90        [${DOXYGEN}],
91        [yes],
92        [no])
93     if test ${BUILD_DOCS} = no; then
94        echo "WARNING:"
95        echo "The doxygen program was not found in your execute"
96        echo "You may have doxygen installed somewhere not covered by your path."
97        echo ""
98        echo "If this is the case make sure you have the packages installed, AND"
99        echo "that the doxygen program is in your execute path (see your"
100        echo "shell manual page on setting the \$PATH environment variable), OR"
101        echo "alternatively, specify the program to use with --with-doxygen."
102        AC_MSG_WARN(
103           [Warning: no doxygen detected. Documentation will not be built])
104     fi])
105 fi
106 AC_MSG_CHECKING([whether documentation is built])
107 AC_MSG_RESULT([${BUILD_DOCS}])
108
109 dnl
110 dnl Substitution
111 dnl
112 AC_SUBST([DOXYGEN])
113
114 AM_CONDITIONAL(BUILD_DOCS, test "x$BUILD_DOCS" = "xyes")
115
116 ])
117
118 dnl Detection and configuration of the visibility feature of gcc
119 dnl Vincent Torri 2006-02-11
120 dnl
121 dnl XCB_EXTENSION(name, default)
122 dnl set the X extension
123 dnl
124 AC_DEFUN([XCB_EXTENSION],
125 [
126 pushdef([UP], translit([$1], [-a-z], [_A-Z]))dnl
127 pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
128
129 AC_ARG_ENABLE(DOWN,
130     [AS_HELP_STRING([--enable-[]DOWN], [Build XCB $1 Extension (default: $2)])],
131     [BUILD_[]UP=$enableval],
132     [BUILD_[]UP=$2])
133
134 AM_CONDITIONAL(BUILD_[]UP, [test "x$BUILD_[]UP" = "xyes"])
135 ])
136
137 dnl End of acinclude.m4