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