From 260dc2c8828c70b0e147ea394f38e9ee6dc69ee3 Mon Sep 17 00:00:00 2001 From: maxim nikonov Date: Fri, 6 Feb 2026 13:18:21 +0500 Subject: wip --- Makefile | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 16 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8739b9460..4ac74875f 100644 --- a/Makefile +++ b/Makefile @@ -37,30 +37,67 @@ DEFINES = -DFL_LIBRARY INCLUDES = -I. -I./src -I./jpeg -I./png -I./zlib -I./fluid # Platform detection and X11 paths +# Set USE_BUNDLED_X11=1 to use headers from xlibs/include (run xlibs/fetch_headers.sh first) +USE_BUNDLED_X11 ?= 0 + +# Cairo rendering option +# Set USE_CAIRO=0 for pure Xlib+Xft rendering (no Cairo/Pango dependency) +# Set USE_CAIRO=1 (default) for Cairo+Pango rendering +USE_CAIRO ?= 1 + UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) - # macOS with XQuartz - X11_CFLAGS = -I/opt/X11/include - X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama -lXcursor -lXfixes -lXrender +ifeq ($(USE_BUNDLED_X11),1) + # Use bundled X11 headers, still link system libraries + X11_CFLAGS = -I./xlibs/include + ifeq ($(UNAME_S),Darwin) + X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama -lXcursor -lXfixes -lXrender + else + X11_CFLAGS += $(shell pkg-config --cflags freetype2 fontconfig) + X11_LIBS = $(shell pkg-config --libs x11 xext xft xinerama xcursor xfixes xrender freetype2 fontconfig) + endif +else ifeq ($(UNAME_S),Darwin) + # macOS with XQuartz (include freetype2 for Xft) + X11_CFLAGS = -I/opt/X11/include -I/opt/X11/include/freetype2 + X11_LIBS = -L/opt/X11/lib -lX11 -lXext -lXft -lXinerama -lXcursor -lXfixes -lXrender -lfontconfig -lfreetype else - # Linux - use pkg-config - X11_CFLAGS = $(shell pkg-config --cflags x11 xext xft xinerama xcursor xfixes xrender) - X11_LIBS = $(shell pkg-config --libs x11 xext xft xinerama xcursor xfixes xrender) + # Linux - use pkg-config (include freetype2 for Xft) + X11_CFLAGS = $(shell pkg-config --cflags x11 xext xft xinerama xcursor xfixes xrender freetype2 fontconfig) + X11_LIBS = $(shell pkg-config --libs x11 xext xft xinerama xcursor xfixes xrender freetype2 fontconfig) endif -CAIRO_CFLAGS = $(shell pkg-config --cflags cairo pangocairo pango) -CAIRO_LIBS = $(shell pkg-config --libs cairo pangocairo pango gobject-2.0) +# Cairo/Pango configuration (only when USE_CAIRO=1) +ifeq ($(USE_CAIRO),1) + CAIRO_CFLAGS = $(shell pkg-config --cflags cairo pangocairo pango) + CAIRO_LIBS = $(shell pkg-config --libs cairo pangocairo pango gobject-2.0) + CAIRO_DEFINES = -DFLTK_USE_CAIRO=1 -DFLTK_HAVE_CAIRO=1 -DUSE_PANGO=1 +else + CAIRO_CFLAGS = + CAIRO_LIBS = + CAIRO_DEFINES = -DFLTK_USE_CAIRO=0 -DFLTK_HAVE_CAIRO=0 -DUSE_PANGO=0 +endif + +# OpenGL configuration (separate from X11 bundling) +ifeq ($(UNAME_S),Darwin) + # macOS uses XQuartz GL - always need system GL headers + GL_CFLAGS = -I/opt/X11/include + GL_LIBS = -L/opt/X11/lib -lGL -lGLU +else + GL_CFLAGS = $(shell pkg-config --cflags gl glu 2>/dev/null) + GL_LIBS = $(shell pkg-config --libs gl glu 2>/dev/null) +endif -GL_CFLAGS = $(shell pkg-config --cflags gl glu) -GL_LIBS = $(shell pkg-config --libs gl glu) +# When using bundled X11 headers, still need system GL headers +ifeq ($(USE_BUNDLED_X11),1) + X11_CFLAGS += $(GL_CFLAGS) +endif # We use bundled jpeg/png/zlib, no system library needed PNG_LIBS = JPEG_LIBS = # Combined flags -ALL_CFLAGS = $(CFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) $(CAIRO_CFLAGS) -ALL_CXXFLAGS = $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) $(CAIRO_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) $(CAIRO_CFLAGS) $(CAIRO_DEFINES) +ALL_CXXFLAGS = $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(X11_CFLAGS) $(CAIRO_CFLAGS) $(CAIRO_DEFINES) # Libraries for linking FLTK_LDLIBS = $(X11_LIBS) $(CAIRO_LIBS) -lm -ldl -lpthread @@ -225,8 +262,8 @@ CORE_SRCS = \ src/print_button.cxx \ src/screen_xywh.cxx -# X11 driver files -DRIVER_SRCS = \ +# X11 driver files (common) +DRIVER_SRCS_COMMON = \ src/Fl_x.cxx \ src/fl_dnd_x.cxx \ src/Fl_get_key.cxx \ @@ -242,10 +279,31 @@ DRIVER_SRCS = \ src/drivers/X11/Fl_X11_Window_Driver.cxx \ src/drivers/X11/fl_X11_platform_init.cxx \ src/drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx \ - src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx \ + src/drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx + +# Cairo graphics driver (USE_CAIRO=1) +DRIVER_SRCS_CAIRO = \ src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx \ src/drivers/Cairo/Fl_X11_Cairo_Graphics_Driver.cxx +# Xlib graphics driver (USE_CAIRO=0) - pure Xlib+Xft rendering +DRIVER_SRCS_XLIB = \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_line_style.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx \ + src/drivers/Xlib/Fl_Xlib_Graphics_Driver_vertex.cxx + +# Select driver based on USE_CAIRO +ifeq ($(USE_CAIRO),1) + DRIVER_SRCS = $(DRIVER_SRCS_COMMON) $(DRIVER_SRCS_CAIRO) +else + DRIVER_SRCS = $(DRIVER_SRCS_COMMON) $(DRIVER_SRCS_XLIB) +endif + # PostScript driver PS_SRCS = \ src/drivers/PostScript/Fl_PostScript.cxx \ -- cgit v1.2.3