You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.1 KiB

# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../lua-pty/lpty-make-install.patch
# Copyright (C) 2013 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
Improve Makefile
- support different config styles
The config style can be either 'auto' (default) or 'pkgconfig'.
Note:
The 'auto' config style will only work properly when building
on the same host the binary is supposed to run on.
- use more commonly used variable names
- use `install` instead of `cp` when installing
- add uninstall target
--- a/Makefile 2013-03-29 00:51:54.000000000 +0100
+++ b/Makefile 2013-04-23 13:43:40.146993101 +0200
@@ -3,25 +3,49 @@
# Gunnar Zötl <gz@tset.de>, 2011.
# Released under MIT/X11 license. See file LICENSE for details.
+DESTDIR=
+PREFIX=/usr/local
+
+# if no config style is given we use 'auto' preserving the initial behavior
+ifeq ($(CONFIGSTYLE), )
+CONFIGSTYLE=auto
+endif
+
# try some automatic discovery
+# Note: This will only work properly when building on the same host
+ifeq ($(CONFIGSTYLE),auto)
OS = $(shell uname -s)
LUAVERSION = $(shell lua -v 2>&1|awk '{split($$2, a, "."); print a[1] "." a[2]}')
LUADIR = $(shell dirname `which lua`)
LUAROOT = $(shell dirname $(LUADIR))
+INCDIRS=-I$(LUAROOT)/include
+LIBDIRS=-L$(LUAROOT)/lib
+INSTALL_CMOD=$(PREFIX)/lib/lua/$(LUAVERSION)
+INSTALL_LMOD=$(PREFIX)/share/lua/$(LUAVERSION)
+else
+# use pkg-config instead of the basic auto discovery
+ifeq ($(CONFIGSTYLE),pkgconfig)
+PKGCONFIG=pkg-config
+PREFIX=$(shell $(PKGCONFIG) --variable=prefix lua)
+INSTALL_CMOD=$(shell $(PKGCONFIG) --variable=INSTALL_CMOD lua)
+INCDIRS+=-I$(shell $(PKGCONFIG) --variable=includedir lua)
+LIBDIRS+=-L$(shell $(PKGCONFIG) --variable=libdir lua)
+else
+$(warning Unknown config style)
+$(warning You need to set the config style to 'auto' or 'pkgconfig')
+$(warning example to use `pkg-config`: "make CONFIGSTYLE=pkgconfig")
+$(error )
+endif
+endif
+
# Defaults
CC = gcc
TARGET = lpty.so
DEBUG= #-g -lefence
CFLAGS=-O2 -fPIC $(DEBUG)
-INCDIRS=-I$(LUAROOT)/include
-LIBDIRS=-L$(LUAROOT)/lib
LDFLAGS=-shared $(DEBUG)
-INSTALL_ROOT=/usr/local
-SO_INST_ROOT=$(INSTALL_ROOT)/lib/lua/$(LUAVERSION)
-LUA_INST_ROOT=$(INSTALL_ROOT)/share/lua/$(LUAVERSION)
-
# OS specialities
ifeq ($(OS),Darwin)
LDFLAGS = -bundle -undefined dynamic_lookup -all_load
@@ -36,7 +60,10 @@
$(CC) $(CFLAGS) $(INCDIRS) -c $< -o $@
install: all
- cp $(TARGET) $(SO_INST_ROOT)
+ install -m 755 $(TARGET) $(DESTDIR)$(INSTALL_CMOD)
+
+uninstall:
+ rm -vf $(DESTDIR)$(INSTALL_CMOD)/$(TARGET)
test: all
cd samples && LUA_CPATH=../\?.so lua lptytest.lua