#
# All application Makefiles should define the following macros:
#
#   NETOS_DIR       :  relative path to the "netos" toplevel
#   BUILD_RAM_IMAGE :  set to "0" if not desired, and to "1"
#                      if desired (and supported by platform)
#   BUILD_ROM_IMAGE :  set to "0" if not desired, and to "1"
#                      if desired (and supported by platform)
#   APP_C_FILES     :  list of application specific "C" files
#                      (must all have a ".c" suffix)
#   APP_C_FLAGS     :  application specific CFLAGS
#   APP_CC_FILES    :  list of application specific "C++" files
#                      (must all have either a ".cc", ".C", or ".cxx" suffix)
#   APP_CC_FLAGS    :  application specific CFLAGS for C++ compilation
#   APP_ASM_FILES   :  list of application specific assembly files
#                      (must all have either a ".s", ".S", or ".arm" suffix)
#   APP_ASM_FLAGS   :  application specific ASFLAGS for assembly
#   APP_INCDIRS     :  list of application specific include directories
#                      in "-I.." format.
#
#   APP_DESCRIPTION :  Simple one line description of application
#                      (for applicable platforms, will be incorporated
#                      into the binary VPD)
#
#   USE_SIMPLE_WEB_SERVER : set to "1" if desired (used for compatibility
#                           with older examples... links against a different
#                           set of libraries)
#
#   INCLUDE_CXX_STARTUP : set to "1" to include C++ initialization libraries
#
#   APP_OBJ_FILES   :  An optional veriable which can specify "extra"
#                      objects to be linked into an image which are
#                      not derived from c, c++, or assembly.  The
#                      application Makefile bears the burden of providing
#                      rules to build these files if necessary.
#
# The application Makefile should also include VPATH specifications
# for all application source.
#

NETOS_DIR= ../../../..

BUILD_RAM_IMAGE= 1
BUILD_ROM_IMAGE= 0

GRAPHICS_ENABLED= FALSE
REALPORT_ENABLED= FALSE
WEBSERVER_ENABLED= TRUE

# CXX is needed if realport or graphics is enabled
ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
INCLUDE_CXX_STARTUP= 1
endif

APP_DESCRIPTION="NET+OS Project"

vpath %.c .. ../web ../web/result/fixed ../web/result/fixed/scripts ../web/result/fixed/img \
        ../web/result/fixed/html ../web/result/fixed/css ../web/result/fixed/mesh \
        ../web/result/fixed/help \
        ../web/result/stubs ../web/result/stubs/html ../sys \
        ../sys/filesys ../sys/ftp ../sys/graphics ../sys/http ../sys/realport ../sys/util \
        $(NETOS_DIR)/src/rphttpd ../sys/tcpserial

vpath %.cxx  ../sys/graphics ../sys/realport

vpath %.cc   ../web/result/fixed/mesh 

APP_CC_FILES=

APP_C_FILES = root.c \
	errhandler.c \
	utils.c \
	validation.c \
	help.c \
	logo.c \
    back.c \
    back_off.c \
    forward.c \
    forward_off.c \
    tabclose.c \
    tabopen.c \
	stylesheet.c \
	appservices.c \
	fileinit.c \
	ftpsvr.c \
	cgi.c \
	httpsvr.c \
	cpu_utilization.c \
	firmware.c \
	nsuptime.c \
    tcpserial.c \
    ssl_cert.c

ifeq '$(WEBSERVER_ENABLED)' 'TRUE'
APP_C_FILES += \
	RpPages.c \
	RpUsrDct.c \
	file.c \
	security.c \
	session.c \
	webmenu.c \
	webutil.c \
	filelist.c \
    filelist_v.c \
	index.c \
	index_v.c \
	network_config.c \
	network_config_v.c \
	reboot_v.c \
	reboot.c \
	reboot_status.c \
	reboot_status_v.c \
	upload_firmware.c \
	upload_firmware_v.c \
	wireless_ip_config.c \
	wireless_network_config.c \
    cwm_connections_config.c \
    cwm_connections_config_v.c \
    cwm_advanced_config.c \
    cwm_advanced_config_v.c \
    cwm_certificate_config.c \
    cwm_certificate_config_v.c \
    cwm_config_help.c \
	wireless_ip_config_v.c \
	wireless_network_config_v.c \
    mesh_config.c \
    mesh_legacy_serial_config.c \
    mesh_zigbee_config.c \
    mesh_zigbee_config_table.c \
    mesh_zigbee_advanced_config.c \
    mesh_device_state.c \
    mesh_network_view.c \
    mesh_fw_update.c 

APP_CC_FILES+= mesh_config_htm.cc \
              mesh_legacy_serial_config_htm.cc \
              mesh_zigbee_config_htm.cc \
              mesh_device_state_htm.cc \
              mesh_network_view_htm.cc \
              mesh_fw_update_htm.cc
endif
              
ifeq '$(REALPORT_ENABLED)' 'TRUE'
APP_CC_FILES += realportsvr.cxx
endif

ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
APP_CC_FILES += wxroot.cxx wxapp.cxx
endif

APP_ASM_FILES=

APP_C_FLAGS= -DAPP_FILE_SYSTEM
ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
APP_C_FLAGS += -D__WXNETOS__ -D__WXUNIVERSAL__ -DGRAPHICS_PLATFORM=TRUE
endif


