From 8662bb34884e5be291893d33b2000e69de4c6b06 Mon Sep 17 00:00:00 2001 From: Jakub Bogusz Date: Tue, 29 Jul 2014 16:28:49 +0200 Subject: [PATCH] - new, based on OpenNI - added link patch - added norpath,paths,soname patches from Debian (soname patch with jni part disabled) --- OpenNI2-link.patch | 11 ++ OpenNI2-norpath.patch | 11 ++ OpenNI2-nosse.patch | 10 ++ OpenNI2-paths.patch | 11 ++ OpenNI2-soname.patch | 77 +++++++++++++ OpenNI2-system-libs.patch | 84 ++++++++++++++ OpenNI2.spec | 233 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 437 insertions(+) create mode 100644 OpenNI2-link.patch create mode 100644 OpenNI2-norpath.patch create mode 100644 OpenNI2-nosse.patch create mode 100644 OpenNI2-paths.patch create mode 100644 OpenNI2-soname.patch create mode 100644 OpenNI2-system-libs.patch create mode 100644 OpenNI2.spec diff --git a/OpenNI2-link.patch b/OpenNI2-link.patch new file mode 100644 index 0000000..2f27332 --- /dev/null +++ b/OpenNI2-link.patch @@ -0,0 +1,11 @@ +--- OpenNI2-2.2-beta2/Source/Tools/NiViewer/Makefile.orig 2013-11-12 15:12:23.000000000 +0100 ++++ OpenNI2-2.2-beta2/Source/Tools/NiViewer/Makefile 2014-07-28 17:18:07.639029694 +0200 +@@ -26,7 +26,7 @@ + endif + + LIB_DIRS += ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) +-USED_LIBS += OpenNI2 XnLib ++USED_LIBS += OpenNI2 XnLib pthread + + EXE_NAME = NiViewer + diff --git a/OpenNI2-norpath.patch b/OpenNI2-norpath.patch new file mode 100644 index 0000000..beb4591 --- /dev/null +++ b/OpenNI2-norpath.patch @@ -0,0 +1,11 @@ +--- a/ThirdParty/PSCommon/BuildSystem/CommonCppMakefile ++++ b/ThirdParty/PSCommon/BuildSystem/CommonCppMakefile +@@ -97,7 +97,7 @@ + ifneq "$(EXE_NAME)" "" + OUTPUT_NAME = $(EXE_NAME) + # We want the executables to look for the .so's locally first: +- LDFLAGS += -Wl,-rpath ./ ++ # LDFLAGS += -Wl,-rpath ./ + OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) + endif + ifneq "$(SLIB_NAME)" "" diff --git a/OpenNI2-nosse.patch b/OpenNI2-nosse.patch new file mode 100644 index 0000000..ba6e328 --- /dev/null +++ b/OpenNI2-nosse.patch @@ -0,0 +1,10 @@ +--- OpenNI2-2.2-beta2/ThirdParty/PSCommon/BuildSystem/Platform.x86.orig 2013-11-12 15:12:23.000000000 +0100 ++++ OpenNI2-2.2-beta2/ThirdParty/PSCommon/BuildSystem/Platform.x86 2014-07-27 18:09:19.649193305 +0200 +@@ -19,7 +19,5 @@ + ifeq ($(SSSE3_ENABLED), 1) + CFLAGS += -mssse3 + endif +- else +- DUMMY:=($error "Only SSE2 and SSE3 are supported") + endif + endif diff --git a/OpenNI2-paths.patch b/OpenNI2-paths.patch new file mode 100644 index 0000000..3752f5a --- /dev/null +++ b/OpenNI2-paths.patch @@ -0,0 +1,11 @@ +--- a/Source/Tools/NiViewer/NiViewer.cpp ++++ b/Source/Tools/NiViewer/NiViewer.cpp +@@ -96,7 +96,7 @@ + // -------------------------------- + // Defines + // -------------------------------- +-#define SAMPLE_XML_PATH "../../../../Data/SamplesConfig.xml" ++#define SAMPLE_XML_PATH "/etc/openni2/SamplesConfig.xml" + + // -------------------------------- + // Types diff --git a/OpenNI2-soname.patch b/OpenNI2-soname.patch new file mode 100644 index 0000000..0e6f4d9 --- /dev/null +++ b/OpenNI2-soname.patch @@ -0,0 +1,77 @@ +--- a/ThirdParty/PSCommon/BuildSystem/CommonCppMakefile ++++ b/ThirdParty/PSCommon/BuildSystem/CommonCppMakefile +@@ -83,8 +83,13 @@ + OUTPUT_NAME = lib$(LIB_NAME).so + ifneq ("$(OSTYPE)","Darwin") + LDFLAGS += -Wl,--no-undefined +- OUTPUT_NAME = lib$(LIB_NAME).so +- OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared ++ ifeq "$(LIB_NAME_SOVERSION)" "" ++ OUTPUT_NAME = lib$(LIB_NAME).so ++ OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared ++ else ++ OUTPUT_NAME = lib$(LIB_NAME).so.$(LIB_NAME_SOVERSION) ++ OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS) -shared -Wl,-soname,${OUTPUT_NAME} && cd ${OUT_DIR} && ln -fs ${OUTPUT_NAME} lib$(LIB_NAME).so ++ endif + else + LDFLAGS += -undefined error + OUTPUT_NAME = lib$(LIB_NAME).dylib +--- a/Packaging/Harvest.py ++++ b/Packaging/Harvest.py +@@ -45,12 +45,25 @@ + self.platformSuffix = '64' + self.glutSuffix = '64' + ++ def debianCopySharedObject(self, sourceDir, name, targetDir): ++ # shutil.copy(os.path.join(sourceDir, 'lib' + name + '.so'), targetDir) ++ lastFile = '' ++ for f in os.listdir(sourceDir): ++ match = re.search('lib' + name + '\.so\.[0-9\.]+',f) ++ if match: ++ shutil.copy(os.path.join(sourceDir , f), targetDir) ++ lastFile = f ++ if len(lastFile) == 0: ++ shutil.copy(os.path.join(sourceDir, 'lib' + name + '.so'),targetDir) ++ else: ++ os.symlink(lastFile,os.path.join(targetDir,'lib' + name + '.so')) ++ + def copySharedObject(self, sourceDir, name, targetDir): + if self.osName == 'Windows': + shutil.copy(os.path.join(sourceDir, name + '.dll'), targetDir) + shutil.copy(os.path.join(sourceDir, name + '.pdb'), targetDir) + elif self.osName == 'Linux': +- shutil.copy(os.path.join(sourceDir, 'lib' + name + '.so'), targetDir) ++ self.debianCopySharedObject(sourceDir, name, targetDir) + elif self.osName == 'Darwin': + shutil.copy(os.path.join(sourceDir, 'lib' + name + '.dylib'), targetDir) + else: +--- a/Source/Core/Makefile ++++ b/Source/Core/Makefile +@@ -19,8 +19,12 @@ + LDFLAGS += -framework CoreFoundation -framework IOKit + endif + +-LIB_NAME = OpenNI2 ++MAJOR_VERSION = $(shell grep "define ONI_VERSION_MAJOR" ../../Include/OniVersion.h | cut -f 2) ++MINOR_VERSION = $(shell grep "define ONI_VERSION_MINOR" ../../Include/OniVersion.h | cut -f 2) ++ + ++LIB_NAME = OpenNI2 ++LIB_NAME_SOVERSION=$(MAJOR_VERSION).$(MINOR_VERSION) + LIB_DIRS = ../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) + USED_LIBS = XnLib dl pthread + ifneq ("$(OSTYPE)","Darwin") +#--- a/Wrappers/java/OpenNI.jni/Makefile +#+++ b/Wrappers/java/OpenNI.jni/Makefile +#@@ -13,6 +13,11 @@ +# +# LIB_NAME = OpenNI2.jni +# +#+MAJOR_VERSION = $(shell grep "define ONI_VERSION_MAJOR" ../../../Include/OniVersion.h | cut -f 2) +#+MINOR_VERSION = $(shell grep "define ONI_VERSION_MINOR" ../../../Include/OniVersion.h | cut -f 2) +#+ +#+LIB_NAME_SOVERSION=$(MAJOR_VERSION).$(MINOR_VERSION) +#+ +# CFLAGS += -Wall +# +# include ../../../ThirdParty/PSCommon/BuildSystem/CommonCppMakefile diff --git a/OpenNI2-system-libs.patch b/OpenNI2-system-libs.patch new file mode 100644 index 0000000..23ee3a3 --- /dev/null +++ b/OpenNI2-system-libs.patch @@ -0,0 +1,84 @@ +--- OpenNI2-2.2-beta2/Source/Core/Makefile.orig 2013-11-12 15:12:23.000000000 +0100 ++++ OpenNI2-2.2-beta2/Source/Core/Makefile 2014-07-27 18:11:46.955853790 +0200 +@@ -5,14 +5,12 @@ + INC_DIRS = \ + ../../Include \ + ../../ThirdParty/PSCommon/XnLib/Include \ +- ../Drivers/OniFile/Formats \ +- ../../ThirdParty/LibJPEG ++ ../Drivers/OniFile/Formats + + SRC_FILES = \ + *.cpp \ + ../Drivers/OniFile/Formats/XnCodec.cpp \ +- ../Drivers/OniFile/Formats/XnStreamCompression.cpp \ +- ../../ThirdParty/LibJPEG/*.c \ ++ ../Drivers/OniFile/Formats/XnStreamCompression.cpp + + ifeq ("$(OSTYPE)","Darwin") + INC_DIRS += /opt/local/include +@@ -23,7 +21,7 @@ + LIB_NAME = OpenNI2 + + LIB_DIRS = ../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) +-USED_LIBS = XnLib dl pthread ++USED_LIBS = XnLib jpeg dl pthread + ifneq ("$(OSTYPE)","Darwin") + USED_LIBS += rt + endif +--- OpenNI2-2.2-beta2/Source/Drivers/OniFile/Makefile.orig 2013-11-12 15:12:23.000000000 +0100 ++++ OpenNI2-2.2-beta2/Source/Drivers/OniFile/Makefile 2014-07-27 18:12:32.599185209 +0200 +@@ -6,14 +6,12 @@ + . \ + ../../../Include \ + ../../../ThirdParty/PSCommon/XnLib/Include \ +- ../../../ThirdParty/LibJPEG \ + Formats + + SRC_FILES = \ + *.cpp \ + Formats/*.cpp \ +- XnLibExtensions/*.cpp \ +- ../../../ThirdParty/LibJPEG/*.c ++ XnLibExtensions/*.cpp + + + ifeq ("$(OSTYPE)","Darwin") +@@ -25,7 +23,7 @@ + LIB_NAME = OniFile + + LIB_DIRS = ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) +-USED_LIBS = XnLib pthread ++USED_LIBS = XnLib jpeg pthread + ifneq ("$(OSTYPE)","Darwin") + USED_LIBS += rt + endif +--- OpenNI2-2.2-beta2/Source/Drivers/PS1080/Makefile.orig 2013-11-12 15:12:23.000000000 +0100 ++++ OpenNI2-2.2-beta2/Source/Drivers/PS1080/Makefile 2014-07-27 18:12:55.702517573 +0200 +@@ -7,7 +7,6 @@ + Include \ + ../../../Include \ + ../../../ThirdParty/PSCommon/XnLib/Include \ +- ../../../ThirdParty/LibJPEG \ + ../../DepthUtils + + SRC_FILES = \ +@@ -16,8 +15,7 @@ + DriverImpl/*.cpp\ + Formats/*.cpp \ + Include/*.cpp \ +- Sensor/*.cpp \ +- ../../../ThirdParty/LibJPEG/*.c ++ Sensor/*.cpp + + + ifeq ("$(OSTYPE)","Darwin") +@@ -30,7 +28,7 @@ + + LIB_DIRS += ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) + LIB_DIRS += $(BIN_DIR)/$(PLATFORM)-$(CFG) +-USED_LIBS = XnLib dl pthread DepthUtils ++USED_LIBS = XnLib dl pthread DepthUtils jpeg + ifneq ("$(OSTYPE)","Darwin") + USED_LIBS += rt usb-1.0 udev + else diff --git a/OpenNI2.spec b/OpenNI2.spec new file mode 100644 index 0000000..109a08e --- /dev/null +++ b/OpenNI2.spec @@ -0,0 +1,233 @@ +# +# Conditional build: +%bcond_without apidocs # API documentation +%bcond_without java # Java wrappers +%bcond_with sse2 # use SSE2 instructions +%bcond_with sse3 # use SSE3 instructions +%bcond_with ssse3 # use SSE3 and SSSE3 instructions + +%if %{with ssse3} +%define with_sse3 1 +%endif +Summary: OpenNI2 framework for Natural Interaction devices +Summary(pl.UTF-8): Szkielet OpenNI2 do urządzeń służących interakcji z naturą +Name: OpenNI2 +Version: 2.2.0.33 +%define subver beta2 +Release: 0.%{subver}.1 +License: Apache v2.0 +Group: Libraries +Source0: https://github.com/occipital/OpenNI2/archive/2.2-%{subver}/%{name}-%{version}.tar.gz +# Source0-md5: 3f2cd6a64776821fb2837c442539f65b +Patch0: %{name}-system-libs.patch +Patch1: %{name}-nosse.patch +Patch2: %{name}-link.patch +Patch3: %{name}-paths.patch +Patch4: %{name}-soname.patch +Patch5: %{name}-norpath.patch +URL: http://structure.io/openni +BuildRequires: OpenGL-devel +BuildRequires: OpenGL-glut-devel >= 3 +%{?with_apidocs:BuildRequires: doxygen} +%{?with_apidocs:BuildRequires: graphviz} +%{?with_java:BuildRequires: jdk >= 1.6.0} +BuildRequires: libjpeg-devel +BuildRequires: libstdc++-devel >= 6:4.0 +BuildRequires: libusb-devel >= 1.0.8 +BuildRequires: python >= 1:2.6 +BuildRequires: rpmbuild(macros) >= 1.566 +BuildRequires: sed >= 4.0 +BuildRequires: udev-devel +# NOTE: other platforms need adding a dozen of defines in Include/Linux-*/*.h +ExclusiveArch: %{ix86} %{x8664} arm +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%ifarch %{ix86} +%define openni_platform x86 +%endif +%ifarch %{x8664} +%define openni_platform x64 +%endif +%ifarch arm +%define openni_platform Arm +%endif + +%description +OpenNI2 framework provides an application programming interface (API) +for writing applications utilizing natural interaction. This API +covers communication with both low level devices (e.g. vision and +audio sensors), as well as high-level middleware solutions (e.g. for +visual tracking using computer vision). + +The OpenNI2 Framework provides the interface for physical devices and +for middleware components. The API enables modules to be registered in +the OpenNI2 framework and used to produce sensory data. Selecting the +hardware or middleware module is easy and flexible. + +%description -l pl.UTF-8 +Szkielet OpenNI2 zapewnia interfejs programistyczny (API) dla +aplikacji wykorzystujących interakcję z naturą. API to pokrywa +komunikację zarówno z urządzeniami niskiego poziomu (takimi jak +czujniki obrazu i dźwięku), jak i rozwiązaniami wysokiego poziomu +warstwy pośredniej (np. do wizualnego śledzenia przy użyciu obrazu +komputerowego). + +Szkielet OpenNI2 zapewnia interfejs dla fizycznych urządzeń oraz +komponentów warstwy pośredniej. API pozwala na rejestrowanie modułów w +szkielecie OpenNI2 i wykorzystywanie do tworzenia danych +sensorycznych. Wybór sprzętu i modułu pośredniego jest prosty i +elastyczny. + +%package devel +Summary: Header files for OpenNI2 library +Summary(pl.UTF-8): Pliki nagłówkowe biblioteki OpenNI2 +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Header files for OpenNI2 library. + +%description devel -l pl.UTF-8 +Pliki nagłówkowe biblioteki OpenNI2. + +%package apidocs +Summary: OpenNI2 API documentation +Summary(pl.UTF-8): Dokumentacja API biblioteki OpenNI2 +Group: Documentation +%if "%{_rpmversion}" >= "5" +BuildArch: noarch +%endif + +%description apidocs +API and internal documentation for OpenNI2 library. + +%description apidocs -l pl.UTF-8 +Dokumentacja API biblioteki OpenNI2. + +%package -n java-OpenNI2 +Summary: Java wrapper for OpenNI2 +Summary(pl.UTF-8): Interfejs Javy do OpenNI2 +Group: Libraries/Java +Requires: %{name} = %{version}-%{release} +Requires: jpackage-utils +Requires: jre >= 1.6.0 + +%description -n java-OpenNI2 +Java wrapper for OpenNI2. + +%description -n java-OpenNI2 -l pl.UTF-8 +Interfejs Javy do OpenNI2. + +%prep +%setup -q -n %{name}-2.2-%{subver} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 + +%build +export CFLAGS="%{rpmcflags} -Wno-unused-local-typedefs -Wno-enum-compare" +%{__make} \ + CFG=Release \ + CXX="%{__cxx}" \ + HOSTPLATFORM=%{openni_platform} \ + SSE_GENERATION=%{?with_sse3:3}%{!?with_sse3:%{?with_sse2:2}} \ + %{?with_ssse3:SSSE3_ENABLED=1} \ + %{!?with_java:ALL_JAVA_PROJS= JAVA_SAMPLES=} + +%if %{with apidocs} +cd Source/Documentation +doxygen Doxyfile +%if %{with java} +javadoc -d java $(find ../../Wrappers/java/OpenNI.java/src/org/openni -type f) +%endif +%endif + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/OpenNI2/Drivers,%{_pkgconfigdir},%{_includedir}/openni2,/lib/udev/rules.d} + +# upstream "install" - no FHS support +#Packaging/Harvest.py $RPM_BUILD_ROOT %{openni_platform} + +BDIR=Bin/%{openni_platform}-Release +install -p ${BDIR}/{NiViewer,PS1080Console,PSLinkConsole} $RPM_BUILD_ROOT%{_bindir} +cp -dpr ${BDIR}/libOpenNI2.so* $RPM_BUILD_ROOT%{_libdir} +cp -p Config/OpenNI.ini $RPM_BUILD_ROOT%{_libdir} +install -p ${BDIR}/OpenNI2/Drivers/*.so $RPM_BUILD_ROOT%{_libdir}/OpenNI2/Drivers +cp -p Config/OpenNI2/Drivers/*.ini $RPM_BUILD_ROOT%{_libdir}/OpenNI2/Drivers +cp -p Packaging/Linux/primesense-usb.rules $RPM_BUILD_ROOT/lib/udev/rules.d/55-primesense-usb.rules +cp -p Include/*.h $RPM_BUILD_ROOT%{_includedir}/openni2 +cp -pr Include/Driver $RPM_BUILD_ROOT%{_includedir}/openni2 +%ifarch %{ix86} %{x8664} +cp -pr Include/Linux-x86 $RPM_BUILD_ROOT%{_includedir}/openni2 +%endif +%ifarch arm +cp -pr Include/Linux-Arm $RPM_BUILD_ROOT%{_includedir}/openni2 +%endif + +cat >$RPM_BUILD_ROOT%{_pkgconfigdir}/libopenni2.pc <<'EOF' +prefix=%{_prefix} +libdir=%{_libdir} +includedir=%{_includedir}/openni2 + +Name: OpenNI2 +Description: A general purpose driver for all OpenNI cameras. +Version: %{version}-%{subver} +Cflags: -I${includedir} +Libs: -L${libdir} -lOpenNI2 +EOF + +%if %{with java} +install -d $RPM_BUILD_ROOT%{_javadir} +install -p ${BDIR}/libOpenNI2.jni.so $RPM_BUILD_ROOT%{_libdir} +cp -p ${BDIR}/org.openni.jar $RPM_BUILD_ROOT%{_javadir} +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%post -n java-OpenNI2 -p /sbin/ldconfig +%postun -n java-OpenNI2 -p /sbin/ldconfig + +%files +%defattr(644,root,root,755) +%doc CHANGES.txt NOTICE README ReleaseNotes.txt +%attr(755,root,root) %{_bindir}/NiViewer +%attr(755,root,root) %{_bindir}/PS1080Console +%attr(755,root,root) %{_bindir}/PSLinkConsole +%attr(755,root,root) %{_libdir}/libOpenNI2.so.*.* +%{_libdir}/OpenNI.ini +%dir %{_libdir}/OpenNI2 +%dir %{_libdir}/OpenNI2/Drivers +%attr(755,root,root) %{_libdir}/OpenNI2/Drivers/libDummyDevice.so +%attr(755,root,root) %{_libdir}/OpenNI2/Drivers/libOniFile.so +%attr(755,root,root) %{_libdir}/OpenNI2/Drivers/libPS1080.so +%attr(755,root,root) %{_libdir}/OpenNI2/Drivers/libPSLink.so +%{_libdir}/OpenNI2/Drivers/PS1080.ini +%{_libdir}/OpenNI2/Drivers/PSLink.ini +/lib/udev/rules.d/55-primesense-usb.rules + +%files devel +%defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/libOpenNI2.so +%{_includedir}/openni2 +%{_pkgconfigdir}/libopenni2.pc + +%if %{with apidocs} +%files apidocs +%defattr(644,root,root,755) +%doc Source/Documentation/html/*.{bmp,css,html,js,png} +%endif + +%if %{with java} +%files -n java-OpenNI2 +%defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/libOpenNI2.jni.so +%{_javadir}/org.openni.jar +%endif -- 2.44.0