export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%if %{with wayland}
+export CFLAGS="$CFLAGS -DWAYLAND"
+export CXXFLAGS="$CXXFLAGS -DWAYLAND"
+%endif
+
+ %if "%{profile}" == "wearable"
+ CFLAGS+=" -D_WEARABLE";
+ CXXFLAGS+=" -D_WEARABLE";
+ %endif
+
+ %if "%{profile}" == "mobile" || "%{profile}" == "common"
+ CFLAGS+=" -D_MOBILE";
+ CXXFLAGS+=" -D_MOBILE";
+ %endif
+
+ %if "%{profile}" == "tv"
+ CFLAGS+=" -D_TV -DENABLE_REMOTE_INPUT=1";
+ CXXFLAGS+=" -D_TV -DENABLE_REMOTE_INPUT=1";
+ %endif
+
+export GC_SECTIONS_FLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections"
+export CFLAGS="$CFLAGS -fvisibility=hidden ${GC_SECTIONS_FLAGS} "
+export CXXFLAGS="$CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden ${GC_SECTIONS_FLAGS} "
+export CFLAGS_BASIS="$CFLAGS"
+export CXXFLAGS_BASIS="$CXXFLAGS"
+
+%autogen
+
+# For product build optimization only. Not for Tizen 4.0 Unified.
+# if tv or unified
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "mobile" && "%{?profile}" != "ivi"
+mkdir -p build_tv
+export CFLAGS="$CFLAGS_BASIS -D_TV -DENABLE_REMOTE_INPUT=1";
+export CXXFLAGS="$CFLAGS_BASIS -D_TV -DENABLE_REMOTE_INPUT=1";
+%configure --disable-static \
+ --disable-tray-icon \
+ --disable-filter-sctc \
+ --disable-include-notification \
%if %{with wayland}
-CFLAGS+=" -DWAYLAND"
-CXXFLAGS+=" -DWAYLAND"
+ --disable-efl-immodule \
+%endif
+ --disable-frontend-x11 \
+ --disable-multiwindow-support \
+ --disable-ime-embed-app \
+ --with-ro-app-dir=%{TZ_SYS_RO_APP} \
+ --with-ro-packages-dir=%{TZ_SYS_RO_PACKAGES}
+make %{?_smp_mflags}
+# Install essential profile-tv files into build_tv
+%make_install
+mkdir -p build_tv/bin
+mkdir -p build_tv/lib
+mv %{buildroot}%{_bindir}/* build_tv/bin/
+mv %{buildroot}%{_libdir}/* build_tv/lib/
+mv %{buildroot}%{_datadir}/scim/remote-input build_tv/
+ls -la build_tv/bin/
+ls -la build_tv/lib/
+ls -la build_tv/
+# if unified
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "mobile" && "%{?profile}" != "ivi" && "%{?profile}" != "tv"
+make clean
%endif
-export GC_SECTIONS_FLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections"
+%endif
+
+# For product build optimization only. Not for Tizen 4.0 Unified.
+# if wearble or ivi or unified
+%if "%{?profile}" != "tv" && "%{?profile}" != "mobile" && "%{?profile}" != "common"
+mkdir -p build_wearable
+export CFLAGS="$CFLAGS_BASIS -D_WEARABLE -DENABLE_HIDE_PANEL_KEY=1";
+export CXXFLAGS="$CXXFLAGS_BASIS -D_WEARABLE -DENABLE_HIDE_PANEL_KEY=1";
+%configure --disable-static \
+ --disable-tray-icon \
+ --disable-filter-sctc \
+ --disable-include-libwebsocket \
+ --disable-include-notification \
+%if %{with wayland}
+ --disable-efl-immodule \
+%endif
+ --disable-frontend-x11 \
+ --disable-multiwindow-support \
+ --disable-ime-embed-app \
+ --with-ro-app-dir=%{TZ_SYS_RO_APP} \
+ --with-ro-packages-dir=%{TZ_SYS_RO_PACKAGES}
+make %{?_smp_mflags}
+# Install essential profile-wearable files into build_wearable
+%make_install
+mkdir -p build_wearable/bin
+mkdir -p build_wearable/lib
+mv %{buildroot}%{_bindir}/* build_wearable/bin/
+mv %{buildroot}%{_libdir}/* build_wearable/lib/
+ls -la build_wearable/bin/
+ls -la build_wearable/lib/
-CFLAGS+=" -fvisibility=hidden ${GC_SECTIONS_FLAGS} "; export CFLAGS
+# if unified
+%if "%{?profile}" != "common" && "%{?profile}" != "wearable" && "%{?profile}" != "mobile" && "%{?profile}" != "ivi" && "%{?profile}" != "tv"
+make clean
+%endif
-CXXFLAGS+=" -fvisibility=hidden -fvisibility-inlines-hidden ${GC_SECTIONS_FLAGS} ";export CXXFLAGS
+%endif
-%autogen
+# For product build optimization only. Not for Tizen 4.0 Unified.
+# if common or mobile or unified
+%if "%{?profile}" != "tv" && "%{?profile}" != "wearable" && "%{?profile}" != "ivi"
+# mobile/common
+export CFLAGS="$CFLAGS_BASIS -D_MOBILE -DENABLE_HIDE_PANEL_KEY=1";
+export CXXFLAGS="$CXXFLAGS_BASIS -D_MOBILE -DENABLE_HIDE_PANEL_KEY=1";
%configure --disable-static \
--disable-tray-icon \
--disable-filter-sctc \