# Makefile # # Copyright (C) 2020 Michel Pollet # # SPDX-License-Identifier: MIT CC = gcc LIBMUI = MUI_SRC := $(wildcard $(LIBMUI)src/*.c) vpath %.c $(LIBMUI)src $(LIBMUI)mui_shell # this is just so we compile the tests if not a submodule IS_SUBMODULE := ${wildcard ../ui_gl/mii_mui.h} all : static mui_shell include $(LIBMUI)Makefile.common ifeq ($(IS_SUBMODULE),) all : tests endif MUI_OBJ := ${patsubst %, $(OBJ)/%, ${notdir ${MUI_SRC:.c=.o}}} TARGET_LIB := $(LIB)/libmui.a .PHONY : mui_shell static tests mui_shell : $(BIN)/mui_shell static : $(TARGET_LIB) tests : | $(TARGET_LIB) $(MAKE) -j -C tests @echo " ** To launch the demo, run " @echo " $(BIN)/mui_shell -f $(LIB)/mui_widgets_demo.so" $(TARGET_LIB) : $(MUI_OBJ) | $(LIB) @echo " AR $@" $(Q)$(AR) rcs $@ $^ .PHONY : fonts define font_to_h src/fonts/$(2).h : $(1) { echo "// Autogenerated by the Makefile, do not edit"; \ echo "#pragma once"; \ xxd -n $(2) -i $$< |\ sed 's/unsigned/static const unsigned/' ; \ }>$$@ $(OBJ)/mii.o : src/fonts/$(2).h fonts: src/fonts/$(2).h endef $(eval $(call font_to_h,fonts/Charcoal_mui.ttf,mui_main_font)) $(eval $(call font_to_h,fonts/typicon.ttf,mui_icon_font)) $(eval $(call font_to_h,fonts/Geneva.ttf,mui_geneva_font)) # # The shell program is used to test the UI library using plugins # It is made using XCB and XKB libraries to have a minimal dependency # on X11. Also, allows partial updates to be tested properly # $(OBJ)/mui_shell.o : CPPFLAGS += -DUI_HAS_XCB=1 -DUI_HAS_XKB=1 ifeq ($(shell uname),NetBSD) # NetBSD requirements $(OBJ)/mui_shell.o : CPPFLAGS += $(shell pkg-config --cflags xorg-server xkbcommon) $(BIN)/mui_shell : LDLIBS += $(shell pkg-config --libs xorg-server) endif $(BIN)/mui_shell : LDLIBS += $(shell pkg-config --libs \ xcb xcb-shm xcb-image \ xkbcommon xkbcommon-x11) $(BIN)/mui_shell : LDLIBS += -lm ifeq ($(shell uname),Linux) $(BIN)/mui_shell : LDLIBS += -ldl endif $(BIN)/mui_shell : $(OBJ)/mui_shell.o $(LIB)/libmui.a clean : rm -rf $(O) # This is for development purpose. This will recompile the project # everytime a file is modified. watch : while true; do \ clear; $(MAKE) -j all tests; \ inotifywait -qre close_write src mui_shell tests/* ../ui_gl; \ done compile_commands.json: lsp lsp: { $$(which gmake) CC=gcc V=1 --always-make --dry-run all tests ; } | \ sh ../utils/clangd_gen.sh >compile_commands.json -include $(OBJ)/*.d DESTDIR ?= /usr/local install: $(TARGET_LIB) install -d $(DESTDIR)/lib install -m 644 $(TARGET_LIB) $(DESTDIR)/lib install -d $(DESTDIR)/include/mui/mui $(DESTDIR)/include/mui/control/ install -m 644 src/*.h $(DESTDIR)/include/mui install -m 644 src/mui/*.h $(DESTDIR)/include/mui/mui/ install -m 644 src/control/*.h $(DESTDIR)/include/mui/control/