make_exports.awk 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. BEGIN {
  2. printf("/*\n")
  3. printf(" * THIS FILE WAS AUTOGENERATED BY make_exports.awk\n")
  4. printf(" *\n")
  5. printf(" * This is an ugly hack that needs to be here, so\n")
  6. printf(" * that libtool will link all of the APR functions\n")
  7. printf(" * into server regardless of whether the base server\n")
  8. printf(" * uses them.\n")
  9. printf(" */\n")
  10. printf("\n")
  11. printf("#define CORE_PRIVATE\n")
  12. printf("\n")
  13. for (i = 1; i < ARGC; i++) {
  14. file = ARGV[i]
  15. sub("([^/]*[/])*", "", file)
  16. printf("#include \"%s\"\n", file)
  17. }
  18. printf("\n")
  19. printf("const void *ap_ugly_hack = NULL;\n")
  20. printf("\n")
  21. TYPE_NORMAL = 0
  22. TYPE_HEADER = 1
  23. stackptr = 0
  24. }
  25. function push(line) {
  26. stack[stackptr] = line
  27. stackptr++
  28. }
  29. function do_output() {
  30. printf("/*\n")
  31. printf(" * %s\n", FILENAME)
  32. printf(" */\n")
  33. for (i = 0; i < stackptr; i++) {
  34. printf("%s\n", stack[i])
  35. }
  36. stackptr = 0
  37. printf("\n");
  38. }
  39. function enter_scope(type) {
  40. scope++
  41. scope_type[scope] = type
  42. scope_stack[scope] = stackptr
  43. delete scope_used[scope]
  44. }
  45. function leave_scope() {
  46. used = scope_used[scope]
  47. if (!used)
  48. stackptr = scope_stack[scope]
  49. scope--
  50. if (used) {
  51. scope_used[scope] = 1
  52. if (!scope)
  53. do_output()
  54. }
  55. }
  56. function add_symbol(symbol) {
  57. if (!index(symbol, "#")) {
  58. push("const void *ap_hack_" symbol " = (const void *)" symbol ";")
  59. scope_used[scope] = 1
  60. }
  61. }
  62. /^[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
  63. sub("[ \t]*AP[RUI]?_(CORE_)?DECLARE[^(]*[(][^)]*[)][ \t]*", "")
  64. sub("[(].*", "")
  65. sub("([^ ]* (^([ \t]*[(])))+", "")
  66. add_symbol($0)
  67. next
  68. }
  69. /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
  70. split($0, args, ",")
  71. symbol = args[2]
  72. sub("^[ \t]+", "", symbol)
  73. sub("[ \t]+$", "", symbol)
  74. add_symbol("ap_hook_" symbol)
  75. add_symbol("ap_hook_get_" symbol)
  76. add_symbol("ap_run_" symbol)
  77. next
  78. }
  79. /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
  80. sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
  81. sub("[)].*$", "", $0)
  82. add_symbol("fspr_" $0 "_pool_get")
  83. next
  84. }
  85. /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
  86. sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
  87. sub("[)].*$", "", $0)
  88. add_symbol("fspr_" $0 "_inherit_set")
  89. next
  90. }
  91. /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
  92. sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
  93. sub("[)].*$", "", $0)
  94. add_symbol("fspr_" $0 "_inherit_unset")
  95. next
  96. }
  97. /^#[ \t]*if(ndef| !defined[(])([^_]*_)*H/ {
  98. enter_scope(TYPE_HEADER)
  99. next
  100. }
  101. /^#[ \t]*if([n]?def)? / {
  102. enter_scope(TYPE_NORMAL)
  103. push($0)
  104. next
  105. }
  106. /^#[ \t]*endif/ {
  107. if (scope_type[scope] == TYPE_NORMAL)
  108. push($0)
  109. leave_scope()
  110. next
  111. }
  112. /^#[ \t]*else/ {
  113. push($0)
  114. next
  115. }
  116. /^#[ \t]*elif/ {
  117. push($0)
  118. next
  119. }