[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiline substitutions
From: |
Bruno Haible |
Subject: |
Re: multiline substitutions |
Date: |
Tue, 5 Oct 2010 23:40:04 +0200 |
User-agent: |
KMail/1.9.9 |
Ralf Wildenhues wrote:
> config.status should be used instead of sed for all the generated
> headers.
>
> I don't really have time to look into this, but if anyone wants to,
> it seemed fairly easy to do at the time: the only thing missing is
> a cd back to top_builddir and having a relative path to the input and
> output files, then you can use ./config.status --file=- < in > out.
An interesting idea.
Pro:
- Supports multiline substitution (starting with automake 1.10).
- Less code to maintain in the module descriptions.
Cons:
- Slower.
Here are times to create a time.h using a modified rule:
0.05 seconds for the single sed invocation, 0.88 seconds by use of
config.status. The resulting time.h files are identical.
Opinions?
Bruno
--- Makefile.am.old 2010-10-05 23:33:28.000000000 +0200
+++ Makefile.am.new 2010-10-05 23:32:29.000000000 +0200
@@ -166,30 +166,10 @@
time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f address@hidden $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
- -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
- -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
- -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
- -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
- -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
- -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
- -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
- -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
- -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
- -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
- -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
- -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
- -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
- -e
's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g'
\
- -e
's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
\
- -e
's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
- -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ (cd $(top_builddir) && ./config.status --file=-) <
$(srcdir)/time.in.h | \
+ sed -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/time.in.h; \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > address@hidden && \
mv address@hidden $@
MOSTLYCLEANFILES += time.h time.h-t
$ time make time.h
rm -f time.h-t time.h && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|include_next|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|#pragma GCC system_header|g' \
-e 's|@''PRAGMA_COLUMNS''@||g' \
-e 's|@''NEXT_TIME_H''@|<time.h>|g' \
-e 's|@''GNULIB_MKTIME''@|0|g' \
-e 's|@''GNULIB_NANOSLEEP''@|0|g' \
-e 's|@''GNULIB_STRPTIME''@|0|g' \
-e 's|@''GNULIB_TIMEGM''@|0|g' \
-e 's|@''GNULIB_TIME_R''@|0|g' \
-e 's|@''HAVE_LOCALTIME_R''@|1|g' \
-e 's|@''HAVE_NANOSLEEP''@|1|g' \
-e 's|@''HAVE_STRPTIME''@|1|g' \
-e 's|@''HAVE_TIMEGM''@|1|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|GNULIB_PORTCHECK|g' \
-e 's|@''REPLACE_MKTIME''@|GNULIB_PORTCHECK|g' \
-e 's|@''REPLACE_NANOSLEEP''@|GNULIB_PORTCHECK|g' \
-e 's|@''REPLACE_TIMEGM''@|GNULIB_PORTCHECK|g' \
-e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|0|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|0|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|1|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r c++defs.h' \
-e '/definition of _GL_ARG_NONNULL/r arg-nonnull.h' \
-e '/definition of _GL_WARN_ON_USE/r warn-on-use.h' \
< ./time.in.h; \
} > time.h-t && \
mv time.h-t time.h
real 0m0.050s
user 0m0.036s
sys 0m0.016s
$ time make time.h
rm -f time.h-t time.h && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
(cd .. && ./config.status --file=-) < ./time.in.h | \
sed -e '/definitions of _GL_FUNCDECL_RPL/r c++defs.h' \
-e '/definition of _GL_ARG_NONNULL/r arg-nonnull.h' \
-e '/definition of _GL_WARN_ON_USE/r warn-on-use.h'; \
} > time.h-t && \
mv time.h-t time.h
real 0m0.882s
user 0m0.264s
sys 0m0.628s
- Re: Fwd: sed porting trouble, (continued)
- Re: Fwd: sed porting trouble, Paul Eggert, 2010/10/05
- Re: Fwd: sed porting trouble, Jim Meyering, 2010/10/05
- Re: Fwd: sed porting trouble, Bruno Haible, 2010/10/05
- Re: Fwd: sed porting trouble, Ralf Wildenhues, 2010/10/05
- Re: Fwd: sed porting trouble, Bruno Haible, 2010/10/05
- Re: Fwd: sed porting trouble, Ralf Wildenhues, 2010/10/05
- Re: multiline substitutions,
Bruno Haible <=
- Re: multiline substitutions, Paul Eggert, 2010/10/05
- Re: multiline substitutions, Ralf Wildenhues, 2010/10/06
- Re: multiline substitutions, Bruno Haible, 2010/10/06
- Re: multiline substitutions, Paolo Bonzini, 2010/10/06
- Re: Fwd: sed porting trouble, Eric Blake, 2010/10/05
- Re: Fwd: sed porting trouble, Bruno Haible, 2010/10/05
- Re: Fwd: sed porting trouble, Eric Blake, 2010/10/05
- Re: minimum automake version, Bruno Haible, 2010/10/05
- Re: Fwd: sed porting trouble, Simon Josefsson, 2010/10/05
- Re: Fwd: sed porting trouble, Bruno Haible, 2010/10/05