Skip to content

Commit

Permalink
wayland: Detect compiler flags
Browse files Browse the repository at this point in the history
Use pkgconfig to detect include path required for building wayland
backend. Do not hardcode wayland libraries, use pkgconfig to detect
them.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
  • Loading branch information
hramrach committed Mar 4, 2023
1 parent 30cc3d4 commit 98ceb4a
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 6 deletions.
103 changes: 102 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ SDL2GUI
sdl2_config
SDL2_LIBS
SDL2_CFLAGS
WAYLAND_LIBS
WAYLAND_CFLAGS
SIXEL_LIBS
SIXEL_CFLAGS
VT_NORM_CFLAGS
Expand Down Expand Up @@ -1033,6 +1035,8 @@ GIO_CFLAGS
GIO_LIBS
FT_CFLAGS
FT_LIBS
WAYLAND_CFLAGS
WAYLAND_LIBS
SDL2_CFLAGS
SDL2_LIBS
FRIBIDI_CFLAGS
Expand Down Expand Up @@ -1796,6 +1800,10 @@ Some influential environment variables:
GIO_LIBS linker flags for GIO, overriding pkg-config
FT_CFLAGS C compiler flags for FT, overriding pkg-config
FT_LIBS linker flags for FT, overriding pkg-config
WAYLAND_CFLAGS
C compiler flags for WAYLAND, overriding pkg-config
WAYLAND_LIBS
linker flags for WAYLAND, overriding pkg-config
SDL2_CFLAGS C compiler flags for SDL2, overriding pkg-config
SDL2_LIBS linker flags for SDL2, overriding pkg-config
FRIBIDI_CFLAGS
Expand Down Expand Up @@ -18268,8 +18276,101 @@ elif test "$gui" = "beos" ; then
GUI="beos"
GUI_CFLAGS="-DUSE_BEOS"
elif test "$gui" = "wayland" ; then

pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WAYLAND" >&5
$as_echo_n "checking for WAYLAND... " >&6; }

