#
#   
#
# Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
#

# Build configuration for GameBoy Advance (GBA). The build host is a
# Win32/Linux PC and the build target is a GBA device.

ifndef ENABLE_THUMB_VM
export ENABLE_THUMB_VM              := false
export ENABLE_THUMB_VM__BY          := gba_arm.cfg
endif

ifndef ENABLE_SOFT_FLOAT
export ENABLE_SOFT_FLOAT         := true
export ENABLE_SOFT_FLOAT__BY     := gba_arm.cfg
endif

ifndef ENABLE_INTERPRETATION_LOG
export ENABLE_INTERPRETATION_LOG      := false
export ENABLE_INTERPRETATION_LOG__BY  := gba_arm.cfg
endif

# profile is not supported yet (no fetch_top_frame)
export ENABLE_PROFILER           := false
export ENABLE_PROFILER__BY       := gba_arm.cfg

ROM_GEN_ARG_APPEND           += +EnableAOTSymbolTable

ifeq ($(ADS_LINUX_HOST),true)

    host_os              = linux
    host_compiler        = gcc

    ifneq ($(IsTarget), true)

    ifndef MERGE_SOURCE_FILES
    MERGE_SOURCE_FILES   = true
    endif

    ifndef SOURCE_MERGER_SIZE
    SOURCE_MERGER_SIZE   = 35
    endif

    # Always disable timer thread on 
    export ENABLE_TIMER_THREAD     := false
    export ENABLE_TIMER_THREAD__BY := gba_arm.cfg

    endif

    ifndef GCCGBA_ROOT
    GCCGBA_ROOT = /usr/local/devkitadv/arm-agb-elf
    endif
else

   host_os              = win32
   host_compiler        = visCPP
  
endif

host_arch = i386

# The following two flags tells jvm.make to include the alternative
# platform/compiler makefiles:
#
# $(JVMWorkSpace)/build/gba/alt_platform.make
# $(JVMWorkSpace)/build/gba/alt_compiler.make

ALT_PLATFORM = gba
ALT_COMPILER = gba

ifeq ($(IsLoopGen),true)
    # LoopGen: an .exe that runs on the HOST. It has
    # an ARM assembler loop generator and will generate the ARM
    # assembler loop.
    os_family = $(host_os)
    arch      = arm
    compiler  = $(host_compiler)

    CPP_DEF_FLAGS = -DARM -DGBA=1 -DGENERATE_LIBC_GLUE=0 -DCROSS_GENERATOR=1
endif

ifeq ($(IsRomGen),true)
    # RomGem: an .exe that runs on the HOST. It has
    # an i386 assembler loop. It runs on the HOST to
    # generate the (machine independent) ROM.cpp file.
    os_family = $(host_os)
    arch      = i386
    compiler  = $(host_compiler)

    ifeq ($(ADS_LINUX_HOST),true)
    LOOP_GEN_ARG   = +GenerateGNUCode +GenerateAssemblyCode
    endif

    # AOT-related settings
    export ENABLE_C_INTERPRETER            := true
    export ENABLE_C_INTERPRETER__BY        := gba_arm.cfg
    export ENABLE_INTERPRETER_GENERATOR    := false
    export ENABLE_INTERPRETER_GENERATOR__BY:= gba_arm.cfg

    carch                                   = arm
    iarch                                   = c
    CPP_DEF_FLAGS                          += -DCROSS_GENERATOR=1 -DARM 
endif

ifeq ($(IsTarget),true)
    # target/{cldc_vm.axf, cldc_vm_r.axf, cldc_vm_g.axf}.
    # These are pure GBA/ARM binaries that run on the TARGET.
    os_family = gba
    arch      = arm
    compiler  = gba


    # GBA toolchain we use gives false warnings
    override ENABLE_COMPILATION_WARNINGS := true

    ifndef MERGE_SOURCE_FILES
    MERGE_SOURCE_FILES  = true
    endif

    ifndef SOURCE_MERGER_SIZE
    SOURCE_MERGER_SIZE  = 35
    endif

    LOOP_GEN_FLAGS = +GenerateGNUCode

    ifeq ($(ENABLE_THUMB_VM), true)
    LOOP_GEN_FLAGS += +GenerateThumbInterwork
    endif

    export ENABLE_TIMER_THREAD       := false
    export ENABLE_TIMER_THREAD__BY   := gba_arm.cfg

    # We never generate the interpreter loop or ROM image on the target.
    ifndef ENABLE_INTERPRETER_GENERATOR
    export ENABLE_INTERPRETER_GENERATOR     := false
    export ENABLE_INTERPRETER_GENERATOR__BY := gba_arm.cfg
    endif
    ifndef ENABLE_ROM_GENERATOR
    export ENABLE_ROM_GENERATOR     := false
    export ENABLE_ROM_GENERATOR__BY := gba_arm.cfg
    endif

endif
