diff Makefile @ 1:2f04ec9e0506

Add preferences application Split settings into separate file.
author Guido Berhoerster <guido+pui@berhoerster.name>
date Fri, 08 Jun 2018 08:38:42 +0200
parents 6884bb8130ca
children 7172a0db97af
line wrap: on
line diff
--- a/Makefile	Sun May 20 11:32:57 2018 +0200
+++ b/Makefile	Fri Jun 08 08:38:42 2018 +0200
@@ -23,6 +23,7 @@
 
 PACKAGE =	package-update-indicator
 APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator
+PREFS_APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator.preferences
 VERSION =	1
 DISTNAME =	$(PACKAGE)-$(VERSION)
 AUTHOR =	Guido Berhoerster
@@ -48,6 +49,7 @@
 GZIP :=		gzip
 SED :=		sed
 GLIB_COMPILE_SCHEMAS := $(shell pkg-config --variable=glib_compile_schemas gio-2.0)
+GLIB_COMPILE_RESOURCES := $(shell pkg-config --variable=glib_compile_resources gio-2.0)
 XSLTPROC :=	xsltproc
 DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
@@ -91,32 +93,45 @@
 localedir ?=	$(datadir)/locale
 sysconfdir ?=	/etc
 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
+xdgapplicationsdir ?= $(datadir)/applications
 
 OS_NAME :=	$(shell uname -s)
 OS_RELEASE :=	$(shell uname -r)
 
-OBJS =		package-update-indicator.o \
+$(PACKAGE)_OBJS = package-update-indicator.o \
 		pui-application.o \
 		pui-backend.o \
 		pui-get-updates.o \
+		pui-settings.o \
 		pui-types.o
 
+$(PACKAGE)-prefs_OBJS = package-update-indicator-prefs.o \
+		pui-prefs-application.o \
+		pui-settings.o \
+		pui-prefs-resources.o
+
+OBJS = $($(PACKAGE)_OBJS) $($(PACKAGE)-prefs_OBJS)
+
 GSETTINGS_SCHEMAS = $(APPLICATION_ID).gschema.xml
 
-AUTOSTART_FILES = $(APPLICATION_ID).desktop
+GRESOURCE_FILES = pui-prefs.gresource.xml
+
+AUTOSTART_FILE = $(APPLICATION_ID).desktop
+
+DESKTOP_FILES = $(PREFS_APPLICATION_ID).desktop
 
 LINGUAS :=	$(shell sed 's/\#.*//' po/LINGUAS)
 MOFILES :=	$(patsubst %,po/%.mo,$(LINGUAS))
 POTFILES_IN :=	$(shell sed 's/\#.*//' po/POTFILES.in)
 POTFILE =	po/$(PACKAGE).pot
 
-MANPAGES =	$(PACKAGE).1
+MANPAGES =	$(PACKAGE).1 $(PACKAGE)-prefs.1
 
 .DEFAULT_TARGET = all
 
 .PHONY: all pot update-po clean clobber dist install
 
-all: $(PACKAGE) $(AUTOSTART_FILES) $(MOFILES) $(MANPAGES)
+all: $(PACKAGE) $(PACKAGE)-prefs $(AUTOSTART_FILE) $(DESKTOP_FILES) $(MOFILES) $(MANPAGES)
 
 $(PACKAGE): XCPPFLAGS =	-DPACKAGE=\"$(PACKAGE)\" \
 			-DAPPLICATION_ID=\"$(APPLICATION_ID)\" \
@@ -124,12 +139,23 @@
 			-DG_LOG_DOMAIN=\"$(PACKAGE)\" \
 			-DPACKAGE_LOCALE_DIR="\"$(localedir)\"" \
 			-DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
+			-DSETTINGS_SCHEMA_ID=\"$(APPLICATION_ID)\" \
 			-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
 $(PACKAGE): XCFLAGS =	$(shell pkg-config --cflags gtk+-3.0 \
 			    appindicator3-0.1 packagekit-glib2)
 $(PACKAGE): LDLIBS =	$(shell pkg-config --libs gtk+-3.0 \
 			    appindicator3-0.1 packagekit-glib2)
 
