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