view Makefile @ 0:9a16bf50daba

Initial revision
author Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
date Sat, 27 Apr 2013 00:33:11 +0200
parents
children 1508a4c35c47
line wrap: on
line source

#
# Copyright (C) 2013 Guido Berhoerster <guido+xinhibit-applet@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 =	xinhibit-applet
APP_NAME =	org.guido-berhoerster.xinhibit-applet
VERSION =	1
DISTNAME :=	$(PACKAGE)-$(VERSION)

INSTALL :=	install
INSTALL.exec :=	$(INSTALL) -D -m 0755
INSTALL.data :=	$(INSTALL) -D -m 0644
PAX :=		pax
GZIP :=		gzip
SED :=		sed
MSGFMT :=	msgfmt
INTLTOOL_UPDATE :=	intltool-update
INTLTOOL_MERGE :=	intltool-merge

DESTDIR ?=
prefix ?=	/usr/local
bindir ?=	$(prefix)/bin
datadir ?=	$(prefix)/share
mandir ?=	$(datadir)/man
localedir ?=	$(datadir)/locale
sysconfdir ?=	/etc
xdgautostartdir ?=	$(sysconfdir)/xdg/autostart

HAVE_LIBXTST ?=	1

ifeq ($(HAVE_LIBXTST),1)
    CPPFLAGS_LIBXTST :=	-DHAVE_LIBXTST
    LDLIBS_LIBXTST :=	-lX11 -lXext -lXtst
endif

OBJS =		main.o xia-icon.o xia-inhibitor.o xia-debug.o
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_LIBXTST) \
		$(shell pkg-config --cflags glib-2.0 gtk+-2.0 unique-1.0) \
		-DPACKAGE="\"$(PACKAGE)\"" \
		-DAPP_NAME=\"$(APP_NAME)\" \
		-DVERSION=\"$(VERSION)\" \
		-DLOCALEDIR="\"$(localedir)\""
LDLIBS :=	$(LDLIBS_LIBXTST) \
		$(shell pkg-config --libs glib-2.0 gtk+-2.0 unique-1.0)

.DEFAULT_TARGET = all

.PHONY: all clean clobber dist install

all: $(PACKAGE) $(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
	$(COMPILE.c) -MD -o $@ $<
	@cp $*.d $*.P; \
	$(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' \
	        -e 's/$$/ :/' < $*.d >> $*.P; \
	rm -f $*.d

%.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
	cd data/icons && for icon in */*/*.png scalable/*/*.svg; do \
	    $(INSTALL.data) $$icon \
	        "$(DESTDIR)$(datadir)/icons/hicolor/$${icon}"; \
	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) $(AUTOSTART_FILE)

clobber: clean
	rm -f *.P

dist: clobber
	$(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
	    -s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz

-include $(patsubst %.o,%.P,$(OBJS))