From: Petr Machata <pmachata@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH 1/2] Enable C++
Date: Fri, 03 Apr 2015 10:28:14 +0200 [thread overview]
Message-ID: <370c9db4a32b4d7a8eee1b9eef9678750d7ccafb.1428049672.git.pmachata@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 4076 bytes --]
- Detect C++ compiler in configure, add supporting infrastructure to
eu.am.
Signed-off-by: Petr Machata <pmachata@redhat.com>
---
ChangeLog | 4 ++++
config/ChangeLog | 6 ++++++
config/eu.am | 21 ++++++++++++++++++++-
configure.ac | 15 +++++++++++++++
4 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 5c8e1c2..6c6f216 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-18 Petr Machata <pmachata@redhat.com>
+
+ * configure.ac (HAVE_CXX): New conditional.
+
2015-03-13 Mark Wielaard <mjw@redhat.com>
* configure.ac (ac_cv_c99): Add explicit return.
diff --git a/config/ChangeLog b/config/ChangeLog
index 586ebb0..32f3c93 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-02 Petr Machata <pmachata@redhat.com>
+
+ * eu.am (AM_CXXFLAGS, CXXCOMPILE.os): New variables.
+ (%.os: %.c %.o): Create dep-file subdirectory if necessary.
+ (%.os: %.cc %.o): New rule.
+
2015-03-18 Petr Machata <pmachata@redhat.com>
* known-dwarf.awk (comment): Drop all uses of this variable.
diff --git a/config/eu.am b/config/eu.am
index faf8add..f1d290b 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -1,6 +1,6 @@
## Common automake fragments for elfutils subdirectory makefiles.
##
-## Copyright (C) 2010, 2014 Red Hat, Inc.
+## Copyright (C) 2010, 2014, 2015 Red Hat, Inc.
##
## This file is part of elfutils.
##
@@ -35,11 +35,17 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
$(if $($(*F)_no_Werror),,-Werror) \
$(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
$($(*F)_CFLAGS)
+AM_CXXFLAGS = -std=gnu++98 -Wall -Wshadow -Wformat=2 \
+ $(if $($(*F)_no_Werror),,-Werror) \
+ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+ $($(*F)_CXXFLAGS)
COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
+CXXCOMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(CXXCOMPILE))
%.os: %.c %.o
if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
@@ -50,6 +56,19 @@ else
$(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
endif
+%.os: %.cc %.o
+if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
+ if $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
+ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
+ rm -f "$(DEPDIR)/$*.Tpo"; \
+ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ fi
+else
+ $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
+endif
+
CLEANFILES = *.gcno *.gcda
textrel_msg = echo "WARNING: TEXTREL found in '$@'"
diff --git a/configure.ac b/configure.ac
index c4b818d..bc40bff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ AS_IF([test "$use_locks" = yes],
AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
AC_PROG_CC
+AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AM_PROG_LEX
@@ -89,6 +90,20 @@ CFLAGS="$old_CFLAGS"])
AS_IF([test "x$ac_cv_c99" != xyes],
AC_MSG_ERROR([gcc with C99 support required]))
+# Above, we check for C++ compiler. However even if none is available,
+# CXX is set to a non-empty value. So we need to figure out whether a
+# C++ compiler is actually available.
+AC_CACHE_CHECK([for working C++ compiler], ac_cv_cxx_works,
+[AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+struct foo {
+ int i;
+ explicit foo () : i (0) {}
+ virtual ~foo () {}
+};])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)
+ AC_LANG_POP()])
+AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
+
AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
# Use the same flags that we use for our DSOs, so the test is representative.
# Some old compiler/linker/libc combinations fail some ways and not others.
--
2.1.0
next reply other threads:[~2015-04-03 8:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 8:28 Petr Machata [this message]
2015-04-03 11:33 Mark Wielaard
2015-04-03 21:40 Petr Machata
2015-04-07 15:27 Mark Wielaard
2015-04-07 17:10 Petr Machata
2015-04-14 14:37 Petr Machata
2015-04-14 14:47 Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=370c9db4a32b4d7a8eee1b9eef9678750d7ccafb.1428049672.git.pmachata@redhat.com \
--to=pmachata@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).