onelua.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. ** Lua core, libraries, and interpreter in a single file.
  3. ** Compiling just this file generates a complete Lua stand-alone
  4. ** program:
  5. **
  6. ** $ gcc -O2 -std=c99 -o lua onelua.c -lm
  7. **
  8. ** or (for C89)
  9. **
  10. ** $ gcc -O2 -std=c89 -DLUA_USE_C89 -o lua onelua.c -lm
  11. **
  12. ** or (for Linux)
  13. **
  14. ** gcc -O2 -o lua -DLUA_USE_LINUX -Wl,-E onelua.c -lm -ldl
  15. **
  16. */
  17. /* default is to build the full interpreter */
  18. #ifndef MAKE_LIB
  19. #ifndef MAKE_LUAC
  20. #ifndef MAKE_LUA
  21. #define MAKE_LUA
  22. #endif
  23. #endif
  24. #endif
  25. /*
  26. ** Choose suitable platform-specific features. Default is no
  27. ** platform-specific features. Some of these options may need extra
  28. ** libraries such as -ldl -lreadline -lncurses
  29. */
  30. #if 0
  31. #define LUA_USE_LINUX
  32. #define LUA_USE_MACOSX
  33. #define LUA_USE_POSIX
  34. #endif
  35. /*
  36. ** Other specific features
  37. */
  38. #if 0
  39. #define LUA_32BITS
  40. #define LUA_USE_C89
  41. #endif
  42. /* no need to change anything below this line ----------------------------- */
  43. #include "lprefix.h"
  44. #include <assert.h>
  45. #include <ctype.h>
  46. #include <errno.h>
  47. #include <float.h>
  48. #include <limits.h>
  49. #include <locale.h>
  50. #include <math.h>
  51. #include <setjmp.h>
  52. #include <signal.h>
  53. #include <stdarg.h>
  54. #include <stddef.h>
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include <string.h>
  58. #include <time.h>
  59. /* setup for luaconf.h */
  60. #define LUA_CORE
  61. #define LUA_LIB
  62. #include "luaconf.h"
  63. /* do not export internal symbols */
  64. #undef LUAI_FUNC
  65. #undef LUAI_DDEC
  66. #undef LUAI_DDEF
  67. #define LUAI_FUNC static
  68. #define LUAI_DDEC(def) /* empty */
  69. #define LUAI_DDEF static
  70. /* core -- used by all */
  71. #include "lzio.c"
  72. #include "lctype.c"
  73. #include "lopcodes.c"
  74. #include "lmem.c"
  75. #include "lundump.c"
  76. #include "ldump.c"
  77. #include "lstate.c"
  78. #include "lgc.c"
  79. #include "llex.c"
  80. #include "lcode.c"
  81. #include "lparser.c"
  82. #include "ldebug.c"
  83. #include "lfunc.c"
  84. #include "lobject.c"
  85. #include "ltm.c"
  86. #include "lstring.c"
  87. #include "ltable.c"
  88. #include "ldo.c"
  89. #include "lvm.c"
  90. #include "lapi.c"
  91. /* auxiliary library -- used by all */
  92. #include "lauxlib.c"
  93. /* standard library -- not used by luac */
  94. #ifndef MAKE_LUAC
  95. #include "lbaselib.c"
  96. #include "lcorolib.c"
  97. #include "ldblib.c"
  98. #include "liolib.c"
  99. #include "lmathlib.c"
  100. #include "loadlib.c"
  101. #include "loslib.c"
  102. #include "lstrlib.c"
  103. #include "ltablib.c"
  104. #include "lutf8lib.c"
  105. #include "linit.c"
  106. #endif
  107. /* test library -- used only for internal development */
  108. #if defined(LUA_DEBUG)
  109. #include "ltests.c"
  110. #endif
  111. /* lua */
  112. #ifdef MAKE_LUA
  113. #include "lua.c"
  114. #endif
  115. /* luac */
  116. #ifdef MAKE_LUAC
  117. #include "luac.c"
  118. #endif