Import GNULIB syntax check rules
[entangle:entangle.git] / cfg.mk
1 # Customize Makefile.maint.                           -*- makefile -*-
2 # Copyright (C) 2008-2011 Red Hat, Inc.
3 # Copyright (C) 2003-2008 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Tests not to run as part of "make distcheck".
19 local-checks-to-skip =                  \
20   changelog-check                       \
21   check-AUTHORS                         \
22   makefile-check                        \
23   makefile_path_separator_check         \
24   patch-check                           \
25   sc_GPL_version                        \
26   sc_always_defined_macros              \
27   sc_cast_of_alloca_return_value        \
28   sc_cross_check_PATH_usage_in_tests    \
29   sc_dd_max_sym_length                  \
30   sc_error_exit_success                 \
31   sc_file_system                        \
32   sc_immutable_NEWS                     \
33   sc_makefile_path_separator_check      \
34   sc_obsolete_symbols                   \
35   sc_prohibit_always_true_header_tests  \
36   sc_prohibit_S_IS_definition           \
37   sc_prohibit_atoi_atof                 \
38   sc_prohibit_hash_without_use          \
39   sc_prohibit_jm_in_m4                  \
40   sc_prohibit_quote_without_use         \
41   sc_prohibit_quotearg_without_use      \
42   sc_prohibit_stat_st_blocks            \
43   sc_root_tests                         \
44   sc_space_tab                          \
45   sc_sun_os_names                       \
46   sc_system_h_headers                   \
47   sc_texinfo_acronym                    \
48   sc_tight_scope                        \
49   sc_two_space_separator_in_usage       \
50   sc_error_message_uppercase            \
51   sc_program_name                       \
52   sc_require_test_exit_idiom            \
53   sc_makefile_check                     \
54   sc_useless_cpp_parens                 \
55   sc_preprocessor_indentation
56
57 # Files that should never cause syntax check failures.
58 VC_LIST_ALWAYS_EXCLUDE_REGEX = \
59   (^HACKING|\.po|maint.mk)$$
60
61 # Functions like free() that are no-ops on NULL arguments.
62 useless_free_options =                          \
63   --name=g_free
64
65 # Ensure that no C source file, docs, or rng schema uses TABs for
66 # indentation.  Also match *.h.in files, to get libvirt.h.in.  Exclude
67 # files in gnulib, since they're imported.
68 space_indent_files=(\.(rng|s?[ch](\.in)?|html.in|py)|(daemon|tools)/.*\.in)
69 sc_TAB_in_indentation:
70         @prohibit='^ *  '                                               \
71         in_vc_files='$(space_indent_files)$$'                           \
72         halt='indent with space, not TAB, in C, sh, html, py, and RNG schemas' \
73           $(_sc_search_regexp)
74
75 # G_GNUC_UNUSED should only be applied in implementations, not
76 # header declarations
77 sc_avoid_attribute_unused_in_header:
78         @prohibit='^[^#]*G_GNUC_UNUSED([^:]|$$)'                        \
79         in_vc_files='\.h$$'                                             \
80         halt='use G_GNUC_UNUSED in .c rather than .h files'             \
81           $(_sc_search_regexp)
82
83 # Enforce recommended preprocessor indentation style.
84 sc_preprocessor_indentation:
85         @if cppi --version >/dev/null 2>&1; then                        \
86           $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c        \
87             || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
88                 exit 1; };                                              \
89         else                                                            \
90           echo '$(ME): skipping test $@: cppi not installed' 1>&2;      \
91         fi
92
93 sc_copyright_format:
94         @require='Copyright .*Red 'Hat', Inc\.'                         \
95         containing='Copyright .*Red 'Hat                                \
96         halt='Red Hat copyright is missing Inc.'                        \
97           $(_sc_search_regexp)
98         @prohibit='Copyright [^(].*Red 'Hat                             \
99         halt='consistently use (C) in Red Hat copyright'                \
100           $(_sc_search_regexp)
101         @prohibit='\<Red''Hat\>'                                        \
102         halt='spell Red Hat as two words'                               \
103           $(_sc_search_regexp)
104
105 # We don't use this feature of maint.mk.
106 prev_version_file = /dev/null
107
108 # Give credit where due:
109 # Ensure that each commit author email address (possibly mapped via
110 # git log's .mailmap) appears in our AUTHORS file.
111 sc_check_author_list:
112         @fail=0;                                                        \
113         for i in $$(git log --pretty=format:%aE%n|sort -u|grep -v '^$$'); do \
114           sanitized=$$(echo "$$i"|LC_ALL=C sed 's/\([^a-zA-Z0-9_@-]\)/\\\1/g'); \
115           grep -iq "<$$sanitized>" $(srcdir)/AUTHORS                    \
116             || { printf '%s\n' "$$i" >&2; fail=1; };                    \
117         done;                                                           \
118         test $$fail = 1                                                 \
119           && echo '$(ME): committer(s) not listed in AUTHORS' >&2;      \
120         test $$fail = 0
121
122
123 exclude_file_name_regexp--sc_prohibit_strcmp = ^*/*.[ch]
124
125 # Due to enum rules - fixme
126 exclude_file_name_regexp--sc_makefile_at_at_check = ^src/Makefile.am
127
128 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^(docs|src)/.*\.png
129
130 exclude_file_name_regexp--sc_prohibit_test_minus_ao = git.mk
131
132 exclude_file_name_regexp--sc_trailing_blank = (src|docs)/.*\.(ep|png)