# /*****************************************************************************
#* Ȩ (C)2015, ͨѶɷ޹˾
#* 
#* ļ:     Makefile
#* ļʶ:     Makefile
#* ժҪ:     Top makefile of ZTE applications
#* ʹ÷:     void
#* 
#* ޸        汾      ޸ı        ޸          ޸
#* -----------------------------------------------------------------------------
#* 2015/02/10      V1.0        Create                    
#* 
# ******************************************************************************/

#*******************************************************************************
# include ZTE application makefile
#*******************************************************************************
include $(zte_app_mak)

#*******************************************************************************
# Default target
#*******************************************************************************
zte_app :=  ccapp slicusr cfg_tool \
			nvserver zte_amt mode_test fac_server  \
			localUpdate zte_log_agent zte_tools_agent zte_audio_ctrl

ifeq ($(CONFIG_USER_SOFTAP_TEAM), y)
softap_team_$(CONFIG_USER_DHCP6) += dhcp6
softap_team_$(CONFIG_USER_DNSMASQ) += dnsmasq-2.40
softap_team_$(CONFIG_USER_PPPOECD) += ppp-2.4.1
softap_team_$(CONFIG_USER_NETPPPD) += pppd
softap_team_$(CONFIG_USER_RADVD) += radvd-2.14
softap_team_$(CONFIG_USER_SCRIPT) += Script
softap_team_$(CONFIG_USER_STRACE) += strace
#softap_team_$(CONFIG_USER_ZTE_IPV6_ADDR_COLLECT) += zte_ipv6_addr_collect
#softap_team_$(CONFIG_USER_ZTE_IPV6_ADDR_CONVER) += zte_ipv6_addr_conver
#softap_team_$(CONFIG_USER_ZTE_IPV6_SLAAC) += zte_ipv6_slaac
softap_team_$(CONFIG_USER_INADYN) += inadyn
softap_team_$(CONFIG_USER_MINIUPNPD_LINUX) += miniupnpd_linux
softap_team_$(CONFIG_USER_NETDOG) += netdog
softap_team_$(CONFIG_USER_ZTE_ARP_PROXY) += zte_arp_proxy
softap_team_$(CONFIG_USER_ZTE_IPSEC_PROXY) += zte_ipsec_proxy
softap_team_$(CONFIG_USER_ZTE_NDP) += zte_ndp
softap_team_$(CONFIG_USER_ZTE_MAINCTRL) += zte_mainctrl
softap_team_$(CONFIG_USER_NETPCAP) += netpcap
softap_team_$(CONFIG_USER_TCPDUMP) += tcpdump
softap_team_$(CONFIG_USER_ETHAUTOCONNCT) += eth_auto_connect
softap_team_$(CONFIG_USER_IPROUTE2) += iproute2
softap_team_$(CONFIG_USER_IPTABLES_IPTABLES) += iptables
softap_team_$(CONFIG_USER_IPTABLES_IP6TABLES) += iptables
softap_team_$(CONFIG_USER_CLAT) += clat
softap_team_$(CONFIG_USER_CARES) += c-ares
softap_team_$(CONFIG_USER_CURL) += curl
softap_team_$(CONFIG_USER_ZTE_HOTPLUG) += zte_hotplug
softap_team_$(CONFIG_USER_SD_HOTPLUG) += sd_hotplug
softap_team_$(CONFIG_USER_ZTE_USBCFGMNG) += zte_usbCfgMng
softap_team_$(CONFIG_USER_FLUXSTAT) += fluxstat
softap_team_$(CONFIG_USER_SNTP) += sntp
softap_team_$(CONFIG_USER_UI_CTL) += ui_ctl
softap_team_$(CONFIG_USER_ZTE_PING) += zte_ping

