Mercurial > projects > xwrited
diff Makefile @ 19:f0accfc74f7b
Port to GLib version 2.48 or later
Use GApplication instead of the custom XWritedUnique object for uniqueness.
Use GNotification from GIO instead of libnotify.
Remove help and debug options from documentation.
Replace intltool with GNU gettext (version 0.19 or later required).
author | Guido Berhoerster <guido+xwrited@berhoerster.name> |
---|---|
date | Sat, 28 Jul 2018 22:02:24 +0200 |
parents | 4a5330979433 |
children | 9d00c0e07c47 |
line wrap: on
line diff
--- a/Makefile Wed Sep 14 09:46:59 2016 +0200 +++ b/Makefile Sat Jul 28 22:02:24 2018 +0200 @@ -1,5 +1,5 @@ # -# Copyright (C) 2016 Guido Berhoerster <guido+xwrited@berhoerster.name> +# Copyright (C) 2018 Guido Berhoerster <guido+xwrited@berhoerster.name> # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -22,9 +22,10 @@ # PACKAGE = xwrited -APP_NAME = org.guido-berhoerster.code.xwrited +APPLICATION_ID = org.guido-berhoerster.code.xwrited VERSION = 2 DISTNAME := $(PACKAGE)-$(VERSION) +BUG_ADDRESS = guido+xwrited@berhoerster.name # gcc, clang, icc, Sun/Solaris Studio CC := $(CC) -std=c99 @@ -35,18 +36,35 @@ #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) # X makedepend #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) -- +LINK.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH) +LINK.o = $(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH) +CP := cp INSTALL := install INSTALL.exec := $(INSTALL) -D -m 0755 INSTALL.data := $(INSTALL) -D -m 0644 +INSTALL.link := $(CP) -f -P PAX := pax GZIP := gzip SED := sed -PASTE := paste -MSGFMT := msgfmt -INTLTOOL_UPDATE := intltool-update -INTLTOOL_MERGE := intltool-merge 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 \ + --stringparam man.copyright.section.enabled 0 +MSGFMT = msgfmt +MSGMERGE = msgmerge +XGETTEXT = xgettext +XGETTEXT_OPTIONS = --copyright-holder "$(AUTHOR)" \ + --package-name '$(PACKAGE)' \ + --package-version '$(VERSION)' \ + --msgid-bugs-address '$(BUG_ADDRESS)' \ + --default-domain '$(PACKAGE)' \ + --from-code UTF-8 \ + --keyword=_ \ + --keyword=N_ \ + --keyword=C_:1c,2 \ + --keyword=NC_:1c,2 \ + --keyword=g_dngettext:2,3 \ + --add-comments define generate-manpage-rule = %.$(1): %.$(1).xml @@ -54,7 +72,7 @@ --xinclude \ --stringparam package $$(PACKAGE) \ --stringparam version $$(VERSION)\ - data/docbook-update-source-data.xsl $$< | \ + docbook-update-source-data.xsl $$< | \ $$(XSLTPROC) \ --xinclude \ $$(DOCBOOK5_MANPAGES_FLAGS) \ @@ -75,95 +93,94 @@ OS_NAME := $(shell uname -s) OS_RELEASE := $(shell uname -r) -ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"),true) - HAVE_GLIB_GDBUS = 1 +OBJS = xwrited.o \ + xwd-application.o +ifneq ($(findstring $(OS_NAME),Linux FreeBSD),) + OBJS += xwd-utmp-utempter.o else - HAVE_GLIB_GDBUS = 0 + OBJS += xwd-utmp-utmpx.o endif -PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify -ifeq ($(HAVE_GLIB_GDBUS),1) - PKGCONFIG_LIBS += dbus-glib-1 -endif -OBJS = main.o xwrited-debug.o xwrited-unique.o -ifneq ($(findstring $(OS_NAME),Linux FreeBSD),) - OBJS += xwrited-utmp-utempter.o -else - OBJS += xwrited-utmp-utmpx.o -endif -MANPAGES = data/$(PACKAGE).1 -AUTOSTART_FILE = data/$(PACKAGE).desktop -MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po)) +MANPAGES = $(PACKAGE).1 + +AUTOSTART_FILE = $(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 -POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \ - -e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ') -DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \ - --stringparam man.copyright.section.enabled 0 .DEFAULT_TARGET = all -.PHONY: all clean clobber dist install +.PHONY: all pot update-po clean clobber dist install -all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE) +all: $(PACKAGE) $(AUTOSTART_FILE) $(MOFILES) $(MANPAGES) -$(PACKAGE): CPPFLAGS := $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \ - -D_XOPEN_SOURCE=600 \ - -DPACKAGE="\"$(PACKAGE)\"" \ - -DAPP_NAME=\"$(APP_NAME)\" \ +$(PACKAGE): XCFLAGS = $(shell pkg-config --cflags gobject-2.0 gio-2.0 \ + glib-2.0) \ + -DPACKAGE=\"$(PACKAGE)\" \ + -DAPPLICATION_ID=\"$(APPLICATION_ID)\" \ -DVERSION=\"$(VERSION)\" \ - -DLOCALEDIR="\"$(localedir)\"" \ - -DG_LOG_DOMAIN=\"$(PACKAGE)\" -$(PACKAGE): LDLIBS := $(shell pkg-config --libs $(PKGCONFIG_LIBS)) -ifeq ($(HAVE_GLIB_GDBUS),1) - $(PACKAGE): XCPPFLAGS += -DHAVE_GLIB_GDBUS -endif + -DG_LOG_DOMAIN=\"$(PACKAGE)\" \ + -DPACKAGE_LOCALE_DIR="\"$(localedir)\"" \ + -DGETTEXT_PACKAGE=\"$(PACKAGE)\" +$(PACKAGE): LDLIBS = $(shell pkg-config --libs gobject-2.0 gio-2.0 \ + glib-2.0) + ifeq ($(OS_NAME),Linux) + $(PACKAGE): XCPPFLAGS += -D_XOPEN_SOURCE=600 $(PACKAGE): LDLIBS += -lutempter else ifeq ($(OS_NAME),FreeBSD) $(PACKAGE): LDLIBS += -lulog else ifeq ($(OS_NAME),SunOS) - $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include + $(PACKAGE): XCPPFLAGS += -D_XOPEN_SOURCE=600 -I/usr/xpg4/include $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib endif + $(PACKAGE): $(OBJS) $(LINK.o) $^ $(LDLIBS) -o $@ -$(POTFILE): po/POTFILES.in $(POSRCS) - cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)" +$(POTFILE): po/POTFILES.in $(POTFILES_IN) + $(XGETTEXT) $(XGETTEXT_OPTIONS) --files-from $< --output $@ pot: $(POTFILE) update-po: $(POTFILE) - cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \ - $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \ - $${lang}; \ + for pofile in $(patsubst %.mo,%.po,$(MOFILES)); do \ + $(MSGMERGE) --update --backup off $$pofile $<; \ done +%.mo: %.po + $(MSGFMT) --output $@ $< + +%.desktop: %.desktop.in + $(MSGFMT) --desktop --template $< -d po --output $@ + +$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section)))) + +%.mo: %.po + $(MSGFMT) -o $@ $< + %.o: %.c $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d $(COMPILE.c) -o $@ $< -$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section)))) - -%.desktop: %.desktop.in $(MOFILES) - $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@ - -%.mo: %.po - $(MSGFMT) -o $@ $< - -install: +install: all $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)" - for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \ - $(INSTALL.data) po/$${lang}.mo \ - "$(DESTDIR)$(localedir)/$${lang}/LC_MESSAGES/$(PACKAGE).mo"; \ + $(INSTALL.data) $(AUTOSTART_FILE) \ + $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE) + for lang in $(LINGUAS); do \ + $(INSTALL.data) po/$${lang}.mo \ + $(DESTDIR)$(localedir)/$${lang}/LC_MESSAGES/$(PACKAGE).mo; \ done - $(INSTALL.data) $(AUTOSTART_FILE) \ - "$(DESTDIR)$(xdgautostartdir)/$(notdir $(AUTOSTART_FILE))" - $(INSTALL.data) data/$(PACKAGE).1 \ - "$(DESTDIR)$(mandir)/man1/$(PACKAGE).1" + for manpage in $(MANPAGES); do \ + $(INSTALL.data) $${manpage} \ + "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \ + done clean: - rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE) + rm -f $(PACKAGE) $(OBJS) $(AUTOSTART_FILE) $(POTFILE) $(MOFILES) \ + $(MANPAGES) clobber: clean rm -f $(patsubst %.o,%.d,$(OBJS)) @@ -173,4 +190,6 @@ -s ',^\.$$,,' -s ',\./,$(DISTNAME)/,' . | \ $(GZIP) > $(DISTNAME).tar.gz +-include local.mk + -include $(patsubst %.o,%.d,$(OBJS))