* build-aux/maint.mk: Add indent target.
[gnulib.git] / build-aux / maint.mk
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.
4
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.
11 ##
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.
16 ##
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.
21
22 ME := maint.mk
23
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]')
28
29 # Add some more files to check, typically set in Makefile.cfg.
30 C_SOURCES += $(C_SOURCES_ADD)
31
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)'
37
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
41
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; } || :
47
48 # Collect the names of rules starting with `sc_'.
49 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
50 .PHONY: $(syntax-check-rules)
51
52 syntax-check: $(syntax-check-rules)
53
54 INDENT_SOURCES ?= $(C_SOURCES)
55 .PHONY: indent
56 indent:
57         indent $(C_SOURCES)