Add new tests for documentation correctness
[pipeglade.git] / Makefile
blob793db1d4328002ab73f4121a8d871550ac5dc260
1 # Copyright (c) 2014-2016 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 bindir ?= $(prefix)/bin
25 mandir ?= $(prefix)/man
26 man1dir ?= $(mandir)/man1
27 CCFLAGS += -Wall -Wextra -pedantic -g
28 # FreeBSD:
29 # Suppressing warning: named variadic macros are a GNU extension
30 # in /usr/local/include/X11/Xfuncproto.h:157:24:
31 CCFLAGS += -Wno-variadic-macros
32 CCFLAGS += -std=c99
33 CCFLAGS += -D_POSIX_C_SOURCE=200809L
34 CCFLAGS += -D_XOPEN_SOURCE=700
35 CCFLAGS += `pkg-config --cflags --libs gtk+-3.0 gmodule-2.0`
36 CCFLAGS += `pkg-config --cflags --libs gtk+-unix-print-3.0`
37 CCFLAGS += `pkg-config --cflags --libs libxml-2.0`
38 CC != which cc
41 all: pipeglade
43 pipeglade: pipeglade.c Makefile
44 $(CC) $< -o $@ $(CCFLAGS)
46 install: pipeglade pipeglade.1
47 install -d $(bindir) $(man1dir)
48 install pipeglade $(bindir)
49 install -m644 pipeglade.1 $(man1dir)
51 uninstall:
52 rm -f $(bindir)/pipeglade
53 rm -f $(man1dir)/pipeglade.1.gz
55 clean:
56 rm -f pipeglade
57 rm -rf gh-pages
59 .PHONY: install uninstall clean
63 # Build targets end here. The rest of this Makefile is only useful
64 # for project maintenance.
66 # It works with FreeBSD's version of make (aka pmake). It won't work
67 # with GNU make.
68 ######################################################################
69 VERSION != (which git >/dev/null && git describe --tags || echo "NONE") | cut -d "-" -f 1
70 CODE_VERSION != awk '/\#define VERSION/{print $$3}' pipeglade.c | tr -d '"'
71 NEWS_VERSION != awk '/^[0-9]+.[0-9]+.[0-9]+ .*(.+)/{print $$1}' NEWS | head -n1
72 NEWS_DATE != awk '/^[0-9]+.[0-9]+.[0-9]+ .*(.+)/{print substr($$2, 2, 10)}' NEWS | head -n1
73 TODAY != date +%F
74 MANPAGE_DATE != grep "^\.Dd " pipeglade.1
75 MANPAGE_TODAY != date '+.Dd %B %e, %Y' | awk '{print $$1, $$2, $$3, $$4}'
78 # Extract a list of actions from source code...
79 prog-actions:
80 @awk -F\" '/eql\((ud->)?action, \"[a-zA-Z0-9_-]+\"/{print $$2}' pipeglade.c | sort -u
82 # ... and from manual page
83 man-actions:
84 @awk -F: '/Cm :[a-zA-Z0-9_-]+/{print $$2}' pipeglade.1 | awk '{print $$1}' | sort -u
86 # Extract from manual page a list of subsections on widgets...
87 man-widgets:
88 @awk '/\.Ss Gtk[A-Z][a-zA-Z]+$$/{print $$2}' pipeglade.1 | sort -u
90 # ... and the respective TOC entries
91 man-toc:
92 @awk '/BEGIN_TOC/,/END_TOC/' pipeglade.1 | awk '/\.Sx Gtk[A-Z][a-zA-Z]+ [,.]$$/{print $$2}'
94 # Our collection of simple test widgets
95 examples-list:
96 @ls -1 widget-examples | grep "\.ui$$"
98 # Items marked done in list of all widgets
99 done-list:
100 @awk '!/^#/&&/Gtk[A-Z][a-zA-Z]/&&/done/{print $$1}' buildables.txt
103 # Prepare the www directory
104 gh-pages: gh-pages/index.html gh-pages/pipeglade.1.html gh-pages/clock.svg
106 gh-pages/index.html gh-pages/pipeglade.1.html: pipeglade.1 www-template/index.html Makefile
107 mkdir -p gh-pages
108 cp www-template/* gh-pages/
109 cp clock.sh gh-pages/clock.sh.txt
110 cp clock.ui gh-pages/clock.ui.txt
111 mandoc -Wall -T xhtml -O style=style.css pipeglade.1 > gh-pages/pipeglade.1.html
112 mandoc -Wall -T pdf -O paper=a4 pipeglade.1 > gh-pages/pipeglade.1.pdf
113 cp LICENSE gh-pages/
114 echo -e '/@/\ns/</\&lt;/\ns/>/\&gt;/\n,s/^$$/<p>/\nwq' | ed -s gh-pages/LICENSE
115 echo -e '/<!-- replace_with_license_text -->/d\n-r gh-pages/LICENSE\nwq' | ed -s gh-pages/index.html
116 echo -e ',s/_PUT_VERSION_HERE_/$(VERSION)/g\nwq' | ed -s gh-pages/index.html
117 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/index.html
118 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/pipeglade.1.html
119 echo -e '/<\/body>/-r gh-pages/statcounter.html\nwq' | ed -s gh-pages/404.html
120 rm -f gh-pages/statcounter.html gh-pages/LICENSE
122 gh-pages/clock.png: clock.sh clock.ui pipeglade
123 mkdir -p gh-pages
124 ./clock.sh&
125 sleep 1
126 import -frame -window pipeglade-clock gh-pages/clock.png
128 gh-pages/clock.svg: clock.sh clock.ui pipeglade
129 mkdir -p gh-pages
130 ./clock.sh gh-pages/clock.svg
132 # Create a new git tag only if there is a NEWS headline in the format
133 # 1.2.3 (2015-03-22)
134 # where 1.2.3 matches the current pipeglade version and the date is of
135 # today, and if pipeglade.1 has today's date in its .Dd line.
136 # (NEWS headlines are lines that start at column 0.)
137 git-tag:
138 if test "$(NEWS_DATE)" != "$(TODAY)"; then \
139 echo "NEWS: $(NEWS_DATE) != $(TODAY)"; false; \
140 fi; \
141 if test "$(NEWS_VERSION)" != "$(CODE_VERSION)"; then \
142 echo "NEWS: $(NEWS_VERSION) != $(CODE_VERSION)"; false; \
143 fi; \
144 if test "$(MANPAGE_DATE)" != "$(MANPAGE_TODAY)"; then \
145 echo "MANPAGE: $(MANPAGE_DATE) != $(MANPAGE_TODAY)"; false; \
146 fi; \
147 git tag $(CODE_VERSION);
149 # Push the www directory to Github Pages
150 publish: clean gh-pages
151 (cd gh-pages; \
152 git init; \
153 git add ./; \
154 git commit -a -m "gh-pages pseudo commit"; \
155 git push git@github.com:trebb/pipeglade.git +master:gh-pages)