mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-18 09:30:40 +01:00
build: Fix C++ issues with automake
This is an attempt to fix the broken situation we've been in where automake links libcairo.la with c++ because it might potentially maybe include C++ files. Those potential files only exist in Chris' throwaway backends (skia, qt) and the BeOS backend, so for 99.99% of cases, these backends are not needed and linking with c++ is overkill. Also, no one wants to have libcairo.so link to libstdc++. This patch fixes that in mutliple steps: 1) Add build infrastructure to distinguish between C and C++ backends. This is done by allowing to specify backend_sources as well as backend_cxx_sources variables in Makefile.sources. 2) Optionally build a libcairo_cxx.la noinst library This intermediate library is built for C++ backends only and therefor linked using c++. It is then linked into the final libcairo.la. This does not require c++, so the linking of libcairo.la is done with cc. This also works around various weirdnesses that the current build system exposes, where it assumes cisms when in fact using c++ semantics, like not detecting c++ properly or: https://bugzilla.redhat.com/show_bug.cgi?id=606523
This commit is contained in:
parent
df6d49f6ea
commit
f7fc8569a7
5 changed files with 40 additions and 7 deletions
|
|
@ -83,15 +83,16 @@ CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,no,!,
|
|||
dnl Collect list of source files for all public features
|
||||
CAIRO_MAKEFILE_ACCUMULATE(*,
|
||||
[dnl
|
||||
all_$1_files = $(all_$1_headers) $(all_$1_private) $(all_$1_sources)
|
||||
all_$1_headers = $($1_headers)
|
||||
all_$1_private = $($1_private)
|
||||
all_$1_cxx_sources = $($1_cxx_sources)
|
||||
all_$1_sources = $($1_sources)
|
||||
])dnl
|
||||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,!,
|
||||
[dnl
|
||||
all_$1_headers += $($1_$2_headers)
|
||||
all_$1_private += $($1_$2_private)
|
||||
all_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
all_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -100,12 +101,14 @@ CAIRO_MAKEFILE_ACCUMULATE(*,
|
|||
[dnl
|
||||
enabled_$1_headers = $($1_headers)
|
||||
enabled_$1_private = $($1_private)
|
||||
enabled_$1_cxx_sources = $($1_cxx_sources)
|
||||
enabled_$1_sources = $($1_sources)
|
||||
])dnl
|
||||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,!,
|
||||
[dnl
|
||||
enabled_$1_headers += $($1_$2_headers)
|
||||
enabled_$1_private += $($1_$2_private)
|
||||
enabled_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
enabled_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -115,6 +118,7 @@ dnl Collect list of source files for all private features
|
|||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,,
|
||||
[dnl
|
||||
all_$1_private += $($1_$2_private) $($1_$2_headers)
|
||||
all_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
all_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
@ -122,6 +126,7 @@ dnl Collect list of source files for enabled private features
|
|||
CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,,
|
||||
[dnl
|
||||
enabled_$1_private += $($1_$2_private) $($1_$2_headers)
|
||||
enabled_$1_cxx_sources += $($1_$2_cxx_sources)
|
||||
enabled_$1_sources += $($1_$2_sources)]dnl
|
||||
)dnl
|
||||
|
||||
|
|
|
|||
10
configure.ac
10
configure.ac
|
|
@ -777,6 +777,16 @@ fi
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
dnl Extra stuff we need to do when building C++ code
|
||||
need_cxx="no"
|
||||
AS_IF([test "x$use_skia" = "xyes"], [need_cxx="yes"])
|
||||
AS_IF([test "x$use_qt" = "xyes"], [need_cxx="yes"])
|
||||
AS_IF([test "x$use_beos" = "xyes"], [need_cxx="yes"])
|
||||
|
||||
AM_CONDITIONAL(BUILD_CXX, test "x$need_cxx" = "xyes")
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
# We use GTK+ for some utility/debugging tools
|
||||
PKG_CHECK_MODULES(gtk, "gtk+-2.0",have_gtk=yes, have_gtk=no)
|
||||
AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes")
|
||||
|
|
|
|||
|
|
@ -24,13 +24,31 @@ cairoinclude_HEADERS = $(enabled_cairo_headers)
|
|||
|
||||
lib_LTLIBRARIES = libcairo.la
|
||||
|
||||
if BUILD_CXX
|
||||
cairo_cxx_lib = libcairo_cxx.la
|
||||
else
|
||||
cairo_cxx_lib = libcairo_cxx.la
|
||||
endif
|
||||
|
||||
noinst_LTLIBRARIES = $(cairo_cxx_lib)
|
||||
libcairo_cxx_la_SOURCES = \
|
||||
$(enabled_cairo_headers) \
|
||||
$(enabled_cairo_private) \
|
||||
$(enabled_cairo_cxx_sources) \
|
||||
$(NULL)
|
||||
libcairo_cxx_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols)
|
||||
libcairo_cxx_la_LIBADD = $(CAIRO_LIBS)
|
||||
libcairo_cxx_la_DEPENDENCIES = $(cairo_def_dependency)
|
||||
|
||||
|
||||
libcairo_la_SOURCES = \
|
||||
$(enabled_cairo_headers) \
|
||||
$(enabled_cairo_private) \
|
||||
$(enabled_cairo_sources) \
|
||||
$(NULL)
|
||||
libcairo_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols)
|
||||
libcairo_la_LIBADD = $(CAIRO_LIBS)
|
||||
libcairo_la_LIBADD = $(CAIRO_LIBS) \
|
||||
$(enabled_cairo_cxx_lib)
|
||||
libcairo_la_DEPENDENCIES = $(cairo_def_dependency)
|
||||
|
||||
# Special headers
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
SPARSE = sparse
|
||||
sparse:
|
||||
@echo Checking enabled sources with sparse checker
|
||||
@status=true; for f in $(enabled_cairo_sources); do \
|
||||
@status=true; for f in $(enabled_cairo_sources) $(enabled_cairo_cxx_sources); do \
|
||||
echo $(SPARSE) $(PREPROCESS_ARGS) $(srcdir)/$$f; \
|
||||
$(SPARSE) $(PREPROCESS_ARGS) $(srcdir)/$$f || status=false; \
|
||||
done; $$status
|
||||
|
|
@ -10,7 +10,7 @@ sparse:
|
|||
SPLINT = splint -badflag
|
||||
splint:
|
||||
@echo Checking enabled sources with splint checker
|
||||
@status=true; for f in $(enabled_cairo_sources); do \
|
||||
@status=true; for f in $(enabled_cairo_sources) $(enabled_cairo_cxx_sources); do \
|
||||
echo $(SPLINT) $(PREPROCESS_ARGS) $(srcdir)/$$f; \
|
||||
$(SPLINT) $(PREPROCESS_ARGS) $(srcdir)/$$f || status=false; \
|
||||
done; $$status
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ cairo_xcb_sources += \
|
|||
endif
|
||||
|
||||
cairo_qt_headers = cairo-qt.h
|
||||
cairo_qt_sources = cairo-qt-surface.cpp
|
||||
cairo_qt_cxx_sources = cairo-qt-surface.cpp
|
||||
|
||||
cairo_quartz_headers = cairo-quartz.h
|
||||
cairo_quartz_private = cairo-quartz-private.h
|
||||
|
|
@ -303,7 +303,7 @@ cairo_win32_sources = cairo-win32-surface.c cairo-win32-printing-surface.c
|
|||
cairo_win32_font_sources = cairo-win32-font.c
|
||||
|
||||
cairo_skia_headers = cairo-skia.h
|
||||
cairo_skia_sources = cairo-skia-surface.cpp
|
||||
cairo_skia_cxx_sources = cairo-skia-surface.cpp
|
||||
|
||||
cairo_os2_headers = cairo-os2.h
|
||||
cairo_os2_private = cairo-os2-private.h
|
||||
|
|
@ -312,7 +312,7 @@ cairo_os2_sources = cairo-os2-surface.c
|
|||
# automake is stupid enough to always use c++ linker if we enable the
|
||||
# following lines, even if beos surface is not enabled. Disable it for now.
|
||||
cairo_beos_headers = cairo-beos.h
|
||||
#cairo_beos_sources = cairo-beos-surface.cpp
|
||||
cairo_beos_cxx_sources = cairo-beos-surface.cpp
|
||||
|
||||
cairo_gl_headers = cairo-gl.h
|
||||
cairo_gl_private = cairo-gl-private.h \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue