summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to 'etc')
-rw-r--r--etc/Makefile48
-rw-r--r--etc/README13
-rw-r--r--etc/dummy.c11
-rw-r--r--etc/one.c6
4 files changed, 54 insertions, 24 deletions
diff --git a/etc/Makefile b/etc/Makefile
index 5f6ed872..34d8571a 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -7,32 +7,48 @@ BIN= $(TOP)/src
SRC= $(TOP)/src
TST= $(TOP)/test
+T= test
CC= gcc
CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS)
MYCFLAGS=
-MYLDFLAGS= -Wl,-E
-MYLIBS= -lm
-#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
+MYLIBS= -lm # -ldl -lreadline -lncurses -Wl,-E
RM= rm -f
+
default:
- @echo 'Please choose a target: min noparser one strict clean'
+ @echo 'Please choose a target: min noparser one one-lua one-lib one-luac so strict clean'
min: min.c
- $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)
- echo 'print"Hello there!"' | ./a.out
- ./a.out $(TST)/hello.lua
- echo 'print("Hello world, from",_VERSION,"!")' | ./a.out
+ $(CC) $(CFLAGS) -o $T min.c -L$(LIB) -llua $(MYLIBS)
+ echo 'print"Hello there!"' | ./$T
+ ./$T $(TST)/hello.lua
+ echo 'print("Hello world, from",_VERSION,"!")' | ./$T
noparser: noparser.o
- $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS)
+ $(CC) -o $T noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS)
$(BIN)/luac $(TST)/hello.lua
- -./a.out luac.out
- -./a.out -e'a=1'
+ -./$T luac.out
+ -./$T -e'a=1'
+
+one: one-lua one-lib one-luac
+
+one-lua:
+ $(CC) $(CFLAGS) -o $T one.c $(MYLIBS)
+ ./$T $(TST)/hello.lua
+
+one-lib:
+ $(CC) $(CFLAGS) -DMAKE_LIB -o liblua.o -c one.c
+ $(CC) $(CFLAGS) -o $T min.c liblua.o $(MYLIBS)
+ ./$T $(TST)/hello.lua
+
+one-luac:
+ $(CC) $(CFLAGS) -o $T -DMAKE_LUAC one.c $(MYLIBS)
+ ./$T -l $(TST)/hello.lua
-one:
- $(CC) $(CFLAGS) one.c $(MYLIBS)
- ./a.out $(TST)/hello.lua
+so:
+ $(CC) $(CFLAGS) -shared -o dummy.so dummy.c
+ @#env MACOSX_DEPLOYMENT_TARGET=10.3 $(CC) $(CFLAGS) -bundle -undefined dynamic_lookup -o dummy.so dummy.c
+ $(BIN)/lua -v -ldummy
strict:
-$(BIN)/lua -e 'print(a);b=2'
@@ -41,6 +57,6 @@ strict:
-$(BIN)/lua -lstrict -e 'function f() b=2 end f()'
clean:
- $(RM) a.out core core.* *.o luac.out
+ $(RM) $T a.out core core.* *.o luac.out dummy.so
-.PHONY: default min noparser one strict clean
+.PHONY: default min noparser one one-lua one-lib one-luac so strict clean
diff --git a/etc/README b/etc/README
index 300257ae..0eda3bd3 100644
--- a/etc/README
+++ b/etc/README
@@ -4,23 +4,26 @@ Unlike the code in ../src, everything here is in the public domain.
If any of the makes fail, you're probably not using the same libraries used
to build Lua. Set MYLIBS in Makefile or in the command line accordingly.
-one.c
- Full Lua interpreter in a single file.
- Do "make one" for a demo.
+dummy.c:
+ A minimal Lua library for testing dynamic loading.
+ Do "make so" for a demo.
luavs.bat
Script to build Lua under "Visual Studio .NET Command Prompt".
Run it from the toplevel as etc\luavs.bat.
min.c
- A minimal Lua interpreter.
- Good for learning and for starting your own.
+ A minimal Lua interpreter for learning and for starting your own.
Do "make min" for a demo.
noparser.c
Linking with noparser.o avoids loading the parsing modules in lualib.a.
Do "make noparser" for a demo.
+one.c
+ Full Lua interpreter in a single file. Also library and compiler.
+ Do "make one" for a demo.
+
strict.lua
Traps uses of undeclared global variables.
Do "make strict" for a demo.
diff --git a/etc/dummy.c b/etc/dummy.c
new file mode 100644
index 00000000..1d40e8be
--- /dev/null
+++ b/etc/dummy.c
@@ -0,0 +1,11 @@
+/*
+* dummy.c -- a minimal Lua library for testing dynamic loading
+*/
+
+#include <stdio.h>
+#include "lua.h"
+
+int luaopen_dummy (lua_State *L) {
+ puts("Hello from dummy");
+ return 0;
+}
diff --git a/etc/one.c b/etc/one.c
index be1f3a40..372543a6 100644
--- a/etc/one.c
+++ b/etc/one.c
@@ -5,10 +5,11 @@
/* default is to build the full interpreter */
#ifndef MAKE_LIB
#ifndef MAKE_LUAC
-#undef MAKE_LUA
+#ifndef MAKE_LUA
#define MAKE_LUA
#endif
#endif
+#endif
/* choose suitable platform-specific features */
/* some of these may need extra libraries such as -ldl -lreadline -lncurses */
@@ -16,7 +17,6 @@
#define LUA_USE_LINUX
#define LUA_USE_MACOSX
#define LUA_USE_POSIX
-#define LUA_USE_DLOPEN
#define LUA_ANSI
#endif
@@ -58,11 +58,11 @@
#include "loslib.c"
#include "lstrlib.c"
#include "ltablib.c"
+#include "linit.c"
#endif
/* lua */
#ifdef MAKE_LUA
-#include "linit.c"
#include "lua.c"
#endif