Add decent cleanup code in command-reading thread
[pipeglade.git] / Makefile
blob297b5656533de577f8b0a0242d16e2bc0ee3becf
1 # Copyright (c) 2014, 2015 Bert Burgemeister <trebbu@googlemail.com>
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation files
5 # (the "Software"), to deal in the Software without restriction,
6 # including without limitation the rights to use, copy, modify, merge,
7 # publish, distribute, sublicense, and/or sell copies of the Software,
8 # and to permit persons to whom the Software is furnished to do so,
9 # subject to the following conditions:
11 # The above copyright notice and this permission notice shall be
12 # included in all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
23 PREFIX = /usr/local
24 CCFLAGS = -Wall `pkg-config --cflags --libs gtk+-3.0 gmodule-2.0`
25 CC != which cc
27 pipeglade: pipeglade.c
28 $(CC) $< -o $@ $(CCFLAGS)
30 install: pipeglade pipeglade.1
31 mkdir -p $(PREFIX)/bin/
32 mkdir -p $(PREFIX)/man/man1/
33 cp -f pipeglade $(PREFIX)/bin/
34 chmod 755 $(PREFIX)/bin/pipeglade
35 gzip -c pipeglade.1 > $(PREFIX)/man/man1/pipeglade.1.gz
36 chmod 644 $(PREFIX)/man/man1/pipeglade.1.gz
38 uninstall:
39 rm -f $(PREFIX)/bin/pipeglade
40 rm -f $(PREFIX)/man/man1/pipeglade.1.gz
42 clean:
43 rm -f pipeglade
44 rm -rf gh-pages
46 .PHONY: install uninstall clean
50 # Build targets end here. The rest of this Makefile is only useful
51 # for project maintenance.
53 # It works with FreeBSD's version of make (aka pmake). It won't work
54 # with GNU make.
55 ######################################################################
56 VERSION != git describe --tags | cut -d "-" -f 1
57 CODE_VERSION != awk '/\#define VERSION/{print $$3}' pipeglade.c | tr -d '"'
58 NEWS_VERSION != awk '/^[0-9]+.[0-9]+.[0-9]+ .*(.+)/{print $$1}' NEWS | head -n1
59 NEWS_DATE != awk '/^[0-9]+.[0-9]+.[0-9]+ .*(.+)/{print substr($$2, 2, 10)}' NEWS | head -n1
60 TODAY != date +%F
61 MANPAGE_DATE != grep "^\.Dd " pipeglade.1
62 MANPAGE_TODAY != date '+.Dd %B %e, %Y' | awk '{print $$1, $$2, $$3, $$4}'
64 # Prepare the www directory
65 gh-pages: gh-pages/index.html gh-pages/pipeglade.1.html
67 gh-pages/index.html gh-pages/pipeglade.1.html: pipeglade.1 html-template/index.html Makefile
68 mkdir -p gh-pages
69 cp html-template/* gh-pages/
70 mandoc -T html -O style=style.css pipeglade.1 > gh-pages/pipeglade.1.html
71 mandoc -T pdf -O paper=a4 pipeglade.1 > gh-pages/pipeglade.1.pdf
72 cp LICENSE gh-pages/
73 echo -e '/@/\ns/</\&lt;/\ns/>/\&gt;/\n,s/^$$/<p>/\nwq' | ed -s gh-pages/LICENSE
74 echo -e '/<!-- replace_with_license_text -->/d\n-r gh-pages/LICENSE\nwq' | ed -s gh-pages/index.html
75 echo -e ',s/_PUT_VERSION_HERE_/$(VERSION)/g\nwq' | ed -s gh-pages/index.html
76 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/index.html
77 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/pipeglade.1.html
78 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/404.html
79 rm -f gh-pages/statcounter.html gh-pages/LICENSE
81 # Create a new git tag only if there is a NEWS headline in the format
82 # 1.2.3 (2015-03-22)
83 # where 1.2.3 matches the current pipeglade version and the date is of
84 # today, and if pipeglade.1 has today's date in its .Dd line.
85 # (NEWS headlines are lines that start at column 0.)
86 git-tag:
87 if test "$(NEWS_DATE)" != "$(TODAY)"; then \
88 echo "NEWS: $(NEWS_DATE) != $(TODAY)"; false; \
89 fi; \
90 if test "$(NEWS_VERSION)" != "$(CODE_VERSION)"; then \
91 echo "NEWS: $(NEWS_VERSION) != $(CODE_VERSION)"; false; \
92 fi; \
93 if test "$(MANPAGE_DATE)" != "$(MANPAGE_TODAY)"; then \
94 echo "MANPAGE: $(MANPAGE_DATE) != $(MANPAGE_TODAY)"; false; \
95 fi; \
96 git tag $(CODE_VERSION);
98 # Push the www directory to Github Pages
99 publish: clean gh-pages
100 (cd gh-pages; \
101 git init; \
102 git add ./; \
103 git commit -a -m "gh-pages pseudo commit"; \
104 git push git@github.com:trebb/pipeglade.git +master:gh-pages)