maint: use COPYING.LIB version 2.1
[libguestfs.git] / cfg.mk
1 # Customize Makefile.maint.                           -*- makefile -*-
2 # Copyright (C) 2003-2009 Free Software Foundation, Inc.
3
4 # This program 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 of the License, or
7 # (at your option) any later version.
8
9 # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Use alpha.gnu.org for alpha and beta releases.
18 # Use ftp.gnu.org for major releases.
19 gnu_ftp_host-alpha = alpha.gnu.org
20 gnu_ftp_host-beta = alpha.gnu.org
21 gnu_ftp_host-major = ftp.gnu.org
22 gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
23
24 url_dir_list = \
25   ftp://$(gnu_rel_host)/gnu/coreutils
26
27 # Tests not to run as part of "make distcheck".
28 local-checks-to-skip =                  \
29   sc_po_check                           \
30   changelog-check                       \
31   check-AUTHORS                         \
32   makefile-check                        \
33   makefile_path_separator_check         \
34   patch-check                           \
35   sc_GPL_version                        \
36   sc_always_defined_macros              \
37   sc_cast_of_alloca_return_value        \
38   sc_dd_max_sym_length                  \
39   sc_error_exit_success                 \
40   sc_file_system                        \
41   sc_immutable_NEWS                     \
42   sc_makefile_path_separator_check      \
43   sc_obsolete_symbols                   \
44   sc_prohibit_S_IS_definition           \
45   sc_prohibit_atoi_atof                 \
46   sc_prohibit_jm_in_m4                  \
47   sc_prohibit_quote_without_use         \
48   sc_prohibit_quotearg_without_use      \
49   sc_prohibit_stat_st_blocks            \
50   sc_prohibit_strcmp_and_strncmp        \
51   sc_prohibit_strcmp                    \
52   sc_root_tests                         \
53   sc_space_tab                          \
54   sc_sun_os_names                       \
55   sc_system_h_headers                   \
56   sc_tight_scope                        \
57   sc_two_space_separator_in_usage       \
58   sc_error_message_uppercase            \
59   sc_program_name                       \
60   sc_require_test_exit_idiom            \
61   sc_makefile_check                     \
62   $(disable_temporarily)                \
63   sc_useless_cpp_parens
64
65 disable_temporarily =                   \
66   sc_makefile_TAB_only_indentation      \
67   sc_unmarked_diagnostics               \
68   sc_prohibit_ctype_h                   \
69   sc_prohibit_asprintf                  \
70   sc_m4_quote_check                     \
71   sc_prohibit_trailing_blank_lines      \
72   sc_avoid_ctype_macros                 \
73   sc_avoid_write                        \
74   sc_trailing_blank
75
76 # Avoid uses of write(2).  Either switch to streams (fwrite), or use
77 # the safewrite wrapper.
78 sc_avoid_write:
79         @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then          \
80           grep '\<write *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$') &&     \
81             { echo "$(ME): the above files use write;"                  \
82               " consider using the safewrite wrapper instead"           \
83                   1>&2; exit 1; } || :;                                 \
84         else :;                                                         \
85         fi
86
87 # Use STREQ rather than comparing strcmp == 0, or != 0.
88 # Similarly, use STREQLEN or STRPREFIX rather than strncmp.
89 sc_prohibit_strcmp_and_strncmp:
90         @grep -nE '! *strn?cmp *\(|\<strn?cmp *\([^)]+\) *=='           \
91             $$($(VC_LIST_EXCEPT))                                       \
92           | grep -vE ':# *define STREQ(LEN)?\(' &&                      \
93           { echo '$(ME): use STREQ(LEN) in place of the above uses of strcmp(strncmp)' \
94                 1>&2; exit 1; } || :
95
96 # Use virAsprintf rather than a'sprintf since *strp is undefined on error.
97 sc_prohibit_asprintf:
98         @re='\<[a]sprintf\>'                                            \
99         msg='use virAsprintf, not a'sprintf                             \
100           $(_prohibit_regexp)
101
102 # Prohibit the inclusion of <ctype.h>.
103 sc_prohibit_ctype_h:
104         @grep -E '^# *include  *<ctype\.h>' $$($(VC_LIST_EXCEPT)) &&    \
105           { echo "$(ME): don't use ctype.h; instead, use c-ctype.h"     \
106                 1>&2; exit 1; } || :
107
108 # Ensure that no C source file uses TABs for indentation.
109 # Exclude some version-controlled symlinks.
110 sc_TAB_in_indentation:
111         @grep -lE '^ *  ' /dev/null                                     \
112              $$($(VC_LIST_EXCEPT)) &&                                   \
113           { echo '$(ME): found TAB(s) used for indentation in C sources;'\
114               'use spaces' 1>&2; exit 1; } || :
115
116 ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
117 |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
118
119 sc_avoid_ctype_macros:
120         @grep -E '\b($(ctype_re)) *\(' /dev/null                        \
121              $$($(VC_LIST_EXCEPT)) &&                                   \
122           { echo "$(ME): don't use ctype macros (use c-ctype.h)"        \
123                 1>&2; exit 1; } || :
124
125 sc_prohibit_virBufferAdd_with_string_literal:
126         @re='\<virBufferAdd *\([^,]+, *"[^"]'                           \
127         msg='use virBufferAddLit, not virBufferAdd, with a string literal' \
128           $(_prohibit_regexp)
129
130 # Not only do they fail to deal well with ipv6, but the gethostby*
131 # functions are also not thread-safe.
132 sc_prohibit_gethostby:
133         @re='\<gethostby(addr|name2?) *\('                              \
134         msg='use getaddrinfo, not gethostby*'                           \
135           $(_prohibit_regexp)
136
137 # Disallow trailing blank lines.
138 sc_prohibit_trailing_blank_lines:
139         @$(VC_LIST_EXCEPT) | xargs perl -ln -0777 -e                    \
140           '/\n\n+$$/ and print $$ARGV' > $@-t
141         @found=0; test -s $@-t && { found=1; cat $@-t 1>&2;             \
142           echo '$(ME): found trailing blank line(s)' 1>&2; };           \
143         rm -f $@-t;                                                     \
144         test $$found = 0
145
146 # We don't use this feature of maint.mk.
147 prev_version_file = /dev/null
148
149 ifeq (0,$(MAKELEVEL))
150   _curr_status = .git-module-status
151   # The sed filter accommodates those who check out on a commit from which
152   # no tag is reachable.  In that case, git submodule status prints a "-"
153   # in column 1 and does not print a "git describe"-style string after the
154   # submodule name.  Contrast these:
155   # -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib
156   #  b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda)
157   _submodule_hash = sed 's/.//;s/ .*//'
158   _update_required := $(shell                                           \
159       actual=$$(git submodule status | $(_submodule_hash));             \
160       stamp="$$($(_submodule_hash) $(_curr_status) 2>/dev/null)";       \
161       test "$$stamp" = "$$actual"; echo $$?)
162   ifeq (1,$(_update_required))
163     $(error gnulib update required; run ./autogen.sh first)
164   endif
165 endif