]>
Commit | Line | Data |
---|---|---|
35fc243f | 1 | # Configure script for c++tools |
7adcbafe | 2 | # Copyright (C) 2020-2022 Free Software Foundation, Inc. |
35fc243f NS |
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) | |
a20893cf | 25 | sinclude(../config/ax_lib_socket_nsl.m4) |
35fc243f NS |
26 | |
27 | AC_INIT(c++tools) | |
28 | ||
29 | AC_CONFIG_SRCDIR([server.cc]) | |
30 | ||
31 | # Determine the noncanonical names used for directories. | |
32 | ACX_NONCANONICAL_TARGET | |
33 | ||
34 | AC_CANONICAL_SYSTEM | |
35 | AC_PROG_INSTALL | |
3f78c8cb NS |
36 | test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' |
37 | AC_SUBST(INSTALL_PROGRAM) | |
35fc243f NS |
38 | |
39 | AC_PROG_CXX | |
40 | MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing | |
41 | AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) | |
42 | AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) | |
43 | ||
e4d306cf IS |
44 | AC_LANG(C++) |
45 | ||
35fc243f NS |
46 | dnl Enabled by default |
47 | AC_MSG_CHECKING([whether to build C++ tools]) | |
48 | AC_ARG_ENABLE(c++-tools, | |
49 | [AS_HELP_STRING([--enable-c++-tools], | |
50 | [build auxiliary c++ tools])], | |
51 | cxx_aux_tools=$enableval, | |
52 | cxx_aux_tools=yes) | |
53 | ||
54 | AC_MSG_RESULT($cxx_aux_tools) | |
55 | CXX_AUX_TOOLS="$cxx_aux_tools" | |
56 | AC_SUBST(CXX_AUX_TOOLS) | |
57 | ||
58 | AC_ARG_ENABLE([maintainer-mode], | |
59 | AS_HELP_STRING([--enable-maintainer-mode], | |
60 | [enable maintainer mode. Add rules to rebuild configurey bits]),, | |
61 | [enable_maintainer_mode=no]) | |
62 | case "$enable_maintainer_mode" in | |
4b1987f8 EB |
63 | yes) maintainer_mode=yes ;; |
64 | no) maintainer_mode=no ;; | |
65 | *) AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode]) ;; | |
35fc243f NS |
66 | esac |
67 | AC_MSG_CHECKING([maintainer-mode]) | |
68 | AC_MSG_RESULT([$maintainer_mode]) | |
69 | test "$maintainer_mode" = yes && MAINTAINER=yes | |
70 | AC_SUBST(MAINTAINER) | |
71 | ||
e4d306cf IS |
72 | # Handle configuration of checking; for the tools in this directory we |
73 | # default to release checking and stricter checks do not change this. | |
74 | ||
75 | AC_ARG_ENABLE(checking, | |
76 | [AS_HELP_STRING([[--enable-checking[=LIST]]], | |
77 | [enable expensive run-time checks. With LIST, | |
78 | enable only specific categories of checks. | |
79 | Categories are: yes,no,all,none,release.])], | |
80 | [ac_checking_flags="${enableval}"],[ | |
81 | # Default to checking. | |
82 | ac_checking_flags=yes | |
83 | ]) | |
84 | IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS," | |
85 | for check in release $ac_checking_flags | |
86 | do | |
87 | case $check in | |
88 | # these set all the flags to specific states | |
89 | yes|all|release|assert) ac_assert_checking=1 ; ;; | |
90 | no|none) ac_assert_checking= ; ;; | |
91 | *) ;; | |
92 | esac | |
93 | done | |
94 | IFS="$ac_save_IFS" | |
95 | ||
96 | if test x$ac_assert_checking != x ; then | |
97 | AC_DEFINE(ENABLE_ASSERT_CHECKING, 1, | |
98 | [Define if you want assertions enabled. This is a cheap check.]) | |
99 | fi | |
100 | ||
544f4775 NS |
101 | # Check whether --enable-default-pie was given. |
102 | AC_ARG_ENABLE(default-pie, | |
103 | [AS_HELP_STRING([--enable-default-pie], | |
104 | [enable Position Independent Executable as default])], | |
251c72a6 MP |
105 | [PICFLAG=-fPIE], [PICFLAG=]) |
106 | ||
107 | # Enable --enable-host-pie | |
108 | AC_ARG_ENABLE(host-pie, | |
109 | [AS_HELP_STRING([--enable-host-pie], | |
110 | [build host code as PIE])], | |
111 | [PICFLAG=-fPIE; LD_PICFLAG=-pie], []) | |
112 | AC_SUBST(PICFLAG) | |
113 | AC_SUBST(LD_PICFLAG) | |
544f4775 | 114 | |
35fc243f NS |
115 | # Check if O_CLOEXEC is defined by fcntl |
116 | AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [ | |
117 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
118 | #include <fcntl.h>]], [[ | |
119 | return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])], | |
120 | [ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])]) | |
121 | if test $ac_cv_o_cloexec = yes; then | |
122 | AC_DEFINE(HOST_HAS_O_CLOEXEC, 1, | |
123 | [Define if O_CLOEXEC supported by fcntl.]) | |
124 | fi | |
125 | ||
09616422 NS |
126 | AC_CHECK_HEADERS(sys/mman.h) |
127 | ||
35fc243f NS |
128 | # C++ Modules would like some networking features to provide the mapping |
129 | # server. You can still use modules without them though. | |
130 | # The following network-related checks could probably do with some | |
131 | # Windows and other non-linux defenses and checking. | |
132 | ||
133 | # Local socket connectivity wants AF_UNIX networking | |
134 | # Check for AF_UNIX networking | |
135 | AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [ | |
136 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
137 | #include <sys/types.h> | |
138 | #include <sys/socket.h> | |
139 | #include <sys/un.h> | |
140 | #include <netinet/in.h>]],[[ | |
141 | sockaddr_un un; | |
142 | un.sun_family = AF_UNSPEC; | |
143 | int fd = socket (AF_UNIX, SOCK_STREAM, 0); | |
144 | connect (fd, (sockaddr *)&un, sizeof (un));]])], | |
145 | [ac_cv_af_unix=yes], | |
146 | [ac_cv_af_unix=no])]) | |
147 | if test $ac_cv_af_unix = yes; then | |
148 | AC_DEFINE(HAVE_AF_UNIX, 1, | |
149 | [Define if AF_UNIX supported.]) | |
150 | fi | |
151 | ||
152 | # Remote socket connectivity wants AF_INET6 networking | |
153 | # Check for AF_INET6 networking | |
154 | AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [ | |
155 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
156 | #include <sys/types.h> | |
157 | #include <sys/socket.h> | |
158 | #include <netinet/in.h> | |
159 | #include <netdb.h>]],[[ | |
160 | sockaddr_in6 in6; | |
161 | in6.sin6_family = AF_UNSPEC; | |
162 | struct addrinfo *addrs = 0; | |
163 | struct addrinfo hints; | |
164 | hints.ai_flags = 0; | |
165 | hints.ai_family = AF_INET6; | |
166 | hints.ai_socktype = SOCK_STREAM; | |
167 | hints.ai_protocol = 0; | |
168 | hints.ai_canonname = 0; | |
169 | hints.ai_addr = 0; | |
170 | hints.ai_next = 0; | |
171 | int e = getaddrinfo ("localhost", 0, &hints, &addrs); | |
172 | const char *str = gai_strerror (e); | |
173 | freeaddrinfo (addrs); | |
174 | int fd = socket (AF_INET6, SOCK_STREAM, 0); | |
175 | connect (fd, (sockaddr *)&in6, sizeof (in6));]])], | |
176 | [ac_cv_af_inet6=yes], | |
177 | [ac_cv_af_inet6=no])]) | |
178 | if test $ac_cv_af_inet6 = yes; then | |
179 | AC_DEFINE(HAVE_AF_INET6, 1, | |
180 | [Define if AF_INET6 supported.]) | |
181 | fi | |
182 | ||
183 | # Efficient server response wants epoll | |
184 | # Check for epoll_create, epoll_ctl, epoll_pwait | |
185 | AC_CACHE_CHECK(for epoll, ac_cv_epoll, [ | |
186 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
187 | #include <sys/epoll.h>]],[[ | |
188 | int fd = epoll_create (1); | |
189 | epoll_event ev; | |
190 | ev.events = EPOLLIN; | |
191 | ev.data.fd = 0; | |
192 | epoll_ctl (fd, EPOLL_CTL_ADD, 0, &ev); | |
193 | epoll_pwait (fd, 0, 0, -1, 0);]])], | |
194 | [ac_cv_epoll=yes], | |
195 | [ac_cv_epoll=no])]) | |
196 | if test $ac_cv_epoll = yes; then | |
197 | AC_DEFINE(HAVE_EPOLL, 1, | |
198 | [Define if epoll_create, epoll_ctl, epoll_pwait provided.]) | |
199 | fi | |
200 | ||
201 | # If we can't use epoll, try pselect. | |
202 | # Check for pselect | |
203 | AC_CACHE_CHECK(for pselect, ac_cv_pselect, [ | |
204 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
205 | #include <sys/select.h>]],[[ | |
206 | pselect (0, 0, 0, 0, 0, 0);]])], | |
207 | [ac_cv_pselect=yes], | |
208 | [ac_cv_pselect=no])]) | |
209 | if test $ac_cv_pselect = yes; then | |
210 | AC_DEFINE(HAVE_PSELECT, 1, | |
211 | [Define if pselect provided.]) | |
212 | fi | |
213 | ||
214 | # And failing that, use good old select. | |
215 | # If we can't even use this, the server is serialized. | |
216 | # Check for select | |
217 | AC_CACHE_CHECK(for select, ac_cv_select, [ | |
218 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
219 | #include <sys/select.h>]],[[ | |
220 | select (0, 0, 0, 0, 0);]])], | |
221 | [ac_cv_select=yes], | |
222 | [ac_cv_select=no])]) | |
223 | if test $ac_cv_select = yes; then | |
224 | AC_DEFINE(HAVE_SELECT, 1, | |
225 | [Define if select provided.]) | |
226 | fi | |
227 | ||
228 | # Avoid some fnctl calls by using accept4, when available. | |
229 | # Check for accept4 | |
230 | AC_CACHE_CHECK(for accept4, ac_cv_accept4, [ | |
231 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
232 | #include <sys/socket.h>]],[[ | |
233 | int err = accept4 (1, 0, 0, SOCK_NONBLOCK);]])], | |
234 | [ac_cv_accept4=yes], | |
235 | [ac_cv_accept4=no])]) | |
236 | if test $ac_cv_accept4 = yes; then | |
237 | AC_DEFINE(HAVE_ACCEPT4, 1, | |
238 | [Define if accept4 provided.]) | |
239 | fi | |
240 | ||
241 | # For better server messages, look for a way to stringize network addresses | |
242 | # Check for inet_ntop | |
243 | AC_CACHE_CHECK(for inet_ntop, ac_cv_inet_ntop, [ | |
244 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
245 | #include <arpa/inet.h> | |
246 | #include <netinet/in.h>]],[[ | |
247 | sockaddr_in6 in6; | |
248 | char buf[INET6_ADDRSTRLEN]; | |
249 | const char *str = inet_ntop (AF_INET6, &in6, buf, sizeof (buf));]])], | |
250 | [ac_cv_inet_ntop=yes], | |
251 | [ac_cv_inet_ntop=no])]) | |
252 | if test $ac_cv_inet_ntop = yes; then | |
253 | AC_DEFINE(HAVE_INET_NTOP, 1, | |
254 | [Define if inet_ntop provided.]) | |
255 | fi | |
256 | ||
4e7e7c13 JJ |
257 | # Determine what GCC version number to use in filesystem paths. |
258 | GCC_BASE_VER | |
259 | ||
a20893cf RO |
260 | # Solaris needs libsocket and libnsl for socket functions before 11.4. |
261 | # libcody uses those. | |
262 | save_LIBS="$LIBS" | |
263 | LIBS= | |
264 | AX_LIB_SOCKET_NSL | |
265 | NETLIBS="$LIBS" | |
266 | LIBS="$save_LIBS" | |
267 | AC_SUBST(NETLIBS) | |
268 | ||
35fc243f NS |
269 | AC_CONFIG_HEADERS([config.h]) |
270 | AC_CONFIG_FILES([Makefile]) | |
271 | ||
272 | AC_OUTPUT |