parse-datetime: simplify test for mktime failure
[gnulib.git] / config / argz.mk
blob4b9eaeaab0091b80c3cf6dbafa1503b2e2383534
1 # Generate argz.c and argz.in.h from glibc sources.
3 glibc_dir = ../glibc
4 glibc_dir = /mirror/d/glibc
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))
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-2018 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, see <https://www.gnu.org/licenses/>. */" \
30 "" \
31 "#include <config.h>" \
32 "" \
33 "#include <argz.h>" \
34 "#include <errno.h>" \
35 "#include <stdlib.h>" \
36 "#include <string.h>"
37 endef
39 targets = argz.c argz.in.h
41 all: $(targets)
43 argz.c: $(argz_files)
44 ($(print-header); \
45 for i in $^; do \
46 perl -pe 's/__(argz_|st|mem)/$$1/g' $$i \
47 | perl -0x0 -pe 's,/\*(.|\n)+?\*/\n,,' \
48 | grep -vE '^(#include|INTDEF|weak_alias|libc_hidden_def)'; \
49 done) > $@-t && mv $@-t $@
51 argz.in.h: $(glibc_dir)/string/argz.h
52 perl -pe 's/__(restrict|const|st|mem)/$$1/g;' \
53 -e 's/\s*__THROW//;' \
54 -e 's/\s*__attribute_pure__//;' \
55 $< \
56 | perl -ne \
57 '/^(#include <features\.h>|__(?:BEGIN|END)_DECLS)/ or print' \
58 | perl -0x3b -pe 's/extern \S+ \*?__argz_(.|\n)*?\)\n*;//' \
59 | perl -pe 's/__(argz_next)/$$1/g;' \
60 > $@-t && mv $@-t $@
62 clean:
63 rm -f $(targets)