projects/package-update-indicator

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