#
# qmake configuration for os2-g++
#
# Written for Innotek GCC/kLIBC and IBM ILINK or OpenWatcom WLINK
#

MAKEFILE_GENERATOR  = GNUMAKE
TEMPLATE        = app
CONFIG          += qt warn_on release link_prl copy_dir_files
QT              += core gui
# @todo
#DEFINES         += QT_LARGEFILE_SUPPORT
QMAKE_COMPILER_DEFINES	+= __OS2__ __EMX__ __INNOTEK_LIBC__ __GNUC__

QMAKE_LINKER_TYPE = $$(EMXOMFLD_TYPE)
equals(QMAKE_LINKER_TYPE, "WLINK"):CONFIG *= wlink
else:equals(QMAKE_LINKER_TYPE, "wlink"):CONFIG *= wlink
else:CONFIG *= ilink

QMAKE_EXT_OBJ           = .obj
QMAKE_EXT_RES           = _res.obj

QMAKE_CC                = gcc
QMAKE_LEX               = flex
QMAKE_LEXFLAGS          =
QMAKE_YACC              = byacc
QMAKE_YACCFLAGS         = -d
QMAKE_CFLAGS            = -Zomf -march=i486 -mtune=generic
QMAKE_CFLAGS_DEPS       = -M
QMAKE_CFLAGS_WARN_ON    = -Wall
QMAKE_CFLAGS_WARN_OFF   = -w
QMAKE_CFLAGS_RELEASE    = -s -O2
QMAKE_CFLAGS_DEBUG      = -g
QMAKE_CFLAGS_YACC       = -Wno-unused -Wno-parentheses

QMAKE_CFLAGS_PRECOMPILE     = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}

QMAKE_CFLAGS_INCDIR     = -I

QMAKE_CXX               = g++
QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS
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  = -frtti
QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions
QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions

# make sure includes from the project directory are always found
QMAKE_INCDIR        = .

QMAKE_INCDIR_QT     = $$[QT_INSTALL_HEADERS]
QMAKE_LIBDIR_QT     = $$[QT_INSTALL_LIBS]

QMAKE_SH=$$(QMAKE_SH)
isEmpty(QMAKE_SH) {
    # we need response files because of CMD.EXE command line limit of 1024 chars
    QMAKE_CFLAGS_RSP_VAR    = CFLAGS_RSP
    QMAKE_CXXFLAGS_RSP_VAR  = CXXFLAGS_RSP
    QMAKE_DEFINES_RSP_VAR   = DEFINES_RSP
    QMAKE_INCPATH_RSP_VAR   = INCPATH_RSP
    QMAKE_OBJECTS_RSP_VAR   = OBJECTS_RSP
    QMAKE_RUN_CC        = $(CC) -c @$(CFLAGS_RSP) @$(DEFINES_RSP) @$(INCPATH_RSP) -o $obj $src
    QMAKE_RUN_CC_IMP    = $(CC) -c @$(CFLAGS_RSP) @$(DEFINES_RSP) @$(INCPATH_RSP) -o $@ $<
    QMAKE_RUN_CXX       = $(CXX) -c @$(CXXFLAGS_RSP) @$(DEFINES_RSP) @$(INCPATH_RSP) -o $obj $src
    QMAKE_RUN_CXX_IMP   = $(CXX) -c @$(CXXFLAGS_RSP) @$(DEFINES_RSP) @$(INCPATH_RSP) -o $@ $<
    QMAKE_OBJECTS_REF   = @$(OBJECTS_RSP)
} else {
    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_OBJECTS_REF   = $(OBJECTS)
}

QMAKE_LINK          = g++
QMAKE_LINK_C        = gcc

ilink {
    QMAKE_LFLAGS            = -Zomf -Zstack 0x2000
    QMAKE_LFLAGS_EXCEPTIONS_ON  =
    QMAKE_LFLAGS_EXCEPTIONS_OFF =
    QMAKE_LFLAGS_RELEASE    = -s -Zlinker /EXEPACK:2
    QMAKE_LFLAGS_DEBUG      =
}
wlink {
    QMAKE_LFLAGS            = -Zomf -Zstack 0x2000 -Zlinker \"DISABLE 1121\"
    QMAKE_LFLAGS_EXCEPTIONS_ON  =
    QMAKE_LFLAGS_EXCEPTIONS_OFF =
    QMAKE_LFLAGS_RELEASE    = -s
    QMAKE_LFLAGS_DEBUG      =
}
QMAKE_LFLAGS_CONSOLE    = -Zlinker /PM:VIO
QMAKE_LFLAGS_WINDOWS    = -Zlinker /PM:PM -Zno-fork
QMAKE_LFLAGS_DLL        = -Zdll
QMAKE_LFLAGS_MAP        = -Zmap
QMAKE_LFLAGS_HIGHMEM    = -Zhigh-mem

QMAKE_LFLAGS_LIBDIR     = -L
QMAKE_LFLAGS_LIB        = -l

QMAKE_RUN_LINK          = $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(DEF_FILE) -Wl,$$QMAKE_OBJECTS_REF $(LIBS)

QMAKE_RUN_IMPLIB        = emximp -p 128 -o $@ $<

