update debian/copyright
[gnulib.git] / config / argz.mk
1 # Generate argz.c and argz.in.h from glibc sources.
2
3 glibc_dir = ../glibc
4 glibc_dir = /mirror/d/glibc
5
6 argz_names = \
7   append addsep ctsep insert next stringify count \
8   extract create delete replace
9 argz_files = $(patsubst %, $(glibc_dir)/string/argz-%.c, $(argz_names))
10
11 define print-header
12   printf '%s\n'                                                         \
13 "/* Functions for dealing with '\0' separated arg vectors."             \
14 "   Copyright (C) 1995-1998, 2000-2002, 2006, 2009-2011 Free Software
15 "   Foundation, Inc."\
16 "   This file is part of the GNU C Library."                            \
17 ""                                                                      \
18 "   This program is free software; you can redistribute it and/or modify"\
19 "   it under the terms of the GNU General Public License as published by"\
20 "   the Free Software Foundation; either version 2, or (at your option)"\
21 "   any later version."                                                 \
22 ""                                                                      \
23 "   This program is distributed in the hope that it will be useful,"    \
24 "   but WITHOUT ANY WARRANTY; without even the implied warranty of"     \
25 "   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"      \
26 "   GNU General Public License for more details."                       \
27 ""                                                                      \
28 "   You should have received a copy of the GNU General Public License along"\
29 "   with this program; if not, write to the Free Software Foundation,"  \
30 "   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */"\
31 ""                                                                      \
32 "#include <config.h>"                                                   \
33 ""                                                                      \
34 "#include <argz.h>"                                                     \
35 "#include <errno.h>"                                                    \
36 "#include <stdlib.h>"                                                   \
37 "#include <string.h>"
38 endef
39
40 targets = argz.c argz.in.h
41
42 all: $(targets)
43
44 argz.c: $(argz_files)
45         ($(print-header);                                               \
46          for i in $^; do                                                \
47            perl -pe 's/__(argz_|st|mem)/$$1/g' $$i                      \
48              | perl -0x0 -pe 's,/\*(.|\n)+?\*/\n,,'                     \
49              | grep -vE '^(#include|INTDEF|weak_alias|libc_hidden_def)'; \
50          done) > $@-t && mv $@-t $@
51
52 argz.in.h: $(glibc_dir)/string/argz.h
53         perl -pe 's/__(restrict|const|st|mem)/$$1/g;'                   \
54             -e 's/\s*__THROW//;'                                        \
55             -e 's/\s*__attribute_pure__//;'                             \
56           $<                                                            \
57           | perl -ne                                                    \
58             '/^(#include <features\.h>|__(?:BEGIN|END)_DECLS)/ or print' \
59           | perl -0x3b -pe 's/extern \S+ \*?__argz_(.|\n)*?\)\n*;//'    \
60           | perl -pe 's/__(argz_next)/$$1/g;'                           \
61           > $@-t && mv $@-t $@
62
63 clean:
64         rm -f $(targets)