Skip to content

Instantly share code, notes, and snippets.

@thejohnny
Created January 13, 2009 22:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thejohnny/46672 to your computer and use it in GitHub Desktop.
Save thejohnny/46672 to your computer and use it in GitHub Desktop.
Build shared libraries for lua 5.1.4
--- lua-5.1.4/Makefile 2008-08-12 00:40:48.000000000 +0000
+++ lua-5.1.4-shared-lib/Makefile 2009-01-13 22:01:33.000000000 +0000
@@ -43,7 +43,7 @@
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.a liblua.so
TO_MAN= lua.1 luac.1
--- lua-5.1.4/src/Makefile 2008-01-19 19:37:58.000000000 +0000
+++ lua-5.1.4-shared-lib/src/Makefile 2009-01-13 22:40:20.000000000 +0000
@@ -8,7 +8,7 @@
PLAT= none
CC= gcc
-CFLAGS= -O2 -Wall $(MYCFLAGS)
+CFLAGS= -O2 -Wall -fPIC $(MYCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
@@ -23,6 +23,7 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
+LUA_SO= liblua.so
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
lundump.o lvm.o lzio.o
@@ -36,7 +37,7 @@
LUAC_O= luac.o print.o
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
ALL_A= $(LUA_A)
default: $(PLAT)
@@ -57,6 +58,8 @@
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+$(LUA_SO): $(CORE_O) $(LIB_O)
+ $(CC) -o $@ -shared $?
clean:
$(RM) $(ALL_T) $(ALL_O)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment