summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-07-15 14:37:50 +0000
committerJim Meyering <jim@meyering.net>2001-07-15 14:37:50 +0000
commitcedd6e358dee8827ce68ec2074001d182751950d (patch)
treed688da7ed708d72b9e19a5207040a78d9b5fc7ff
parentd010bd778c5440148acfe82949d3cd18d4cffda2 (diff)
downloadcoreutils-cedd6e358dee8827ce68ec2074001d182751950d.tar.xz
(unlocked-io.h): New rule.
($(srcdir)/m4/jm-glibc-io.m4): New rule.
-rw-r--r--Makefile.cfg43
1 files changed, 43 insertions, 0 deletions
diff --git a/Makefile.cfg b/Makefile.cfg
index 9400a3502..4a002d544 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -1,3 +1,4 @@
+# -*- makefile -*-
## Customize Makefile.maint.
move_if_change = move-if-change
@@ -19,3 +20,45 @@ wget_files = \
$(srcdir)/config.sub \
$(srcdir)/doc/texinfo.tex \
$(srcdir)/src/ansi2knr.c
+
+###############################################
+
+io_functions = \
+ clearerr feof ferror fflush fgets fputc fputs \
+ fread fwrite getc getchar putc putchar
+unlocked_io_functions = $(patsubst %,%_unlocked,$(io_functions))
+
+comma_separated = $(shell echo $(unlocked_io_functions)|tr -s ' ' ,)
+base_functions = $(patsubst %_unlocked,%,$(unlocked_io_functions))
+
+# This temp file may not be e.g., $@t, since that may be in a read-only
+# directory. Instead, use a file in the current directory.
+t_io = $(notdir $@)t
+
+# This rule requires GNU make.
+$(srcdir)/m4/jm-glibc-io.m4: $(srcdir)/m4/jm-glibc-io.m4n Makefile.am
+ echo dnl This file is automatically generated from $(notdir $<). \
+ > $(t_io)
+ echo >> $(t_io)
+ sed \
+ -e 's/@space_separated@/$(unlocked_io_functions)/g' \
+ -e 's/@comma_separated@/$(comma_separated)/g' \
+ $< >> $(t_io)
+ move-if-change $(t_io) $@
+
+# This rule requires GNU make.
+unlocked-io.h: unlocked-io.hin Makefile.cfg
+ 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 $@