Debian Codegraph @

m4/module-application.m4

raw
1 dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
2 dnl All rights reserved.
3 dnl
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that the following conditions
6 dnl are met:
7 dnl 1. Redistributions of source code must retain the above copyright
8 dnl notice, this list of conditions and the following disclaimer.
9 dnl 2. Redistributions in binary form must reproduce the above copyright
10 dnl notice, this list of conditions and the following disclaimer in the
11 dnl documentation and/or other materials provided with the distribution.
12 dnl
13 dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14 dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 AC_DEFUN([ATF_MODULE_APPLICATION], [
27 ATF_CHECK_STD_VSNPRINTF
28
29 AC_CACHE_CHECK(
30 [whether getopt allows a + sign for POSIX behavior],
31 [kyua_cv_getopt_plus], [
32 AC_LANG_PUSH([C])
33 AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>
34 #include <string.h>
35 #include <unistd.h>], [
36 int argc = 4;
37 char* argv@<:@5@:>@ = {
38 strdup("conftest"),
39 strdup("-+"),
40 strdup("-a"),
41 strdup("bar"),
42 NULL
43 };
44 int ch;
45 int seen_a = 0, seen_plus = 0;
46
47 while ((ch = getopt(argc, argv, "+a:")) != -1) {
48 switch (ch) {
49 case 'a':
50 seen_a = 1;
51 break;
52
53 case '+':
54 seen_plus = 1;
55 break;
56
57 case '?':
58 default:
59 ;
60 }
61 }
62
63 return (seen_a && !seen_plus) ? EXIT_SUCCESS : EXIT_FAILURE;
64 ])],
65 [kyua_cv_getopt_plus=yes],
66 [kyua_cv_getopt_plus=no])
67 AC_LANG_POP([C])
68 ])
69 if test x"${kyua_cv_getopt_plus}" = xyes; then
70 AC_DEFINE([HAVE_GNU_GETOPT], [1],
71 [Define to 1 if getopt allows a + sign for POSIX behavior])
72 fi
73
74 AC_CACHE_CHECK(
75 [whether getopt has optreset],
76 [kyua_cv_getopt_optreset], [
77 AC_LANG_PUSH([C])
78 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>
79 #include <unistd.h>], [
80 optreset = 1;
81 return EXIT_SUCCESS;
82 ])],
83 [kyua_cv_getopt_optreset=yes],
84 [kyua_cv_getopt_optreset=no])
85 AC_LANG_POP([C])
86 ])
87 if test x"${kyua_cv_getopt_optreset}" = xyes; then
88 AC_DEFINE([HAVE_OPTRESET], [1], [Define to 1 if getopt has optreset])
89 fi
90 ])