#
# qmake configuration for symbian-*
#

TEMPLATE		= app
CONFIG			+= qt warn_on release incremental
QT			+= core gui
QMAKE_INCREMENTAL_STYLE = sublib

DEFINES			+= UNICODE QT_KEYPAD_NAVIGATION QT_SOFTKEYS_ENABLED QT_USE_MATH_H_FLOATS
QMAKE_COMPILER_DEFINES  += SYMBIAN

QMAKE_EXT_OBJ           = .o
QMAKE_EXT_RES           = _res.o

QMAKE_CC		= gcc
QMAKE_LEX		= flex
QMAKE_LEXFLAGS		=
QMAKE_YACC		= byacc
QMAKE_YACCFLAGS		= -d
QMAKE_CFLAGS		=
QMAKE_CFLAGS_DEPS	=
QMAKE_CFLAGS_WARN_ON	=
QMAKE_CFLAGS_WARN_OFF	=
QMAKE_CFLAGS_RELEASE	=
QMAKE_CFLAGS_DEBUG	=
QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses

MMP_OPTION_KEYWORDS = CW ARMCC GCCE
VERSION_FLAGS.ARMCC = ARMCC_4_0
QMAKE_CXX		= g++
QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS
QMAKE_CXXFLAGS.CW	= 
QMAKE_CXXFLAGS.ARMCC      = --visibility_inlines_hidden
QMAKE_CXXFLAGS.ARMCC_4_0  = --import_all_vtbl
QMAKE_CXXFLAGS.GCCE	= -fvisibility-inlines-hidden
QMAKE_CXXFLAGS_DEPS	= $$QMAKE_CFLAGS_DEPS
QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF	= $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE	= $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG	= $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_YACC	= $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD	= $$QMAKE_CFLAGS_THREAD
QMAKE_CXXFLAGS_RTTI_ON	=
QMAKE_CXXFLAGS_RTTI_OFF	=
QMAKE_CXXFLAGS_EXCEPTIONS_ON =
QMAKE_CXXFLAGS_EXCEPTIONS_OFF =

QMAKE_INCDIR		=
QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]

QMAKE_RUN_CC		= $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src
QMAKE_RUN_CC_IMP	= $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
QMAKE_RUN_CXX		= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src
QMAKE_RUN_CXX_IMP	= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

QMAKE_LINK              =
QMAKE_LFLAGS            =
QMAKE_LFLAGS.ARMCC      = 
QMAKE_LFLAGS_EXCEPTIONS_ON =
QMAKE_LFLAGS_EXCEPTIONS_OFF =
QMAKE_LFLAGS_RELEASE    =
QMAKE_LFLAGS_DEBUG      =
QMAKE_LFLAGS_CONSOLE    =
QMAKE_LFLAGS_WINDOWS    =
QMAKE_LFLAGS_DLL        =
QMAKE_LINK_OBJECT_MAX   =
QMAKE_LINK_OBJECT_SCRIPT=

QMAKE_LIBS              = -llibc -llibm -leuser -llibdl -lcone -leikcore -lmediaclientaudio -leikcoctl -leiksrv -lapparc -lavkon -lefsrv -lcharconv -lws32 -lhal -lgdi -lapgrfx
QMAKE_LIBS_CORE         = $$QMAKE_LIBS -llibpthread -lefsrv
QMAKE_LIBS_GUI          = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lhal -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -leikcoctl -leiksrv -lapparc -lcentralrepository
QMAKE_LIBS_NETWORK      = 
QMAKE_LIBS_EGL          = -llibEGL
QMAKE_LIBS_OPENGL       = 
QMAKE_LIBS_OPENVG       = -llibOpenVG -lfbscli -lbitgdi -lgdi
QMAKE_LIBS_COMPAT       = 
QMAKE_LIBS_QT_ENTRY     = -llibcrt0.lib
QMAKE_LIBS_S60          = -lavkon

exists($${EPOCROOT}epoc32/include/platform/sgresource/sgimage.h) {
    QMAKE_LIBS_OPENVG += -lsgresource
}

contains(QMAKE_HOST.os,Windows) {
    QMAKE_COPY           = copy /y
    QMAKE_COPY_DIR       = xcopy /s /q /y /i
    QMAKE_MOVE           = move
    QMAKE_DEL_FILE       = del
    QMAKE_MKDIR          = mkdir
    QMAKE_DEL_DIR        = rmdir
    QMAKE_CHK_DIR_EXISTS = if not exist
} else {
    QMAKE_COPY           = cp
    QMAKE_COPY_DIR       = cp -r
    QMAKE_MOVE           = mv
    QMAKE_DEL_FILE       = rm -f
    QMAKE_MKDIR          = mkdir
    QMAKE_DEL_DIR        = rmdir
    QMAKE_CHK_DIR_EXISTS = test -d
}

