%prep
%setup -q -n %{name}-%{version} -a 10
-%build
+%define build_mode debug
+
+%define RPM_ARCH %{_arch}
+
+# overide arch if needed
%ifarch %arm
-export RPM_ARCH=arm
+%define RPM_ARCH arm
%else
%ifarch aarch64
-export RPM_ARCH=arm64
+%define RPM_ARCH arm64
%else
%ifarch i586 i686 %{ix86}
-export RPM_ARCH=x86
-%else
-export RPM_ARCH=%{_arch}
+%define RPM_ARCH x86
%endif
%endif
%endif
+%build
+
find . -iname "*.h*" -exec chmod -v a-x "{}" \;
-scons -j 4 TARGET_ARCH=$RPM_ARCH
+scons -j 4 TARGET_ARCH=%{RPM_ARCH}
%__make \
-C examples/OICMiddle \
- TARGET_ARCH=$RPM_ARCH
+ TARGET_ARCH=%{RPM_ARCH}
touch resource/deps resource/applyDepPatches
find . -iname "lib*.a" -exec install "{}" %{buildroot}%{_libdir}/ \;
find . -iname "lib*.so" -exec install "{}" %{buildroot}%{_libdir}/ \;
+find resource service -iname "include" -o -iname 'inc' -a -type d\
+ | while read include ; do \
+ dirname=$(dirname -- "$include") ; \
+ install -d %{buildroot}%{_includedir}/%{name}/${dirname} ; \
+ install $include/*.* %{buildroot}%{_includedir}/%{name}/${dirname}/ ; \
+ done
-install -d %{buildroot}%{_includedir}
-install -d %{buildroot}%{_includedir}/%{name}/
-install resource/include/*.h %{buildroot}%{_includedir}/%{name}/
-install service/things-manager/sdk/inc/*.h %{buildroot}%{_includedir}/%{name}/
-install service/soft-sensor-manager/SDK/cpp/include/*.h %{buildroot}%{_includedir}/%{name}/
-
-install -d %{buildroot}%{_bindir}
-install examples/OICMiddle/debug/OICMiddle %{buildroot}%{_bindir}
+install -d %{buildroot}%{_libdir}/%{name}/
+install examples/OICMiddle/%{build_mode}/OICMiddle %{buildroot}%{_libdir}/%{name}/examples/
rm -fv %{buildroot}%{_libdir}/libcoap.a
rm -fv %{buildroot}%{_libdir}/liboc.a
rm -fv %{buildroot}%{_libdir}/liboc_logger.a
rm -fv %{buildroot}%{_libdir}/libmosquitto.a
+
%clean
rm -rf %{buildroot}
%files devel
%defattr(644,root,root,755)
-%{_includedir}/*/*.h*
-%{_includedir}/*/*/*.h*
+%{_includedir}/%{name}/
%{_libdir}/lib*.a
%files examples
%defattr(-,root,root,-)
-%{_bindir}/OICMiddle
-%{_libdir}/%{name}/examples/*client*
-%{_libdir}/%{name}/examples/*server*
-%{_libdir}/%{name}/examples/*sample*
+%{_libdir}/%{name}/examples/*