isEmpty(QMAKE_SH) {
QMAKE_RUN_GENDEF            = \
    $(QMAKESPECDIR)\\emxexpw.cmd -name $(basename $(TARGET)) \
        -def $(DEF_FILE) \
        $(if $(DEF_FILE_VERSION),-version \"$(DEF_FILE_VERSION)\") \
        $(if $(DEF_FILE_DESCRIPTION),-desc \"$(DEF_FILE_DESCRIPTION)\") \
        $(if $(DEF_FILE_VENDOR),-vendor \"$(DEF_FILE_VENDOR)\") \
        $(if $(DEF_FILE_TEMPLATE),-template \"$(DEF_FILE_TEMPLATE)\")
} else {
QMAKE_RUN_GENDEF            = \
    $(QMAKESPECDIR)/emxexpw.cmd -name $(basename $(TARGET)) \
        -def $(DEF_FILE) \
        $(if $(DEF_FILE_VERSION),-version \"$(DEF_FILE_VERSION)\") \
        $(if $(DEF_FILE_DESCRIPTION),-desc \"$(DEF_FILE_DESCRIPTION)\") \
        $(if $(DEF_FILE_VENDOR),-vendor \"$(DEF_FILE_VENDOR)\") \
        $(if $(DEF_FILE_TEMPLATE),-template \"$(DEF_FILE_TEMPLATE)\")
}

QMAKE_RUN_GENDEF_EXPORT_ALL = $$QMAKE_RUN_GENDEF \
        $(if $(DEF_FILE_MAP),-map \"$(DEF_FILE_MAP)\") \
        $$QMAKE_OBJECTS_REF

QMAKE_RUN_GENDEF_EXE    = $$QMAKE_RUN_GENDEF \
        $(if $(DEF_FILE_EXETYPE),-exe \"$(DEF_FILE_EXETYPE)\")

QMAKE_LIBS              =
QMAKE_LIBS_CORE         = -lregistry.dll -lsocket
QMAKE_LIBS_GUI          =
QMAKE_LIBS_NETWORK      =
QMAKE_LIBS_OPENGL       =
QMAKE_LIBS_COMPAT       =
QMAKE_LIBS_QT_ENTRY     =

QMAKE_LIB               = emxomfar r
QMAKE_RUN_LIB           = $(LIB) $(DESTDIR_TARGET) $$QMAKE_OBJECTS_REF

isEmpty(QMAKE_SH) {
    QMAKE_COPY          = copy
    QMAKE_COPY_DIR      = $(QMAKESPECDIR)\\cpdir.cmd
    QMAKE_MOVE          = move
    QMAKE_DEL_FILE      = del
    QMAKE_MKDIR         = $(QMAKESPECDIR)\\mkdir-p.cmd
    QMAKE_DEL_DIR       = rmdir
    QMAKE_CHK_DIR_EXISTS    = if not exist
} else {
    MINGW_IN_SHELL      = 1
    QMAKE_DIR_SEP       = /
    QMAKE_COPY          = cp
    QMAKE_COPY_DIR      = $(QMAKESPECDIR)/cpdir.cmd
    QMAKE_MOVE          = mv
    QMAKE_DEL_FILE      = rm
    QMAKE_MKDIR         = || mkdir -p
    QMAKE_DEL_DIR       = rmdir
    QMAKE_CHK_DIR_EXISTS    = test -d
}

isEmpty(QMAKE_SH) {
QMAKE_MOC       = $$[QT_INSTALL_BINS]\\moc.exe
QMAKE_UIC       = $$[QT_INSTALL_BINS]\\uic.exe
QMAKE_IDC       = $$[QT_INSTALL_BINS]\\idc.exe
} else {
QMAKE_MOC       = $$[QT_INSTALL_BINS]/moc.exe
QMAKE_UIC       = $$[QT_INSTALL_BINS]/uic.exe
QMAKE_IDC       = $$[QT_INSTALL_BINS]/idc.exe
}

QMAKE_IDL       =
QMAKE_ZIP       = zip -r -9

QMAKE_RC                = rc
QMAKE_RUN_RC2RES_ENV    = export INCLUDE = $(INCLUDEPATH)
QMAKE_RUN_RC2RES        = $(RC) -n -r $(RC_FILE) $(RES_FILE)
QMAKE_RUN_RC2EXE        = $(RC) -n -x2 $(RES_FILE) $(DESTDIR_TARGET)

QMAKE_STRIP     =

QMAKE_MAP_FILE  = $(basename $(DESTDIR_TARGET)).map
QMAKE_SYM_FILE  = $(basename $(DESTDIR_TARGET)).sym
ilink:QMAKE_RUN_MAPSYM  = $(QMAKESPECDIR)\\runmapsym.cmd \
    mapsym $$QMAKE_MAP_FILE $$QMAKE_SYM_FILE
wlink:QMAKE_RUN_MAPSYM  = $(QMAKESPECDIR)\\runmapsym.cmd \
    $(QMAKESPECDIR)\\wmapsym.cmd $$QMAKE_MAP_FILE $$QMAKE_SYM_FILE

QMAKE_IFDEF     = ifdef
QMAKE_IFNDEF    = ifndef
QMAKE_ENDIF     = endif

load(qt_config)
