[vte/wip/c++: 1/2] build: Add C++ infrastructure
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/c++: 1/2] build: Add C++ infrastructure
- Date: Tue, 31 Mar 2015 19:42:57 +0000 (UTC)
commit 84cba07e25de3a8625df7cf5c51195a16120f950
Author: Christian Persch <chpe gnome org>
Date: Mon Mar 30 15:19:27 2015 +0200
build: Add C++ infrastructure
In preparation of moving to C++, add configure check for C++ compiler,
and add compiler flags and a check script to make sure we do NOT link
to libstdc++.
configure.ac | 117 ++++++++++++++++++++++++++++++------------------
src/Makefile.am | 18 ++++++--
src/check-libstdc++.sh | 13 +++++
3 files changed, 101 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 73eb43c..0f9e96b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,7 @@ AC_SUBST([GTK_API_VERSION])
# Check for programs
AC_PROG_CC
+AC_PROG_CXX
AC_USE_SYSTEM_EXTENSIONS
AC_HEADER_STDC
AM_PROG_CC_C_O
@@ -63,6 +64,9 @@ AC_PROG_SED
LT_PREREQ([2.2])
LT_INIT
+AM_CONDITIONAL([HAVE_GCC],[test "$GCC" = "yes"])
+AM_CONDITIONAL([HAVE_GXX],[test "$GXX" = "yes"])
+
################################################################################
# Enable debugging messages and additional run-time checks.
################################################################################
@@ -93,50 +97,64 @@ AC_CHECK_DECLS(bind_textdomain_codeset,,,[#include "libintl.h"])
# Compilation
################################################################################
-CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
- -pipe \
- -Waggregate-return \
- -Wall \
- -Wcast-align \
- -Wendif-labels \
- -Werror=declaration-after-statement \
- "-Werror=format=2 -Werror=format-nonliteral -Werror=format-security" \
- -Werror=implicit-function-declaration \
- -Werror=init-self \
- -Werror=missing-include-dirs \
- -Werror=missing-prototypes \
- -Werror=pointer-arith \
- -Wextra \
- -Wfloat-equal \
- -Wimplicit \
- -Wlogical-op \
- -Wmissing-declarations \
- -Wmissing-include-dirs \
- -Wmissing-format-attribute \
- -Wmissing-noreturn \
- -Wnested-externs \
- -Wno-missing-field-initializers \
- -Wno-switch-enum \
- -Wno-unused-parameter \
- -Wold-style-definition \
- -Wpacked \
- -Wshadow \
- -Wsign-compare \
- -Wstrict-aliasing=2 \
- -Wstrict-prototypes \
- -Wundef \
- -Wuninitialized \
- -Wunsafe-loop-optimizations \
- -Wwrite-strings \
- -fno-common \
- -fdiagnostics-show-option \
- -fno-strict-aliasing \
- -fstack-protector \
- -fstack-protector-strong \
- -fno-semantic-interposition \
- -Wno-deprecated-declarations \
+m4_define([compiler_flags_common],[ dnl
+ -pipe dnl
+ -Waggregate-return dnl
+ -Wall dnl
+ -Wcast-align dnl
+ -Wendif-labels dnl
+ -Werror=declaration-after-statement dnl
+ "-Werror=format=2 -Werror=format-nonliteral -Werror=format-security" dnl
+ -Werror=implicit-function-declaration dnl
+ -Werror=init-self dnl
+ -Werror=missing-include-dirs dnl
+ -Werror=missing-prototypes dnl
+ -Werror=pointer-arith dnl
+ -Wextra dnl
+ -Wfloat-equal dnl
+ -Wlogical-op dnl
+ -Wmissing-declarations dnl
+ -Wmissing-include-dirs dnl
+ -Wmissing-format-attribute dnl
+ -Wmissing-noreturn dnl
+ -Wno-missing-field-initializers dnl
+ -Wno-switch-enum dnl
+ -Wno-unused-parameter dnl
+ -Wpacked dnl
+ -Wshadow dnl
+ -Wsign-compare dnl
+ -Wstrict-aliasing=2 dnl
+ -Wundef dnl
+ -Wuninitialized dnl
+ -Wunsafe-loop-optimizations dnl
+ -Wwrite-strings dnl
+ -fno-common dnl
+ -fdiagnostics-show-option dnl
+ -fno-strict-aliasing dnl
+ -fstack-protector dnl
+ -fstack-protector-strong dnl
+ -fno-semantic-interposition dnl
+ -Wno-deprecated-declarations dnl
+])
+
+m4_define([compiler_flags_only_c],[ dnl
+ -Wimplicit dnl
+ -Wnested-externs dnl
+ -Wold-style-definition dnl
+ -Wstrict-prototypes dnl
+])
+
+m4_define([compiler_flags_only_cxx],[ dnl
+ -fno-rtti dnl
+ -fno-exceptions dnl
])
+CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[compiler_flags_common compiler_flags_only_c])
+
+AC_LANG_PUSH([C++])
+CC_CHECK_FLAGS_APPEND([AM_CXXFLAGS],[CXXFLAGS],[compiler_flags_common compiler_flags_only_cxx])
+AC_LANG_POP([C++])
+
##########################################################
# Check for -Bsymbolic-functions linker flag used to avoid
# intra-library PLT jumps, if available.
@@ -150,16 +168,28 @@ AC_ARG_ENABLE([Bsymbolic],
VTE_LDFLAGS=
if test "$enable_Bsymbolic" != "no"; then
CC_CHECK_LDFLAGS(["-Wl,-Bsymbolic-functions"],
- [VTE_LDFLAGS="$VTE_LDFLAGS -Wl,-Bsymbolic-functions"],
+ [VTE_LDFLAGS="$VTE_CXXLDFLAGS -Wl,-Bsymbolic-functions"],
+ [if test "$enable_Bsymbolic" = "auto"; then
+ AC_MSG_WARN([-Bsymbolic not supported by ld; disabling])
+ enable_Bsymbolic=no
+ else
+ AC_MSG_ERROR([-Bsymbolic requested but not supported by ld. Use --disable-Bsymbolic to disable])
+ fi])
+
+ AC_LANG_PUSH([C++])
+ CC_CHECK_LDFLAGS(["-Wl,-Bsymbolic-functions"],
+ [VTE_LDFLAGS="$VTE_CXXLDFLAGS -Wl,-Bsymbolic-functions"],
[if test "$enable_Bsymbolic" = "auto"; then
AC_MSG_WARN([-Bsymbolic not supported by ld; disabling])
enable_Bsymbolic=no
else
AC_MSG_ERROR([-Bsymbolic requested but not supported by ld. Use --disable-Bsymbolic to disable])
fi])
+ AC_LANG_POP([C++])
fi
AC_SUBST([VTE_LDFLAGS])
+AC_SUBST([VTE_CXXLDFLAGS])
################################################################################
# Core
@@ -332,6 +362,7 @@ AC_SUBST([VTE_MICRO_VERSION],[version_micro])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
+AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
################################################################################
diff --git a/src/Makefile.am b/src/Makefile.am
index 9536b4d..af54114 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -111,6 +111,10 @@ libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_CFLAGS = \
$(VTE_CFLAGS) \
$(AM_CFLAGS)
+libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_CXXFLAGS = \
+ $(VTE_CFLAGS) \
+ $(AM_CXXFLAGS)
+
libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LDFLAGS = \
$(VTE_LDFLAGS) \
-version-info $(LT_VERSION_INFO) \
@@ -311,14 +315,20 @@ noinst_PROGRAMS += interpret slowcat
noinst_SCRIPTS = decset osc window
EXTRA_DIST += $(noinst_SCRIPTS)
-TEST_SH = \
+check_PROGRAMS = dumpkeys reflect-text-view reflect-vte mev table xticker vteconv vtestream-file
+
+dist_check_SCRIPTS = \
check-doc-syntax.sh \
+ check-libstdc++.sh \
test-vte-sh.sh \
$(NULL)
-EXTRA_DIST += $(TEST_SH)
-check_PROGRAMS = dumpkeys reflect-text-view reflect-vte mev table xticker vteconv vtestream-file
-TESTS = table vteconv vtestream-file $(TEST_SH)
+TESTS = table vteconv vtestream-file $(dist_check_SCRIPTS)
+TESTS_ENVIRONMENT = \
+ srcdir="$(srcdir)" \
+ top_builddir="$(top_builddir)" \
+ VTE_API_VERSION="$(VTE_API_VERSION)" \
+ $(NULL)
reflect_text_view_CPPFLAGS = -DUSE_TEXT_VIEW -I$(srcdir) -I $(builddir) $(AM_CPPFLAGS)
reflect_text_view_CFLAGS = $(VTE_CFLAGS) $(AM_CFLAGS)
diff --git a/src/check-libstdc++.sh b/src/check-libstdc++.sh
new file mode 100755
index 0000000..80d8757
--- /dev/null
+++ b/src/check-libstdc++.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+export LC_ALL=C
+
+LDD=ldd
+GREP=grep
+
+if $LDD .libs/libvte-$VTE_API_VERSION.so | $GREP 'libstdc++' &>/dev/null; then
+ echo "FAIL: libvte-$VTE_API_VERSION.so is linked to libstdc++"
+ exit 1
+fi
+
+exit 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]