comparison Makefile @ 0:52694b49dcc4

Initial revision
author Guido Berhoerster <guido+xwrited@berhoerster.name>
date Sun, 27 Apr 2014 23:07:51 +0200
parents
children c53bcdabbba7
comparison
equal deleted inserted replaced
-1:000000000000 0:52694b49dcc4
1 #
2 # Copyright (C) 2011 Guido Berhoerster <guido+xwrited@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 = xwrited
25 APP_NAME = org.guido-berhoerster.code.xwrited
26 VERSION = 1
27 DISTNAME := $(PACKAGE)-$(VERSION)
28
29 # gcc, clang, icc
30 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(CPPFLAGS)
31 # Sun/Solaris Studio
32 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(CPPFLAGS)
33 # X makedepend
34 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(CPPFLAGS) --
35 INSTALL := install
36 INSTALL.exec := $(INSTALL) -D -m 0755
37 INSTALL.data := $(INSTALL) -D -m 0644
38 PAX := pax
39 GZIP := gzip
40 SED := sed
41 PASTE := paste
42 MSGFMT := msgfmt
43 INTLTOOL_UPDATE := intltool-update
44 INTLTOOL_MERGE := intltool-merge
45
46 DESTDIR ?=
47 prefix ?= /usr/local
48 bindir ?= $(prefix)/bin
49 datadir ?= $(prefix)/share
50 localedir ?= $(datadir)/locale
51 sysconfdir ?= /etc
52 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
53
54 OS_NAME := $(shell uname -s)
55
56 PKGCONFIG_LIBS := dbus-1 glib-2.0 dbus-glib-1 libnotify
57 EXTRA_LIBS :=
58
59 ifeq ($(OS_NAME),Linux)
60 OBJS_UTMP := xwrited-utmp-utempter.o
61 EXTRA_LIBS += -lutempter
62 else ifeq ($(OS_NAME),FreeBSD)
63 OBJS_UTMP := xwrited-utmp-utempter.o
64 EXTRA_LIBS += -lutempter
65 else
66 OBJS_UTMP := xwrited-utmp-utmpx.o
67 endif
68
69 OBJS = main.o xwrited-debug.o xwrited-unique.o $(OBJS_UTMP)
70 AUTOSTART_FILE = $(PACKAGE).desktop
71 MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
72 POTFILE = po/$(PACKAGE).pot
73 POSRCS := $(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \
74 -e 's/^\[[^]]*\]//' po/POTFILES.in | $(PASTE) -s -d ' ')
75 CPPFLAGS := $(CPPFLAGS_EXTRA) \
76 $(CPPFLAGS_LIBUTEMPTER) \
77 $(shell pkg-config --cflags $(PKGCONFIG_LIBS)) \
78 -DPACKAGE="\"$(PACKAGE)\"" \
79 -DAPP_NAME=\"$(APP_NAME)\" \
80 -DVERSION=\"$(VERSION)\" \
81 -DLOCALEDIR="\"$(localedir)\"" \
82 -DG_LOG_DOMAIN=\"$(PACKAGE)\"
83 LDLIBS := $(EXTRA_LIBS) \
84 $(shell pkg-config --libs $(PKGCONFIG_LIBS))
85
86 .DEFAULT_TARGET = all
87
88 .PHONY: all clean clobber dist install
89
90 all: $(PACKAGE) $(MOFILES) $(AUTOSTART_FILE)
91
92 $(PACKAGE): $(OBJS)
93 $(LINK.o) $^ $(LDLIBS) -o $@
94
95 $(POTFILE): po/POTFILES.in $(POSRCS)
96 cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"
97
98 pot: $(POTFILE)
99
100 update-po: $(POTFILE)
101 cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
102 $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
103 $${lang}; \
104 done
105
106 %.o: %.c
107 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
108 $(COMPILE.c) -o $@ $<
109
110 %.desktop: %.desktop.in $(MOFILES)
111 $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
112
113 %.mo: %.po
114 $(MSGFMT) -o $@ $<
115
116 install:
117 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
118 for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
119 $(INSTALL.data) po/$${lang}.mo \
120 "$(DESTDIR)$(localedir)/$${lang}/LC_MESSAGES/$(PACKAGE).mo"; \
121 done
122 $(INSTALL.data) $(AUTOSTART_FILE) \
123 "$(DESTDIR)$(xdgautostartdir)/$(notdir $(AUTOSTART_FILE))"
124
125 clean:
126 rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(AUTOSTART_FILE)
127
128 clobber: clean
129 rm -f $(patsubst %.o,%.d,$(OBJS))
130
131 dist: clobber
132 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
133 -s ',\./,$(DISTNAME)/,' . | $(GZIP) > $(DISTNAME).tar.gz
134
135 -include $(patsubst %.o,%.d,$(OBJS))