gensymlist.sh.in 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #! /bin/sh
  2. #
  3. # Copyright (C) 2002,2006,2007,2008 Free Software Foundation, Inc.
  4. #
  5. # This gensymlist.sh.in is free software; the author
  6. # gives unlimited permission to copy and/or distribute it,
  7. # with or without modifications, as long as this notice is preserved.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  11. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. # PARTICULAR PURPOSE.
  13. ### The configure script will replace these variables.
  14. : ${srcdir=@srcdir@}
  15. : ${CC=@TARGET_CC@}
  16. cat <<EOF
  17. /* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
  18. /*
  19. * GRUB -- GRand Unified Bootloader
  20. * Copyright (C) 2002,2006,2007,2008 Free Software Foundation, Inc.
  21. *
  22. * GRUB is free software: you can redistribute it and/or modify
  23. * it under the terms of the GNU General Public License as published by
  24. * the Free Software Foundation, either version 3 of the License, or
  25. * (at your option) any later version.
  26. *
  27. * GRUB is distributed in the hope that it will be useful,
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. * GNU General Public License for more details.
  31. *
  32. * You should have received a copy of the GNU General Public License
  33. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  34. */
  35. #include <grub/symbol.h>
  36. EOF
  37. for i in $*; do
  38. echo "#include <$i>"
  39. done
  40. cat <<EOF
  41. #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
  42. void
  43. grub_register_exported_symbols (void)
  44. {
  45. EOF
  46. cat <<EOF
  47. struct symtab { const char *name; void *addr; };
  48. struct symtab *p;
  49. static struct symtab tab[] =
  50. {
  51. EOF
  52. $CC @TARGET_CFLAGS@ -DGRUB_SYMBOL_GENERATOR=1 -E -I. -Iinclude -I"$srcdir/include" $* \
  53. | grep -v '^#' \
  54. | sed -n \
  55. -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1},/;p;}' \
  56. -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", \&\1},/;p;}' \
  57. | sort -u
  58. cat <<EOF
  59. {0, 0}
  60. };
  61. COMPILE_TIME_ASSERT (sizeof (tab) > sizeof (tab[0]));
  62. for (p = tab; p->name; p++)
  63. grub_dl_register_symbol (p->name, p->addr, 0);
  64. }
  65. EOF