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
24 bindir ?
= $(prefix)/bin
25 mandir ?
= $(prefix)/man
26 man1dir ?
= $(mandir)/man1
27 CCFLAGS
+= -Wall
-Wextra
-pedantic
-g
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
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`
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)
52 rm -f
$(bindir)/pipeglade
53 rm -f
$(man1dir)/pipeglade
.1.gz
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
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]+ .*([0-9]+-[01][0-9]-[0-3][0-9])/{print $$1}' NEWS | head
-n1
72 NEWS_DATE
!= awk
'/^[0-9]+\.[0-9]+\.[0-9]+ .*([0-9]+-[01][0-9]-[0-3][0-9])/{print substr($$2, 2, 10)}' NEWS | head
-n1
74 MANPAGE_DATE
!= grep
"^\.Dd " pipeglade
.1
75 MANPAGE_TODAY
!= date
'+.Dd %B %e, %Y' | awk
'{print $$1, $$2, $$3, $$4}'
76 .SUFFIXES
: .ui .svg .jpg
79 # Create a new git tag only if there is a NEWS headline in the format
82 # where 1.2.3 matches the current pipeglade version and the date is of
83 # today, and if pipeglade.1 has today's date in its .Dd line.
84 # (NEWS headlines are lines that start at column 0.)
86 @if
test "$(NEWS_DATE)" != "$(TODAY)"; then \
87 echo
"NEWS: $(NEWS_DATE) != $(TODAY)"; false
; \
89 @if
test "$(NEWS_VERSION)" != "$(CODE_VERSION)"; then \
90 echo
"NEWS: $(NEWS_VERSION) != $(CODE_VERSION)"; false
; \
92 @if
test "$(MANPAGE_DATE)" != "$(MANPAGE_TODAY)"; then \
93 echo
"MANPAGE: $(MANPAGE_DATE) != $(MANPAGE_TODAY)"; false
; \
95 git tag
$(CODE_VERSION
);
98 # Extract a list of actions from source code...
100 @awk
-F
\" '/eql\((ud->)?action, \"[a-zA-Z0-9_-]+\"/{print $$2}' pipeglade.c |
sort -u
102 # ... and from manual page
104 @awk
-F
: '/Cm :[a-zA-Z0-9_-]+/{print $$2}' pipeglade
.1 | awk
'{print $$1}' |
sort -u
106 # Extract from manual page a list of subsections on widgets...
108 @awk
'/\.Ss Gtk[A-Z][a-zA-Z]+$$/{print $$2}' pipeglade
.1 |
sort -u
110 # ... and the respective TOC entries
112 @awk
'/BEGIN_TOC/,/END_TOC/' pipeglade
.1 | awk
'/\.Sx Gtk[A-Z][a-zA-Z]+ [,.]$$/{print $$2}'
114 # Our collection of simple test widgets
116 @ls
-1 widget-examples | grep
"\.ui$$"
118 # Items marked done in list of all widgets
120 @awk
'!/^#/&&/Gtk[A-Z][a-zA-Z]/&&/done/{print $$1}' buildables.txt
123 # Prepare the www directory
124 GH_PAGES_SIMPLE
= style.css CNAME README robots.txt
125 GH_PAGES_PUBLIC
= ${GH_PAGES_SIMPLE} pipeglade
.1.html pipeglade
.1.pdf clock.jpg clock.ui.txt clock.sh.txt
404.html
126 GH_PAGES_TEMP
= LICENSE gallery.html index-hrefs
127 .if
${.MAKE.LEVEL
} == 0
128 WIDGETS
!= make man-widgets
130 WIDGET_TXTS
!= ls
-1 widget-examples | grep
"\.txt$$"
131 SNAPSHOTS
= ${WIDGETS
:C|
(.
*)|gh-pages
/\
1.jpg|
}
133 gh-pages
: gh-pages-untested test-index-hrefs
134 rm -f
${GH_PAGES_TEMP
:S|^|gh-pages
/|
}
136 gh-pages-untested
: ${GH_PAGES_PUBLIC
:S|^|gh-pages
/|
} ${SNAPSHOTS} gh-pages
/index.html
138 .for FILE in
${GH_PAGES_SIMPLE}
139 gh-pages
/${FILE}: www-template
/${FILE}
141 cp
${.ALLSRC
} ${.TARGET
}
144 gh-pages
/index.html
: pipeglade gh-pages
/pipeglade
.1.html www-template
/index.html \
145 gh-pages
/gallery.html gh-pages
/LICENSE \
146 www-template
/statcounter.html www-template
/index-toc.xsl Makefile
147 xsltproc
--html
-o
${.TARGET
} www-template
/index-toc.xsl www-template
/index.html
148 echo
-e
'/<!-- replace_with_widget_gallery -->/d\n-r gh-pages/gallery.html\nwq' | ed
-s gh-pages
/index.html
149 echo
-e
'/<!-- replace_with_license_text -->/d\n-r gh-pages/LICENSE\nwq' | ed
-s gh-pages
/index.html
150 echo
-e
',s/_PUT_VERSION_HERE_/$(VERSION)/g\nwq' | ed
-s gh-pages
/index.html
151 echo
-e
'/<\/body>/-r www-template/statcounter.html\nwq' | ed
-s gh-pages
/index.html
153 gh-pages
/LICENSE
: LICENSE Makefile
155 sed
's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g; s|^$$|<p/>|g' <LICENSE
>${.TARGET
}
157 gh-pages
/404.html
: gh-pages
/pipeglade
.1.html Makefile www-template
/statcounter.html
159 cp www-template
/404.html gh-pages
/
160 echo
-e
'/<\/body>/-r www-template/statcounter.html\nwq' | ed
-s gh-pages
/404.html
162 gh-pages
/clock.sh.txt gh-pages
/clock.ui.txt
: clock.sh clock.ui
164 cp clock.sh gh-pages
/clock.sh.txt
165 cp clock.ui gh-pages
/clock.ui.txt
167 gh-pages
/pipeglade
.1.html gh-pages
/pipeglade
.1.pdf
: pipeglade
.1 Makefile www-template
/statcounter.html
169 mandoc
-Wall
-T xhtml
-O style
=style.css pipeglade
.1 > gh-pages
/pipeglade
.1.html
170 mandoc
-Wall
-T pdf
-O paper
=a4 pipeglade
.1 > gh-pages
/pipeglade
.1.pdf
171 echo
-e
'/<\/body>/-r www-template/statcounter.html\nwq' | ed
-s gh-pages
/pipeglade
.1.html
173 gh-pages
/clock.jpg
: clock.svg
175 convert
"${.ALLSRC}" -frame
2 "${.TARGET}"
177 clock.svg
: clock.sh clock.ui pipeglade
178 .
/clock.sh
${.TARGET
}
180 # Screenshots of the widget examples
183 .if exists
(widget-examples
/${W
:S
/Gtk
//:tl
}.txt
)
184 gh-pages
/${W
:S
/$/.jpg
/}: widget-examples
/${W
:S
/Gtk
//:tl
}.ui widget-examples
/${W
:S
/Gtk
//:tl
}.txt
185 @echo
"creating widget snapshot ${.TARGET}"
187 @echo
"_:load widget-examples/${W:S/Gtk//:tl}.txt" | \
188 .
/pipeglade
-u widget-examples
/${W
:S
/Gtk
//:tl
}.ui
>/dev
/null
189 @convert
"${.TARGET:R}.svg" -resize
80% -frame
2 "${.TARGET}" && rm "${.TARGET:R}.svg"
191 gh-pages
/${W
:S
/$/.jpg
/}: widget-examples
/${W
:S
/Gtk
//:tl
}.ui
192 @echo
"creating widget snapshot ${.TARGET}"
194 @
(echo
"main:snapshot ${.TARGET:R}.svg"; echo
"_:main_quit") | \
195 .
/pipeglade
-u
${.ALLSRC
} >/dev
/null
196 @convert
"${.TARGET:R}.svg" -resize
80% -frame
2 "${.TARGET}" && rm "${.TARGET:R}.svg"
200 gh-pages
/gallery.html
: ${SNAPSHOTS}
201 @echo
"writing html for widget snapshots: ${SNAPSHOTS:T:R}"
202 @for i in
${.ALLSRC
:T
:R
}; do \
204 echo
"<div class=\"display\">"; \
205 echo
" <i class=\"link-sec\">"; \
206 echo
-n
" <a href=\"pipeglade.1.html#"; \
207 xmllint
--html
--xpath
"string(//div[@class=\"section\"]/h1[text()=\"WIDGETS\"]/../div[@class=\"subsection\"]/h2[text()=\"$${i}\"]/@id)" gh-pages
/pipeglade
.1.html
; \
208 echo
-n
"\">$${i}</a>"; \
210 echo
" (cf. <a class=\"link-ext\" href=\"https://developer.gnome.org/gtk3/stable/$${i}.html\">GTK+ 3 Reference Manual</a>)"; \
212 echo
" <img src=\"$${i}.jpg\">"; \
217 # Do we have dead links?
218 gh-pages
/index-hrefs
: gh-pages
/index.html www-template
/a-hrefs.xsl
219 xsltproc
--html www-template
/a-hrefs.xsl gh-pages
/index.html | grep
-E
"^http.?://" | grep
-v
"../github.com/trebb/pipeglade" > ${.TARGET
}
221 test-index-hrefs
: gh-pages
/index-hrefs
222 @echo
"checking for dead links..."
223 @for i in
`cat ${.ALLSRC}`; do \
224 if curl
-w
%{http_code
} -s
-o
/dev
/null
$$i | grep
-q
200; then \
227 echo
; echo
"dead link: $$i"; \
234 # Push the www directory to Github Pages
239 git commit
-a
-m
"gh-pages pseudo commit"; \
240 git push git@github.com
:trebb
/pipeglade.git
+master
:gh-pages
)