-%if "%{?profile}" == "mobile"
-%global PREFIX /usr/ug
-%endif
-
-%if "%{?profile}" == "wearable"
-%global PREFIX %{_prefix}/apps/org.tizen.nfc-setting-app/
-%endif
-
-%if "%{?profile}" == "tv"
-ExcludeArch: %{arm} %ix86 x86_64
-%endif
-
-%if "%{?profile}" == "common"
-%global PREFIX /usr/ug
-%endif
-
Name: ug-nfc-efl
Summary: NFC Setting UI
Version: 3.1.6
License: Flora-1.1
Source0: %{name}-%{version}.tar.gz
-%if "%{?profile}" == "mobile"
+
BuildRequires: pkgconfig(ui-gadget-1)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(capi-content-mime-type)
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(notification)
-%endif
-%if "%{?profile}" == "wearable"
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(syspopup)
-%endif
-
-%if "%{?profile}" == "common"
-BuildRequires: pkgconfig(ui-gadget-1)
-BuildRequires: pkgconfig(notification)
-BuildRequires: pkgconfig(capi-content-mime-type)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(notification)
-%endif
BuildRequires: pkgconfig(capi-network-nfc)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: gettext-tools
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
+Requires: %{name}-compat = %{version}-%{release}
+Recommends: %{name}-profile_common = %{version}-%{release}
%description
NFC Setting UI
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if common || tv || ivi || "undefined"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "mobile"
+%package profile_common
+Summary: NFC Setting UI for Common (+TV, +IVI)
+Provides: %{name}-compat = %{version}-%{release}
+Provides: %{name}-profile_tv = %{version}-%{release}
+Provides: %{name}-profile_ivi = %{version}-%{release}
+Conflicts: %{name}-profile_mobile
+Conflicts: %{name}-profile_wearable
+Requires: %{name}-resource_common
+%description profile_common
+NFC Setting UI for common profile. TV/IVI profile may share this if needed.
+Note that as of 2016/10/07, TV/IVI do not include ug-nfc-efl.
+But, for future usage, we assume that they will be based on this profile
+if someone adds ug-nfc-efl for TV/IVI.
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if wearable || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "mobile" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+%package profile_wearable
+Summary: NFC Setting UI for Wearable
+Provides: %{name}-compat = %{version}-%{release}
+Conflicts: %{name}-profile_mobile
+Conflicts: %{name}-profile_common
+%description profile_wearable
+NFC Setting UI for wearable profile.
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if mobile || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+%package profile_mobile
+Summary: NFC Setting UI for Mobile
+Provides: %{name}-compat = %{version}-%{release}
+Conflicts: %{name}-profile_wearable
+Conflicts: %{name}-profile_common
+Requires: %{name}-resource_common
+%description profile_mobile
+NFC Setting UI for mobile profile.
+Note that againve wearable, only the .so is different.
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if wearable || "undefined"
+%if "%{?profile}" != "wearable"
+%package resource_common
+Summary: NFC Setting UI Resource for Common/Mobile/TV/IVI
+%description resource_common
+Common resource files of common and mobile.
+%endif
+
%prep
%setup -q
%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} \
-%if "%{?profile}" == "mobile"
- -DTIZEN_MOBILE=1
-%endif
-%if "%{?profile}" == "wearable"
- -DTIZEN_WEARABLE=1
-%endif
-%if "%{?profile}" == "common"
- -DTIZEN_COMMON=1
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if mobile || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+# reinstall (ln -sf) /usr/ug/mobile to /usr/ug at post
+mkdir -p mobile
+pushd mobile
+
+cmake .. -DCMAKE_INSTALL_PREFIX=/usr/ug/mobile -DTIZEN_MOBILE=1
+make %{?jobs:-j%jobs}
+%make_install
+
+popd
+mkdir -p mobile_ins
+mv %{buildroot}/usr/ug/mobile/* mobile_ins/
%endif
+mkdir -p common
+pushd common
+
+# reinstall (ln -sf) /usr/ug/common to /usr/ug at post
+cmake .. -DCMAKE_INSTALL_PREFIX=/usr/ug/common -DTIZEN_COMMON=1
make %{?jobs:-j%jobs}
+%make_install
-%install
+popd
+mkdir -p common_ins
+mkdir -p common_ins/packages
+mv %{buildroot}/usr/ug/common/* common_ins/
+mv %{buildroot}/usr/share/packages/* common_ins/packages/
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if wearable || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "mobile" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+mkdir -p wearable
+pushd wearable
+cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix}/apps/org.tizen.nfc-setting-app/ -DTIZEN_WEARABLE=1
+make %{?jobs:-j%jobs}
%make_install
+popd
+mkdir -p wearable_ins
+mv %{buildroot}/%{_prefix}/apps/org.tizen.nfc-setting-app/* wearable_ins/
+%endif
+
+%install
mkdir -p %{buildroot}/usr/share/license
cp -af %{_builddir}/%{name}-%{version}/LICENSE.Flora %{buildroot}/usr/share/license/
+mkdir -p %{buildroot}/usr/share/packages
+mv common_ins/packages/* %{buildroot}/usr/share/packages/
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if common || tv || ivi || "undefined"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "mobile"
+mkdir -p %{buildroot}/usr/ug/common
+mv common_ins/lib %{buildroot}/usr/ug/common/
+
+# resource from common == resource from mobile
+mv common_ins/res %{buildroot}/usr/ug/
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if mobile || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+mkdir -p %{buildroot}/usr/ug/mobile
+mv mobile_ins/lib %{buildroot}/usr/ug/mobile/
+
+# resource from common == resource from mobile
+mv common_ins/res %{buildroot}/usr/ug/
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if wearable || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "mobile" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+mkdir -p %{buildroot}/%{_prefix}/apps/org.tizen.nfc-setting-app
+mv wearable_ins/* %{buildroot}/%{_prefix}/apps/org.tizen.nfc-setting-app/
+%endif
+
%post
/sbin/ldconfig
%postun -p /sbin/ldconfig
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if common || tv || ivi || "undefined"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "mobile"
+%post profile_common
+mkdir -p /usr/ug/lib
+ln -sf /usr/ug/common/lib/libug-nfc-efl* /usr/ug/lib/
+
+%preun profile_common
+rm /usr/ug/lib/libug-nfc-efl*
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if mobile || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+%post profile_mobile
+mkdir -p /usr/ug/lib
+ln -sf /usr/ug/mobile/lib/libug-nfc-efl* /usr/ug/lib/
+
+%preun profile_mobile
+rm /usr/ug/lib/libug-nfc-efl*
+%endif
+
%files
%defattr(-,root,root,-)
%{_datadir}/license/LICENSE.Flora
%{_datadir}/packages/*
-%{PREFIX}/*
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if common || tv || ivi || "undefined"
+%if "%{?profile}" != "wearable" && "%{?profile}" != "mobile"
+%files profile_common
+/usr/ug/common/lib/*
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if mobile || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+%files profile_mobile
+/usr/ug/mobile/lib/*
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if wearable || "undefined"
+%if "%{?profile}" != "common" && "%{?profile}" != "mobile" && "%{?profile}" != "tv" && "%{?profile}" != "ivi"
+%files profile_wearable
+%{_prefix}/apps/org.tizen.nfc-setting-app/*
+%endif
+
+# This is for backward-compatibility. This does not deteriorate 4.0 Configurability
+# if common || mobile || tv || ivi || "undefined"
+%if "%{?profile}" != "wearable"
+%files resource_common
+/usr/ug/res/*
+%endif