-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
executable file
·103 lines (79 loc) · 3 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
94
95
96
97
98
99
100
101
102
103
pkg_cflags ?= $(shell pkg-config --cflags $(1))
pkg_ldflags ?= $(shell pkg-config --libs $(1))
CC ?= gcc
PATH_SRC = src
PATH_EXTRA = extras/statusnotifier/src
PATH_BUILD ?= build
PATH_BUILD2 ?= $(PATH_BUILD)/gtk2
PATH_BUILD3 ?= $(PATH_BUILD)/gtk3
OUT_GTK2 ?= sni_gtk2.so
OUT_GTK3 ?= sni_gtk3.so
APP_GLIB_MKENUMS ?= $(abspath tools/glib-mkenums)
LIST_CLEAN = CMakeCache.txt \
CMakeFiles \
cmake_install.cmake \
cmake_uninstall.cmake \
install_manifest.txt \
build \
_build \
*.so \
*.swp \
enums.[c,h] \
.ninja_deps \
.ninja_log \
*.ninja
SNI_DEPS += dbusmenu-glib-0.4
SNI_CFLAGS ?= $(call pkg_cflags, $(SNI_DEPS))
SNI_LDFLAGS ?= $(call pkg_ldflags, $(SNI_DEPS))
SNI_CFLAGS += -DUSE_DBUSMENU -DENABLE_NLS -DG_LOG_DOMAIN=\"plugin-sni\"
CFLAGS += -Wall -Wextra -fPIC -std=c99 -D_GNU_SOURCE -Wno-missing-field-initializers -Wno-unused -O2 -fvisibility=hidden
LDFLAGS += -shared -s -fdata-sections -ffunction-sections -Wl,-gc-sections -lX11
INCLUDES += -I $(abspath ./) -I $(abspath $(PATH_SRC)) -I $(abspath $(PATH_EXTRA))
GTK2 = gtk+-2.0
GTK3 = gtk+-3.0
GTK2_CFLAGS ?= $(call pkg_cflags, $(GTK2))
GTK2_LIBS ?= $(call pkg_ldflags, $(GTK2))
GTK3_CFLAGS ?= $(call pkg_cflags, $(GTK3))
GTK3_LIBS ?= $(call pkg_ldflags, $(GTK3))
SNI_SRC_LIST = menu.c sni.c
SNI_EXT_LIST = statusnotifier.c closures.c
SNI_SRC = enums.c $(addprefix $(PATH_SRC)/,$(SNI_SRC_LIST)) $(addprefix $(PATH_EXTRA)/,$(SNI_EXT_LIST))
OBJ_GTK2 = $(patsubst %.c, $(PATH_BUILD2)/%.o, $(SNI_SRC))
OBJ_GTK3 = $(patsubst %.c, $(PATH_BUILD3)/%.o, $(SNI_SRC))
### FUNCTIONS
define compile
$(CC) $(CFLAGS) $(INCLUDES) $(SNI_CFLAGS) $1 $(abspath $2) -c -o $(abspath $@)
endef
define link
$(CC) $(LDFLAGS) $(abspath $^) $(SNI_LDFLAGS) $1 -o $(abspath $@)
endef
### TARGETS
all: gtk3
mkenums: enums.c enums.h
enums.h: $(PATH_EXTRA)/enums.h.template $(PATH_EXTRA)/statusnotifier.h
@$(APP_GLIB_MKENUMS) --template $^ > $@
enums.c: $(PATH_EXTRA)/enums.c.template $(PATH_EXTRA)/statusnotifier.h
@$(APP_GLIB_MKENUMS) --template $^ > $@
.PHONY: clean format mkdirs_gtk3 mkdirs_gtk3
format:
@echo $(abspath $(PATH_SRC))
@find $(abspath $(PATH_SRC)) -type f -name "*.[c,h]" -print0 | xargs -0 clang-format -i
clean:
@rm -rf $(LIST_CLEAN)
gtk3: mkdirs_gtk3 mkenums $(PATH_BUILD)/$(OUT_GTK3)
gtk2: mkdirs_gtk2 mkenums $(PATH_BUILD)/$(OUT_GTK2)
mkdirs_gtk3:
@mkdir -p $(abspath $(PATH_BUILD3)/$(PATH_SRC))
@mkdir -p $(abspath $(PATH_BUILD3)/$(PATH_EXTRA))
mkdirs_gtk2:
@mkdir -p $(abspath $(PATH_BUILD2)/$(PATH_SRC))
@mkdir -p $(abspath $(PATH_BUILD2)/$(PATH_EXTRA))
## BUILD TARGETS
$(PATH_BUILD)/$(OUT_GTK3): $(OBJ_GTK3)
@$(call link, $(GTK3_LIBS))
$(PATH_BUILD3)/%.o: $(SNI_SRC)
@$(call compile, $(GTK3_CFLAGS), $(filter %$(@F:%.o=%.c), $^))
$(PATH_BUILD)/$(OUT_GTK2): $(OBJ_GTK2)
@$(call link, $(GTK2_LIBS))
$(PATH_BUILD2)/%.o: $(SNI_SRC)
@$(call compile, $(GTK2_CFLAGS), $(filter %$(@F:%.o=%.c), $^))