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-2007 Free Software Foundation, Inc.
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 3 of the License,
10 # or (at your option) 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, see <http://www.gnu.org/licenses/>.
22 # List of all C-like source code files that will be tested for
23 # stylistic "errors". You may want to define this to something
24 # more complex in Makefile.cfg.
25 C_SOURCES ?
= $(shell find .
-name
'*.[chly]')
27 # Add some more files to check, typically set in Makefile.cfg.
28 C_SOURCES
+= $(C_SOURCES_ADD
)
30 # Do not save the original name or timestamp in the .tar.gz file.
31 # Use --rsyncable if available.
33 $(shell gzip
--help
2>/dev
/null|grep rsyncable
>/dev
/null
&& echo
--rsyncable
)
34 GZIP_ENV
= '--no-name --best $(gzip_rsyncable)'
36 # Prevent programs like 'sort' from considering distinct strings to be equal.
37 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
40 # Casting arguments to free is never necessary.
41 sc_cast_of_argument_to_free
:
42 @grep
-nE
'\<free *\( *\(' $(C_SOURCES
) && \
43 { echo
'$(ME): don'\''t cast free argument' 1>&2; \
46 sc_cast_of_x_alloc_return_value
:
47 @grep
-nE
'\*\) *x(m|c|re)alloc\>' $(C_SOURCES
) && \
48 { echo
'$(ME): don'\''t cast x*alloc return value' 1>&2; \
51 sc_cast_of_alloca_return_value
:
52 @grep
-nE
'\*\) *alloca\>' $(C_SOURCES
) && \
53 { echo
'$(ME): don'\''t cast alloca return value' 1>&2; \
57 @grep
-n
'[ ] ' $(C_SOURCES
) && \
58 { echo
'$(ME): found SPACE-TAB sequence; remove the SPACE' \
61 # Don't use the old ato* functions in `real' code.
62 # They provide no error checking mechanism.
63 # Instead, use strto* functions.
64 sc_prohibit_atoi_atof
:
65 @grep
-nE
'\<ato([filq]|ll)\>' $(C_SOURCES
) && \
66 { echo
'$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
69 # Using EXIT_SUCCESS as the first argument to error is misleading,
70 # since when that parameter is 0, error does not exit. Use `0' instead.
71 sc_error_exit_success
:
72 @grep
-nF
'error (EXIT_SUCCESS,' $(C_SOURCES
) && \
73 { echo
'$(ME): found error (EXIT_SUCCESS' 1>&2; \
76 # Stylistic, use #ifdef instead of #if
77 sc_no_if_have_config_h
:
78 @grep
-n
'^# *if HAVE_CONFIG_H' $(C_SOURCES
) && \
79 { echo
'$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
82 # Prohibit the inclusion of assert.h without an actual use of assert.
83 sc_prohibit_assert_without_use
:
84 @files
=$$(grep
-l
'# *include [<"]assert\.h[>"]' $(C_SOURCES
) \
85 | grep
'\.[cy]$$') && \
86 grep
-L
'\<assert (' $$files \
88 { echo
"$(ME): the above files include <assert.h> but don't use it" \
92 @grep
-nE
'\<(HAVE''_FCNTL_H|O''_NDELAY)\>' $(C_SOURCES
) && \
93 { echo
'$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
96 # Each nonempty line must start with a year number, or a TAB.
98 @grep
-n
'^[^12 ]' $$(find .
-name ChangeLog
) && \
99 { echo
'$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
102 # Collect the names of rules starting with `sc_'.
103 syntax-check-rules
:= $(shell sed
-n
's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME
))
104 .PHONY
: $(syntax-check-rules
)
106 syntax-check
: $(syntax-check-rules
)
108 # Update gettext files.
109 PACKAGE ?
= $(shell basename $(PWD
))
110 POURL
= http
://translationproject.org
/latest
/$(PACKAGE
)/
113 rm -f
$(PODIR
)/*.po
&& \
114 echo
"$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
115 wget
--no-verbose
--directory-prefix
$(PODIR
) --no-directories
--recursive
--level
1 --accept .po
--accept .po
.1 $(POURL
) && \
116 echo
'en@boldquot' > $(PODIR
)/LINGUAS
&& \
117 echo
'en@quot' >> $(PODIR
)/LINGUAS
&& \
118 ls
$(PODIR
)/*.po | sed
's/.po//' | sed
's,$(PODIR)/,,' |
sort >> $(PODIR
)/LINGUAS
120 INDENT_SOURCES ?
= $(C_SOURCES
)
123 indent
$(INDENT_SOURCES
)