comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:9a16bf50daba
1 #
2 # Copyright (C) 2013 Guido Berhoerster <guido+xinhibit-applet@berhoerster.name>
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 PACKAGE = xinhibit-applet
25 APP_NAME = org.guido-berhoerster.xinhibit-applet
26 VERSION = 1
27 DISTNAME := $(PACKAGE)-$(VERSION)
28
29 INSTALL := install
30 INSTALL.exec := $(INSTALL) -D -m 0755
31 INSTALL.data := $(INSTALL) -D -m 0644
32 PAX := pax
33 GZIP := gzip
34 SED := sed
35 MSGFMT := msgfmt
36 INTLTOOL_UPDATE := intltool-update
37 INTLTOOL_MERGE := intltool-merge
38
39 DESTDIR ?=
40 prefix ?= /usr/local
41 bindir ?= $(prefix)/bin
42 datadir ?= $(prefix)/share
43 mandir ?= $(datadir)/man
44 localedir ?= $(datadir)/locale
45 sysconfdir ?= /etc
46 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
47
48 HAVE_LIBXTST ?= 1
49
50 ifeq ($(HAVE_LIBXTST),1)
51 CPPFLAGS_LIBXTST := -DHAVE_LIBXTST
52 LDLIBS_LIBXTST := -lX11 -lXext -lXtst
53 endif
54
55 OBJS = main.o xia-icon.o xia-inhibitor.o xia-debug.o
56 AUTOSTART_FILE = data/$(PACKAGE).desktop
57 MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
58 POTFILE = po/$(PACKAGE).pot
59 POSRCS := $(shell sed -e 's/\#.*//' -e '/^[ \t]*$$/d' \
60 -e 's/^\[[^]]*\]//' po/POTFILES.in | paste -s -d ' ')
61 CPPFLAGS := $(CPPFLAGS_LIBXTST) \
62 $(shell pkg-config --cflags glib-2.0 gtk+-2.0 unique-1.0) \
63 -DPACKAGE="\"$(PACKAGE)\"" \
64 -DAPP_NAME=\"$(APP_NAME)\" \
65 -DVERSION=\"$(VERSION)\" \
66 -DLOCALEDIR="\"$(localedir)\""
67 LDLIBS := $(LDLIBS_LIBXTST) \
68 $(shell pkg-config --libs glib-2.0 gtk+-2.0 unique-1.0)
69
70 .DEFAULT_TARGET = all
71
72 .PHONY: all clean clobber dist install
73
74 all: $(PACKAGE) $(MOFILES) $(AUTOSTART_FILE)
75
76 $(PACKAGE): $(OBJS)
77 $(LINK.o) $^ $(LDLIBS) -o $@
78
79 $(POTFILE): po/POTFILES.in $(POSRCS)
80 cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"
81
82 pot: $(POTFILE)
83
84 update-po: $(POTFILE)
85 cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
86 $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
87 $${lang}; \
88 done
89
90 %.o: %.c
91 $(COMPILE.c) -MD -o $@ $<
92 @cp $*.d $*.P; \
93 $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' \
94 -e 's/$$/ :/' < $*.d >> $*.P; \
95 rm -f $*.d
96
97 %.desktop: %.desktop.in $(MOFILES)
98 $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
99
100 %.mo: %.po
101 $(MSGFMT) -o $@ $<
102
103 install:
104 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
105 for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
106 $(INSTALL.data) po/$${lang}.mo \
107 "$(DESTDIR)$(localedir)/$${lang}/LC_MESSAGES/$(PACKAGE).mo"; \
108 done
109 cd data/icons && for icon in */*/*.png scalable/*/*.svg; do \
110 $(INSTALL.data) $$icon \
111 "$(DESTDIR)$(datadir)/icons/hicolor/$${icon}"; \
112 done
113 $(INSTALL.data) $(AUTOSTART_FILE) \
114 "$(DESTDIR)$(xdgautostartdir)/$(notdir $(AUTOSTART_FILE))"
115 $(INSTALL.data) data/$(PACKAGE).1 \
116 "$(DESTDIR)$(mandir)/man1/$(PACKAGE).1"
117
118 clean:
119 rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(AUTOSTART_FILE)
120
121 clobber: clean
122 rm -f *.P
123
124 dist: clobber
125 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
126 -s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz
127
128 -include $(patsubst %.o,%.P,$(OBJS))