From 9c2194d1b035a7b00d402e12c2d812adc1da81c9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 15 Aug 2020 15:20:18 +0200 Subject: [PATCH] Made installation more portable and robust against different name of the swig executable --- Makefile | 10 +--------- build.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100755 build.sh diff --git a/Makefile b/Makefile index a9e716a..728806b 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,10 @@ PREFIX := $(if $(PREFIX),$(PREFIX),/usr) PYTHON3_VERSION := $(shell python3 --version | cut -d' ' -f 2 | cut -d. -f 1,2) ARCH := $(shell uname -m | sed -e 's/x86_64/x64/') - SDK_PATH=./leap/LeapSDK all: - [ -f ./LeapSDK.tar.gz ] || wget -O LeapSDK.tar.gz http://warehouse.leapmotion.com/apps/4185/download/ - mkdir -p leap - tar xvf LeapSDK.tar.gz -C leap --strip-components 1 - cp -r $(SDK_PATH)/include ./include - wget http://tinyurl.com/leap-i-patch -O Leap.i.diff - patch -p0 < Leap.i.diff - swig-3 -c++ -python -o LeapPython.cpp -interface LeapPython ./include/Leap.i - g++ -fPIC -I/usr/include/python$(PYTHON3_VERSION)m -I/usr/include/python$(PYTHON3_VERSION) -I$(SDK_PATH)/include LeapPython.cpp $(SDK_PATH)/lib/$(ARCH)/libLeap.so -shared -o LeapPython.so + @./build.sh clean: rm -rf __pycache__ diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3782fbe --- /dev/null +++ b/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + + +SDK_PATH=./leap/LeapSDK +ARCH=$(uname -m | sed -e 's/x86_64/x64/') +SWIG=swig + +[ -f ./LeapSDK.tar.gz ] || wget -O LeapSDK.tar.gz http://warehouse.leapmotion.com/apps/4185/download/ +mkdir -p leap +tar xvf LeapSDK.tar.gz -C leap --strip-components 1 +cp -r ${SDK_PATH}/include ./include +wget http://tinyurl.com/leap-i-patch -O Leap.i.diff +patch -p0 < Leap.i.diff +[ ! -z "$(type -p "swig-3")" ] && SWIG=swig-3 +[ ! -z "$(type -p "swig3.0")" ] && SWIG=swig3.0 + +${SWIG} -c++ -python -o LeapPython.cpp -interface LeapPython ./include/Leap.i +g++ -fPIC $(pkg-config --cflags --libs python3) -I${SDK_PATH}/include LeapPython.cpp ${SDK_PATH}/lib/${ARCH}/libLeap.so -shared -o LeapPython.so +