make_lang_list 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. #####################################################-*-mode:shell-script-*-
  3. ## ##
  4. ## Language Technologies Institute ##
  5. ## Carnegie Mellon University ##
  6. ## Copyright (c) 2012 ##
  7. ## All Rights Reserved. ##
  8. ## ##
  9. ## Permission is hereby granted, free of charge, to use and distribute ##
  10. ## this software and its documentation without restriction, including ##
  11. ## without limitation the rights to use, copy, modify, merge, publish, ##
  12. ## distribute, sublicense, and/or sell copies of this work, and to ##
  13. ## permit persons to whom this work is furnished to do so, subject to ##
  14. ## the following conditions: ##
  15. ## 1. The code must retain the above copyright notice, this list of ##
  16. ## conditions and the following disclaimer. ##
  17. ## 2. Any modifications must be clearly marked as such. ##
  18. ## 3. Original authors' names are not deleted. ##
  19. ## 4. The authors' names are not used to endorse or promote products ##
  20. ## derived from this software without specific prior written ##
  21. ## permission. ##
  22. ## ##
  23. ## CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ##
  24. ## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
  25. ## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
  26. ## SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ##
  27. ## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
  28. ## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
  29. ## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
  30. ## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
  31. ## THIS SOFTWARE. ##
  32. ## ##
  33. ###########################################################################
  34. ## ##
  35. ## Build a compilable C file with a list of the available languages ##
  36. ## ##
  37. ###########################################################################
  38. rm -f flite_lang_list.c
  39. echo "/* Generated automatically from make_lang_list */" >flite_lang_list.c
  40. echo >>flite_lang_list.c
  41. echo '#include "flite.h"' >>flite_lang_list.c
  42. echo >>flite_lang_list.c
  43. echo $* |
  44. awk '{n = NF/2;
  45. for (i=1; i<=n; i++)
  46. {
  47. printf("void %s_init(cst_voice *v);\n",$i);
  48. printf("cst_lexicon *%s_init(void);\n\n",$(i+n));
  49. }}' >>flite_lang_list.c
  50. echo >>flite_lang_list.c
  51. echo "void flite_set_lang_list(void)" >>flite_lang_list.c
  52. echo "{" >>flite_lang_list.c
  53. echo $* |
  54. awk '{n = NF/2;
  55. for (i=1; i<=n; i++)
  56. {
  57. if ($i == "usenglish")
  58. {
  59. printf(" flite_add_lang(\"eng\",usenglish_init,cmulex_init);\n");
  60. }
  61. printf(" flite_add_lang(\"%s\",%s_init,%s_init);\n",$i,$i,$(i+n));
  62. }}' >>flite_lang_list.c
  63. echo "}" >>flite_lang_list.c
  64. echo >>flite_lang_list.c