summaryrefslogtreecommitdiff
path: root/libopenni2-dev.spec
blob: 22b1a30d426f337d8d9b48f9c36d864defdaf3b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# OpenNI 2 is built with its own Makefile-based build system (no CMake/Meson).
# The upstream platform detection only knows x86 / x86_64 / arm32 and errors
# out on aarch64; Patch0 adds the aarch64 (Arm64) platform with neutral,
# SSE-free flags so the library and drivers build natively on aarch64.
#
# topdir: libopenni2-dev-2.2.0

Name:           libopenni2-dev
Version:        2.2.0
Release:        2%{?dist}
Summary:        OpenNI 2 framework for 3D sensors (development package)

License:        Apache-2.0
URL:            https://github.com/occipital/OpenNI2
%global commit0 3b787cc8b06e4129d1c5d7daf99e04413ac42266
Source0:        https://github.com/occipital/OpenNI2/archive/%{commit0}/OpenNI2-%{commit0}.tar.gz#/%{name}-%{version}.tar.gz
Patch0:         aarch64-support.patch

Group:          Development/Libraries
Packager:       openEuler Builder <builder@openeuler.org>

BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  make
BuildRequires:  libusbx-devel
BuildRequires:  systemd-devel

Requires:       libusbx%{?_isa}
Requires:       systemd-libs%{?_isa}

%description
OpenNI 2 is a framework for acquiring, processing and understanding the output
of 3D sensors (depth and RGB). It exposes a C and C++ API for depth and color
streams, device enumeration, recording and playback.

This package is the ROS-bundled development package: it ships the core runtime
library (libOpenNI2.so), the bundled device-driver plugins and the public C/C++
headers, so that dependent packages can build against OpenNI 2.

%prep
%autosetup -p1

%build
# The upstream Makefile has no "install" target and only knows x86/x86_64/
# arm32; Patch0 makes aarch64 (Arm64) a supported native platform (no SSE,
# no -march flags; NEON fast paths fall back to the scalar reference code).
#
# Build order matters because the top-level Makefile only declares the
# cross-project dependency graph for its aggregate targets: XnLib (static
# helper) must be built first, then DepthUtils (static), then the core
# libOpenNI2.so, and finally the four device-driver plugins. Each stage is
# a separate make invocation so -j cannot reorder the stages.
#
# The Java wrapper, the GLUT-based NiViewer tool and the samples are
# intentionally not built: they would pull in a JDK and freeglut which this
# library package does not need.
export ALLOW_WARNINGS=1
make %{?_smp_mflags} ThirdParty/PSCommon/XnLib/Source
make %{?_smp_mflags} Source/DepthUtils
make %{?_smp_mflags} Source/Core
make %{?_smp_mflags} \
    Source/Drivers/DummyDevice \
    Source/Drivers/OniFile \
    Source/Drivers/PS1080 \
    Source/Drivers/PSLink

%install
# No upstream "make install" target exists; install the produced artefacts
# by hand. The build system names output directories after the auto-detected
# platform (Arm64 on aarch64, x64 on x86_64), so locate the built tree
# generically instead of hard-coding an architecture.
BUILD_OUT=$(ls -d Bin/*-Release 2>/dev/null | head -n1)

# Core shared library linked by every application using OpenNI 2.
install -d %{buildroot}%{_libdir}
install -p -m 0755 "$BUILD_OUT"/libOpenNI2.so %{buildroot}%{_libdir}/

# Device drivers are dlopen()'d at runtime. libOpenNI2.so looks for them in
# <directory-of-libOpenNI2.so>/OpenNI2/Drivers (ONI_DEFAULT_DRIVERS_REPOSITORY),
# so that is where they must live.
install -d %{buildroot}%{_libdir}/OpenNI2/Drivers
install -p -m 0755 "$BUILD_OUT"/OpenNI2/Drivers/*.so \
    %{buildroot}%{_libdir}/OpenNI2/Drivers/

# Public C/C++ headers (Debian/ROS layout: /usr/include/openni2/).
install -d %{buildroot}%{_includedir}/openni2
install -p -m 0644 Include/*.h %{buildroot}%{_includedir}/openni2/

%files
%license LICENSE
%doc README.md CHANGES.txt ReleaseNotes.txt NOTICE
%{_libdir}/libOpenNI2.so
%{_libdir}/OpenNI2/Drivers/
%{_includedir}/openni2/

%changelog
* Thu Sep 24 2026 openEuler Builder <builder@openeuler.org> - 2.2.0-2
- Extend aarch64-support.patch: route __aarch64__ in XnPlatform.h to the
  arch-neutral Linux-x86 platform header so the C++ build no longer hits
  '#error Unsupported Platform' and the XnChar/XnUInt32/XnUInt64 typedefs
  resolve. The original patch only taught the Makefile build system about
  aarch64 (CommonDefs.mak + Platform.Arm64); the C++ header still fell
  through to the unsupported-platform #error.

* Thu Sep 24 2026 openEuler Builder <builder@openeuler.org> - 2.2.0-1
- Initial package of OpenNI 2.2.0 for openEuler (aarch64 native build)