Made installation more portable and robust against different name of the swig executable

This commit is contained in:
Fabio Manganiello 2020-08-15 15:20:18 +02:00
parent 97c784b3f7
commit 9c2194d1b0
2 changed files with 20 additions and 9 deletions

View File

@ -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__

19
build.sh Executable file
View File

@ -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