Add.
[gsasl.git] / maint.mk
blob81952027eb75d32b7c467dab1b99e5d66d102ea5
1 # -*-Makefile-*-
2 # This Makefile fragment is intended to be useful by any GNU-like project.
3 # This file originate from coreutils, CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2006 Free Software Foundation, Inc.
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2, or (at your option)
10 ## any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, write to the Free Software
19 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 ## 02110-1301, USA.
22 ME := maint.mk
24 # List of all C-like source code files that will be tested for
25 # stylistic "errors". You may want to define this to something
26 # more complex in Makefile.cfg.
27 C_SOURCES ?= $(shell find . -name '*.[chly]')
29 # Add some more files to check, typically set in Makefile.cfg.
30 C_SOURCES += $(C_SOURCES_ADD)
32 # Do not save the original name or timestamp in the .tar.gz file.
33 # Use --rsyncable if available.
34 gzip_rsyncable := \
35 $(shell gzip --help|grep rsyncable >/dev/null && echo --rsyncable)
36 GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
38 # Prevent programs like 'sort' from considering distinct strings to be equal.
39 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
40 export LC_ALL = C
42 # Casting arguments to free is never necessary.
43 sc_cast_of_argument_to_free:
44 @grep -nE '\<free *\( *\(' $(C_SOURCES) && \
45 { echo '$(ME): don'\''t cast free argument' 1>&2; \
46 exit 1; } || :
48 sc_cast_of_x_alloc_return_value:
49 @grep -nE '\*\) *x(m|c|re)alloc\>' $(C_SOURCES) && \
50 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
51 exit 1; } || :
53 sc_cast_of_alloca_return_value:
54 @grep -nE '\*\) *alloca\>' $(C_SOURCES) && \
55 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
56 exit 1; } || :
58 sc_space_tab:
59 @grep -n '[ ] ' $(C_SOURCES) && \
60 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
61 1>&2; exit 1; } || :
63 # Don't use the old ato* functions in `real' code.
64 # They provide no error checking mechanism.
65 # Instead, use strto* functions.
66 sc_prohibit_atoi_atof:
67 @grep -nE '\<ato([filq]|ll)\>' $(C_SOURCES) && \
68 { echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
69 1>&2; exit 1; } || :
71 # Using EXIT_SUCCESS as the first argument to error is misleading,
72 # since when that parameter is 0, error does not exit. Use `0' instead.
73 sc_error_exit_success:
74 @grep -nF 'error (EXIT_SUCCESS,' $(C_SOURCES) && \
75 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
76 exit 1; } || :
78 # Stylistic, use #ifdef instead of #if
79 sc_no_if_have_config_h:
80 @grep -n '^# *if HAVE_CONFIG_H' $(C_SOURCES) && \
81 { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
82 1>&2; exit 1; } || :
84 # Prohibit the inclusion of assert.h without an actual use of assert.
85 sc_prohibit_assert_without_use:
86 @files=$$(grep -l '# *include [<"]assert\.h[>"]' $(C_SOURCES) \
87 | grep '\.[cy]$$') && \
88 grep -L '\<assert (' $$files \
89 | grep . && \
90 { echo "$(ME): the above files include <assert.h> but don't use it" \
91 1>&2; exit 1; } || :
93 sc_obsolete_symbols:
94 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' $(C_SOURCES) && \
95 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
96 1>&2; exit 1; } || :
98 # Each nonempty line must start with a year number, or a TAB.
99 sc_changelog:
100 @grep -n '^[^12 ]' $$(find . -name ChangeLog) && \
101 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
102 exit 1; } || :
104 # Collect the names of rules starting with `sc_'.
105 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
106 .PHONY: $(syntax-check-rules)
108 syntax-check: $(syntax-check-rules)
110 # Update gettext files.
111 PACKAGE ?= $(shell basename $(PWD))
112 POURL = http://www.iro.umontreal.ca/translation/maint/$(PACKAGE)/
113 PODIR ?= po
114 refresh-po:
115 rm -f $(PODIR)/*.po && \
116 echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
117 wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
118 echo 'en@boldquot' > $(PODIR)/LINGUAS && \
119 echo 'en@quot' >> $(PODIR)/LINGUAS && \
120 ls $(PODIR)/*.po | sed 's/.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
122 INDENT_SOURCES ?= $(C_SOURCES)
123 .PHONY: indent
124 indent:
125 indent $(INDENT_SOURCES)