summaryrefslogtreecommitdiff
path: root/m4/Makefile.am.in
blob: 36a4da4e654e3a0a2fcf9ecdbb92e6318a2231af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Process this file with automake to produce Makefile.in -*-Makefile-*-

##m4-files-begin
##m4-files-end

Makefile.am: Makefile.am.in
	rm -f $@ $@t
	sed -n '1,/^##m4-files-begin/p' $< > $@t
	((echo EXTRA_DIST = README jm-glibc-io.m4n Makefile.am.in|tr '\012' @);\
	  (echo *.m4|tr ' ' @) ) \
	  |sed 's/@$$/%/;s/@/ \\@/g' |tr @% '\012\012' \
	  >> $@t
	sed -n '/^##m4-files-end/,$$p' $< >> $@t
	echo >> $@t
	echo all-local: jm-glibc-io.m4 >> $@t
	chmod a-w $@t
	mv $@t $@

unlocked_functions = \
  clearerr_unlocked feof_unlocked ferror_unlocked \
  fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked \
  fread_unlocked fwrite_unlocked getc_unlocked getchar_unlocked \
  putc_unlocked putchar_unlocked

comma_separated = $(shell echo $(unlocked_functions)|tr -s ' ' ,)
base_functions = $(patsubst %_unlocked,%,$(unlocked_functions))
jm-glibc-io.m4: jm-glibc-io.m4n Makefile
	echo 'dnl This file is automatically generated from $<' > $@t
	echo '' >> $@t
	sed							\
	  -e 's/@space_separated@/$(unlocked_functions)/g'	\
	  -e 's/@comma_separated@/$(comma_separated)/g'		\
	  $< >> $@t
	move-if-change $@t $@

unlocked-io.h: unlocked-io.hin Makefile.am.in
	tmp=t$$$$;							\
	echo ''						> $$tmp;	\
	for f in $(base_functions); do					\
	  u=`echo $$f|tr '[:lower:]' '[:upper:]'`;			\
	  echo "#  if HAVE_$${u}_UNLOCKED"		>> $$tmp;	\
	  echo "#   undef $$f"				>> $$tmp;	\
	  echo "#   define $$f(S) $${f}_unlocked (S)"	>> $$tmp;	\
	  echo '#endif'					>> $$tmp;	\
	done;								\
	sed "/^@replace_this@$$/r$$tmp" $<				\
	  | sed "/^@replace_this@$$/d"					\
	  $< > $@t;							\
	rm -f $$tmp;							\
	mv $@t $@