]>
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 | |
3f78c8cb NS |
35 | test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' |
36 | AC_SUBST(INSTALL_PROGRAM) | |
35fc243f NS |
37 | |
38 | AC_PROG_CXX | |
39 | MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing | |
40 | AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) | |
41 | AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) | |
42 | ||
43 | dnl Enabled by default | |
44 | AC_MSG_CHECKING([whether to build C++ tools]) | |
45 | AC_ARG_ENABLE(c++-tools, | |
46 | [AS_HELP_STRING([--enable-c++-tools], | |
47 | [build auxiliary c++ tools])], | |
48 | cxx_aux_tools=$enableval, | |
49 | cxx_aux_tools=yes) | |
50 | ||
51 | AC_MSG_RESULT($cxx_aux_tools) | |
52 | CXX_AUX_TOOLS="$cxx_aux_tools" | |
53 | AC_SUBST(CXX_AUX_TOOLS) | |
54 | ||
55 | AC_ARG_ENABLE([maintainer-mode], | |
56 | AS_HELP_STRING([--enable-maintainer-mode], | |
57 | [enable maintainer mode. Add rules to rebuild configurey bits]),, | |
58 | [enable_maintainer_mode=no]) | |
59 | case "$enable_maintainer_mode" in | |
60 | ("yes") maintainer_mode=yes ;; | |
61 | ("no") maintainer=no ;; | |
62 | (*) AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode]) ;; | |
63 | esac | |
64 | AC_MSG_CHECKING([maintainer-mode]) | |
65 | AC_MSG_RESULT([$maintainer_mode]) | |
66 | test "$maintainer_mode" = yes && MAINTAINER=yes | |
67 | AC_SUBST(MAINTAINER) | |
68 | ||
544f4775 NS |
69 | # Check whether --enable-default-pie was given. |
70 | AC_ARG_ENABLE(default-pie, | |
71 | [AS_HELP_STRING([--enable-default-pie], | |
72 | [enable Position Independent Executable as default])], | |
73 | [PIEFLAG=-fPIE], [PIEFLAG=]) | |
74 | AC_SUBST([PIEFLAG]) | |
75 | ||
35fc243f NS |
76 | # Check if O_CLOEXEC is defined by fcntl |
77 | AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [ | |
78 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
79 | #include <fcntl.h>]], [[ | |
80 | return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])], | |
81 | [ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])]) | |
82 | if test $ac_cv_o_cloexec = yes; then | |
83 | AC_DEFINE(HOST_HAS_O_CLOEXEC, 1, | |
84 | [Define if O_CLOEXEC supported by fcntl.]) | |
85 | fi | |
86 | ||
09616422 NS |
87 | AC_CHECK_HEADERS(sys/mman.h) |
88 | ||
35fc243f NS |
89 | # C++ Modules would like some networking features to provide the mapping |
90 | # server. You can still use modules without them though. | |
91 | # The following network-related checks could probably do with some | |
92 | # Windows and other non-linux defenses and checking. | |
93 | ||
94 | # Local socket connectivity wants AF_UNIX networking | |
95 | # Check for AF_UNIX networking | |
96 | AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [ | |
97 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
98 | #include <sys/types.h> | |
99 | #include <sys/socket.h> | |
100 | #include <sys/un.h> | |
101 | #include <netinet/in.h>]],[[ | |
102 | sockaddr_un un; | |
103 | un.sun_family = AF_UNSPEC; | |
104 | int fd = socket (AF_UNIX, SOCK_STREAM, 0); | |
105 | connect (fd, (sockaddr *)&un, sizeof (un));]])], | |
106 | [ac_cv_af_unix=yes], | |
107 | [ac_cv_af_unix=no])]) | |
108 | if test $ac_cv_af_unix = yes; then | |
109 | AC_DEFINE(HAVE_AF_UNIX, 1, | |
110 | [Define if AF_UNIX supported.]) | |
111 | fi | |
112 | ||
113 | # Remote socket connectivity wants AF_INET6 networking | |
114 | # Check for AF_INET6 networking | |
115 | AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [ | |
116 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
117 | #include <sys/types.h> | |
118 | #include <sys/socket.h> | |
119 | #include <netinet/in.h> | |
120 | #include <netdb.h>]],[[ | |
121 | sockaddr_in6 in6; | |
122 | in6.sin6_family = AF_UNSPEC; | |
123 | struct addrinfo *addrs = 0; | |
124 | struct addrinfo hints; | |
125 | hints.ai_flags = 0; | |
126 | hints.ai_family = AF_INET6; | |
127 | hints.ai_socktype = SOCK_STREAM; | |
128 | hints.ai_protocol = 0; | |
129 | hints.ai_canonname = 0; | |
130 | hints.ai_addr = 0; | |
131 | hints.ai_next = 0; | |
132 | int e = getaddrinfo ("localhost", 0, &hints, &addrs); | |
133 | const char *str = gai_strerror (e); | |
134 | freeaddrinfo (addrs); | |
135 | int fd = socket (AF_INET6, SOCK_STREAM, 0); | |
136 | connect (fd, (sockaddr *)&in6, sizeof (in6));]])], | |
137 | [ac_cv_af_inet6=yes], | |
138 | [ac_cv_af_inet6=no])]) | |
139 | if test $ac_cv_af_inet6 = yes; then | |
140 | AC_DEFINE(HAVE_AF_INET6, 1, | |
141 | [Define if AF_INET6 supported.]) | |
142 | fi | |
143 | ||
144 | # Efficient server response wants epoll | |
145 | # Check for epoll_create, epoll_ctl, epoll_pwait | |
146 | AC_CACHE_CHECK(for epoll, ac_cv_epoll, [ | |
147 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
148 | #include <sys/epoll.h>]],[[ | |
149 | int fd = epoll_create (1); | |
150 | epoll_event ev; | |
151 | ev.events = EPOLLIN; | |
152 | ev.data.fd = 0; | |
153 | epoll_ctl (fd, EPOLL_CTL_ADD, 0, &ev); | |
154 | epoll_pwait (fd, 0, 0, -1, 0);]])], | |
155 | [ac_cv_epoll=yes], | |
156 | [ac_cv_epoll=no])]) | |
157 | if test $ac_cv_epoll = yes; then | |
158 | AC_DEFINE(HAVE_EPOLL, 1, | |
159 | [Define if epoll_create, epoll_ctl, epoll_pwait provided.]) | |
160 | fi | |
161 | ||
162 | # If we can't use epoll, try pselect. | |
163 | # Check for pselect | |
164 | AC_CACHE_CHECK(for pselect, ac_cv_pselect, [ | |
165 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
166 | #include <sys/select.h>]],[[ | |
167 | pselect (0, 0, 0, 0, 0, 0);]])], | |
168 | [ac_cv_pselect=yes], | |
169 | [ac_cv_pselect=no])]) | |
170 | if test $ac_cv_pselect = yes; then | |
171 | AC_DEFINE(HAVE_PSELECT, 1, | |
172 | [Define if pselect provided.]) | |
173 | fi | |
174 | ||
175 | # And failing that, use good old select. | |
176 | # If we can't even use this, the server is serialized. | |
177 | # Check for select | |
178 | AC_CACHE_CHECK(for select, ac_cv_select, [ | |
179 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
180 | #include <sys/select.h>]],[[ | |
181 | select (0, 0, 0, 0, 0);]])], | |
182 | [ac_cv_select=yes], | |
183 | [ac_cv_select=no])]) | |
184 | if test $ac_cv_select = yes; then | |
185 | AC_DEFINE(HAVE_SELECT, 1, | |
186 | [Define if select provided.]) | |
187 | fi | |
188 | ||
189 | # Avoid some fnctl calls by using accept4, when available. | |
190 | # Check for accept4 | |
191 | AC_CACHE_CHECK(for accept4, ac_cv_accept4, [ | |
192 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
193 | #include <sys/socket.h>]],[[ | |
194 | int err = accept4 (1, 0, 0, SOCK_NONBLOCK);]])], | |
195 | [ac_cv_accept4=yes], | |
196 | [ac_cv_accept4=no])]) | |
197 | if test $ac_cv_accept4 = yes; then | |
198 | AC_DEFINE(HAVE_ACCEPT4, 1, | |
199 | [Define if accept4 provided.]) | |
200 | fi | |
201 | ||
202 | # For better server messages, look for a way to stringize network addresses | |
203 | # Check for inet_ntop | |
204 | AC_CACHE_CHECK(for inet_ntop, ac_cv_inet_ntop, [ | |
205 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
206 | #include <arpa/inet.h> | |
207 | #include <netinet/in.h>]],[[ | |
208 | sockaddr_in6 in6; | |
209 | char buf[INET6_ADDRSTRLEN]; | |
210 | const char *str = inet_ntop (AF_INET6, &in6, buf, sizeof (buf));]])], | |
211 | [ac_cv_inet_ntop=yes], | |
212 | [ac_cv_inet_ntop=no])]) | |
213 | if test $ac_cv_inet_ntop = yes; then | |
214 | AC_DEFINE(HAVE_INET_NTOP, 1, | |
215 | [Define if inet_ntop provided.]) | |
216 | fi | |
217 | ||
4e7e7c13 JJ |
218 | # Determine what GCC version number to use in filesystem paths. |
219 | GCC_BASE_VER | |
220 | ||
35fc243f NS |
221 | AC_CONFIG_HEADERS([config.h]) |
222 | AC_CONFIG_FILES([Makefile]) | |
223 | ||
224 | AC_OUTPUT |