]>
Commit | Line | Data |
---|---|---|
35fc243f NS |
1 | # Configure script for c++tools |
2 | # Copyright (C) 2020 Free Software Foundation, Inc. | |
3 | # Written by Nathan Sidwell <nathan@acm.org> while at FaceBook | |
4 | # | |
5 | # This file is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, but | |
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | # General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program; see the file COPYING3. If not see | |
17 | # <http://www.gnu.org/licenses/>. | |
18 | ||
19 | # C++ has grown a C++20 mapper server. This may be used to provide | |
20 | # and/or learn and/or build required modules. This sample server | |
21 | # shows how the protocol introduced by wg21.link/p1184 may be used. | |
22 | # By default g++ uses an in-process mapper. | |
23 | ||
24 | sinclude(../config/acx.m4) | |
25 | ||
26 | AC_INIT(c++tools) | |
27 | ||
28 | AC_CONFIG_SRCDIR([server.cc]) | |
29 | ||
30 | # Determine the noncanonical names used for directories. | |
31 | ACX_NONCANONICAL_TARGET | |
32 | ||
33 | AC_CANONICAL_SYSTEM | |
34 | AC_PROG_INSTALL | |
35 | ||
36 | AC_PROG_CXX | |
37 | MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing | |
38 | AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) | |
39 | AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) | |
40 | ||
41 | dnl Enabled by default | |
42 | AC_MSG_CHECKING([whether to build C++ tools]) | |
43 | AC_ARG_ENABLE(c++-tools, | |
44 | [AS_HELP_STRING([--enable-c++-tools], | |
45 | [build auxiliary c++ tools])], | |
46 | cxx_aux_tools=$enableval, | |
47 | cxx_aux_tools=yes) | |
48 | ||
49 | AC_MSG_RESULT($cxx_aux_tools) | |
50 | CXX_AUX_TOOLS="$cxx_aux_tools" | |
51 | AC_SUBST(CXX_AUX_TOOLS) | |
52 | ||
53 | AC_ARG_ENABLE([maintainer-mode], | |
54 | AS_HELP_STRING([--enable-maintainer-mode], | |
55 | [enable maintainer mode. Add rules to rebuild configurey bits]),, | |
56 | [enable_maintainer_mode=no]) | |
57 | case "$enable_maintainer_mode" in | |
58 | ("yes") maintainer_mode=yes ;; | |
59 | ("no") maintainer=no ;; | |
60 | (*) AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode]) ;; | |
61 | esac | |
62 | AC_MSG_CHECKING([maintainer-mode]) | |
63 | AC_MSG_RESULT([$maintainer_mode]) | |
64 | test "$maintainer_mode" = yes && MAINTAINER=yes | |
65 | AC_SUBST(MAINTAINER) | |
66 | ||
67 | # Check if O_CLOEXEC is defined by fcntl | |
68 | AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [ | |
69 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
70 | #include <fcntl.h>]], [[ | |
71 | return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])], | |
72 | [ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])]) | |
73 | if test $ac_cv_o_cloexec = yes; then | |
74 | AC_DEFINE(HOST_HAS_O_CLOEXEC, 1, | |
75 | [Define if O_CLOEXEC supported by fcntl.]) | |
76 | fi | |
77 | ||
78 | # C++ Modules would like some networking features to provide the mapping | |
79 | # server. You can still use modules without them though. | |
80 | # The following network-related checks could probably do with some | |
81 | # Windows and other non-linux defenses and checking. | |
82 | ||
83 | # Local socket connectivity wants AF_UNIX networking | |
84 | # Check for AF_UNIX networking | |
85 | AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [ | |
86 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
87 | #include <sys/types.h> | |
88 | #include <sys/socket.h> | |
89 | #include <sys/un.h> | |
90 | #include <netinet/in.h>]],[[ | |
91 | sockaddr_un un; | |
92 | un.sun_family = AF_UNSPEC; | |
93 | int fd = socket (AF_UNIX, SOCK_STREAM, 0); | |
94 | connect (fd, (sockaddr *)&un, sizeof (un));]])], | |
95 | [ac_cv_af_unix=yes], | |
96 | [ac_cv_af_unix=no])]) | |
97 | if test $ac_cv_af_unix = yes; then | |
98 | AC_DEFINE(HAVE_AF_UNIX, 1, | |
99 | [Define if AF_UNIX supported.]) | |
100 | fi | |
101 | ||
102 | # Remote socket connectivity wants AF_INET6 networking | |
103 | # Check for AF_INET6 networking | |
104 | AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [ | |
105 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
106 | #include <sys/types.h> | |
107 | #include <sys/socket.h> | |
108 | #include <netinet/in.h> | |
109 | #include <netdb.h>]],[[ | |
110 | sockaddr_in6 in6; | |
111 | in6.sin6_family = AF_UNSPEC; | |
112 | struct addrinfo *addrs = 0; | |
113 | struct addrinfo hints; | |
114 | hints.ai_flags = 0; | |
115 | hints.ai_family = AF_INET6; | |
116 | hints.ai_socktype = SOCK_STREAM; | |
117 | hints.ai_protocol = 0; | |
118 | hints.ai_canonname = 0; | |
119 | hints.ai_addr = 0; | |
120 | hints.ai_next = 0; | |
121 | int e = getaddrinfo ("localhost", 0, &hints, &addrs); | |
122 | const char *str = gai_strerror (e); | |
123 | freeaddrinfo (addrs); | |
124 | int fd = socket (AF_INET6, SOCK_STREAM, 0); | |
125 | connect (fd, (sockaddr *)&in6, sizeof (in6));]])], | |
126 | [ac_cv_af_inet6=yes], | |
127 | [ac_cv_af_inet6=no])]) | |
128 | if test $ac_cv_af_inet6 = yes; then | |
129 | AC_DEFINE(HAVE_AF_INET6, 1, | |
130 | [Define if AF_INET6 supported.]) | |
131 | fi | |
132 | ||
133 | # Efficient server response wants epoll | |
134 | # Check for epoll_create, epoll_ctl, epoll_pwait | |
135 | AC_CACHE_CHECK(for epoll, ac_cv_epoll, [ | |
136 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
137 | #include <sys/epoll.h>]],[[ | |
138 | int fd = epoll_create (1); | |
139 | epoll_event ev; | |
140 | ev.events = EPOLLIN; | |
141 | ev.data.fd = 0; | |
142 | epoll_ctl (fd, EPOLL_CTL_ADD, 0, &ev); | |
143 | epoll_pwait (fd, 0, 0, -1, 0);]])], | |
144 | [ac_cv_epoll=yes], | |
145 | [ac_cv_epoll=no])]) | |
146 | if test $ac_cv_epoll = yes; then | |
147 | AC_DEFINE(HAVE_EPOLL, 1, | |
148 | [Define if epoll_create, epoll_ctl, epoll_pwait provided.]) | |
149 | fi | |
150 | ||
151 | # If we can't use epoll, try pselect. | |
152 | # Check for pselect | |
153 | AC_CACHE_CHECK(for pselect, ac_cv_pselect, [ | |
154 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
155 | #include <sys/select.h>]],[[ | |
156 | pselect (0, 0, 0, 0, 0, 0);]])], | |
157 | [ac_cv_pselect=yes], | |
158 | [ac_cv_pselect=no])]) | |
159 | if test $ac_cv_pselect = yes; then | |
160 | AC_DEFINE(HAVE_PSELECT, 1, | |
161 | [Define if pselect provided.]) | |
162 | fi | |
163 | ||
164 | # And failing that, use good old select. | |
165 | # If we can't even use this, the server is serialized. | |
166 | # Check for select | |
167 | AC_CACHE_CHECK(for select, ac_cv_select, [ | |
168 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
169 | #include <sys/select.h>]],[[ | |
170 | select (0, 0, 0, 0, 0);]])], | |
171 | [ac_cv_select=yes], | |
172 | [ac_cv_select=no])]) | |
173 | if test $ac_cv_select = yes; then | |
174 | AC_DEFINE(HAVE_SELECT, 1, | |
175 | [Define if select provided.]) | |
176 | fi | |
177 | ||
178 | # Avoid some fnctl calls by using accept4, when available. | |
179 | # Check for accept4 | |
180 | AC_CACHE_CHECK(for accept4, ac_cv_accept4, [ | |
181 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
182 | #include <sys/socket.h>]],[[ | |
183 | int err = accept4 (1, 0, 0, SOCK_NONBLOCK);]])], | |
184 | [ac_cv_accept4=yes], | |
185 | [ac_cv_accept4=no])]) | |
186 | if test $ac_cv_accept4 = yes; then | |
187 | AC_DEFINE(HAVE_ACCEPT4, 1, | |
188 | [Define if accept4 provided.]) | |
189 | fi | |
190 | ||
191 | # For better server messages, look for a way to stringize network addresses | |
192 | # Check for inet_ntop | |
193 | AC_CACHE_CHECK(for inet_ntop, ac_cv_inet_ntop, [ | |
194 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
195 | #include <arpa/inet.h> | |
196 | #include <netinet/in.h>]],[[ | |
197 | sockaddr_in6 in6; | |
198 | char buf[INET6_ADDRSTRLEN]; | |
199 | const char *str = inet_ntop (AF_INET6, &in6, buf, sizeof (buf));]])], | |
200 | [ac_cv_inet_ntop=yes], | |
201 | [ac_cv_inet_ntop=no])]) | |
202 | if test $ac_cv_inet_ntop = yes; then | |
203 | AC_DEFINE(HAVE_INET_NTOP, 1, | |
204 | [Define if inet_ntop provided.]) | |
205 | fi | |
206 | ||
207 | AC_CONFIG_HEADERS([config.h]) | |
208 | AC_CONFIG_FILES([Makefile]) | |
209 | ||
210 | AC_OUTPUT |