]> git.ipfire.org Git - thirdparty/gcc.git/blame - c++tools/configure.ac
Add c++tools
[thirdparty/gcc.git] / c++tools / configure.ac
CommitLineData
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
24sinclude(../config/acx.m4)
25
26AC_INIT(c++tools)
27
28AC_CONFIG_SRCDIR([server.cc])
29
30# Determine the noncanonical names used for directories.
31ACX_NONCANONICAL_TARGET
32
33AC_CANONICAL_SYSTEM
34AC_PROG_INSTALL
35
36AC_PROG_CXX
37MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
38AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
39AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
40
41dnl Enabled by default
42AC_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
49AC_MSG_RESULT($cxx_aux_tools)
50CXX_AUX_TOOLS="$cxx_aux_tools"
51AC_SUBST(CXX_AUX_TOOLS)
52
53AC_ARG_ENABLE([maintainer-mode],
54AS_HELP_STRING([--enable-maintainer-mode],
55[enable maintainer mode. Add rules to rebuild configurey bits]),,
56[enable_maintainer_mode=no])
57case "$enable_maintainer_mode" in
58 ("yes") maintainer_mode=yes ;;
59 ("no") maintainer=no ;;
60 (*) AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode]) ;;
61esac
62AC_MSG_CHECKING([maintainer-mode])
63AC_MSG_RESULT([$maintainer_mode])
64test "$maintainer_mode" = yes && MAINTAINER=yes
65AC_SUBST(MAINTAINER)
66
67# Check if O_CLOEXEC is defined by fcntl
68AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
69AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
70#include <fcntl.h>]], [[
71return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])],
72[ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])])
73if test $ac_cv_o_cloexec = yes; then
74 AC_DEFINE(HOST_HAS_O_CLOEXEC, 1,
75 [Define if O_CLOEXEC supported by fcntl.])
76fi
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
85AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [
86AC_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>]],[[
91sockaddr_un un;
92un.sun_family = AF_UNSPEC;
93int fd = socket (AF_UNIX, SOCK_STREAM, 0);
94connect (fd, (sockaddr *)&un, sizeof (un));]])],
95[ac_cv_af_unix=yes],
96[ac_cv_af_unix=no])])
97if test $ac_cv_af_unix = yes; then
98 AC_DEFINE(HAVE_AF_UNIX, 1,
99 [Define if AF_UNIX supported.])
100fi
101
102# Remote socket connectivity wants AF_INET6 networking
103# Check for AF_INET6 networking
104AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [
105AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
106#include <sys/types.h>
107#include <sys/socket.h>
108#include <netinet/in.h>
109#include <netdb.h>]],[[
110sockaddr_in6 in6;
111in6.sin6_family = AF_UNSPEC;
112struct addrinfo *addrs = 0;
113struct addrinfo hints;
114hints.ai_flags = 0;
115hints.ai_family = AF_INET6;
116hints.ai_socktype = SOCK_STREAM;
117hints.ai_protocol = 0;
118hints.ai_canonname = 0;
119hints.ai_addr = 0;
120hints.ai_next = 0;
121int e = getaddrinfo ("localhost", 0, &hints, &addrs);
122const char *str = gai_strerror (e);
123freeaddrinfo (addrs);
124int fd = socket (AF_INET6, SOCK_STREAM, 0);
125connect (fd, (sockaddr *)&in6, sizeof (in6));]])],
126[ac_cv_af_inet6=yes],
127[ac_cv_af_inet6=no])])
128if test $ac_cv_af_inet6 = yes; then
129 AC_DEFINE(HAVE_AF_INET6, 1,
130 [Define if AF_INET6 supported.])
131fi
132
133# Efficient server response wants epoll
134# Check for epoll_create, epoll_ctl, epoll_pwait
135AC_CACHE_CHECK(for epoll, ac_cv_epoll, [
136AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
137#include <sys/epoll.h>]],[[
138int fd = epoll_create (1);
139epoll_event ev;
140ev.events = EPOLLIN;
141ev.data.fd = 0;
142epoll_ctl (fd, EPOLL_CTL_ADD, 0, &ev);
143epoll_pwait (fd, 0, 0, -1, 0);]])],
144[ac_cv_epoll=yes],
145[ac_cv_epoll=no])])
146if test $ac_cv_epoll = yes; then
147 AC_DEFINE(HAVE_EPOLL, 1,
148 [Define if epoll_create, epoll_ctl, epoll_pwait provided.])
149fi
150
151# If we can't use epoll, try pselect.
152# Check for pselect
153AC_CACHE_CHECK(for pselect, ac_cv_pselect, [
154AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
155#include <sys/select.h>]],[[
156pselect (0, 0, 0, 0, 0, 0);]])],
157[ac_cv_pselect=yes],
158[ac_cv_pselect=no])])
159if test $ac_cv_pselect = yes; then
160 AC_DEFINE(HAVE_PSELECT, 1,
161 [Define if pselect provided.])
162fi
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
167AC_CACHE_CHECK(for select, ac_cv_select, [
168AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
169#include <sys/select.h>]],[[
170select (0, 0, 0, 0, 0);]])],
171[ac_cv_select=yes],
172[ac_cv_select=no])])
173if test $ac_cv_select = yes; then
174 AC_DEFINE(HAVE_SELECT, 1,
175 [Define if select provided.])
176fi
177
178# Avoid some fnctl calls by using accept4, when available.
179# Check for accept4
180AC_CACHE_CHECK(for accept4, ac_cv_accept4, [
181AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
182#include <sys/socket.h>]],[[
183int err = accept4 (1, 0, 0, SOCK_NONBLOCK);]])],
184[ac_cv_accept4=yes],
185[ac_cv_accept4=no])])
186if test $ac_cv_accept4 = yes; then
187 AC_DEFINE(HAVE_ACCEPT4, 1,
188 [Define if accept4 provided.])
189fi
190
191# For better server messages, look for a way to stringize network addresses
192# Check for inet_ntop
193AC_CACHE_CHECK(for inet_ntop, ac_cv_inet_ntop, [
194AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
195#include <arpa/inet.h>
196#include <netinet/in.h>]],[[
197sockaddr_in6 in6;
198char buf[INET6_ADDRSTRLEN];
199const char *str = inet_ntop (AF_INET6, &in6, buf, sizeof (buf));]])],
200[ac_cv_inet_ntop=yes],
201[ac_cv_inet_ntop=no])])
202if test $ac_cv_inet_ntop = yes; then
203 AC_DEFINE(HAVE_INET_NTOP, 1,
204 [Define if inet_ntop provided.])
205fi
206
207AC_CONFIG_HEADERS([config.h])
208AC_CONFIG_FILES([Makefile])
209
210AC_OUTPUT