softap_team_$(CONFIG_USER_ZTE_MMI) += zte_mmi
softap_team_$(CONFIG_USER_GOAHEAD) += goahead
#softap_team_$(CONFIG_USER_ZTE_WATCHDOG) += zte_watchdog
softap_team_$(CONFIG_USER_RTC_SERVICE) += rtc-service
softap_team_$(CONFIG_USER_AT_CTL) += at_ctl
softap_team_$(CONFIG_USER_ZTE_DRVCOMMNG) += zte_drvComMng
softap_team_$(CONFIG_USER_SMS) += sms
softap_team_$(CONFIG_USER_PHONEBOOK) += phonebook

softap_team_$(CONFIG_USER_ZTE_ISMS) += zte_isms
softap_team_$(CONFIG_USER_ZTE_DM) += zte_dm

softap_team_$(CONFIG_USER_FOTA_UPI) += fota_upi
softap_team_$(CONFIG_USER_FOTA_DM) += fota_dm
softap_team_$(CONFIG_USER_ZTE_PCS) += zte_pcs
softap_team_$(CONFIG_USER_AT_TOOL) += at_tool
#app sdk start
ifneq ($(MK_SDK_VERSION), yes)
softap_team_$(CONFIG_USER_EMBMS_CTRL) += embms_ctrl
softap_team_$(CONFIG_USER_EMBMS_DATA) += embms_data
softap_team_$(CONFIG_USER_SALE_STAT) += sale_stat
softap_team_$(CONFIG_USER_ZTE_PERF) += zte_perf

softap_team_$(CONFIG_USER_ERASEFLASH) += eraseflash
softap_team_$(CONFIG_USER_TR069) += tr069
softap_team_$(CONFIG_USER_ZTE_SOCKET) += zte_socket
endif
#app sdk end

zte_app += $(softap_team_y)
endif
all:
ifeq ($(CONFIG_USER_MINIUPNPD_LINUX), y)
miniupnpd_linux: iptables
endif

$(waring CONFIG_WIFI_MODULE = $(CONFIG_WIFI_MODULE))
#ifeq ($(CONFIG_WIFI_MODULE), broadcom)
#zte_app += wlan wpa_supplicant zte_topsw_qrcode  \
#	awps wl_tools wireless_tools.29
#endif	
#ifeq ($(CONFIG_WIFI_MODULE), realtek)
#zte_app += wlan wpa_supplicant zte_topsw_qrcode  \
#	wireless_tools.25 auth utility wsc mini_upnp
#wlan: wpa_supplicant
#endif
ifeq ($(CONFIG_WIFI_MODULE), broadcom)
zte_app += wlan
endif
ifeq ($(CONFIG_WIFI_MODULE), realtek)
zte_app += wlan
endif
.PHONY: all $(zte_app) romfs

#*******************************************************************************
# Default target of uClinux makefile framework
#*******************************************************************************
export ZTARGET
all: ZTARGET=all
romfs: ZTARGET=romfs
all romfs:$(sort $(zte_app))
	@touch .sgbuilt_user
	@if [ x"$(ZTARGET)" = x"all" ]; then echo ""|awk -v "ZAPP=$(zte_app)" '{ \
        printf("\n--------------------------------------------\n"); \
        printf("|      Module           |       Built      |\n"); \
        printf("--------------------------------------------\n"); \
        n = split(ZAPP, array, " "); \
        for (i = 1; i <= n; i++)   \
            printf("|%-23s|%-18s|\n", array[i], "y");    \
        printf("--------------------------------------------\n\n"); \
    }'; \
    fi


$(sort $(zte_app)):
	${MAKE} -C ${ROOT_DIR}/linux/user/zte_apps/$@ $(ZTARGET)
	


clean:
	if [ -f .sgbuilt_user ]; then                                           \
		for app in ${sort ${zte_app}} ; do                                  \
			${MAKE} -j1 -C $$app clean ;                                    \
		done;                                                               \
		rm -f .sgbuilt_user;                                                \
	fi;

#*******************************************************************************
# ZTE application target
#*******************************************************************************

