| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- # m2-GTK4 - GNU Modula-2 bindings for GTK4
- GM2 ?= gm2
- 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)
- GTKCFG += $(shell pkg-config --cflags libadwaita-1 2>/dev/null)
- GTKLIBS += $(ADWLIBS)
- 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
- 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_application
- EXAMPLES := hello counter inputs containers actions headerbar editor layouts files views builder feedback styling popover dialogs
- # Include the libadwaita test/example only when libadwaita is installed.
- ifneq ($(ADWLIBS),)
- TESTS += test_adw
- EXAMPLES += adw
- endif
- .PHONY: all tests examples check clean gir gir-check gir-verify
- all: tests examples
- $(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 $@
- 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)
- 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
- 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
|