241abdabcbb15742155c0b2e8e48184438326f45
[gnulib.git] / m4 / Makefile.am.in
1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
2
3 ##m4-files-begin
4 ##m4-files-end
5
6 Makefile.am: Makefile.am.in
7         rm -f $@ $@t
8         sed -n '1,/^##m4-files-begin/p' $< > $@t
9         (((echo EXTRA_DIST =; \
10            echo "  README jm-glibc-io.m4 jm-glibc-io.m4n Makefile.am.in" \
11           ) | tr '\012' @); \
12           (echo *.m4|tr ' ' @) ) \
13           |sed 's/@$$/%/;s/@/ \\@/g' |tr @% '\012\012' \
14           >> $@t
15         sed -n '/^##m4-files-end/,$$p' $< >> $@t
16         echo >> $@t
17         echo all-local: glibc-io.stamp >> $@t
18         chmod a-w $@t
19         mv $@t $@
20
21 unlocked_functions = \
22   clearerr_unlocked feof_unlocked ferror_unlocked \
23   fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked \
24   fread_unlocked fwrite_unlocked getc_unlocked getchar_unlocked \
25   putc_unlocked putchar_unlocked
26
27 comma_separated = $(shell echo $(unlocked_functions)|tr -s ' ' ,)
28 base_functions = $(patsubst %_unlocked,%,$(unlocked_functions))
29
30 # Don't depend directly on jm-glibc-io.m4, because that would cause it
31 # to be created in non-srcdir==. builds, and that leads to problems with
32 # distcheck.  Note also that we can't add it to DISTCLEANFILES for similar
33 # reasons.
34 glibc-io.stamp: jm-glibc-io.m4n Makefile
35         if test `pwd` = `cd $(srcdir); pwd`; then                       \
36           t=jm-glibc-io.m4;                                             \
37           src=$(srcdir)/jm-glibc-io.m4n;                                \
38           echo "dnl This file is automatically generated from $${t}n."  \
39             > $${t}t;                                                   \
40           echo '' >> $${t}t;                                            \
41           sed                                                           \
42             -e 's/@space_separated@/$(unlocked_functions)/g'            \
43             -e 's/@comma_separated@/$(comma_separated)/g'               \
44             $$src >> $${t}t;                                            \
45           move-if-change $${t}t $$t;                                    \
46         fi
47         touch $@
48
49 DISTCLEANFILES = glibc-io.stamp
50
51 unlocked-io.h: unlocked-io.hin Makefile.am.in
52         tmp=t$$$$;                                                      \
53         echo ''                                         > $$tmp;        \
54         for f in $(base_functions); do                                  \
55           u=`echo $$f|tr '[:lower:]' '[:upper:]'`;                      \
56           echo "#  if HAVE_$${u}_UNLOCKED"              >> $$tmp;       \
57           echo "#   undef $$f"                          >> $$tmp;       \
58           echo "#   define $$f(S) $${f}_unlocked (S)"   >> $$tmp;       \
59           echo '#endif'                                 >> $$tmp;       \
60         done;                                                           \
61         sed "/^@replace_this@$$/r$$tmp" $<                              \
62           | sed "/^@replace_this@$$/d"                                  \
63           $< > $@t;                                                     \
64         rm -f $$tmp;                                                    \
65         mv $@t $@