if test -n "$WAYLAND_CFLAGS"; then
pkg_cv_WAYLAND_CFLAGS="$WAYLAND_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"wayland-client wayland-cursor xkbcommon\""; } >&5
($PKG_CONFIG --exists --print-errors "wayland-client wayland-cursor xkbcommon") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WAYLAND_CFLAGS=`$PKG_CONFIG --cflags "wayland-client wayland-cursor xkbcommon" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$WAYLAND_LIBS"; then
pkg_cv_WAYLAND_LIBS="$WAYLAND_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"wayland-client wayland-cursor xkbcommon\""; } >&5
($PKG_CONFIG --exists --print-errors "wayland-client wayland-cursor xkbcommon") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WAYLAND_LIBS=`$PKG_CONFIG --libs "wayland-client wayland-cursor xkbcommon" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
WAYLAND_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "wayland-client wayland-cursor xkbcommon" 2>&1`
else
WAYLAND_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "wayland-client wayland-cursor xkbcommon" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$WAYLAND_PKG_ERRORS" >&5

as_fn_error $? "Package requirements (wayland-client wayland-cursor xkbcommon) were not met:

$WAYLAND_PKG_ERRORS

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables WAYLAND_CFLAGS
and WAYLAND_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables WAYLAND_CFLAGS
and WAYLAND_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See \`config.log' for more details" "$LINENO" 5; }
else
WAYLAND_CFLAGS=$pkg_cv_WAYLAND_CFLAGS
WAYLAND_LIBS=$pkg_cv_WAYLAND_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

fi
GUI="wayland"
GUI_CFLAGS="-DUSE_WAYLAND"


elif test "$gui" = "sdl2" ; then

pkg_failed=no
Expand Down Expand Up @@ -18342,7 +18443,7 @@ else
$as_echo "yes" >&6; }
have_sdl2=yes
fi
if test "$have_sdl2" != "yes" ; then
if test "$have_sdl2" != "yes" ; then
# Extract the first word of "sdl2-config", so it can be a program name with args.
set dummy sdl2-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
Expand Down
5 changes: 4 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,14 @@ elif test "$gui" = "beos" ; then
GUI="beos"
GUI_CFLAGS="-DUSE_BEOS"
elif test "$gui" = "wayland" ; then
PKG_CHECK_MODULES(WAYLAND, [wayland-client wayland-cursor xkbcommon])
GUI="wayland"
GUI_CFLAGS="-DUSE_WAYLAND"
AC_SUBST(WAYLAND_CFLAGS)
AC_SUBST(WAYLAND_LIBS)
elif test "$gui" = "sdl2" ; then
PKG_CHECK_MODULES(SDL2, sdl2, have_sdl2=yes, have_sdl2=no)
if test "$have_sdl2" != "yes" ; then
if test "$have_sdl2" != "yes" ; then
AC_CHECK_PROG(sdl2_config, sdl2-config, yes)
if test "$sdl2_config" = "yes"; then
SDL2_CFLAGS="`sdl2-config --cflags`"
Expand Down
1 change: 1 addition & 0 deletions inputmethod/canna/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/fcitx/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/ibus/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/iiimf/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@TYPE_CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/kbd/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/m17nlib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/scim/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@MEF_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/skk/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/uim/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
1 change: 1 addition & 0 deletions inputmethod/wnn/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFLAGS = $(CFLAGS_LOCAL) \
@DEB_CFLAGS@ \
@X_CFLAGS@ \
@GUI_CFLAGS@ \
@WAYLAND_CFLAGS@ \
@SDL2_CFLAGS@ \
@TRUECOLOR_CFLAGS@ \
@CFLAGS@ \
Expand Down
5 changes: 2 additions & 3 deletions main/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LMEF_DEB = -lmef_deb

# XDATADIR is to avoid conflicting with DATADIR structure in w32api/objidl.h.
CFLAGS = $(CFLAGS_LOCAL) @POBL_CFLAGS@ @MEF_CFLAGS@ @DEB_CFLAGS@ @BRLAPI_CFLAGS@ \
@X_CFLAGS@ @GUI_CFLAGS@ @SSH2_CFLAGS@ @TYPE_CFLAGS@ @FT_CFLAGS@ @SDL2_CFLAGS@ \
@X_CFLAGS@ @GUI_CFLAGS@ @SSH2_CFLAGS@ @TYPE_CFLAGS@ @FT_CFLAGS@ @WAYLAND_CFLAGS@ @SDL2_CFLAGS@ \
@DAEMON_CFLAGS@ @SPLIT_CFLAGS@ @DND_CFLAGS@ @TRANSFER_CFLAGS@ @IMAGE_CFLAGS@ \
@TRUECOLOR_CFLAGS@ @CFLAGS@ @CPPFLAGS@ -DSYSCONFDIR=\"$(sysconfdir)\" \
-I$(top_srcdir)/vtemu \
Expand All @@ -63,8 +63,7 @@ LIBS2_beos = -lbe -ltranslation -lsocket

LIBS2_console = @SIXEL_LIBS@ @MATH_LIBS@ @DL_LIBS_IM@ @DL_LIBS_SB@ @SOCK_LIBS@

LIBS2_wayland = @FT_LIBS@ @MATH_LIBS@ @DL_LIBS_IM@ @DL_LIBS_SB@ @SOCK_LIBS@ \
-lwayland-client -lwayland-cursor -lxkbcommon
LIBS2_wayland = @WAYLAND_LIBS@ @FT_LIBS@ @MATH_LIBS@ @DL_LIBS_IM@ @DL_LIBS_SB@ @SOCK_LIBS@

LIBS2_sdl2_win32 = ../uitoolkit/winrs.o

Expand Down
2 changes: 1 addition & 1 deletion uitoolkit/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CFLAGS = $(CFLAGS_LOCAL) @POBL_CFLAGS@ @MEF_CFLAGS@ @DEB_CFLAGS@ @MATH_CFLAGS@ \
@IMAGELIB_CFLAGS@ @X_CFLAGS@ @GUI_CFLAGS@ @SSH2_CFLAGS@ @XUTF8_CFLAGS@ @DND_CFLAGS@ \
@IM_CFLAGS@ @SB_CFLAGS@ @REGEX_CFLAGS@ @CTL_CFLAGS@ @TYPE_CFLAGS@ @FT_CFLAGS@ \
@IMAGE_CFLAGS@ @TOOLS_CFLAGS@ @OT_LAYOUT_CFLAGS@ @SIXEL_CFLAGS@ @BRLAPI_CFLAGS@ \
@SDL2_CFLAGS@ @SPLIT_CFLAGS@ @TRUECOLOR_CFLAGS@ @CFLAGS@ @CPPFLAGS@ \
@WAYLAND_CFLAGS@ @SDL2_CFLAGS@ @SPLIT_CFLAGS@ @TRUECOLOR_CFLAGS@ @CFLAGS@ @CPPFLAGS@ \
-DBINDIR=\"$(bindir)\" -DLIBDIR=\"$(libdir)\" -DLIBEXECDIR=\"$(libexecdir)\" \
-DXDATADIR=\"$(datadir)\" \
-I$(top_srcdir)/vtemu -I$(top_srcdir)/uitoolkit/libotl -I/usr/local/include
Expand Down

0 comments on commit 98ceb4a

Please sign in to comment.