+$(PACKAGE)-prefs: XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \
+			-DAPPLICATION_ID=\"$(PREFS_APPLICATION_ID)\" \
+			-DVERSION=\"$(VERSION)\" \
+			-DG_LOG_DOMAIN=\"$(PACKAGE)\" \
+			-DPACKAGE_LOCALE_DIR="\"$(localedir)\"" \
+			-DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
+			-DSETTINGS_SCHEMA_ID=\"$(APPLICATION_ID)\"
+$(PACKAGE)-prefs: XCFLAGS = $(shell pkg-config --cflags gtk+-3.0)
+$(PACKAGE)-prefs: LDLIBS = $(shell pkg-config --libs gtk+-3.0)
+
 ifneq ($(findstring $(OS_NAME),FreeBSD DragonFly OpenBSD),)
   $(PACKAGE): XCPPFLAGS +=	-I/usr/local/include
   $(PACKAGE): XLDFLAGS +=	-L/usr/local/lib
@@ -141,9 +167,19 @@
   $(PACKAGE): XCPPFLAGS +=	-D_XOPEN_SOURCE=600
 endif
 
-$(PACKAGE): $(OBJS)
+$(PACKAGE): $($(PACKAGE)_OBJS)
+	$(LINK.o) $^ $(LDLIBS) -o $@
+
+$(PACKAGE)-prefs: $($(PACKAGE)-prefs_OBJS)
 	$(LINK.o) $^ $(LDLIBS) -o $@
 
+%-resources.c: %.gresource.xml
+	$(GLIB_COMPILE_RESOURCES) --generate-dependencies $< | \
+	    while read -r resource_file; do \
+	        printf '%s: %s\n' $@ "$${resource_file}"; \
+	    done
+	$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=. --generate-source $<
+
 $(POTFILE): po/POTFILES.in $(POTFILES_IN)
 	$(XGETTEXT) $(XGETTEXT_OPTIONS) --files-from $< --output $@
 
@@ -168,15 +204,19 @@
 
 install: all
 	$(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
+	$(INSTALL.exec) $(PACKAGE)-prefs \
+	    "$(DESTDIR)$(bindir)/$(PACKAGE)-prefs"
 	for schema in $(GSETTINGS_SCHEMAS); do \
 	    $(INSTALL.data) $${schema} \
 	        $(DESTDIR)$(datadir)/glib-2.0/schemas/$${schema}; \
 	done
 	[ -n "$(GSETTINGS_SCHEMAS)" ] && \
 	    $(GLIB_COMPILE_SCHEMAS) $(datadir)/glib-2.0/schemas
-	for desktop_file in $(AUTOSTART_FILES); do \
+	$(INSTALL.data) $(AUTOSTART_FILE) \
+	    $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
+	for desktop_file in $(DESKTOP_FILES); do \
 	    $(INSTALL.data) $${desktop_file} \
-	        $(DESTDIR)$(xdgautostartdir)/$${desktop_file}; \
+	        $(DESTDIR)$(xdgapplicationsdir)/$${desktop_file}; \
 	done
 	for lang in $(LINGUAS); do \
 	   $(INSTALL.data) po/$${lang}.mo \
@@ -188,8 +228,8 @@
 	done
 
 clean:
-	rm -f $(PACKAGE) $(OBJS) $(AUTOSTART_FILES) $(POTFILE) $(MOFILES) \
-	    $(MANPAGES)
+	rm -f $(PACKAGE) $(OBJS) $(AUTOSTART_FILE) $(DESKTOP_FILES) $(POTFILE) \
+	    $(MOFILES) $(MANPAGES)
 
 clobber: clean
 	rm -f $(patsubst %.o,%.d,$(OBJS))
@@ -202,3 +242,4 @@
 -include local.mk
 
 -include $(patsubst %.o,%.d,$(OBJS))
+-include $(patsubst %.gresource.xml,%.gresource.d,$(GRESOURCE_FILES))