1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
From: Denis Osterland <Denis.Osterland@diehl.com>
Date: Wed, 28 Jun 2017 15:52:42 +0200
Subject: [PATCH] Cross-compile in ptxdist envirionment.
Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
---
Makefile | 10 +++++++---
src/Makefile | 18 ++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index 119110d2f010..c40c4cd6e0f7 100644
--- a/Makefile
+++ b/Makefile
@@ -4,13 +4,13 @@
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
-PLAT= none
+PLAT= linux
# Where to install. The installation starts in the src and doc directories,
# so take care if INSTALL_TOP is not an absolute path. See the local target.
# You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with
# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h.
-INSTALL_TOP= /usr/local
+INSTALL_TOP= $(DESTDIR)/usr
INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
@@ -52,7 +52,7 @@ R= $V.4
all: $(PLAT)
$(PLATS) clean:
- cd src && $(MAKE) $@
+ cd src && $(MAKE) $@ R=$R
test: dummy
src/lua -v
@@ -62,6 +62,10 @@ install: dummy
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
+ cd src && $(INSTALL_EXEC) liblua.so.$R $(INSTALL_LIB)
+ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so.$V
+ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so.$(basename $V)
+ ln -s liblua.so.$V $(INSTALL_LIB)/liblua.so
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
uninstall:
diff --git a/src/Makefile b/src/Makefile
index d71c75c87322..8ad9a1b718ad 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,15 +4,13 @@
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
-PLAT= none
+PLAT= linux
-CC= gcc -std=gnu99
-CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
+CFLAGS= -std=gnu99 -fPIC -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS)
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
LIBS= -lm $(SYSLIBS) $(MYLIBS)
-AR= ar rcu
-RANLIB= ranlib
+ARFLAGS= rcu
RM= rm -f
SYSCFLAGS=
@@ -29,6 +27,7 @@ MYOBJS=
PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.a
+LUA_SO= liblua.so.$R
CORE_O= lapi.o lcode.o lctype.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
@@ -43,8 +42,8 @@ LUAC_T= luac
LUAC_O= luac.o
ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
-ALL_A= $(LUA_A)
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
+ALL_A= $(LUA_A) $(LUA_SO)
# Targets start here.
default: $(PLAT)
@@ -56,9 +55,12 @@ o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
+ $(AR) $(ARFLAGS) $@ $(BASE_O)
$(RANLIB) $@
+$(LUA_SO): $(BASE_O)
+ $(CC) -shared -Wl,-soname=liblua.so.$(basename $V) -o $@ $(BASE_O) $(filter-out %readline, $(LIBS))
+
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|