#########################################################
#
# This define, AIROHA_TRANSCEIVER should be set to 1 on all WiFi platforms that
# use the Airoha transceiver.  These are the Wi9P9215 and the Wiem9210.  Below is a hack
# to avoid confusion between the wiem9210 and the wiem (7520).
#
ifneq ($(findstring $(PLATFORM), connectcorewi9c_b connectcorewi9p9215_a),)
APP_C_FLAGS += -DAIROHA_TRANSCEIVER=1
endif
#
# Now add the particular case to distinguish connectwiem from connectwiem9210
#
ifeq '$(PLATFORM)' 'connectwiem9210'
APP_C_FLAGS += -DAIROHA_TRANSCEIVER=1
endif
#
#########################################################


APP_CC_FLAGS=
ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
APP_CC_FLAGS += -xc++ -D__WXNETOS__ -D__WXUNIVERSAL__  -DGRAPHICS_PLATFORM=TRUE -fno-rtti
endif

APP_ASM_FLAGS=

APP_INCDIRS= -I.. -I../web -I../web/result/stubs -I../sys -I../sys/cli -I../sys/filesys -I../sys/ftp -I../sys/graphics -I../sys/http -I../sys/realport -I../sys/util -I../sys/tcpserial
APP_INCDIRS += -I$(NETOS_DIR)/src/bsp/devices/common/mesh -I$(NETOS_DIR)/src/bsp/devices/common/mesh/maxstream -I$(NETOS_DIR)/src/bsp/devices/common/xbeeif -I$(NETOS_DIR)/src/bsp/cli/includes
ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/graphics -I$(NETOS_DIR)/src/shared/freetype
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/freetype/custom 
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/freetype/ft_dist/include 
APP_INCDIRS += -I$(NETOS_DIR)/h/usb_host 
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/graphics 
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/graphics/wxWidgets/netos/lib/wx/include/netosuniv-ansi-release-2.8
APP_INCDIRS += -I$(NETOS_DIR)/src/shared/graphics/wxWidgets/include
APP_INCDIRS += -I$(NETOS_DIR)/src/usb_host_drivers/usb_magstripe 
APP_INCDIRS += -I$(NETOS_DIR)/src/usb_host_drivers/keyboard 
APP_INCDIRS += -I$(NETOS_DIR)/src/usb_host_drivers/mouse 
APP_INCDIRS += -I$(NETOS_DIR)/src/usb_host_drivers/hub
endif


# List of libraries needed for the application.
APP_LIBS =  $(NETOS_BSPLIBPATH)/libbsp.a \
            $(NETOS_LIBPATH)/libflash.a \
            $(NETOS_LIBPATH)/libtx.a \
            $(NETOS_LIBPATH)/libdnsclnt.a \
            $(NETOS_LIBPATH)/libaddp.a \
            $(NETOS_LIBPATH)/libftpsvr.a \
            $(NETOS_LIBPATH)/libtcpip.a \
            $(NETOS_LIBPATH)/libssh.a \
            $(NETOS_LIBPATH)/libtelnsvr.a \
            $(NETOS_LIBPATH)/libfilesys.a \
            $(NETOS_LIBPATH)/libemailc.a \
            $(NETOS_LIBPATH)/libmanapi.a \
            $(NETOS_LIBPATH)/librealport.a \
            $(NETOS_LIBPATH)/librphttpd.a \
            $(NETOS_LIBPATH)/libssl.a \
            $(NETOS_LIBPATH)/libwpa.a \
            $(NETOS_LIBPATH)/libwps.a \
            $(NETOS_LIBPATH)/libcrypto.a \
            $(NETOS_LIBPATH)/libssh.a \
            $(NETOS_LIBPATH)/libsntp.a \
            $(NETOS_LIBPATH)/libedp.a \
            $(NETOS_LIBPATH)/libz.a \
            $(NETOS_LIBPATH)/libposix.a

ifeq '$(GRAPHICS_ENABLED)' 'TRUE'
APP_LIBS += $(NETOS_LIBPATH)/libfreetype.a \
            $(NETOS_LIBPATH)/libgfx.a \
            $(NETOS_LIBPATH)/libwxwidgets.a \
            $(NETOS_LIBPATH)/libz.a
endif



#########################################################
# Makefile.tools requires BASEDIR for appropriate BSP 
#
BASEDIR =$(NETOS_DIR)

#
# Include common compiler tools setup.
#
-include $(NETOS_DIR)/Makefile.tools

#
# Include all libraries for wiwave. 
# These libraries are only available for arm9 and must be listed after Makefile.tools
# for arm9 to be defined. 
#
ifeq '$(CPU)' 'arm9'
APP_LIBS += $(NETOS_LIBPATH)/libusbhub.a \
            $(NETOS_LIBPATH)/libusbwifi.a \
            $(NETOS_LIBPATH)/libusbhost.a \
            $(NETOS_LIBPATH)/libusbprinter.a \
            $(NETOS_LIBPATH)/libusbkeyboard.a \
            $(NETOS_LIBPATH)/libusbmassstorage.a \
            $(NETOS_LIBPATH)/libusbmouse.a
endif

#
# All "required" elements must be supplied prior to including the
# "core" Makefile and targets.
#

include $(NETOS_DIR)/src/linkerScripts/Makefile.app.inc

#
# Application specific macros and targets can go below here.
#

