projects/package-update-indicator

view Makefile @ 10:adba37525ee5

Notify about required session or system restarts

Follow all PackageKit transactions and indicate when a session or system
restart is required.
Generate enum types with glib-mkenums.
author Guido Berhoerster <guido+pui@berhoerster.name>
date Fri Jul 06 14:12:46 2018 +0200 (2018-07-06)
parents 2477a6151087
children 329aeecdd83a
line source
1 #
2 # Copyright (C) 2018 Guido Berhoerster <guido+pui@berhoerster.name>
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
24 PACKAGE = package-update-indicator
25 APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator
26 PREFS_APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator.preferences
27 VERSION = 1
28 DISTNAME = $(PACKAGE)-$(VERSION)
29 AUTHOR = Guido Berhoerster
30 BUG_ADDRESS = guido+pui@berhoerster.name
32 # gcc, clang, icc, Sun/Solaris Studio
33 CC := $(CC) -std=c99
34 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c
35 # gcc, clang, icc
36 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
37 # Sun/Solaris Studio
38 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
39 # X makedepend
40 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) --
41 LINK.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
42 LINK.o = $(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
43 CP := cp
44 INSTALL := install
45 INSTALL.exec := $(INSTALL) -D -m 0755
46 INSTALL.data := $(INSTALL) -D -m 0644
47 INSTALL.link := $(CP) -f -P
48 PAX := pax
49 GZIP := gzip
50 SED := sed
51 GLIB_COMPILE_SCHEMAS := $(shell pkg-config --variable=glib_compile_schemas gio-2.0)
52 GLIB_COMPILE_RESOURCES := $(shell pkg-config --variable=glib_compile_resources gio-2.0)
53 GLIB_MKENUMS := $(shell pkg-config --variable=glib_mkenums glib-2.0)
54 XSLTPROC := xsltproc
55 DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
56 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
57 --stringparam man.copyright.section.enabled 0
58 MSGFMT = msgfmt
59 MSGMERGE = msgmerge
60 XGETTEXT = xgettext
61 XGETTEXT_OPTIONS = --copyright-holder "$(AUTHOR)" \
62 --package-name '$(PACKAGE)' \
63 --package-version '$(VERSION)' \
64 --msgid-bugs-address '$(BUG_ADDRESS)' \
65 --default-domain '$(PACKAGE)' \
66 --from-code UTF-8 \
67 --keyword=_ \
68 --keyword=N_ \
69 --keyword=C_:1c,2 \
70 --keyword=NC_:1c,2 \
71 --keyword=g_dngettext:2,3 \
72 --add-comments
74 define generate-manpage-rule =
75 %.$1: %.$(addsuffix .xml,$1) docbook-update-source-data.xsl
76 $$(XSLTPROC) \
77 --xinclude \
78 --stringparam package $$(PACKAGE) \
79 --stringparam version $$(VERSION) \
80 docbook-update-source-data.xsl $$< | \
81 $$(XSLTPROC) \
82 --xinclude \
83 --output $$@ \
84 $$(DOCBOOK5_MANPAGES_FLAGS) \
85 $$(DOCBOOK5_MANPAGES_STYLESHEET) \
86 -
87 endef
89 DESTDIR ?=
90 prefix ?= /usr/local
91 bindir ?= $(prefix)/bin
92 datadir ?= $(prefix)/share
93 mandir ?= $(datadir)/man
94 localedir ?= $(datadir)/locale
95 sysconfdir ?= /etc
96 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
97 xdgapplicationsdir ?= $(datadir)/applications
99 OS_NAME := $(shell uname -s)
100 OS_RELEASE := $(shell uname -r)
102 $(PACKAGE)_OBJS = package-update-indicator.o \
103 pui-application.o \
104 pui-backend.o \
105 pui-get-updates.o \
106 pui-settings.o \
107 pui-types.o \
108 pui-resources.o
110 $(PACKAGE)-prefs_OBJS = package-update-indicator-prefs.o \
111 pui-prefs-application.o \
112 pui-settings.o \
113 pui-prefs-resources.o
115 OBJS = $($(PACKAGE)_OBJS) $($(PACKAGE)-prefs_OBJS)
117 ENUM_DEPS = pui-backend.h \
118 pui-application.h
120 ENUM_HEADER = pui-types.h
122 ENUM_FILES = $(ENUM_HEADER) \
123 pui-types.c
125 GSETTINGS_SCHEMAS = $(APPLICATION_ID).gschema.xml
127 GRESOURCE_FILES = pui-prefs.gresource.xml
129 AUTOSTART_FILE = $(APPLICATION_ID).desktop
131 DESKTOP_FILES = $(PREFS_APPLICATION_ID).desktop
133 LINGUAS := $(shell sed 's/\#.*//' po/LINGUAS)
134 MOFILES := $(patsubst %,po/%.mo,$(LINGUAS))
135 POTFILES_IN := $(shell sed 's/\#.*//' po/POTFILES.in)
136 POTFILE = po/$(PACKAGE).pot
138 MANPAGES = $(PACKAGE).1 $(PACKAGE)-prefs.1
140 .DEFAULT_TARGET = all
142 .PHONY: all pot update-po clean clobber dist install
144 all: $(PACKAGE) $(PACKAGE)-prefs $(AUTOSTART_FILE) $(DESKTOP_FILES) $(MOFILES) $(MANPAGES)
146 $(PACKAGE): XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \
147 -DAPPLICATION_ID=\"$(APPLICATION_ID)\" \
148 -DVERSION=\"$(VERSION)\" \
149 -DG_LOG_DOMAIN=\"$(PACKAGE)\" \
150 -DPACKAGE_LOCALE_DIR="\"$(localedir)\"" \
151 -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
152 -DSETTINGS_SCHEMA_ID=\"$(APPLICATION_ID)\" \
153 -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
154 $(PACKAGE): XCFLAGS = $(shell pkg-config --cflags gtk+-3.0 \
155 appindicator3-0.1 packagekit-glib2 \
156 polkit-gobject-1 upower-glib)
157 $(PACKAGE): LDLIBS = $(shell pkg-config --libs gtk+-3.0 \
158 appindicator3-0.1 packagekit-glib2 \
159 polkit-gobject-1 upower-glib)
161 $(PACKAGE)-prefs: XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \
162 -DAPPLICATION_ID=\"$(PREFS_APPLICATION_ID)\" \
163 -DVERSION=\"$(VERSION)\" \
164 -DG_LOG_DOMAIN=\"$(PACKAGE)\" \
165 -DPACKAGE_LOCALE_DIR="\"$(localedir)\"" \
166 -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
167 -DSETTINGS_SCHEMA_ID=\"$(APPLICATION_ID)\"
168 $(PACKAGE)-prefs: XCFLAGS = $(shell pkg-config --cflags gtk+-3.0)
169 $(PACKAGE)-prefs: LDLIBS = $(shell pkg-config --libs gtk+-3.0)
171 ifneq ($(findstring $(OS_NAME),FreeBSD DragonFly OpenBSD),)
172 $(PACKAGE): XCPPFLAGS += -I/usr/local/include
173 $(PACKAGE): XLDFLAGS += -L/usr/local/lib
174 else ifeq ($(OS_NAME),NetBSD)
175 $(PACKAGE): XCPPFLAGS += -I/usr/pkg/include
176 $(PACKAGE): XLDFLAGS += -L/usr/pkg/lib
177 endif
178 ifeq ($(findstring $(OS_NAME),FreeBSD DragonFly NetBSD OpenBSD),)
179 $(PACKAGE): XCPPFLAGS += -D_XOPEN_SOURCE=600
180 endif
182 $(PACKAGE): $($(PACKAGE)_OBJS)
183 $(LINK.o) $^ $(LDLIBS) -o $@
185 $(PACKAGE)-prefs: $($(PACKAGE)-prefs_OBJS)
186 $(LINK.o) $^ $(LDLIBS) -o $@
188 $(OBJS): $(ENUM_HEADER)
190 %-types.h: %-types.h.in $(ENUM_DEPS)
191 $(GLIB_MKENUMS) --template $< >$@ $(filter-out $<,$^)
193 %-types.c: %-types.c.in $(ENUM_DEPS)
194 $(GLIB_MKENUMS) --template $< >$@ $(filter-out $<,$^)
196 %-resources.c: %.gresource.xml
197 $(GLIB_COMPILE_RESOURCES) --generate-dependencies $< | \
198 while read -r resource_file; do \
199 printf '%s: %s\n' $@ "$${resource_file}"; \
200 done
201 $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=. --generate-source $<
203 $(POTFILE): po/POTFILES.in $(POTFILES_IN)
204 $(XGETTEXT) $(XGETTEXT_OPTIONS) --files-from $< --output $@
206 pot: $(POTFILE)
208 update-po: $(POTFILE)
209 for pofile in $(patsubst %.mo,%.po,$(MOFILES)); do \
210 $(MSGMERGE) --update --backup off $$pofile $<; \
211 done
213 %.mo: %.po
214 $(MSGFMT) --output $@ $<
216 %.desktop: %.desktop.in
217 $(MSGFMT) --desktop --template $< -d po --output $@
219 $(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
221 %.o: %.c
222 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
223 $(COMPILE.c) -o $@ $<
225 install: all
226 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
227 $(INSTALL.exec) $(PACKAGE)-prefs \
228 "$(DESTDIR)$(bindir)/$(PACKAGE)-prefs"
229 for schema in $(GSETTINGS_SCHEMAS); do \
230 $(INSTALL.data) $${schema} \
231 $(DESTDIR)$(datadir)/glib-2.0/schemas/$${schema}; \
232 done
233 [ -n "$(GSETTINGS_SCHEMAS)" ] && \
234 $(GLIB_COMPILE_SCHEMAS) $(datadir)/glib-2.0/schemas
235 $(INSTALL.data) $(AUTOSTART_FILE) \
236 $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
237 for desktop_file in $(DESKTOP_FILES); do \
238 $(INSTALL.data) $${desktop_file} \
239 $(DESTDIR)$(xdgapplicationsdir)/$${desktop_file}; \
240 done
241 for lang in $(LINGUAS); do \
242 $(INSTALL.data) po/$${lang}.mo \
243 $(DESTDIR)$(localedir)/$${lang}/LC_MESSAGES/$(PACKAGE).mo; \
244 done
245 for manpage in $(MANPAGES); do \
246 $(INSTALL.data) $${manpage} \
247 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
248 done
250 clean:
251 rm -f $(PACKAGE) $(OBJS) $(ENUM_FILES) $(AUTOSTART_FILE) \
252 $(DESKTOP_FILES) $(POTFILE) $(MOFILES) $(MANPAGES)
254 clobber: clean
255 rm -f $(patsubst %.o,%.d,$(OBJS))
257 dist: clobber
258 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
259 -s ',^\.$$,,' -s ',\./,$(DISTNAME)/,' . | \
260 $(GZIP) > $(DISTNAME).tar.gz
262 -include local.mk
264 -include $(patsubst %.o,%.d,$(OBJS))
265 -include $(patsubst %.gresource.xml,%.gresource.d,$(GRESOURCE_FILES))