Avoid potential negative array index access to cached text.
[LibreOffice.git] / external / cairo / ExternalProject_cairo.mk
blobdf6bd5a37b784e5eccdb87d528aa1ca1a17d68f6
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 $(eval $(call gb_ExternalProject_ExternalProject,cairo))
12 $(eval $(call gb_ExternalProject_use_external_project,cairo,pixman))
14 $(eval $(call gb_ExternalProject_use_externals,cairo,\
15 fontconfig \
16 freetype \
17 libpng \
18 zlib \
21 $(eval $(call gb_ExternalProject_register_targets,cairo,\
22 build \
25 # Including -rtlib=compiler-rt in pixman_LIBS is a BAD HACK: At least when compiling with Clang
26 # -fsanitize=undefined on Linux x86-64, the generated code references __muloti4, which is an
27 # extension provided by libclang_rt.builtins-x86_64.a runtime, but not by GCC's libgcc_s.so.1 (which
28 # ultimately boils down to a bug in LLVM, I would say). I am not sure whether it should in general
29 # work to mix uses of the (default on Linux, at least) GCC libgcc_s and LLVM's libclang_rt.builtins
30 # runtime libraries in one process, but for this specific case of libcairo.so it appears to work
31 # well: For one, the only symbol referenced by libcairo.so from the runtime library is __muloti4;
32 # for another, at least in my LLVM build, lib/clang/12.0.0/lib/linux/libclang_rt.builtins-x86_64.a
33 # is only provided as a static archive; so libcairo.so will only contain a "harmless" copy of
34 # __muloti4 and not have a DT_NEEDED of any libclang_rt.builtins dynamic library that it would pull
35 # in at runtime.
36 # But passing -rtlib=compiler-rt into cairo's configure via the more obvious LDFLAGS would fail at
37 # least when building with -fsanitize=address and -fsanitize=undefined, as then the executable
38 # compiled by configure when "checking whether the C compiler works" would reference
39 # _Unwind_Backtrace etc. that are provided by GCC's libgcc_s.so.1 but not by LLVM's
40 # libclang_rt.builtins-x86_64.a (and whatever the reason for that inconsistency). So
41 # -rtlib=compiler-rt must be passed just into the linking of libcairo.so, but not generally into
42 # cairo's configure. And pixman_LIBS happens to offer that. (The -Wc is necessary so that libtool
43 # does not throw away the -rtlib=compiler-rt which it does not understand.)
45 $(call gb_ExternalProject_get_state_target,cairo,build) :
46 $(call gb_Trace_StartRange,cairo,EXTERNAL)
47 $(call gb_ExternalProject_run,build,\
48 $(gb_RUN_CONFIGURE) ./configure \
49 $(if $(debug),STRIP=" ") \
50 $(if $(filter ANDROID iOS,$(OS)),CFLAGS="$(if $(debug),-g) $(ZLIB_CFLAGS) $(gb_VISIBILITY_FLAGS)") \
51 $(if $(filter EMSCRIPTEN,$(OS)),CFLAGS="-O3 -DCAIRO_NO_MUTEX $(ZLIB_CFLAGS) -Wno-enum-conversion $(gb_EMSCRIPTEN_CPPFLAGS)" ) \
52 $(if $(filter -fsanitize=undefined,$(CC)),CC='$(CC) -fno-sanitize=function') \
53 $(if $(filter-out EMSCRIPTEN ANDROID iOS,$(OS)), \
54 CFLAGS="$(CFLAGS) $(call gb_ExternalProject_get_build_flags,cairo) $(ZLIB_CFLAGS)" \
55 LDFLAGS="$(call gb_ExternalProject_get_link_flags,cairo)" \
56 ) \
57 $(if $(filter ANDROID iOS,$(OS)),PKG_CONFIG=./dummy_pkg_config) \
58 LIBS="$(ZLIB_LIBS)" \
59 $(if $(filter -fsanitize=%,$(LDFLAGS)),LDFLAGS="$(LDFLAGS) -fuse-ld=bfd") \
60 pixman_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,pixman)/pixman -pthread" \
61 pixman_LIBS="-L$(call gb_UnpackedTarball_get_dir,pixman)/pixman/.libs -lpixman-1 \
62 $(if $(filter LINUX,$(OS)),-Wl$(COMMA)-z$(COMMA)origin \
63 -Wl$(COMMA)-rpath$(COMMA)\\\$$\$$ORIGIN) \
64 $(if $(filter -fsanitize=%,$(CC)), \
65 $(if $(filter LINUX-X86_64-TRUE,$(OS)-$(CPUNAME)-$(COM_IS_CLANG)), \
66 -Wc$(COMMA)-rtlib=compiler-rt))" \
67 png_REQUIRES="trick_configure_into_using_png_CFLAGS_and_LIBS" \
68 png_CFLAGS="$(LIBPNG_CFLAGS)" png_LIBS="$(LIBPNG_LIBS)" \
69 $(if $(SYSTEM_FREETYPE),,FREETYPE_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,freetype)/include") \
70 $(if $(SYSTEM_FONTCONFIG),,FONTCONFIG_CFLAGS="-I$(call gb_UnpackedTarball_get_dir,fontconfig)") \
71 $(if $(verbose),--disable-silent-rules,--enable-silent-rules) \
72 $(if $(filter TRUE,$(DISABLE_DYNLOADING)),--disable-shared,--disable-static) \
73 $(if $(filter EMSCRIPTEN ANDROID iOS,$(OS)),--disable-xlib --disable-xcb,$(if $(filter TRUE,$(DISABLE_GUI)),--disable-xlib --disable-xcb,--enable-xlib --enable-xcb)) \
74 $(if $(filter iOS,$(OS)),--enable-quartz --enable-quartz-font) \
75 --disable-valgrind \
76 $(if $(filter iOS,$(OS)),--disable-ft,--enable-ft --enable-fc) \
77 --disable-svg --enable-gtk-doc=no --enable-test-surfaces=no \
78 $(gb_CONFIGURE_PLATFORMS) \
79 $(if $(CROSS_COMPILING),$(if $(filter INTEL ARM,$(CPUNAME)),ac_cv_c_bigendian=no ax_cv_c_float_words_bigendian=no)) \
80 $(if $(filter MACOSX,$(OS)),--prefix=/@.__________________________________________________OOO) \
81 && cd src && $(MAKE) \
83 $(call gb_Trace_EndRange,cairo,EXTERNAL)
85 # vim: set noet sw=4 ts=4: