From: Zack Weinberg Date: Fri, 27 Apr 2012 13:32:51 +0000 (-0400) Subject: Generate event-config.h with a single sed script X-Git-Tag: release-2.0.19-stable~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30b6f889f7d8a6dc3174a35641772d3c9294eaec;p=libevent Generate event-config.h with a single sed script This approach should make the creation of the file more atomic, to fix a bug reported by Dinh. This patch has one change from Zack's original version: it avoids $<, since Dave Hart tells me he thinks that's not so portable. (commit message by nickm) --- diff --git a/Makefile.am b/Makefile.am index 09505bd7..d3fb97f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -100,6 +100,7 @@ EXTRA_DIST = \ autogen.sh \ event_rpcgen.py \ libevent.pc.in \ + make-event-config.sed \ Doxyfile \ whatsnew-2.0.txt \ Makefile.nmake test/Makefile.nmake \ @@ -161,26 +162,12 @@ if SIGNAL_SUPPORT SYS_SRC += signal.c endif -BUILT_SOURCES = ./include/event2/event-config.h - -./include/event2/event-config.h: config.h - @MKDIR_P@ ./include/event2 - echo '/* event2/event-config.h' > $@ - echo ' *' >> $@ - echo ' * This file was generated by autoconf when libevent was built, and post-' >> $@ - echo ' * processed by Libevent so that its macros would have a uniform prefix.' >> $@ - echo ' *' >> $@ - echo ' * DO NOT EDIT THIS FILE.' >> $@ - echo ' *' >> $@ - echo ' * Do not rely on macros in this file existing in later versions.'>> $@ - echo ' */' >> $@ - echo '#ifndef _EVENT2_EVENT_CONFIG_H_' >> $@ - echo '#define _EVENT2_EVENT_CONFIG_H_' >> $@ - - sed -e 's/#define /#define _EVENT_/' \ - -e 's/#undef /#undef _EVENT_/' \ - -e 's/#ifndef /#ifndef _EVENT_/' < config.h >> $@ - echo "#endif" >> $@ +BUILT_SOURCES = include/event2/event-config.h + +include/event2/event-config.h: config.h make-event-config.sed + test -d include/event2 || $(MKDIR_P) include/event2 + $(SED) -f $(srcdir)/make-event-config.sed < config.h > $@T + mv -f $@T $@ CORE_SRC = event.c evthread.c buffer.c \ bufferevent.c bufferevent_sock.c bufferevent_filter.c \ diff --git a/make-event-config.sed b/make-event-config.sed new file mode 100644 index 00000000..b343e3b7 --- /dev/null +++ b/make-event-config.sed @@ -0,0 +1,23 @@ +# Sed script to postprocess config.h into event-config.h. + +1i\ +/* event2/event-config.h\ + *\ + * This file was generated by autoconf when libevent was built, and post-\ + * processed by Libevent so that its macros would have a uniform prefix.\ + *\ + * DO NOT EDIT THIS FILE.\ + *\ + * Do not rely on macros in this file existing in later versions.\ + */\ +\ +#ifndef _EVENT2_EVENT_CONFIG_H_\ +#define _EVENT2_EVENT_CONFIG_H_\ + +$a\ +\ +#endif /* event2/event-config.h */ + +s/#define /#define _EVENT_/ +s/#undef /#undef _EVENT_/ +s/#ifndef /#ifndef _EVENT_/