Bug 1721962 - Switch to pkg-config for X11 libraries. r=firefox-build-system-reviewers,jgilbert,andi

Differential Revision: https://phabricator.services.mozilla.com/D121309
This commit is contained in:
Mike Hommey 2021-07-30 11:39:39 +00:00
Родитель e9954811d5
Коммит 221139493a
8 изменённых файлов: 39 добавлений и 100 удалений

Просмотреть файл

@ -7,7 +7,7 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
'-Wno-range-loop-construct',
]
CXXFLAGS += CONFIG['XCFLAGS']
CXXFLAGS += CONFIG['MOZ_X11_CFLAGS']
if CONFIG['INTEL_ARCHITECTURE']:
CXXFLAGS += CONFIG['SSE2_FLAGS']

Просмотреть файл

@ -284,7 +284,7 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc') and CONFIG['OS_TARGET'] == 'Android' an
CXXFLAGS += ['-O2']
if CONFIG['MOZ_X11']:
CFLAGS += CONFIG['XCFLAGS']
CFLAGS += CONFIG['MOZ_X11_CFLAGS']
if CONFIG['MOZ_ENABLE_CAIRO_FT']:
CFLAGS += CONFIG['CAIRO_FT_CFLAGS']

Просмотреть файл

@ -240,24 +240,6 @@ AC_SUBST(GNU_CXX)
AC_SUBST_LIST(STL_FLAGS)
AC_SUBST(WRAP_STL_INCLUDES)
dnl ========================================================
dnl Checks for programs.
dnl ========================================================
if test "$COMPILE_ENVIRONMENT"; then
dnl autoconf's xmkmf test tries to find X11 headers and libraries via
dnl running xmkmf if it's available. This doesn't take into account
dnl sysroots, so we're better off without the test. Moreover, most of
dnl the time, xmkmf is not available, and things work just fine anyway.
dnl This avoids breaking the build when xmkmf _is_ available and a
dnl sysroot is used.
define([AC_PATH_X_XMKMF], [])
AC_PATH_XTRA
XCFLAGS="$X_CFLAGS"
fi # COMPILE_ENVIRONMENT
dnl ========================================================
dnl set the defaults first
dnl ========================================================
@ -980,41 +962,6 @@ fi
AC_CHECK_LIB(socket, socket)
XLDFLAGS="$X_LIBS"
XLIBS="$X_EXTRA_LIBS"
dnl ========================================================
dnl Checks for X libraries.
dnl ========================================================
if test -n "$MOZ_X11"; then
AC_DEFINE_UNQUOTED(FUNCPROTO,15)
_SAVE_LDFLAGS="$LDFLAGS"
_SAVE_LIBS="$LIBS"
LDFLAGS="$XLDFLAGS $LDFLAGS"
AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
[MISSING_X="$MISSING_X -lX11"], $XLIBS)
AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
[MISSING_X="$MISSING_X -lXext"], $XLIBS)
dnl ========================================================
dnl = Check for xcb
dnl ========================================================
AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
[MISSING_X="$MISSING_X -lxcb"], $XLIBS)
AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
[MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
[MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
LDFLAGS="$_SAVE_LDFLAGS"
LIBS="$_SAVE_LIBS"
fi # $MOZ_X11
AC_SUBST_LIST(XCFLAGS)
AC_SUBST_LIST(XLDFLAGS)
AC_SUBST_LIST(XLIBS)
AC_SUBST_LIST(XEXT_LIBS)
dnl ========================================================
dnl = pthread support
dnl = Start by checking whether the system support pthreads
@ -2258,7 +2205,7 @@ if test "$USE_FC_FREETYPE"; then
fi
_SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS"
MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
[AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
CPPFLAGS="$_SAVE_CPPFLAGS"
@ -2627,37 +2574,6 @@ AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
if test -n "$COMPILE_ENVIRONMENT"; then
AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
dnl Check for missing components
if test "$MOZ_X11"; then
dnl ====================================================
dnl = Check if X headers exist
dnl ====================================================
_SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $XCFLAGS"
AC_TRY_COMPILE([
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/extensions/XShm.h>
],
[
Display *dpy = 0;
if ((dpy = XOpenDisplay(NULL)) == NULL) {
fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
exit(1);
}
], [],
[ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
CFLAGS="$_SAVE_CFLAGS"
if test -n "$MISSING_X"; then
AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
fi
fi # MOZ_X11
fi # COMPILE_ENVIRONMENT
dnl Set various defines and substitutions

Просмотреть файл

@ -10,7 +10,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk" and CONFIG["MOZ_X11"]:
"gdk-screenshot.cpp",
]
CXXFLAGS += CONFIG["TK_CFLAGS"]
LDFLAGS += CONFIG["XLDFLAGS"]
OS_LIBS += CONFIG["TK_LIBS"]
if CONFIG["MOZ_ENABLE_DBUS"]:
OS_LIBS += CONFIG["MOZ_DBUS_GLIB_LIBS"]

Просмотреть файл

@ -278,13 +278,8 @@ if CONFIG["MOZ_ENABLE_DBUS"]:
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
OS_LIBS += [l for l in CONFIG["TK_LIBS"] if l not in ("-lgtk-3", "-lgdk-3")]
OS_LIBS += CONFIG["XLDFLAGS"]
OS_LIBS += CONFIG["XLIBS"]
OS_LIBS += CONFIG["XEXT_LIBS"]
OS_LIBS += CONFIG["MOZ_X11_LIBS"]
OS_LIBS += CONFIG["MOZ_PANGO_LIBS"]
OS_LIBS += [
"Xrender",
]
if CONFIG["MOZ_ENABLE_LIBPROXY"]:
OS_LIBS += CONFIG["MOZ_LIBPROXY_LIBS"]

Просмотреть файл

@ -314,10 +314,6 @@ def toolkit_gtk(toolkit):
return toolkit == "gtk"
set_config("MOZ_X11", True, when=toolkit_gtk)
set_define("MOZ_X11", True, when=toolkit_gtk)
add_old_configure_assignment("MOZ_X11", True, when=toolkit_gtk)
# Wayland support
# ==============================================================
wayland_headers = pkg_check_modules(
@ -1171,6 +1167,39 @@ option(
set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
# X11
# ==============================================================
set_config("MOZ_X11", True, when=toolkit_gtk)
set_define("MOZ_X11", True, when=toolkit_gtk)
@depends(webrtc, when=toolkit_gtk)
def x11_libs(webrtc):
libs = [
"x11",
"xcb",
"xcb-shm",
"x11-xcb",
"xext",
"xrender",
]
if webrtc:
# third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
# manually, ensure they're available.
libs += [
"xcomposite",
"xcursor",
"xdamage",
"xfixes",
"xi",
]
return " ".join(libs)
pkg_check_modules("MOZ_X11", x11_libs, when=toolkit_gtk)
# ASan Reporter Addon
# ==============================================================
option(

Просмотреть файл

@ -10,7 +10,7 @@ SOURCES += [
"mozgtk.c",
]
CFLAGS += CONFIG["XCFLAGS"]
CFLAGS += CONFIG["MOZ_X11_CFLAGS"]
# If LDFLAGS contains -Wl,--as-needed or if it's the default for the toolchain,
# we need to add -Wl,--no-as-needed before the gtk libraries, otherwise the

Просмотреть файл

@ -13,4 +13,4 @@ SOURCES += [
FINAL_LIBRARY = "xul"
CFLAGS += CONFIG["XCFLAGS"]
CFLAGS += CONFIG["MOZ_X11_CFLAGS"]