Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
protect against failed get
[simgrid.git] / tools / lualib.patch
1 This patch is to be applied to the Lua 5.3 source file to get a shared
2 library. This is because the authors of Lua don't bother distributing
3 a working build system for their software, so we have to make one...
4
5 As unfortunate as it may be, there is nothing else we can do.
6
7                                             -- Da SimGrid team.
8
9 diff --git a/Makefile b/Makefile
10 index 5ee5601..93830a3 100644
11 --- a/Makefile
12 +++ b/Makefile
13 @@ -52,7 +52,7 @@ R= $V.1
14  all:   $(PLAT)
15
16  $(PLATS) clean:
17 -       cd src && $(MAKE) $@
18 +       cd src && $(MAKE) $@ V=$(V) R=$(R)
19
20  test:  dummy
21         src/lua -v
22 diff --git a/src/Makefile b/src/Makefile
23 index d71c75c..64bda79 100644
24 --- a/src/Makefile
25 +++ b/src/Makefile
26 @@ -7,7 +7,7 @@
27  PLAT= none
28
29  CC= gcc -std=gnu99
30 -CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
31 +CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) -fPIC
32  LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
33  LIBS= -lm $(SYSLIBS) $(MYLIBS)
34
35 @@ -29,6 +29,7 @@ MYOBJS=
36  PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
37
38  LUA_A= liblua.a
39 +LUA_SO= liblua.so
40  CORE_O=        lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
41         lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
42         ltm.o lundump.o lvm.o lzio.o
43 @@ -43,7 +44,7 @@ LUAC_T=       luac
44  LUAC_O=        luac.o
45
46  ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
47 -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
48 +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
49  ALL_A= $(LUA_A)
50
51  # Targets start here.
52 @@ -59,6 +60,11 @@ $(LUA_A): $(BASE_O)
53         $(AR) $@ $(BASE_O)
54         $(RANLIB) $@
55
56 +$(LUA_SO): $(CORE_O) $(LIB_O)
57 +       $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
58 +       ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
59 +       ln -sf $(LUA_SO).$(R) $(LUA_SO)
60 +
61  $(LUA_T): $(LUA_O) $(LUA_A)
62         $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
63