QMAKE_MOC		= /epoc32/tools/moc$$(DOTEXE)
QMAKE_UIC		= /epoc32/tools/uic$$(DOTEXE)
QMAKE_IDC		= /epoc32/tools/idc$$(DOTEXE)
QMAKE_RCC		= /epoc32/tools/rcc$$(DOTEXE)

QMAKE_IDL		= midl
QMAKE_LIB		= /epoc32/gcc_mingw/bin/ar -ru
QMAKE_RC		= /epoc32/gcc_mingw/bin/windres
QMAKE_ZIP		= zip -r -9

QMAKE_STRIP		= $${EPOCROOT}epoc32/gcc_mingw/bin/strip
QMAKE_STRIPFLAGS_LIB 	+= --strip-unneeded

load(qt_config)
load(platform_paths)
load(add_mmp_rules)

symbian-abld {
# Versions of abld prior to Symbian^3 have a bug where you cannot remove something from the command line without replacing it
# Rather than figure out which version of abld we're using, we'll replace the command with a macro *that should never be used*
    MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA = "OPTION_REPLACE ARMCC --export_all_vtbl -D__QT_NOEFFECTMACRO_DONOTUSE"
} else {
    MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA = "OPTION_REPLACE ARMCC --export_all_vtbl // don't use --export_all_vtbl"
}
MMP_RULES += PAGED BYTEPAIRCOMPRESSTARGET
MMP_RULES += $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA
SYMBIAN_PLATFORMS = WINSCW GCCE ARMV5 ARMV6

INCLUDEPATH = \
    $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian/stl-off \
    $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian \
    $${EPOCROOT}epoc32/include \
    $$OS_LAYER_LIBC_SYSTEMINCLUDE \
    $$INCLUDEPATH

# Ensure '.' directory is the first in include path.
# RVCT seems to do this automatically, but WINSCW compiler does not, so add it here.
MMP_RULES += "USERINCLUDE ."

# pkg_depends_webkit, pkg_depends_core, and pkg_platform_dependencies can be removed by developer
# if multiple languages need to be supported by pkg file. In that case the developer should declare
# multiple language compatible dependency statements him/herself.

default_deployment.pkg_prerules += pkg_depends_webkit pkg_depends_qt pkg_platform_dependencies

# Supports S60 3.0, 3.1, 3.2 and 5.0 by default
pkg_platform_dependencies = \
    "; Default HW/platform dependencies" \
    "[0x101F7961],0,0,0,{\"S60ProductID\"}" \
    "[0x102032BE],0,0,0,{\"S60ProductID\"}" \
    "[0x102752AE],0,0,0,{\"S60ProductID\"}" \
    "[0x1028315F],0,0,0,{\"S60ProductID\"}" \
    " "

DEPLOYMENT += default_deployment

exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/Series60v5.0.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/Series60v5.0.sis) {
    S60_VERSION = 5.0
} else {
    exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/Series60v3.2.sis )|exists($${EPOCROOT}epoc32/data/z/system/install/Series60v3.2.sis) {
        S60_VERSION = 3.2
    } else {
        S60_VERSION = 3.1
        MMP_RULES -= PAGED BYTEPAIRCOMPRESSTARGET
    }
}

QMAKE_CXXFLAGS_FAST_VFP.ARMCC = --fpmode fast
# [TODO] QMAKE_CXXFLAGS_FAST_VFP.GCCE =

symbian {
    armfpu = $$find(MMP_RULES, "ARMFPU")
    !isEmpty(armfpu) {
        vfpv2 = $$find(MMP_RULES, "vfpv2")
        !isEmpty(vfpv2) {
            # we will respect fpu setting obtained from configure, but,
            # if vfpv2 or softvfp+vfpv2 used we want to force RunFast VFP mode
            QMAKE_CXXFLAGS.ARMCC += $${QMAKE_CXXFLAGS_FAST_VFP.ARMCC}
            # [TODO] QMAKE_CXXFLAGS.GCCE += $${QMAKE_CXXFLAGS_FAST_VFP.GCCE}
        }
    }
}
