summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2004-12-30 12:00:00 +0000
committerrepogen <>2004-12-30 12:00:00 +0000
commite2493a40ee611d5a718fd2a81fe67e24c04c91a0 (patch)
tree0dca96133b3cd52d262dfa2592ad076fc0ea7852 /etc
parent226f7859b5392b6680b7e703f9cc7f7f101fd365 (diff)
downloadlua-github-e2493a40ee611d5a718fd2a81fe67e24c04c91a0.tar.gz
Lua 5.1-work45.1-work4
Diffstat (limited to 'etc')
-rw-r--r--etc/Makefile44
-rw-r--r--etc/README7
-rw-r--r--etc/lua.hpp1
-rw-r--r--etc/noparser.c17
-rw-r--r--etc/saconfig.c30
5 files changed, 42 insertions, 57 deletions
diff --git a/etc/Makefile b/etc/Makefile
index 805df1d2..51bbb407 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -1,32 +1,36 @@
# makefile for Lua etc
-LUA= ..
-
-include $(LUA)/config
-
-ALL= min noparser luab 1
+TOP= ..
+LIB= $(TOP)/src
+INC= $(TOP)/src
+BIN= $(TOP)/src
+SRC= $(TOP)/src
+TST= $(TOP)/test
+
+CC= gcc
+CFLAGS= -O2 -Wall $(MYCFLAGS)
+MYCFLAGS= -ansi -I$(INC)
+MYLDFLAGS= -Wl,-E
+MYLIBS= -lm -ldl
+RM= rm -f
+
+ALL= min noparser.o 1
all:
@echo 'choose a target:' $(ALL)
-min: min.c $(LIBLUA)
+min: min.c
$(CC) $(CFLAGS) -o $@ $@.c -L$(LIB) -llua -llualib
-noparser: noparser.c
- $(CC) $(CFLAGS) -I$(LUA)/src -o $@.o -c $@.c
-
-luab: noparser
- $(CC) -o $@ noparser.o $(LUA)/src/lua/lua.o -L$(LIB) -llua -llualib $(EXTRA_LIBS) $(DLLIB)
- $(BIN)/luac $(LUA)/test/hello.lua
- $@ luac.out
- -$@ -e'a=1'
+noparser: noparser.o
+ $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua -llualib $(MYLIBS)
+ $(BIN)/luac $(TST)/hello.lua
+ -./a.out luac.out
+ -./a.out -e'a=1'
1:
- $(CC) $(CFLAGS) -I../src -I../src/lib -I../src/lua all.c $(EXTRA_LIBS) $(DLLIB)
- ./a.out $(LUA)/test/hello.lua
-
-flat:
- cd ..; mkdir flat; mv include/*.h src/*.[ch] src/*/*.[ch] flat
+ $(CC) $(CFLAGS) all.c $(MYLIBS)
+ ./a.out $(TST)/hello.lua
clean:
- rm -f $(ALL) a.out core *.o luac.out
+ $(RM) $(ALL) a.out core core.* *.o luac.out
diff --git a/etc/README b/etc/README
index 01df94c4..77b6f19a 100644
--- a/etc/README
+++ b/etc/README
@@ -5,6 +5,10 @@ all.c
Full Lua interpreter in a single file.
Do "make 1".
+lua.hpp
+ Lua header files for C++.
+ This keeps the C interface to Lua. But Lua also compiles as clean C++.
+
lua.ico
A Lua icon for Windows (and web sites, as favicon.ico).
Drawn by hand by Markus Gritsch <gritsch@iue.tuwien.ac.at>.
@@ -15,8 +19,7 @@ min.c
noparser.c
Linking with noparser.o avoids loading the parsing modules in lualib.a.
- Do "make luab" to build a sample Lua intepreter that does not parse
- Lua programs, only loads precompiled programs.
+ Do "make noparser" to see a demo.
saconfig.c
Configuration for Lua interpreter.
diff --git a/etc/lua.hpp b/etc/lua.hpp
index 273ec44c..ec417f59 100644
--- a/etc/lua.hpp
+++ b/etc/lua.hpp
@@ -1,5 +1,6 @@
// lua.hpp
// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
extern "C" {
#include "lua.h"
diff --git a/etc/noparser.c b/etc/noparser.c
index dc58faff..9396ad60 100644
--- a/etc/noparser.c
+++ b/etc/noparser.c
@@ -4,9 +4,12 @@
* You'll only be able to load binary files and strings, precompiled with luac.
* (Of course, you'll have to build luac with the original parsing modules!)
*
-* To use this module, simply compile it ("make noparser" does that) and
-* list its object file before the Lua libraries. The linker should then not
-* load the parsing modules. To try it, do "make luab".
+* To use this module, simply compile it ("make noparser" does that) and list
+* its object file before the Lua libraries. The linker should then not load
+* the parsing modules. To try it, do "make luab".
+*
+* If you also want to avoid the dump module (ldump.o), define NODUMP.
+* #define NODUMP
*/
#define LUA_CORE
@@ -22,22 +25,18 @@ void luaX_init (lua_State *L) {
Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
UNUSED(z);
UNUSED(buff);
- lua_pushstring(L,"parser not loaded");
+ lua_pushliteral(L,"parser not loaded");
lua_error(L);
return NULL;
}
-/*
-* If you also want to avoid the dump module, ldump.o, enable the code below.
-*/
-#define NODUMP
#ifdef NODUMP
#include "lundump.h"
int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, void* data, int strip)
{
return 0;
- lua_pushstring(L,"dumper not loaded");
+ lua_pushliteral(L,"dumper not loaded");
lua_error(L);
}
#endif
diff --git a/etc/saconfig.c b/etc/saconfig.c
index 6c07cce1..676b38e1 100644
--- a/etc/saconfig.c
+++ b/etc/saconfig.c
@@ -6,39 +6,17 @@
*
*** Line editing and history:
* #define USE_READLINE to use the GNU readline library.
+* Add "-lreadline -ltermcap" to MYLIBS.
*
* To use another library for this, use the code below as a start.
* Make sure you #define lua_readline and lua_saveline accordingly.
+*
* If you do not #define lua_readline, you'll get a version based on fgets
* that uses a static buffer of size MAXINPUT.
-*
-*
-*** Static Lua libraries to be loaded at startup:
-* #define lua_userinit(L) to a Lua function that loads libraries; typically
-* #define lua_userinit(L) openstdlibs(L);myinit(L)
-* or
-* #define lua_userinit(L) myinit(L)
-*
-* Another way is to add the prototypes of the init functions here and
-* #define LUA_EXTRALIBS accordingly. For example,
-* #define LUA_EXTRALIBS {"mylib","luaopen_mylib"},
-* Note the ending comma!
-*
-*
-*** Prompts:
-* The stand-alone Lua interpreter uses two prompts: PROMPT and PROMPT2.
-* PROMPT is the primary prompt, shown when the intepreter is ready to receive
-* a new statement. PROMPT2 is the secondary prompt, shown while a statement
-* is being entered but is still incomplete.
-*
-*
-*** Program name:
-* Error messages usually show argv[0] as a program name. In systems that do
-* not give a valid string as argv[0], error messages show PROGNAME instead.
-*
-*
*/
+#define USE_READLINE
+
#ifdef USE_READLINE
/*
* This section implements of lua_readline and lua_saveline for lua.c using