qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Fontana <claudio.fontana@huawei.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [RFC 2/4] rules.mak: support C++ compiling and linking
Date: Wed, 11 Sep 2013 15:02:45 +0200	[thread overview]
Message-ID: <523069F5.50107@huawei.com> (raw)
In-Reply-To: <52306808.4030701@huawei.com>

support compilation of .cc and .cpp files,
and if C++ is enabled always link with C++ in the non-libtool case.

Signed-off-by: Claudio Fontana <claudio.fontana@linaro.org>
---
 rules.mak | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/rules.mak b/rules.mak
index 4499745..d2f1b1f 100644
--- a/rules.mak
+++ b/rules.mak
@@ -8,9 +8,14 @@ MAKEFLAGS += -rR
 %.d:
 %.h:
 %.c:
+%.cc:
+%.cpp:
 %.m:
 %.mak:
 
+# Flags for C++ compilation
+QEMU_CXXFLAGS = -D__STDC_LIMIT_MACROS $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls, $(QEMU_CFLAGS))
+
 # Flags for dependency generation
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
@@ -21,11 +26,21 @@ QEMU_INCLUDES += -I$(<D) -I$(@D)
 	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 %.o: %.rc
 	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
+%.o: %.cc
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) -c -o $@ $<, "  CXX    $(TARGET_DIR)$@")
+%.o: %.cpp
+	$(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) -c -o $@ $<, "  CXX    $(TARGET_DIR)$@")
 
 ifeq ($(LIBTOOL),)
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
-       $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
-       $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  ifeq ($(CXX),)
+  LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
+         $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
+         $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  else
+  LINK = $(call quiet-command,$(CXX) $(QEMU_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ \
+         $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
+         $(LIBS),"  LINK  $(TARGET_DIR)$@")
+  endif
 else
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
@@ -70,7 +85,8 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
               >/dev/null 2>&1 && echo OK), $2, $3)
 
-VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh %.rc
+VPATH_SUFFIXES = %.c %.h %.S %.cpp %.cc %.m %.mak %.texi %.sh %.rc
+
 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
 
 # find-in-path
-- 
1.8.1

  parent reply	other threads:[~2013-09-11 13:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 12:54 [Qemu-devel] [RFC 0/4] ARM aarch64 disas output libvixl support Claudio Fontana
2013-09-11 12:59 ` [Qemu-devel] [RFC 1/4] configure: add c++ compiler support Claudio Fontana
2013-09-11 13:02 ` Claudio Fontana [this message]
2013-09-11 13:05 ` [Qemu-devel] [RFC 3/4] disas: add libvixl source code for aarch64 Claudio Fontana
2013-09-11 13:08 ` [Qemu-devel] [RFC 4/4] disas: implement host disassembly output " Claudio Fontana
2013-09-16  6:53   ` Andreas Färber
2013-09-16 10:43     ` Claudio Fontana
2013-09-11 13:14 ` [Qemu-devel] [RFC 0/4] ARM aarch64 disas output libvixl support Andreas Färber
2013-09-11 13:29   ` Peter Maydell
2013-09-11 13:37 ` Peter Maydell
2013-09-11 14:35 ` [Qemu-devel] [RFC 3/4] disas: add libvixl source code for aarch64 Claudio Fontana
2013-09-15 16:41 ` [Qemu-devel] [RFC 0/4] ARM aarch64 disas output libvixl support Rob Landley
2013-09-15 17:27   ` Peter Maydell
2013-09-15 20:04     ` Laurent Desnogues

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=523069F5.50107@huawei.com \
    --to=claudio.fontana@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 NNTP newsgroup(s).