gensymlist.sh.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. EOF
  36. for i in $*; do
  37. echo "#include <$i>"
  38. done
  39. cat <<EOF
  40. #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
  41. void
  42. grub_register_exported_symbols (void)
  43. {
  44. EOF
  45. cat <<EOF
  46. struct symtab { const char *name; void *addr; };
  47. struct symtab *p;
  48. static struct symtab tab[] =
  49. {
  50. EOF
  51. $CC @TARGET_CFLAGS@ -DGRUB_SYMBOL_GENERATOR=1 -E -I. -Iinclude -I"$srcdir/include" $* \
  52. | grep -v '^#' \
  53. | sed -n \
  54. -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/ {"\1", \1},/;p;}' \
  55. -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/ {"\1", \&\1},/;p;}' \
  56. | sort -u
  57. cat <<EOF
  58. {0, 0}
  59. };
  60. COMPILE_TIME_ASSERT (sizeof (tab) > sizeof (tab[0]));
  61. for (p = tab; p->name; p++)
  62. grub_dl_register_symbol (p->name, p->addr, 0);
  63. }
  64. EOF