############################################################################
# arch/z80/src/ez80/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.  The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

CMN_CSRCS  = z80_allocateheap.c z80_createstack.c z80_doirq.c
CMN_CSRCS += z80_exit.c z80_interruptcontext.c z80_idle.c
CMN_CSRCS += z80_initialize.c z80_mdelay.c z80_nputs.c
CMN_CSRCS += z80_releasestack.c z80_switchcontext.c
CMN_CSRCS += z80_stackframe.c z80_udelay.c z80_usestack.c

CHIP_ASRCS  = ez80_startup.asm ez80_io.asm ez80_irqsave.asm
CHIP_ASRCS += ez80_irqcommon.asm
CHIP_ASRCS += ez80_saveusercontext.asm ez80_restorecontext.asm

ifeq ($(CONFIG_ARCH_CHIP_EZ80F91),y)
HEAD_ASRC = ez80_reset.asm
CHIP_ASRCS += ez80f91_init.asm ez80f91_handlers.asm
chip/ez80f91_handlers.asm_AFLAGS := -include clang_handlers.inc
endif

ifeq ($(CONFIG_ARCH_CHIP_EZ80F92),y)
CHIP_ASRCS += ez80f92_init.asm
ifeq ($(CONFIG_EZ80_BOOTLOADER),y)
HEAD_ASRC = ez80_reset.asm
CHIP_ASRCS += ez80f92_loader.asm
else ifeq ($(CONFIG_EZ80_PROGRAM),y)
HEAD_ASRC = ez80_progentry.asm
CHIP_ASRCS += ez80f92_program.asm
else
HEAD_ASRC = ez80_reset.asm
CHIP_ASRCS += ez80f92_handlers.asm
endif
endif

ifeq ($(CONFIG_ARCH_STACKDUMP),y)
CHIP_ASRCS += ez80_getsp.asm
endif

CHIP_CSRCS  = ez80_clock.c ez80_initialstate.c ez80_irq.c ez80_copystate.c
CHIP_CSRCS += ez80_timerisr.c ez80_serial.c

ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CHIP_CSRCS += ez80_schedulesigaction.c ez80_sigdeliver.c
endif

ifeq ($(CONFIG_ARCH_STACKDUMP),y)
CHIP_CSRCS += ez80_registerdump.c
endif

ifeq ($(CONFIG_EZ80_I2C),y)
CHIP_CSRCS += ez80_i2c.c
endif

ifeq ($(CONFIG_EZ80_SPI),y)
CHIP_CSRCS += ez80_spi.c
endif

ifeq ($(CONFIG_EZ80_RTC),y)
CHIP_CSRCS += ez80_rtc.c
ifeq ($(CONFIG_RTC_DRIVER),y)
CHIP_CSRCS += ez80_rtc_lowerhalf.c
endif
endif

ifeq ($(CONFIG_ARCH_CHIP_EZ80F91),y)
ifeq ($(CONFIG_EZ80_EMAC),y)
CHIP_CSRCS += ez80_emac.c
endif
endif

AFLAGS += -Ichip