Package: scratchbox2
Version: 1.99.0.11
Tags: patch

Hi,

For security reasons and maintainability it would be good if sbox2
would switch to link against system provided libraries instead of the
embedded ones. Attached a patch against current git (the embeddeed lua
sources can be removed, but I've not done so to not bloat the patch).

regards,
guillem
>From 32fd8db3d233566614dc76f9a0f62387549b70ba Mon Sep 17 00:00:00 2001
From: Guillem Jover <[EMAIL PROTECTED]>
Date: Fri, 27 Jul 2007 18:24:42 +0300
Subject: [PATCH] Link against system LUA libraries

---
 Makefile          |    6 ++++++
 debian/control    |    3 ++-
 mapping/Makefile  |    7 ++-----
 mapping/mapping.c |    6 +++---
 preload/Makefile  |    2 +-
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index f18ca2e..2f1a340 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,12 @@ LLBUILD ?= $(TOPDIR)/llbuild
 
 export CC CFLAGS CXX CXXFLAGS TOPDIR LLBUILD
 
+LUA = lua5.1
+LUA_CFLAGS = $(shell pkg-config --cflags $(LUA))
+LUA_LIBS = $(shell pkg-config --libs $(LUA))
+
+export LUA_CFLAGS LUA_LIBS
+
 # targets variable will be filled by llbuild
 targets = 
 subdirs = mapping preload utils
diff --git a/debian/control b/debian/control
index 94a7b2a..767e471 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,8 @@ Maintainer: Riku Voipio <[EMAIL PROTECTED]>
 Section: utils
 Priority: extra
 Standards-Version: 3.7.2
-Build-Depends: debhelper (>=5), automake1.9, autoconf
+Build-Depends: debhelper (>= 5), automake1.9, autoconf, pkg-config,
+ liblua5.1-0-dev
 XS-Vcs-Git: git://anongit.freedesktop.org/git/sbox2
 XS-Vcs-Browser: http://gitweb.freedesktop.org/?p=sbox2.git
 
diff --git a/mapping/Makefile b/mapping/Makefile
index 5eea61e..965d5c7 100644
--- a/mapping/Makefile
+++ b/mapping/Makefile
@@ -1,12 +1,9 @@
-source_list := $(shell find $(D)/lua-5.1.1/src -name "*.c" -not -name "lua.c" \
-		-not -name "luac.c" -not -name "print.c")
-
-objs := $(source_list:.c=.o) $(D)/mapping.o
+objs := $(D)/mapping.o
 
 mapping/libmapping.a: $(objs)
 
 mapping/libmapping.a: override CFLAGS := -O2 -g -fPIC -Wall -W \
-			-I$(D)/lua-5.1.1/src $(CFLAGS)
+			$(LUA_CFLAGS) $(CFLAGS)
 mapping/libmapping.a: override LDFLAGS := $(LDFLAGS)
 mapping/libmapping.a: override LIBS := 
 
diff --git a/mapping/mapping.c b/mapping/mapping.c
index 35bf3a6..36fd8fc 100644
--- a/mapping/mapping.c
+++ b/mapping/mapping.c
@@ -37,9 +37,9 @@
 #include <assert.h>
 #include <pthread.h>
 
-#include "lua.h"
-#include "lualib.h"
-#include "lauxlib.h"
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
 
 #include <mapping.h>
 #include <sb2.h>
diff --git a/preload/Makefile b/preload/Makefile
index bd8cf63..a650360 100644
--- a/preload/Makefile
+++ b/preload/Makefile
@@ -6,7 +6,7 @@ $(D)/libsb2.so: mapping/libmapping.a
 
 $(D)/libsb2.so: CFLAGS := $(CFLAGS) -fPIC -Wall -W
 $(D)/libsb2.so: LDFLAGS := $(LDFLAGS) -Wl,-soname=$(LIBSB2_SONAME)
-$(D)/libsb2.so: LIBS := -ldl -lm -lpthread -lrt 
+$(D)/libsb2.so: LIBS := -ldl -lm -lpthread -lrt $(LUA_LIBS)
 
 targets := $(targets) $(D)/libsb2.so
 
-- 
1.5.2.4

Reply via email to