Clean up the build around xF
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success

And make sure it gets built at all, if possible.

It's actually pretty good now, reaching feature parity with xP and xC.
This commit is contained in:
2026-08-07 11:09:16 +02:00
parent 4f5d4cb64b
commit 2d8867f6fa
4 changed files with 51 additions and 37 deletions
+20 -13
View File
@@ -8,9 +8,6 @@ string (STRIP "${project_version}" project_version)
project (xK VERSION "${project_version}"
DESCRIPTION "IRC daemon, bot, TUI client and its web frontend" LANGUAGES C)
# Options
option (WITH_XF "Build the xF frontend" OFF)
# Moar warnings
set (CMAKE_C_STANDARD 99)
set (CMAKE_C_STANDARD_REQUIRED ON)
@@ -138,8 +135,27 @@ else ()
message (SEND_ERROR "Curses not found")
endif ()
# Dependencies for xF
find_package (Unistring)
set (xF_SATISFIED FALSE)
if (ncursesw_FOUND AND Unistring_FOUND)
set (xF_SATISFIED TRUE)
endif ()
option (WITH_XF "Build the xF frontend" "${xF_SATISFIED}")
if (WITH_XF AND NOT xF_SATISFIED)
message (FATAL_ERROR "Some xF dependencies were not found")
endif ()
pkg_check_modules (x11 x11 xrender xft fontconfig libpng)
option (WITH_X11 "Build xF with X11 support" "${x11_FOUND}")
if (WITH_X11 AND NOT x11_FOUND)
message (FATAL_ERROR "Some X11 libraries were not found")
endif ()
# Generate a configuration file
set (HAVE_LUA "${WITH_LUA}")
set (HAVE_X11 "${WITH_X11}")
include (GNUInstallDirs)
set (project_config ${PROJECT_BINARY_DIR}/config.h)
@@ -171,8 +187,8 @@ add_custom_command (OUTPUT xC-proto.c
add_custom_target (xC-proto DEPENDS ${PROJECT_BINARY_DIR}/xC-proto.c)
# Build
set (project_binaries xB xC xD)
foreach (name xB xC xD)
list (APPEND project_binaries ${name})
add_executable (${name} ${name}.c ${project_config})
target_link_libraries (${name} PRIVATE ${project_libraries})
add_threads (${name})
@@ -186,14 +202,6 @@ target_include_directories (xC PRIVATE ${Termo_INCLUDE_DIRS})
if (WITH_XF)
list (APPEND project_binaries xF)
find_package (Unistring REQUIRED)
pkg_check_modules (x11 x11 xrender xft fontconfig libpng)
option (WITH_X11 "Build xF with X11 support" "${x11_FOUND}")
if (WITH_X11 AND NOT x11_FOUND)
message (FATAL_ERROR "Some X11 libraries were not found")
endif ()
add_executable (xF xF.c ${project_config})
add_dependencies (xF xC-proto)
target_include_directories (xF PRIVATE
@@ -202,7 +210,6 @@ if (WITH_XF)
${Unistring_LIBRARIES} ${Termo_LIBRARIES}
${ncursesw_LIBRARIES} ${project_libraries})
if (WITH_X11)
target_compile_definitions (xF PRIVATE WITH_X11)
target_include_directories (xF PRIVATE ${x11_INCLUDE_DIRS})
target_link_directories (xF PRIVATE ${x11_LIBRARY_DIRS})
target_link_libraries (xF PRIVATE ${x11_LIBRARIES})
+8 -2
View File
@@ -37,7 +37,9 @@ image::xP.webp[align="center"]
xF
--
The hybrid terminal/X11 frontend for 'xC'. It has simplified word wrapping,
limited colour support, and X11 doesn't support text selection.
limited colour support, and X11 doesn't support text selection (but in 'xC'
tradition, it will happily launch embedded gVim on both the input and the log).
This frontend is perfect for testing.
xA, xT, xW, xM
@@ -102,7 +104,7 @@ Additionally for 'xF': ncursesw, libunistring, termo (included),
$ mkdir xK/build
$ cd xK/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWITH_LUA=ON -DWITH_XF=OFF
-DWITH_LUA=ON -DWITH_XF=ON
$ make
To install the application, you can do either the usual:
@@ -154,6 +156,10 @@ For remote use, it's recommended to put 'xP' behind a reverse proxy, with TLS,
and some form of HTTP authentication. Pass the external URL of the WebSocket
endpoint as the third command line argument in this case.
xF
~~
The terminal/X11 frontend needs the relay address on its command line.
xA
~~
The Fyne frontend supports all of Linux, FreeBSD, Windows, macOS, Android, and
+1
View File
@@ -7,6 +7,7 @@
#define PROJECT_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}"
#cmakedefine HAVE_LUA
#cmakedefine HAVE_X11
#cmakedefine01 ICONV_ACCEPTS_TRANSLIT
+22 -22
View File
@@ -27,9 +27,9 @@
#include <locale.h>
#ifdef WITH_X11
#ifdef HAVE_X11
#define LIBERTY_XUI_WANT_X11
#endif // WITH_X11
#endif // HAVE_X11
#include "liberty/liberty-xui.c"
// --- Relay model -------------------------------------------------------------
@@ -1951,7 +1951,7 @@ tui_make_editor (chtype attrs)
// --- X11 widgets -------------------------------------------------------------
#ifdef WITH_X11
#ifdef HAVE_X11
static void
x11_process_editor (struct widget *self, int *x, int *caret, bool draw)
@@ -2075,7 +2075,7 @@ app_x11_render_scrollbar (struct widget *widget)
bar.length);
}
#endif // WITH_X11
#endif // HAVE_X11
// --- XUI ---------------------------------------------------------------------
@@ -2108,10 +2108,10 @@ static void
app_select_backend (void)
{
g.backend.make_editor = tui_make_editor;
#ifdef WITH_X11
#ifdef HAVE_X11
if (g_xui.ui == &x11_ui)
g.backend.make_editor = x11_make_editor;
#endif // WITH_X11
#endif // HAVE_X11
}
static struct widget *
@@ -2125,10 +2125,10 @@ app_make_scrollbar (enum app_widget_id id)
struct widget *scrollbar = g_xui.ui->scrollbar
(g_attrs[ATTRIBUTE_SCROLLBAR].attrs, top, view.total);
#ifdef WITH_X11
#ifdef HAVE_X11
if (g_xui.ui == &x11_ui)
scrollbar->on_render = app_x11_render_scrollbar;
#endif // WITH_X11
#endif // HAVE_X11
scrollbar->widget_id = id;
return scrollbar;
}
@@ -3462,10 +3462,10 @@ app_external_editor_cleanup (void)
g_winch_received = false;
xui_tui_resume ();
}
#ifdef WITH_X11
#ifdef HAVE_X11
else
x11_embed_end ();
#endif // WITH_X11
#endif // HAVE_X11
if (unlink (g.editor_filename))
print_error ("failed to remove `%s': %s",
@@ -3484,7 +3484,7 @@ app_external_editor_launch (struct error **e)
char xid[32] = "";
if (g_xui.ui == &tui_ui)
xui_tui_suspend ();
#ifdef WITH_X11
#ifdef HAVE_X11
else
{
Window socket = x11_embed_start (0, g_xui.vunit, 0, 2 * g_xui.vunit);
@@ -3494,7 +3494,7 @@ app_external_editor_launch (struct error **e)
// Emacs only accepts decimal notation, so it must be like this.
snprintf (xid, sizeof xid, "%lu", (unsigned long) socket);
}
#endif // WITH_X11
#endif // HAVE_X11
const char *editor = getenv ("VISUAL");
if (!editor)
@@ -3515,7 +3515,7 @@ app_external_editor_launch (struct error **e)
hard_assert (tcsetpgrp (STDOUT_FILENO, getpgrp ()) != -1);
execlp (editor, editor, g.editor_filename, NULL);
}
#ifdef WITH_X11
#ifdef HAVE_X11
#define LAUNCH(x, ...) execlp (x, x, __VA_ARGS__, g.editor_filename, NULL)
else
{
@@ -3531,7 +3531,7 @@ app_external_editor_launch (struct error **e)
LAUNCH ("xterm", "-into", xid, "-e", editor);
}
#undef LAUNCH
#endif // WITH_X11
#endif // HAVE_X11
// AppKit offers no similar mechanism.
@@ -3796,10 +3796,10 @@ app_process_mouse (termo_mouse_event_t type, int x, int y, int button,
if (!url)
return false;
#ifdef WITH_X11
#ifdef HAVE_X11
if (g_xui.ui == &x11_ui)
app_open (url);
#endif // WITH_X11
#endif // HAVE_X11
free (url);
return true;
}
@@ -4166,15 +4166,15 @@ app_free_context (void)
static const char *
app_parse_options (int argc, char *argv[], bool *requested_gui)
{
#ifndef WITH_X11
#ifndef HAVE_X11
(void) requested_gui;
#endif // ! WITH_X11
#endif // ! HAVE_X11
static const struct opt opts[] =
{
#ifdef WITH_X11
#ifdef HAVE_X11
{ 'g', "gui", NULL, 0, "use graphical interface even from a terminal" },
#endif // WITH_X11
#endif // HAVE_X11
{ 'h', "help", NULL, 0, "display this help and exit" },
{ 'V', "version", NULL, 0, "output version information and exit" },
{ 0, NULL, NULL, 0, NULL }
@@ -4186,11 +4186,11 @@ app_parse_options (int argc, char *argv[], bool *requested_gui)
while ((c = opt_handler_get (&oh)) != -1)
switch (c)
{
#ifdef WITH_X11
#ifdef HAVE_X11
case 'g':
*requested_gui = true;
break;
#endif // WITH_X11
#endif // HAVE_X11
case 'h':
opt_handler_usage (&oh, stdout);
exit (EXIT_SUCCESS);