File: 0001-debian_make.patch

package info (click to toggle)
lua5.1 5.1.5-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,316 kB
  • sloc: ansic: 12,763; makefile: 408; sh: 73
file content (95 lines) | stat: -rw-r--r-- 3,671 bytes parent folder | download | duplicates (2)
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
From: "John V. Belmonte" <jbelmonte@debian.org>
Date: Tue, 26 Aug 2014 16:20:49 +0200
Subject: debian_make

===================================================================
---
 Makefile     | 29 ++++++++++++++++++++++++++++-
 src/Makefile | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 209a132..98f9e31 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ PLAT= none
 INSTALL_TOP= /usr/local
 INSTALL_BIN= $(INSTALL_TOP)/bin
 INSTALL_INC= $(INSTALL_TOP)/include
-INSTALL_LIB= $(INSTALL_TOP)/lib
+INSTALL_LIB= $(INSTALL_TOP)/lib/$(DEB_HOST_MULTIARCH)
 INSTALL_MAN= $(INSTALL_TOP)/man/man1
 #
 # You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
@@ -126,3 +126,30 @@ lecho:
 .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho
 
 # (end of Makefile)
+
+# Use libtool for binary installs, etc.
+
+export V
+export LIBTOOL = libtool --quiet --tag=CC
+export LIBTOOLPP = libtool --quiet --tag=CXX
+# See libtool manual about how to set this
+export LIB_VERSION = 0:0:0
+
+debian_clean:
+	cd src; $(MAKE) $@
+
+debian_test: debian_linux
+	src/lua$(V) test/hello.lua
+
+debian_install: debian_linux
+	cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN)
+	cd src; $(LIBTOOL) --mode=install $(INSTALL_EXEC) lua$(V) luac$(V) $(INSTALL_BIN)
+	cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
+	cd src; $(LIBTOOL) --mode=install $(INSTALL_DATA) liblua$(V).la $(INSTALL_LIB)
+	cd src; $(LIBTOOLPP) --mode=install $(INSTALL_DATA) liblua$(V)-c++.la $(INSTALL_LIB)
+	$(foreach NAME,$(TO_MAN),$(INSTALL_DATA) doc/$(NAME) $(INSTALL_MAN)/$(basename $(NAME))$(V)$(suffix $(NAME));)
+
+# ISSUE: MYCFLAGS not honored in the case of a CFLAGS override
+debian_linux:
+	cd src; $(MAKE) debian_all CFLAGS+=-DLUA_USE_LINUX \
+		LIB_LIBS="-lm -ldl" LUA_LIBS="-lreadline" LDFLAGS="$(LDFLAGS)"
diff --git a/src/Makefile b/src/Makefile
index e0d4c9f..8860c3b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -180,3 +180,36 @@ print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
   ltm.h lzio.h lmem.h lopcodes.h lundump.h
 
 # (end of Makefile)
+
+# The following rules use libtool for compiling and linking in order to
+# provide shared library support.  While we are at it, our desired version
+# suffixes are added to the targets, preventing conflicts with rules in
+# the upstream makefile.
+
+LIB_NAME = liblua$(V).la
+LIBPP_NAME = liblua$(V)-c++.la
+LIB_OBJS = $(CORE_O:.o=.lo) $(LIB_O:.o=.lo)
+LIBPP_OBJS = $(CORE_O:%.o=%-c++.lo) $(LIB_O:%.o=%-c++.lo)
+
+%-c++.lo %-c++.o: %.c
+	$(LIBTOOLPP) --mode=compile $(CXX) -o $*-c++.lo -c $(CPPFLAGS) $(CFLAGS) $<
+%.lo %.o: %.c
+	$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
+
+$(LIB_NAME) $(LIB_NAME:.la=.a): $(LIB_OBJS)
+	$(LIBTOOL) --mode=link $(CC) -version-info $(LIB_VERSION) \
+            -rpath $(RPATH) -Wl,--version-script,../debian/version-script -o $(LIB_NAME) $(LIB_OBJS) $(LIB_LIBS)
+$(LIBPP_NAME) $(LIBPP_NAME:.la=.a): $(LIBPP_OBJS)
+	$(LIBTOOLPP) --mode=link $(CXX) -version-info $(LIB_VERSION) \
+            -rpath $(RPATH) -Wl,--version-script,../debian/version-script -o $(LIBPP_NAME) $(LIBPP_OBJS) $(LIB_LIBS)
+
+lua$(V): $(LUA_O) $(LIB_NAME)
+	$(LIBTOOL) --mode=link $(CC) -Wl,--version-script,../debian/version-script -static -Wl,-E -o $@ $(LUA_O) $(LIB_NAME) $(LUA_LIBS) $(LDFLAGS)
+
+luac$(V): $(LUAC_O) $(LIB_NAME)
+	$(LIBTOOL) --mode=link $(CC) -static -o $@ $(LUAC_O) $(LIB_NAME)
+
+debian_clean:
+	$(LIBTOOL) --mode=clean $(RM) $(ALL_O:.o=.lo) $(LIB_NAME) lua$(V) luac$(V)
+
+debian_all: $(LIB_NAME) $(LIBPP_NAME) lua$(V) luac$(V)