"Initial commit to Gerrit"
[profile/ivi/xorg-utils.git] / luit / acinclude.m4
1 dnl ---------------------------------------------------------------------------
2 dnl
3 dnl Copyright 2006-2009,2010 by Thomas E. Dickey
4 dnl
5 dnl                         All Rights Reserved
6 dnl
7 dnl Permission to use, copy, modify, and distribute this software and its
8 dnl documentation for any purpose and without fee is hereby granted,
9 dnl provided that the above copyright notice appear in all copies and that
10 dnl both that copyright notice and this permission notice appear in
11 dnl supporting documentation, and that the name of the above listed
12 dnl copyright holder(s) not be used in advertising or publicity pertaining
13 dnl to distribution of the software without specific, written prior
14 dnl permission.
15 dnl
16 dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
17 dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
19 dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 dnl
24 dnl ---------------------------------------------------------------------------
25
26 dnl ---------------------------------------------------------------------------
27 dnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
28 dnl ------------
29 dnl See if the poll function really works.  Some platforms have poll(), but
30 dnl it does not work for terminals or files.
31 AC_DEFUN([CF_FUNC_POLL],[
32 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
33 AC_TRY_RUN([
34 #include <stdio.h>
35 #ifdef HAVE_POLL_H
36 #include <poll.h>
37 #else
38 #include <sys/poll.h>
39 #endif
40 int main() {
41         struct pollfd myfds;
42         int ret;
43
44         myfds.fd = 0;
45         myfds.events = POLLIN;
46
47         ret = poll(&myfds, 1, 100);
48         ${cf_cv_main_return:-return}(ret != 0);
49 }],
50         [cf_cv_working_poll=yes],
51         [cf_cv_working_poll=no],
52         [cf_cv_working_poll=unknown])])
53 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL, 1, [poll() works])
54 ])dnl
55
56 dnl ---------------------------------------------------------------------------
57 dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
58 dnl -----------
59 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
60 dnl programs need this test).
61 dnl
62 dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
63 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
64 dnl winsize declaration is left alone - we may revisit this if Apple choose to
65 dnl break that part of the interface as well.
66 AC_DEFUN([CF_SIGWINCH],
67 [
68 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
69         AC_TRY_COMPILE([
70 #include <sys/types.h>
71 #include <sys/signal.h>
72 ],[int x = SIGWINCH],
73         [cf_cv_define_sigwinch=yes],
74         [AC_TRY_COMPILE([
75 #undef _XOPEN_SOURCE
76 #undef _POSIX_SOURCE
77 #undef _POSIX_C_SOURCE
78 #include <sys/types.h>
79 #include <sys/signal.h>
80 ],[int x = SIGWINCH],
81         [cf_cv_define_sigwinch=maybe],
82         [cf_cv_define_sigwinch=no])
83 ])
84 ])
85
86 if test "$cf_cv_define_sigwinch" = maybe ; then
87 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
88 cf_cv_fixup_sigwinch=unknown
89 cf_sigwinch=32
90 while test $cf_sigwinch != 1
91 do
92         AC_TRY_COMPILE([
93 #undef _XOPEN_SOURCE
94 #undef _POSIX_SOURCE
95 #undef _POSIX_C_SOURCE
96 #include <sys/types.h>
97 #include <sys/signal.h>
98 ],[
99 #if SIGWINCH != $cf_sigwinch
100 make an error
101 #endif
102 int x = SIGWINCH],
103         [cf_cv_fixup_sigwinch=$cf_sigwinch
104          break])
105
106 cf_sigwinch=`expr $cf_sigwinch - 1`
107 done
108 ])
109
110         if test "$cf_cv_fixup_sigwinch" != unknown ; then
111                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
112         fi
113 fi
114 ])dnl
115
116