]> mj.ucw.cz Git - libucw.git/commitdiff
Filter config.h and autoconf.h in the public API.
authorMartin Mares <mj@ucw.cz>
Thu, 30 Oct 2008 19:48:02 +0000 (20:48 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 30 Oct 2008 19:48:02 +0000 (20:48 +0100)
This tries to avoid leaking private symbols to autoconf.h which is a part
of the public API.

ucw/Makefile
ucw/filter-autoconf.sed [new file with mode: 0644]

index 476950278ab402452d31532e8b3fe097e171e087..0af1d71d0aa64a07a192d7bbb2b4866f96a07d31 100644 (file)
@@ -34,7 +34,7 @@ LIBUCW_MODS= \
        getopt
 
 LIBUCW_MAIN_INCLUDES= \
-       lib.h config.h threads.h \
+       lib.h threads.h \
        mempool.h \
        arraysort.h \
        clists.h slists.h simple-lists.h \
@@ -130,12 +130,23 @@ endif
 
 API_LIBS+=libucw
 API_INCLUDES+=$(o)/ucw/.include-stamp
-$(o)/ucw/.include-stamp: $(addprefix $(s)/ucw/,$(LIBUCW_INCLUDES)) obj/autoconf.h
+$(o)/ucw/.include-stamp: $(addprefix $(s)/ucw/,$(LIBUCW_INCLUDES)) $(o)/ucw/autoconf.h $(o)/ucw/config.h
        $(Q)$(s)/build/install-includes $(<D) run/include/ucw $(LIBUCW_INCLUDES)
-       $(Q)$(s)/build/install-includes obj run/include/ucw autoconf.h
+       $(Q)$(s)/build/install-includes $(o)/ucw run/include/ucw autoconf.h config.h
        $(Q)touch $@
 run/lib/pkgconfig/libucw.pc: $(o)/ucw/libucw.pc
 
+# The version of autoconf.h that is a part of the public API needs to have
+# the internal symbols filtered out.
+$(o)/ucw/autoconf.h: $(o)/autoconf.h
+       $(M)"FILTER $< -> $@"
+       $(Q)sed -f $(s)/ucw/filter-autoconf.sed <$< >$@
+
+# Also, public config.h needs to refer to <ucw/autoconf.h> instead of "autoconf.h"
+$(o)/ucw/config.h: $(s)/ucw/config.h
+       $(M)"FILTER $< -> $@"
+       $(Q)sed -e 's/^#include "autoconf\.h"/#include <ucw\/autoconf.h>/' <$< >$@
+
 ifdef CONFIG_UCW_PERL
 include $(s)/ucw/perl/Makefile
 endif
@@ -147,9 +158,7 @@ endif
 INSTALL_TARGETS+=install-libucw
 install-libucw:
        install -d -m 755 $(DESTDIR)$(INSTALL_LIB_DIR) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/ $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
-       install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES)) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
-       install -m 644 obj/autoconf.h $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
-       sed -e 's/^#include .autoconf\.h./#include <ucw\/autoconf.h>/' <run/include/ucw/config.h >$(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/config.h
+       install -m 644 $(addprefix run/include/ucw/,$(LIBUCW_MAIN_INCLUDES) autoconf.h config.h) $(DESTDIR)$(INSTALL_INCLUDE_DIR)/ucw/
        install -m 644 run/lib/pkgconfig/libucw.pc $(DESTDIR)$(INSTALL_PKGCONFIG_DIR)
        install -m 644 run/lib/libucw.$(LS) $(DESTDIR)$(INSTALL_LIB_DIR)
 
diff --git a/ucw/filter-autoconf.sed b/ucw/filter-autoconf.sed
new file mode 100644 (file)
index 0000000..f6b598e
--- /dev/null
@@ -0,0 +1,12 @@
+# A sed script to weed out private symbols from <ucw/autoconf.h>
+
+/^\//n
+
+# Excluded symbols (danger of collision)
+/^#define CONFIG_DEBUG$/d
+
+# Included symbols
+/^#define CONFIG_/n
+/^#define CPU_/n
+
+d