From f11c8745f56a088fe292288854631f30a646907a Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 15:11:02 +0200 Subject: [PATCH 1/6] Add a reasonable .gitignore Some editor temporary files and autogenerated files are excluded --- .gitignore | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6e88f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*~ +Release/ +/Source/DoxyGen/html +/Platform/Linux-x86/Bin +/Platform/Linux-x86/CreateRedist/Final +/Platform/Linux-x86/CreateRedist/Output +/Platform/Linux-x86/Redist +/Platform/Linux-x86/Build -- 1.7.6 From 4c0e14f36b2f2159b059f3b9acc502a2387a7bde Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 16:03:20 +0200 Subject: [PATCH 2/6] Added missing link lib GL Samples were not linked against GL. Symbols of GL are used directly, but linking happens only indirectly. This is forbidden on Fedora. --- .../Build/Samples/NiSimpleViewer/Makefile | 2 +- .../Linux-x86/Build/Samples/NiUserTracker/Makefile | 2 +- Platform/Linux-x86/Build/Samples/NiViewer/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Platform/Linux-x86/Build/Samples/NiSimpleViewer/Makefile b/Platform/Linux-x86/Build/Samples/NiSimpleViewer/Makefile index 371eb11..944ed49 100644 --- a/Platform/Linux-x86/Build/Samples/NiSimpleViewer/Makefile +++ b/Platform/Linux-x86/Build/Samples/NiSimpleViewer/Makefile @@ -11,7 +11,7 @@ EXE_NAME = Sample-NiSimpleViewer ifeq ("$(OSTYPE)","Darwin") LDFLAGS += -framework OpenGL -framework GLUT else - USED_LIBS += glut + USED_LIBS += glut GL endif USED_LIBS += OpenNI diff --git a/Platform/Linux-x86/Build/Samples/NiUserTracker/Makefile b/Platform/Linux-x86/Build/Samples/NiUserTracker/Makefile index f5adf1c..5f53618 100644 --- a/Platform/Linux-x86/Build/Samples/NiUserTracker/Makefile +++ b/Platform/Linux-x86/Build/Samples/NiUserTracker/Makefile @@ -14,7 +14,7 @@ ifneq "$(GLES)" "1" ifeq ("$(OSTYPE)","Darwin") LDFLAGS += -framework OpenGL -framework GLUT else - USED_LIBS += glut + USED_LIBS += glut GL endif else DEFINES += USE_GLES diff --git a/Platform/Linux-x86/Build/Samples/NiViewer/Makefile b/Platform/Linux-x86/Build/Samples/NiViewer/Makefile index 8aca16e..15eed4c 100644 --- a/Platform/Linux-x86/Build/Samples/NiViewer/Makefile +++ b/Platform/Linux-x86/Build/Samples/NiViewer/Makefile @@ -11,7 +11,7 @@ SRC_FILES = ../../../../../Samples/NiViewer/*.cpp ifeq ("$(OSTYPE)","Darwin") LDFLAGS += -framework OpenGL -framework GLUT else - USED_LIBS += glut + USED_LIBS += glut GL endif USED_LIBS += OpenNI -- 1.7.6 From 7a74ded5a46261689d707e23ab8ee47232132126 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 16:06:32 +0200 Subject: [PATCH 3/6] Fix gcc typecast warnings for jni Make members of JNINativeMethod const in order to avoid recent gcc warnings. --- Wrappers/OpenNI.jni/jni.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Wrappers/OpenNI.jni/jni.h b/Wrappers/OpenNI.jni/jni.h index e11c681..e28ad31 100644 --- a/Wrappers/OpenNI.jni/jni.h +++ b/Wrappers/OpenNI.jni/jni.h @@ -160,9 +160,9 @@ typedef enum _jobjectType { */ typedef struct { - char *name; - char *signature; - void *fnPtr; + const char *name; + const char *signature; + const void *fnPtr; } JNINativeMethod; /* -- 1.7.6 From 63e342fef4e79c8eca5460cb4f3a063ab806b121 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 16:07:51 +0200 Subject: [PATCH 4/6] Make OpenNI coexist with kernel camera drivers Disconnect connected kernel drivers before claiming the interface. Code found in libfreenect, N.B: no check if kernel driver is currently in use! --- Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp b/Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp index 7e6bae6..0a7fe80 100644 --- a/Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp +++ b/Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp @@ -350,6 +350,16 @@ XN_C_API XnStatus xnUSBOpenDeviceImpl(libusb_device* pDevice, XN_USB_DEV_HANDLE* return (XN_STATUS_USB_SET_CONFIG_FAILED); } */ + // detach any active kernel driver, code extracted from libfreenect + rc = libusb_kernel_driver_active(handle, 0); + if (rc == 1) { + rc = libusb_detach_kernel_driver(handle, 0); + if (rc != 0) + { + libusb_close(handle); + return (XN_STATUS_USB_SET_INTERFACE_FAILED); + } + } // claim the interface (you cannot open any end point before claiming the interface) rc = libusb_claim_interface(handle, 0); if (rc != 0) @@ -463,7 +473,7 @@ XN_C_API XnStatus xnUSBCloseDevice(XN_USB_DEV_HANDLE pDevHandle) { return (XN_STATUS_USB_DEVICE_CLOSE_FAILED); } - + rc = libusb_attach_kernel_driver(pDevHandle->hDevice, 0); libusb_close(pDevHandle->hDevice); XN_FREE_AND_NULL(pDevHandle); -- 1.7.6 From a5dfb33ce02b3dc576c5f283c5007fe82a096a75 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 16:38:38 +0200 Subject: [PATCH 5/6] Use system wide libraries as default For Fedora, packages must use system-wide installed libraries and not rely on internally bundled ones. This change detects the availability of the system-wide version and uses the bundled one only as a fallback. --- .../Linux-x86/Build/Modules/nimCodecs/Makefile | 13 +++++++++---- Platform/Linux-x86/Build/OpenNI/Makefile | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Platform/Linux-x86/Build/Modules/nimCodecs/Makefile b/Platform/Linux-x86/Build/Modules/nimCodecs/Makefile index d416aa9..8213e87 100644 --- a/Platform/Linux-x86/Build/Modules/nimCodecs/Makefile +++ b/Platform/Linux-x86/Build/Modules/nimCodecs/Makefile @@ -2,16 +2,21 @@ BIN_DIR = ../../../Bin INC_DIRS = \ ../../../../../Include \ - ../../../../../Source \ - ../../../../../Source/External/LibJPEG + ../../../../../Source SRC_FILES = \ - ../../../../../Source/Modules/nimCodecs/*.cpp \ - ../../../../../Source/External/LibJPEG/*.c + ../../../../../Source/Modules/nimCodecs/*.cpp LIB_NAME = nimCodecs USED_LIBS = OpenNI +ifneq ($(wildcard /usr/lib/libjpeg.so /usr/lib32/libjpeg.so /usr/lib64/libjpeg.so /usr/local/lib/libjpeg.so /usr/local/lib32/libjpeg.so /usr/local/lib64/libjpeg.so),) + USED_LIBS += jpeg +else + INC_DIRS += ../../../../../Source/External/LibJPEG + SRC_FILES += ../../../../../Source/External/LibJPEG/*.c +endif + include ../../CommonCppMakefile diff --git a/Platform/Linux-x86/Build/OpenNI/Makefile b/Platform/Linux-x86/Build/OpenNI/Makefile index dfbb416..785df0a 100644 --- a/Platform/Linux-x86/Build/OpenNI/Makefile +++ b/Platform/Linux-x86/Build/OpenNI/Makefile @@ -4,13 +4,11 @@ BIN_DIR = ../../Bin INC_DIRS = \ ../../../../Include \ - ../../../../Source \ - ../../../../Source/External/TinyXml + ../../../../Source SRC_FILES = \ ../../../../Source/OpenNI/*.cpp \ - ../../../../Source/OpenNI/Linux-x86/*.cpp \ - ../../../../Source/External/TinyXml/*.cpp + ../../../../Source/OpenNI/Linux-x86/*.cpp ifeq ("$(OSTYPE)","Darwin") INC_DIRS += /opt/local/include @@ -25,6 +23,13 @@ ifneq ("$(OSTYPE)","Darwin") endif DEFINES = XN_EXPORTS +ifneq ($(wildcard /usr/include/tinyxml.h /usr/local/include/tinyxml.h),) + USED_LIBS += tinyxml +else + INC_DIRS += ../../../../Source/External/TinyXml + SRC_FILES += ../../../../Source/External/TinyXml/*.cpp +endif + include ../CommonCppMakefile -- 1.7.6 From 4e3aa14278588101d6c46c3f8c70e416437dd437 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 12 Aug 2011 16:44:23 +0200 Subject: [PATCH 6/6] Make it possible to omit module registration Module registration can be omitted. For packaging this needs to be after installation, not during compilation/installation. Allow overriding the INSTALL_* variables from the outside. --- Platform/Linux-x86/CreateRedist/install.sh | 86 +++++++++++++++++++--------- 1 files changed, 59 insertions(+), 27 deletions(-) diff --git a/Platform/Linux-x86/CreateRedist/install.sh b/Platform/Linux-x86/CreateRedist/install.sh index ef5484e..63d7498 100755 --- a/Platform/Linux-x86/CreateRedist/install.sh +++ b/Platform/Linux-x86/CreateRedist/install.sh @@ -8,6 +8,8 @@ Installs OpenNI to current machine. Installs OpenNI (default mode) -u,--uninstall Uninstalls OpenNI. +-n,--noregister + Do not (un)register the modules -c,--cross-compile-rootfs <path> Used for cross-compiling. Installs OpenNI to <path> instead of '/'. -h,--help @@ -45,6 +47,9 @@ while [ "$1" ]; do -u|--uninstall) uninstall=yes ;; + -n|--noregister) + register=no + ;; -c|--cross-staging-dir) shift rootfs=$1 @@ -65,17 +70,32 @@ if [ ! "$install" = yes ] && [ ! "$uninstall" = yes ]; then install=yes fi +# default mode is register +if [ ! "$register" = no ] ; then + register=yes +fi + # validity check if [ "$install" = yes ] && [ "$uninstall" = yes ]; then echo "-i and -u flags cannot be used together!" exit 1 fi -INSTALL_LIB=$rootfs/usr/lib -INSTALL_BIN=$rootfs/usr/bin -INSTALL_INC=$rootfs/usr/include/ni -INSTALL_VAR=$rootfs/usr/etc/ni -INSTALL_JAR=$rootfs/usr/share/java +if [ -z "$INSTALL_LIB" ]; then + INSTALL_LIB=$rootfs/usr/lib +fi +if [ -z "$INSTALL_BIN" ]; then + INSTALL_BIN=$rootfs/usr/bin +fi +if [ -z "$INSTALL_INC" ]; then + INSTALL_INC=$rootfs/usr/include/ni +fi +if [ -z "$INSTALL_VAR" ]; then + INSTALL_VAR=$rootfs/usr/etc/ni +fi +if [ -z "$INSTALL_JAR" ]; then + INSTALL_JAR=$rootfs/usr/share/java +fi # make all calls into OpenNI run in this filesystem export OPEN_NI_INSTALL_PATH=$rootfs @@ -86,6 +106,12 @@ if [ "$install" = yes ]; then printf "Installing OpenNI\n" printf "****************************\n\n" + mkdir -p $INSTALL_LIB + mkdir -p $INSTALL_BIN + mkdir -p $INSTALL_INC + mkdir -p $INSTALL_VAR + mkdir -p $INSTALL_JAR + # copy libraries printf "copying shared libraries..." cp $LIB_FILES $INSTALL_LIB @@ -107,17 +133,20 @@ if [ "$install" = yes ]; then mkdir -p $INSTALL_VAR printf "OK\n" - # register modules - for module in $MODULES; do - printf "registering module '$module'..." - $INSTALL_BIN/niReg -r $INSTALL_LIB/$module - printf "OK\n" - done + if [ "$register" = yes ]; then + # register modules + for module in $MODULES; do + printf "registering module '$module'..." + $INSTALL_BIN/niReg -r $INSTALL_LIB/$module + printf "OK\n" + done + fi - # mono - if [ -f $rootfs/usr/bin/gmcs ] - then - gacutil -i Bin/OpenNI.net.dll -package 2.0 $GACDIR + if [ "$register" = yes ]; then + # mono + if [ -f $rootfs/usr/bin/gmcs ] ; then + gacutil -i Bin/OpenNI.net.dll -package 2.0 $GACDIR + fi fi # java wrappers @@ -135,13 +164,15 @@ elif [ "$uninstall" = yes ]; then printf "Uninstalling OpenNI\n" printf "****************************\n\n" - # unregister modules - for module in $MODULES; do - printf "unregistering module '$module'..." - if $INSTALL_BIN/niReg -u $INSTALL_LIB/$module; then - printf "OK\n" - fi - done + if [ "$register" = yes ]; then + # unregister modules + for module in $MODULES; do + printf "unregistering module '$module'..." + if $INSTALL_BIN/niReg -u $INSTALL_LIB/$module; then + printf "OK\n" + fi + done + fi # include files printf "removing include files..." @@ -162,11 +193,12 @@ elif [ "$uninstall" = yes ]; then done printf "OK\n" - # mono - if [ -f $rootfs/usr/bin/gmcs ] - then - printf "Removing OpenNI.net: " - gacutil -u OpenNI.net $GACDIR + if [ "$register" = yes ]; then + # mono + if [ -f $rootfs/usr/bin/gmcs ] ; then + printf "Removing OpenNI.net: " + gacutil -u OpenNI.net $GACDIR + fi fi # java -- 1.7.6