1# This file is part of Imprimatur.
2# Copyright (C) 2006, 2007, 2010, 2011 Sergey Poznyakoff
3#
4# Imprimatur is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Imprimatur is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Imprimatur.  If not, see <http://www.gnu.org/licenses/>.
16
17imprimatur-format:
18	@if test -n "`cat $(imprimatur_INPUT) | tr -d -c '\t'`"; then \
19		echo "Sources contain tabs; run make imprimatur-untabify"; \
20		false; \
21	fi
22
23imprimatur-refs:
24	@for file in $(imprimatur_INPUT); \
25	do \
26          grep -q '^@c imprimatur-ignore' $$file && continue; \
27	  sed -e = $$file | \
28           sed -n 'N;/@FIXME-.*ref/{s/\(^[0-9][0-9]*\).*@FIXME-.*ref{\([^}]*\)}.*/'$$file':\1: \2/gp}'; \
29	done > $@-t; \
30	if [ -s $@-t ]; then \
31	  echo "Unresolved cross-references:"; \
32	  cat $@-t;\
33	  rm $@-t; \
34	else \
35	  rm -f $@-t; \
36	fi
37
38imprimatur-fixmes:
39	@for file in $(imprimatur_INPUT); \
40	do \
41          grep -q '^@c imprimatur-ignore' $$file && continue; \
42	  sed -e = $$file | \
43           sed -n 'N;/@FIXME{/{s/\(^[0-9][0-9]*\).*@FIXME{\([^}]*\).*/'$$file':\1: \2/gp}'; \
44	done > $@-t; \
45	if [ -s $@-t ]; then \
46	  echo "Unresolved FIXMEs:"; \
47	  cat $@-t; \
48	  rm $@-t; \
49	  false; \
50	else \
51          rm -f $@-t; \
52	fi
53
54imprimatur-writemes:
55	@files=`grep -c '^@c imprimatur-ignore' $(imprimatur_INPUT) | sed -n 's/:0$$//p'`; \
56	test -n "$$files" && grep -Hn '^[ \t]*@WRITEME' $$files > $@-t; \
57	if [ -s $@-t ]; then \
58	  echo "Empty nodes:"; \
59	  cat $@-t; \
60	  rm $@-t; \
61	  false;\
62	else \
63	   rm $@-t; \
64	fi
65
66imprimatur-empty-nodes:
67	@awk -f $(top_srcdir)/$(IMPRIMATUR_MODULE_DIR)/emptynodes.awk \
68         -v scriptname=$(top_srcdir)/$(IMPRIMATUR_MODULE_DIR)/emptynodes.awk \
69         -v makeinfoflags="$(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS)" \
70	        $(info_TEXINFOS)
71
72imprimatur-unrevised:
73	@files=`grep -c '^@c imprimatur-ignore' $(imprimatur_INPUT) | sed -n 's/:0$$//p'`; \
74	grep -Hn '^[ \t]*@UNREVISED' $$files > $@-t; \
75	if [ -s $@-t ]; then \
76	  echo "Unrevised nodes:"; \
77	  cat $@-t; \
78	  rm $@-t; \
79	  false;\
80	else \
81          rm $@-t; \
82	fi
83
84if IMPRIMATUR_COND_FRENCHSPACING
85imprimatur-check-sentence-spacing:
86	@if grep -q '\.  [@A-Z]' $(imprimatur_INPUT); then \
87	   echo >&2 "Sources contain double-space sentence separators."; \
88	   echo >&2 "Run make imprimatur-fix-sentence-spacing to fix."; \
89	fi
90
91imprimatur-fix-sentence-spacing:
92	@for file in $(imprimatur_INPUT); \
93	do \
94	  if grep -q '\.  [@A-Z]' $$file; then \
95	    mv $$file $${file}~; \
96	    sed -r 's/\.  ([@A-Z])/. \1/g' $${file}~ > $$file; \
97	  fi; \
98	done
99else
100imprimatur-check-sentence-spacing:
101	@if grep -q '\. [@A-Z]' $(imprimatur_INPUT); then \
102		echo >&2 "Sources contain single-space sentence separators."; \
103		echo >&2 "Run make imprimatur-fix-sentence-spacing to fix."; \
104	fi
105
106imprimatur-fix-sentence-spacing:
107	@for file in $(imprimatur_INPUT); \
108	do \
109	  if grep -q '\. [@A-Z]' $$file; then \
110	    mv $$file $${file}~; \
111	    sed -r 's/\. ([@A-Z])/.  \1/g' $${file}~ > $$file; \
112	  fi; \
113	done
114endif
115
116
117imprimatur-basic-checks: imprimatur-format imprimatur-check-sentence-spacing \
118                 imprimatur-refs imprimatur-fixmes \
119                 imprimatur-empty-nodes imprimatur-unrevised
120
121imprimatur-master-menu:
122	@emacs -batch -l $(top_srcdir)/$(IMPRIMATUR_MODULE_DIR)/mastermenu.el \
123               -f make-master-menu $(info_TEXINFOS)
124
125imprimatur-untabify:
126	@emacs -batch -l $(top_srcdir)/$(IMPRIMATUR_MODULE_DIR)/untabify.el \
127               $(imprimatur_INPUT)
128
129imprimatur-final: imprimatur-untabify imprimatur-master-menu
130
131
132