export CFLAGS_DEFAULT="$CFLAGS"
+# Add GCC9 exception
+export CFLAGS+=" -Wno-stringop-truncation -Wno-format-truncation -Wno-address-of-packed-member"
+
export LDFLAGS=" -lncurses -Wl,--as-needed "
export CFLAGS+=" -Werror -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_A2DP_MULTISTREAM -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DTIZEN_FEATURE_BLUEZ_AVRCP_CONTROL -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DENABLE_AVRCP_CATEGORY1 -DTIZEN_BT_HID_DEVICE_ENABLE"
-# Add GCC9 exception
-export CFLAGS+=" -Wno-error=stringop-truncation -Wno-error=format-truncation -Wno-error=address-of-packed-member"
-
%ifarch aarch64
echo arch64
export CFLAGS+=" -DARCH64"
export CFLAGS="$CFLAGS_DEFAULT"
+# Add GCC9 exception
+export CFLAGS+=" -Wno-stringop-truncation -Wno-format-truncation -Wno-address-of-packed-member"
+
export LDFLAGS=" -lncurses -Wl,--as-needed "
export CFLAGS+=" -Werror -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_A2DP_MULTISTREAM -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DTIZEN_FEATURE_BLUEZ_AVRCP_CONTROL -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DENABLE_AVRCP_CATEGORY1 -DTIZEN_BT_HID_DEVICE_ENABLE"
-# Add GCC9 exception
-export CFLAGS+=" -Wno-error=stringop-truncation -Wno-error=format-truncation -Wno-error=address-of-packed-member"
-
%ifarch aarch64
echo arch64
export CFLAGS+=" -DARCH64"
export CFLAGS="$CFLAGS_DEFAULT"
+# Add GCC9 exception
+export CFLAGS+=" -Wno-stringop-truncation -Wno-format-truncation -Wno-address-of-packed-member"
+
export LDFLAGS=" -lncurses -Wl,--as-needed "
export CFLAGS+=" -Werror -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_A2DP_MULTISTREAM -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DTIZEN_FEATURE_BLUEZ_AVRCP_CONTROL -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET -DENABLE_AVRCP_CATEGORY1 -DTIZEN_BT_HID_DEVICE_ENABLE"
-# Add GCC9 exception
-export CFLAGS+=" -Wno-error=stringop-truncation -Wno-error=format-truncation -Wno-error=address-of-packed-member"
-
%ifarch aarch64
echo arch64
export CFLAGS+=" -DARCH64"