summaryrefslogtreecommitdiff
path: root/lib/Makefile.am
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-04-11 16:09:45 +0200
committerBruno Haible <bruno@clisp.org>2009-04-11 16:09:45 +0200
commitd598f9e1e016735397e9dca53b436d13c6fb28f3 (patch)
tree98b8e47c701495b3f12ea0739c9705cb17ebd134 /lib/Makefile.am
parent3f5fe3223382a51a3057e0806aa02463addd12e4 (diff)
downloadlibunistring-d598f9e1e016735397e9dca53b436d13c6fb28f3.tar.gz
Limit the exported symbols through a config.h trick.
Diffstat (limited to 'lib/Makefile.am')
-rw-r--r--lib/Makefile.am79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4e8d6a6..6eaed43 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -136,6 +136,85 @@ clean-local: clean-generic
fi; \
:
+# List of header files that get installed and that declared 'extern' symbols.
+HEADERS_WITH_EXTERNS = \
+ unitypes.h \
+ unistr.h \
+ uniconv.h \
+ unistdio.h \
+ uniname.h \
+ unictype.h \
+ uniwidth.h \
+ uniwbrk.h \
+ unilbrk.h \
+ uninorm.h \
+ unicase.h \
+ localcharset.h \
+ iconveh.h
+
+# List of exported symbols.
+# We extract it from the header files that get installed, removing symbols
+# start with "_UC".
+# This file has the same format as the one expected by the libtool option
+# '-export-symbols', but we don't use this option, because it would prevent us
+# from building some of the gnulib unit tests.
+libunistring.sym : $(HEADERS_WITH_EXTERNS)
+ for f in $(HEADERS_WITH_EXTERNS); do cat $(srcdir)/$$f; done \
+ | $(srcdir)/declared.sh | LC_ALL=C sort | LC_ALL=C uniq \
+ | grep -v '^_UC' \
+ > $@-t
+ mv $@-t $@
+# We distribute it because declared.sh relies on GNU sed.
+MOSTLYCLEANFILES += libunistring.sym-t
+MAINTAINERCLEANFILES += libunistring.sym
+EXTRA_DIST += libunistring.sym
+
+# Hide undesired symbols that are defined by libunistring_la_SOURCES or
+# libunistring_la_LIBADD from the global namespace, by prefixing them with
+# "libunistring_".
+all check install: config.h
+config.h: $(BUILT_SOURCES) libunistring.sym
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ : "Avoid double inclusion, to avoid a warning about redefinition of DLL_VARIABLE."; \
+ echo '#ifndef UNISTRING_CONFIG_H'; \
+ echo '#define UNISTRING_CONFIG_H'; \
+ echo; \
+ echo '#include "../config.h"'; \
+ : "All code is collected in a single library,"; \
+ : "No references to variables in other libraries exist."; \
+ echo '#undef DLL_VARIABLE'; \
+ echo '#define DLL_VARIABLE'; \
+ echo; \
+ echo '#endif /* UNISTRING_CONFIG_H */'; \
+ } > config.h && \
+ if test -n "$(HAVE_GLOBAL_SYMBOL_PIPE)"; then \
+ { \
+ for f in $(libunistring_la_SOURCES) $(libunistring_la_LIBADD); do \
+ case $$f in \
+ *.c | *.$(OBJEXT) | *.lo ) \
+ sf=`echo "$$f" | sed -e 's,\\.[^.]*$$,,'`.c; \
+ test -f $$sf || sf=$(srcdir)/$$sf; \
+ of=`echo "$$f" | sed -e 's,^.*/,,' -e 's,\\.[^.]*$$,,'`.$(OBJEXT); \
+ $(COMPILE) -c $$sf || { rm -f config.h; exit 1; }; \
+ sh ./exported.sh $$of 1>&5; \
+ rm -f $$of `echo "$$of" | sed -e 's,\\.$(OBJEXT)$$,.lo,'`; \
+ ;; \
+ esac; \
+ done; \
+ } 5>&1 \
+ | sed -e 's,.* ,,' | LC_ALL=C sort | LC_ALL=C uniq \
+ | LC_ALL=C join -v 1 - $(srcdir)/libunistring.sym \
+ | sed -e 's,^\(.*\)$$,#define \1 libunistring_\1,' > config.h-t && \
+ if test -f config.h; then \
+ cat config.h-t >> config.h; \
+ rm -f config.h-t; \
+ else \
+ rm -f config.h-t; \
+ exit 1; \
+ fi \
+ fi
+MOSTLYCLEANFILES += config.h config.h-t
+
# Libtool's library version information for libunistring.
# See the libtool documentation, section "Library interface versions".
LTV_CURRENT=0