| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- # m2-GTK4 - GNU Modula-2 bindings for GTK4
- GM2 ?= gm2
- CC ?= gcc
- GTKCFG := $(shell pkg-config --cflags gtk4 2>/dev/null)
- GTKLIBS := $(shell pkg-config --libs gtk4 2>/dev/null || echo -lgtk-4)
- # libadwaita is optional; added to the flags when present.
- ADWLIBS := $(shell pkg-config --libs libadwaita-1 2>/dev/null)
- # GtkSourceView 5 is optional too.
- SRCVLIBS := $(shell pkg-config --libs gtksourceview-5 2>/dev/null)
- # libspelling + libpanel are optional platform libraries.
- SPELLIBS := $(shell pkg-config --libs libspelling-1 2>/dev/null)
- PANELLIBS := $(shell pkg-config --libs libpanel-1 2>/dev/null)
- GLLIBS := $(shell pkg-config --libs gl 2>/dev/null)
- GTKCFG += $(shell pkg-config --cflags libadwaita-1 2>/dev/null)
- GTKCFG += $(shell pkg-config --cflags gtksourceview-5 2>/dev/null)
- GTKCFG += $(shell pkg-config --cflags libspelling-1 libpanel-1 2>/dev/null)
- GTKLIBS += $(ADWLIBS) $(SRCVLIBS) $(SPELLIBS) $(PANELLIBS) $(GLLIBS)
- GM2FLAGS ?= -fiso
- GIR ?= Gtk-4.0
- GIR_DIR ?= /usr/share/gir-1.0
- SRC_DIR := src
- LIB_DIR := lib
- BLD := build
- OBJDIR := $(BLD)/objs
- OBJS := $(OBJDIR)/GtkUtils.o $(OBJDIR)/GtkClosures.o $(OBJDIR)/m2gtkshim.o
- INCLUDES := -I$(SRC_DIR) -I$(LIB_DIR)
- TESTS := test_glib test_version test_widgets test_inputs test_inputs2 test_containers test_containers2 test_actions test_closure test_headerbar test_gio test_gerror test_filedialog test_views test_builder test_utility test_css test_popover test_dialogs test_models test_cairo test_drawing test_gestures test_models2 test_widgets3 test_shim test_shim2 test_shim3 test_dnd test_media test_gl test_print test_text test_expr test_constraints test_shortcuts test_snapshot test_lastwidgets test_application
- EXAMPLES := hello counter inputs containers actions headerbar editor layouts files views builder feedback styling popover dialogs drawing demo gestures customwidget customlayout media clipboard gl richtext snapshot
- # Include the libadwaita test/example only when libadwaita is installed.
- ifneq ($(ADWLIBS),)
- TESTS += test_adw
- EXAMPLES += adw adw_widgets adw_views
- endif
- # Include the GtkSourceView example when gtksourceview-5 is installed.
- ifneq ($(SRCVLIBS),)
- EXAMPLES += sourceview
- endif
- # Include the spell-checking example with GtkSourceView + libspelling.
- ifneq ($(SRCVLIBS)$(SPELLIBS),)
- EXAMPLES += spelling
- endif
- .PHONY: all tests examples demos check clean gir gir-check gir-verify
- all: tests examples demos
- $(OBJDIR):
- mkdir -p $(OBJDIR)
- $(BLD)/tests:
- mkdir -p $(BLD)/tests
- $(BLD)/examples:
- mkdir -p $(BLD)/examples
- # The FOR "C" .def modules carry no code; only the pure-M2 helpers are
- # compiled to object files and linked into every program.
- $(OBJDIR)/GtkUtils.o: $(LIB_DIR)/GtkUtils.mod $(LIB_DIR)/GtkUtils.def | $(OBJDIR)
- $(GM2) $(INCLUDES) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/GtkClosures.o: $(LIB_DIR)/GtkClosures.mod $(LIB_DIR)/GtkClosures.def | $(OBJDIR)
- $(GM2) $(INCLUDES) $(GM2FLAGS) -c $< -o $@
- # C shim for GObject subclassing (custom GtkWidget / GdkPaintable).
- $(OBJDIR)/m2gtkshim.o: $(LIB_DIR)/m2gtkshim.c | $(OBJDIR)
- $(CC) $(GTKCFG) -c $< -o $@
- tests: $(BLD)/tests $(OBJS) $(addprefix $(BLD)/tests/,$(TESTS))
- $(BLD)/tests/%: tests/%.mod $(OBJS) | $(BLD)/tests
- $(GM2) $(INCLUDES) $(GM2FLAGS) $(GTKCFG) $< $(OBJS) -o $@ $(GTKLIBS)
- examples: $(BLD)/examples $(OBJS) $(addprefix $(BLD)/examples/,$(EXAMPLES))
- $(BLD)/examples/%: examples/%.mod $(OBJS) | $(BLD)/examples
- $(GM2) $(INCLUDES) $(GM2FLAGS) $(GTKCFG) $< $(OBJS) -o $@ $(GTKLIBS)
- # --- m2 gtk-demo (demos/) -------------------------------------------------
- DEMO_DIR := demos
- $(BLD)/demos:
- mkdir -p $(BLD)/demos
- $(OBJDIR)/DemoCatalog.o: $(DEMO_DIR)/DemoCatalog.mod $(DEMO_DIR)/DemoCatalog.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemoImpl.o: $(DEMO_DIR)/DemoImpl.mod $(DEMO_DIR)/DemoImpl.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosBasic.o: $(DEMO_DIR)/DemosBasic.mod $(DEMO_DIR)/DemosBasic.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosLayout.o: $(DEMO_DIR)/DemosLayout.mod $(DEMO_DIR)/DemosLayout.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosText.o: $(DEMO_DIR)/DemosText.mod $(DEMO_DIR)/DemosText.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosWindows.o: $(DEMO_DIR)/DemosWindows.mod $(DEMO_DIR)/DemosWindows.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosInput.o: $(DEMO_DIR)/DemosInput.mod $(DEMO_DIR)/DemosInput.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosChooser.o: $(DEMO_DIR)/DemosChooser.mod $(DEMO_DIR)/DemosChooser.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/DemosCanvas.o: $(DEMO_DIR)/DemosCanvas.mod $(DEMO_DIR)/DemosCanvas.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- $(OBJDIR)/GtkDemo.o: $(DEMO_DIR)/GtkDemo.mod $(DEMO_DIR)/GtkDemo.def | $(OBJDIR)
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) -c $< -o $@
- DEMO_OBJS := $(OBJDIR)/DemoCatalog.o $(OBJDIR)/DemoImpl.o $(OBJDIR)/DemosBasic.o \
- $(OBJDIR)/DemosLayout.o $(OBJDIR)/DemosText.o \
- $(OBJDIR)/DemosWindows.o $(OBJDIR)/DemosInput.o \
- $(OBJDIR)/DemosChooser.o $(OBJDIR)/DemosCanvas.o $(OBJDIR)/GtkDemo.o
- demos: $(BLD)/demos $(OBJS) $(DEMO_OBJS) $(BLD)/demos/m2gtkdemo
- $(BLD)/demos/m2gtkdemo: $(DEMO_DIR)/m2gtkdemo.mod $(OBJS) $(DEMO_OBJS) | $(BLD)/demos
- $(GM2) $(INCLUDES) -I$(DEMO_DIR) $(GM2FLAGS) $(GTKCFG) $< \
- $(OBJS) $(DEMO_OBJS) -o $@ $(GTKLIBS)
- check: tests
- ./tests/run_tests.sh
- # Optional GIR -> .def generator (broad, auto-generated coverage).
- # make gir # Gtk-4.0 -> gen/
- # make gir GIR=Gio-2.0 # another namespace
- gir:
- python3 tools/gir2def.py $(GIR) --gir-dir $(GIR_DIR) -o gen
- # Generate and compile/link-check a sample of the output.
- gir-check:
- ./tools/run_gir_check.sh
- # Check that every generated identifier exists in the installed library.
- GIR_VERIFY ?= Gtk-4.0 GLib-2.0 Gio-2.0 Adw-1 GtkSource-5 Gdk-4.0 Gsk-4.0 Spelling-1 Panel-1
- gir-verify:
- set -e; for ns in $(GIR_VERIFY); do \
- python3 tools/gir_verify.py $$ns --gir-dir $(GIR_DIR); \
- done
- clean:
- rm -rf $(BLD) gen
|