-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
124 lines (98 loc) · 3.21 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# options
### verbosity: 0 for off, 1 for on (default: off)
V = 0
### whether to link against gtk3 or gtk2 (default: gtk3)
WITH_GTK3 = 1
### libnotify support: 0 for off, 1 for on (default: on)
WITH_NOTIFY = 1
# programs
CC ?= gcc
MSGFMT = msgfmt
PKG_CONFIG ?= pkg-config
RM = rm -f
GETTEXT=xgettext
INSTALL = install
INSTALL_BIN = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
# variables
PACKAGE_NAME = cbatticon
VERSION = $(shell grep CBATTICON_VERSION_NUMBER cbatticon.c | awk '{print $$3}')
PREFIX ?= /usr
BINDIR = $(PREFIX)/bin
DOCDIR = $(PREFIX)/share/doc/$(PACKAGE_NAME)-$(VERSION)
MANDIR = $(PREFIX)/share/man/man1
NLSDIR = $(PREFIX)/share/locale
LANGUAGES = bs de el es fr he hr id ja pt_BR ru sk sr tr zh_TW
BIN = $(PACKAGE_NAME)
SOURCEFILES := $(wildcard *.c)
OBJECTS := $(patsubst %.c,%.o,$(SOURCEFILES))
SOURCECATALOGS := $(wildcard *.po)
TRANSLATIONS := $(patsubst %.po,%.mo,$(SOURCECATALOGS))
# flags and libs
ifeq ($(V),0)
VERBOSE=@
else
VERBOSE=
endif
ifeq ($(WITH_NOTIFY),1)
CPPFLAGS += -DWITH_NOTIFY
endif
CPPFLAGS += -DNLSDIR=\"$(NLSDIR)\"
CFLAGS ?= -O2
CFLAGS += -Wall -Wno-deprecated-declarations -std=c99
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKG_DEPS))
ifeq ($(WITH_GTK3), 0)
PKG_DEPS = gtk+-2.0
else
PKG_DEPS = gtk+-3.0
endif
ifeq ($(WITH_NOTIFY),1)
PKG_DEPS += libnotify
endif
LIBS += $(shell $(PKG_CONFIG) --libs $(PKG_DEPS)) -lm
# targets
all: $(BIN) $(TRANSLATIONS)
$(BIN): $(OBJECTS)
@echo -e '\033[0;35mLinking executable $@\033[0m'
$(VERBOSE) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJECTS): $(SOURCEFILES)
@echo -e '\033[0;32mBuilding object $@\033[0m'
$(VERBOSE) $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(TRANSLATIONS): %.mo: %.po
@echo -e '\033[0;36mCompiling messages catalog $@\033[0m'
$(VERBOSE) $(MSGFMT) -o $@ $<
install: $(BIN) $(TRANSLATIONS)
@echo -e '\033[0;33mInstalling $(PACKAGE_NAME)\033[0m'
$(VERBOSE) $(INSTALL) -d "$(DESTDIR)$(BINDIR)"
$(VERBOSE) $(INSTALL_BIN) $(BIN) "$(DESTDIR)$(BINDIR)"/
$(VERBOSE) $(INSTALL) -d "$(DESTDIR)$(DOCDIR)"
$(VERBOSE) $(INSTALL_DATA) README "$(DESTDIR)$(DOCDIR)"/
$(VERBOSE) $(INSTALL) -d "$(DESTDIR)$(MANDIR)"
$(VERBOSE) $(INSTALL_DATA) cbatticon.1 "$(DESTDIR)$(MANDIR)"/
$(VERBOSE) for language in $(LANGUAGES); \
do \
$(INSTALL) -d "$(DESTDIR)$(NLSDIR)"/$$language/LC_MESSAGES; \
$(INSTALL_DATA) $$language.mo "$(DESTDIR)$(NLSDIR)"/$$language/LC_MESSAGES/$(PACKAGE_NAME).mo; \
done
uninstall:
@echo -e '\033[0;33mUninstalling $(PACKAGE_NAME)\033[0m'
$(VERBOSE) $(RM) "$(DESTDIR)$(BINDIR)"/$(BIN)
$(VERBOSE) $(RM) "$(DESTDIR)$(DOCDIR)"/README
$(VERBOSE) $(RM) "$(DESTDIR)$(MANDIR)"/cbatticon.1
$(VERBOSE) for language in $(LANGUAGES); \
do \
$(VERBOSE) $(RM) "$(DESTDIR)$(NLSDIR)"/$$language/LC_MESSAGES/$(PACKAGE_NAME).mo; \
done
clean:
@echo -e '\033[0;33mCleaning up source directory\033[0m'
$(VERBOSE) $(RM) $(BIN) $(OBJECTS) $(TRANSLATIONS)
translation-refresh-pot:
$(VERBOSE) $(GETTEXT) --default-domain=$(PACKAGE_NAME) --add-comments \
--keyword=_ --keyword=N_ --keyword=g_dngettext:2,3 $(SOURCEFILES) \
--output=$(PACKAGE_NAME).pot
translation-status:
$(VERBOSE) for catalog in $(SOURCECATALOGS); \
do \
$(MSGFMT) -v --statistics -o /dev/null $$catalog; \
done
.PHONY: install uninstall clean translation-status