diff options
-rw-r--r-- | .cvsignore | 4 | ||||
-rw-r--r-- | Makefile.in | 36 | ||||
-rw-r--r-- | build/make_exports.awk | 129 | ||||
-rw-r--r-- | build/make_var_export.awk (renamed from build/make_export.awk) | 24 |
4 files changed, 165 insertions, 28 deletions
diff --git a/.cvsignore b/.cvsignore index d66bf90db..5cb40de2a 100644 --- a/.cvsignore +++ b/.cvsignore @@ -12,7 +12,9 @@ Debug Release *.opt *.plg -apr.exports +apr.exp +exports.c +export_vars.h .libs *.la libapr.rc diff --git a/Makefile.in b/Makefile.in index 6e53bc96f..904d31154 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,22 +17,22 @@ CLEAN_SUBDIRS= . test build INSTALL_SUBDIRS=@INSTALL_SUBDIRS@ TARGET_LIB = libapr.la -TARGET_EXPORTS = apr.exports # # Rules for building specific targets, starting with 'all' for # building the entire package. # -TARGETS = delete-lib $(TARGET_LIB) delete-exports $(TARGET_EXPORTS) +TARGETS = delete-lib $(TARGET_LIB) delete-exports export_vars.h apr.exp # bring in rules.mk for standard functionality @INCLUDE_RULES@ -CLEAN_TARGETS = $(TARGET_EXPORTS) +CLEAN_TARGETS = DISTCLEAN_TARGETS = config.cache config.log config.status \ include/apr.h include/arch/unix/apr_private.h \ - APRVARS libtool -EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in + APRVARS libtool apr.exp +EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in \ + exports.c export_vars.h prefix=@prefix@ exec_prefix=@exec_prefix@ @@ -41,6 +41,8 @@ includedir=@includedir@ srcdir=@srcdir@ top_srcdir=@top_srcdir@ +EXPORT_FILES = $(top_srcdir)/include/*.h + delete-lib: @if test -f $(TARGET_LIB); then \ for i in $(SUBDIRS); do objects="$$objects $$i/*.@so_ext@"; done ; \ @@ -72,17 +74,27 @@ $(TARGET_LIB): $(LINK) @lib_target@ delete-exports: - @if test -f $(TARGET_EXPORTS); then \ - headers="`find include/*.h -newer $(TARGET_EXPORTS)`" ; \ + @if test -f apr.exp; then \ + headers="`find include/*.h -newer apr.exp`" ; \ if test -n "$$headers"; then \ - echo Found newer headers. Will rebuild $(TARGET_EXPORTS). ; \ - echo $(RM) -f $(TARGET_EXPORTS) ; \ - $(RM) -f $(TARGET_EXPORTS) ; \ + echo Found newer headers. Will rebuild apr.exp. ; \ + echo $(RM) -f apr.exp ; \ + $(RM) -f apr.exp ; \ fi \ fi -$(TARGET_EXPORTS): - $(MKEXPORT) $(top_srcdir)/include/*.h > $@ +exports.c: + $(AWK) -f $(top_srcdir)/build/make_exports.awk $(EXPORT_FILES) > $@ + +export_vars.h: + $(AWK) -f $(top_srcdir)/build/make_var_export.awk $(EXPORT_FILES) > $@ + +apr.exp: exports.c export_vars.h + @echo "#! ." > $@ + @echo "* This file was AUTOGENERATED at build time." >> $@ + @echo "* Please do not edit by hand." >> $@ + $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $@ + $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.h | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $@ dox: doxygen $(top_srcdir)/docs/doxygen.conf diff --git a/build/make_exports.awk b/build/make_exports.awk new file mode 100644 index 000000000..b50768125 --- /dev/null +++ b/build/make_exports.awk @@ -0,0 +1,129 @@ + +BEGIN { + printf("/*\n") + printf(" * THIS FILE WAS AUTOGENERATED BY make_exports.awk\n") + printf(" *\n") + printf(" * This is an ugly hack that needs to be here, so\n") + printf(" * that libtool will link all of the APR functions\n") + printf(" * into server regardless of whether the base server\n") + printf(" * uses them.\n") + printf(" */\n") + printf("\n") + printf("#define CORE_PRIVATE\n") + printf("\n") + + for (i = 1; i < ARGC; i++) { + file = ARGV[i] + sub("([^/]*[/])*", "", file) + printf("#include \"%s\"\n", file) + } + + printf("\n") + printf("const void *ap_ugly_hack = NULL;\n") + printf("\n") + + TYPE_NORMAL = 0 + TYPE_HEADER = 1 + + stackptr = 0 +} + +function push(line) { + stack[stackptr] = line + stackptr++ +} + +function do_output() { + printf("/*\n") + printf(" * %s\n", FILENAME) + printf(" */\n") + + for (i = 0; i < stackptr; i++) { + printf("%s\n", stack[i]) + } + + stackptr = 0 + + printf("\n"); +} + +function enter_scope(type) { + scope++ + scope_type[scope] = type + scope_stack[scope] = stackptr + delete scope_used[scope] +} + +function leave_scope() { + used = scope_used[scope] + + if (!used) + stackptr = scope_stack[scope] + + scope-- + if (used) { + scope_used[scope] = 1 + + if (!scope) + do_output() + } +} + +function add_symbol(symbol) { + if (!index(symbol, "#")) { + push("const void *ap_hack_" symbol " = (const void *)" symbol ";") + scope_used[scope] = 1 + } +} + +/^[ \t]*AP[RU]?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ { + sub("[ \t]*AP[RU]?_DECLARE[^(]*[(][^)]*[)][ \t]*", "") + sub("[(].*", "") + sub("([^ ]* (^([ \t]*[(])))+", "") + + add_symbol($0) + next +} + +/^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*[)]/ { + split($0, args, ",") + symbol = args[2] + sub("^[ \t]+", "", symbol) + sub("[ \t]+$", "", symbol) + + add_symbol("ap_hook_" symbol) + add_symbol("ap_hook_get_" symbol) + add_symbol("ap_run_" symbol) + next +} + +/^#[ \t]*if(ndef| !defined[(])([^_]*_)*H/ { + enter_scope(TYPE_HEADER) + next +} + +/^#[ \t]*if([n]?def)? / { + enter_scope(TYPE_NORMAL) + push($0) + next +} + +/^#[ \t]*endif/ { + if (scope_type[scope] == TYPE_NORMAL) + push($0) + + leave_scope() + next +} + +/^#[ \t]*else/ { + push($0) + next +} + +/^#[ \t]*elif/ { + push($0) + next +} + + diff --git a/build/make_export.awk b/build/make_var_export.awk index a92136e77..966e14ecc 100644 --- a/build/make_export.awk +++ b/build/make_var_export.awk @@ -1,4 +1,5 @@ -# Based on Ryan Bloom's make_export.pl +# Based on apr's make_export.awk, which is +# based on Ryan Bloom's make_export.pl /^#[ \t]*if(def)? (AP[RU]?_|!?defined).*/ { if (old_filename != FILENAME) { @@ -12,14 +13,14 @@ macro_stack[macro_no++] = macro macro = substr($0, length($1)+2) count++ - line = line macro "\n" + line = line "#ifdef " macro "\n" next } /^#[ \t]*endif/ { if (count > 0) { count-- - line = line "/" macro "\n" + line = line "#endif /* " macro " */\n" macro = macro_stack[--macro_no] } if (count == 0) { @@ -46,18 +47,11 @@ function add_symbol (sym_name) { } } -/^[ \t]*(AP[RU]?_DECLARE[^(]*[(])?(const[ \t])?[a-z_]+[ \t\*]*[)]?[ \t]+[*]?([A-Za-z0-9_]+)\(/ { - sub("^[ \t]*(AP[UR]?_DECLARE[^(]*[(])?(const[ \t])?[a-z_]+[ \t\*]*[)]?[ \t]+[*]?", ""); - sub("[(].*", ""); - add_symbol($0); - next -} - -/^[ \t]*AP_DECLARE_HOOK[(][^,]+,[a-z_]+,.+[)]$/ { - split($0, args, ","); - add_symbol("ap_hook_" args[2]); - add_symbol("ap_hook_get_" args[2]); - add_symbol("ap_run_" args[2]); +/^[ \t]*AP[RU]?_DECLARE_DATA .*;$/ { + varname = $NF; + gsub( /[*;]/, "", varname); + gsub( /\[.*\]/, "", varname); + add_symbol(varname); } END { |