-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
93 lines (75 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Makefile
#
# Copyright (C) 2020 Michel Pollet <buserror@gmail.com>
#
# 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