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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
#
# Copyright (C) 2011 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
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
PACKAGE = xwrited
APP_NAME = org.guido-berhoerster.code.xwrited
VERSION = 2
DISTNAME := $(PACKAGE)-$(VERSION)
# gcc, clang, icc
MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(CPPFLAGS)
# Sun/Solaris Studio
#MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(CPPFLAGS)
# X makedepend
#MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) --
INSTALL := install
INSTALL.exec := $(INSTALL) -D -m 0755
INSTALL.data := $(INSTALL) -D -m 0644
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
define generate-manpage-rule =
%.$(1): %.$(1).xml
$$(XSLTPROC) \
--xinclude \
--stringparam package $$(PACKAGE) \
--stringparam version $$(VERSION)\
data/docbook-update-source-data.xsl $$< | \
$$(XSLTPROC) \
--xinclude \
$$(DOCBOOK5_MANPAGES_FLAGS) \
--output $$@ \
$$(DOCBOOK5_MANPAGES_STYLESHEET) \
-
endef
DESTDIR ?=
prefix ?= /usr/local
bindir ?= $(prefix)/bin
datadir ?= $(prefix)/share
mandir ?= $(datadir)/man
localedir ?= $(datadir)/locale
sysconfdir ?= /etc
xdgautostartdir ?= $(sysconfdir)/xdg/autostart
OS_NAME := $(shell uname -s)
OS_RELEASE := $(shell uname -r)
is_in = $(if $(filter $2, $1),true,false)
PKGCONFIG_LIBS := dbus-1 glib-2.0 libnotify
EXTRA_LIBS :=
ifeq ($(OS_NAME),Linux)
OBJS_UTMP := xwrited-utmp-utempter.o
EXTRA_LIBS += -lutempter
else ifeq ($(OS_NAME),FreeBSD)
OBJS_UTMP := xwrited-utmp-utempter.o
FREEBSD_RELEASE_MAJOR := $(firstword $(subst ., ,$(OS_RELEASE)))
# FreeBSD < 9.0 needs libutempter
ifeq ($(call is_in, $(OS_RELEASE_MAJOR), 7 8), true)
EXTRA_LIBS += -lutempter
else
EXTRA_LIBS += -lulog
endif
else
OBJS_UTMP := xwrited-utmp-utmpx.o
endif
ifeq ($(shell pkg-config --exists 'glib-2.0 >= 2.25.5' && printf "true"), true)
CPPFLAGS_EXTRA := -DHAVE_GLIB_GDBUS
else
PKGCONFIG_LIBS += dbus-glib-1
endif
OBJS = main.o xwrited-debug.o xwrited-unique.o $(OBJS_UTMP)
MANPAGES = data/$(PACKAGE).1
AUTOSTART_FILE = data/$(PACKAGE).desktop
MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
POTFILE = po/$(PACKAGE).pot
POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \
-e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ')
CPPFLAGS := $(CPPFLAGS_EXTRA) \
$(CPPFLAGS_LIBUTEMPTER) \
$(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \
-DPACKAGE="\"$(PACKAGE)\"" \
-DAPP_NAME=\"$(APP_NAME)\" \
-DVERSION=\"$(VERSION)\" \
-DLOCALEDIR="\"$(localedir)\"" \
-DG_LOG_DOMAIN=\"$(PACKAGE)\" \
$(CPPFLAGS)
LDLIBS := $(EXTRA_LIBS) \
$(shell pkg-config --libs $(PKGCONFIG_LIBS))
DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
--stringparam man.copyright.section.enabled 0
.DEFAULT_TARGET = all
.PHONY: all clean clobber dist install
all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE)
$(PACKAGE): $(OBJS)
$(LINK.o) $^ $(LDLIBS) -o $@
$(POTFILE): po/POTFILES.in $(POSRCS)
cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"
pot: $(POTFILE)
update-po: $(POTFILE)
cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
$(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
$${lang}; \
done
%.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.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"; \
done
$(INSTALL.data) $(AUTOSTART_FILE) \
"$(DESTDIR)$(xdgautostartdir)/$(notdir $(AUTOSTART_FILE))"
$(INSTALL.data) data/$(PACKAGE).1 \
"$(DESTDIR)$(mandir)/man1/$(PACKAGE).1"
clean:
rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE)
clobber: clean
rm -f $(patsubst %.o,%.d,$(OBJS))
dist: clobber
$(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
-s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz
-include $(patsubst %.o,%.d,$(OBJS))
|