nuttx/arch/z80/src/Makefile.sdccw
Abdelatif Guettouche e85b119363 arch/: Clean what was made during context in distclean.
Cleaning during `clean_context` had the issue of remaking everything
when `menuconfig` was issued.  That's because `menuconfig` has a
`clean_context` on its way.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-07-21 16:52:36 -03:00

211 lines
6.6 KiB
Makefile

############################################################################
# arch/z80/src/Makefile.sdccw
#
# 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.
#
############################################################################
# Tools
# CFLAGS, CPPFLAGS, ASFLAGS, LDFLAGS are set in $(TOPDIR)\Make.defs
CFLAGS += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip}
CFLAGS += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)common}
CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)sched}
CPPFLAGS += -D__ASSEMBLY__
# Files and directories
# There should be one head source (.asm file)
HEAD_OBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT))
STARTUP_OBJS ?= $(HEAD_OBJ)
# Assembly sources and objects
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT))
# C sources and objects
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
# All sources and objcts
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
# Sources that can have dependencies (no .asm files)
DEPSRCS = $(CSRCS)
# Directories
ARCH_SRCDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src
BOARDDIR = $(TOPDIR)\arch\$(CONFIG_ARCH)\src\board
VPATH = chip:common:board
# Targets
all: $(HEAD_OBJ) libarch$(LIBEXT)
.PHONY: board\libboard$(LIBEXT) nuttx.lnk
$(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %$(ASMEXT)
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
# This is a kludge to work around some conflicting symbols in the SDCC libraries
$(TOPDIR)\staging\$(SDCCLIB): $(SDCC_LIBDIR)\$(SDCCLIB)
$(Q) cp $(SDCC_LIBDIR)\$(SDCCLIB) $(TOPDIR)\staging\$(SDCCLIB)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) calloc.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) malloc.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) realloc.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) free.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) printf_large.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) sprintf.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) vprintf.rel
ifneq ($(CONFIG_LIBC_ARCH_STRCPY),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) strcpy.rel
endif
ifneq ($(CONFIG_LIBC_ARCH_STRLEN),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) strlen.rel
endif
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strcat.rel
ifneq ($(CONFIG_LIBC_ARCH_STRCHR),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strchr.rel
endif
ifneq ($(CONFIG_LIBC_ARCH_STRCMP),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strcmp.rel
endif
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strcspn.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strncat.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strncmp.rel
ifneq ($(CONFIG_LIBC_ARCH_STRNCPY),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strncpy.rel
endif
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strpbrk.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strrchr.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strspn.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strstr.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _strtok.rel
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _memchr.rel
ifneq ($(CONFIG_LIBC_ARCH_MEMCMP),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _memcmp.rel
endif
ifneq ($(CONFIG_LIBC_ARCH_MEMCPY),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _memcpy.rel
endif
ifneq ($(CONFIG_LIBC_ARCH_MEMSET),y)
$(Q) sdar d $(TOPDIR)\staging\$(SDCCLIB) _memset.rel
endif
# Create a header file that contains addressing information needed by the
# assemlby language start-up code. Locate the IDLE thread stack at the
# end of RAM. The heap then extends from s__HEAP to the bottom of the
# IDLE thread stack
asm_mem.h:
@echo CONFIG_STACK_END == ($(CONFIG_RAM_SIZE) - 1)>>asm_mem.h
@echo CONFIG_STACK_BASE == (CONFIG_STACK_END - $(CONFIG_IDLETHREAD_STACKSIZE))>>asm_mem.h
# Combine all objects in this directory into a library
libarch$(LIBEXT): asm_mem.h $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
# This builds the libboard library in the board\ subdirectory
board\libboard$(LIBEXT):
$(Q) $(MAKE) -C board libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)"
# This target builds the final executable
nuttx.lnk:
@echo LD: nuttx.lnk
@echo -->nuttx.lnk
@echo -k $(BOARDDIR)>>nuttx.lnk
@echo -k $(TOPDIR)\staging>>nuttx.lnk
@echo -l libboard$(LIBEXT)>>nuttx.lnk
$(Q) for %%G in ($(LINKLIBS)) do ( echo -l $(TOPDIR)\staging\%%G>> nuttx.lnk )
@echo -l $(SDCCLIB)>>nuttx.lnk
ifneq ($(CONFIG_LINKER_HOME_AREA),)
@echo -b _HOME=$(CONFIG_LINKER_HOME_AREA)>>nuttx.lnk
endif
ifneq ($(CONFIG_LINKER_CODE_AREA),)
@echo -b _CODE=$(CONFIG_LINKER_CODE_AREA)>>nuttx.lnk
else
@echo -b _CODE=0x0200>>nuttx.lnk
endif
ifneq ($(CONFIG_LINKER_DATA_AREA),)
@echo -b _DATA=$(CONFIG_LINKER_DATA_AREA)>>nuttx.lnk
else
@echo -b _DATA=0x8000>>nuttx.lnk
endif
@echo -i>>nuttx.lnk
@echo -x>>nuttx.lnk
@echo -m>>nuttx.lnk
@echo -j>>nuttx.lnk
@echo nuttx.ihx>>nuttx.lnk
@echo $(HEAD_OBJ)>>nuttx.lnk
@echo -e>>nuttx.lnk
nuttx$(EXEEXT): asm_mem.h $(TOPDIR)\staging\$(SDCCLIB) $(HEAD_OBJ) board\libboard$(LIBEXT) nuttx.lnk
@echo LD: nuttx.ihx
$(Q) $(LD) -f nuttx.lnk
$(Q) cp -f nuttx.map $(TOPDIR)\.
ifeq ($(EXEEXT),.cmd)
sed s/:00000001FF/:00520001AD/ nuttx.ihx | \
hex2cmd > $(TOPDIR)\nuttx.cmd
else
$(Q) packihx nuttx.ihx > $(TOPDIR)\nuttx$(EXEEXT)
endif
# This is part of the top-level export target
export_startup: board\libboard$(LIBEXT) $(STARTUP_OBJS)
$(Q) if not exist board\Makefile ( echo $(EXPORT_DIR)\startup does not exist )
$(Q) if exist board\Makefile ( cp -f $(STARTUP_OBJS) "$(EXPORT_DIR)\startup" )
# Build dependencies
.depend: Makefile asm_mem.h chip\Make.defs $(DEPSRCS) $(TOPDIR)$(DELIM).config
$(Q) if exist board\Makefile ( $(MAKE) -C board depend )
$(Q) $(MKDEP) --dep-path chip --dep-path common "$(CC)" -- $(CFLAGS) -- $(DEPSRCS) >Make.dep
$(Q) touch $@
depend: .depend
context::
clean:
$(Q) if exist board\Makefile ( $(MAKE) -C board clean )
$(call DELFILE, asm_mem.h)
$(call DELFILE, nuttx.*)
$(call DELFILE, libarch$(LIBEXT))
$(call CLEAN)
distclean:: clean
$(Q) if exist board\Makefile ( $(MAKE) -C board distclean )
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep