7ed0b97414
For incremental compilation, skip the stage 1 dummy link operation if nuttx elf has been generated Signed-off-by: chao.an <anchao@xiaomi.com>
179 lines
5.1 KiB
Makefile
179 lines
5.1 KiB
Makefile
############################################################################
|
|
# arch/xtensa/src/Makefile
|
|
#
|
|
# 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.
|
|
#
|
|
############################################################################
|
|
|
|
include $(TOPDIR)/Make.defs
|
|
include chip/Make.defs
|
|
|
|
ifeq ($(CONFIG_ARCH_FAMILY_LX6),y)
|
|
ARCH_SUBDIR = lx6
|
|
endif
|
|
|
|
ifeq ($(CONFIG_ARCH_FAMILY_LX7),y)
|
|
ARCH_SUBDIR = lx7
|
|
endif
|
|
|
|
ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
|
|
|
|
INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip}
|
|
INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)common}
|
|
INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)$(ARCH_SUBDIR)}
|
|
INCLUDES += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)sched}
|
|
|
|
CPPFLAGS += $(INCLUDES)
|
|
CFLAGS += $(INCLUDES)
|
|
CXXFLAGS += $(INCLUDES)
|
|
AFLAGS += $(INCLUDES)
|
|
|
|
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
|
NUTTX = "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx$(EXEEXT)}"
|
|
else
|
|
NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)"
|
|
endif
|
|
|
|
HEAD_AOBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
|
HEAD_COBJ = $(HEAD_CSRC:.c=$(OBJEXT))
|
|
STARTUP_OBJS ?= $(HEAD_AOBJ) $(HEAD_COBJ)
|
|
|
|
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
|
|
|
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
|
|
|
SRCS = $(ASRCS) $(CSRCS)
|
|
OBJS = $(AOBJS) $(COBJS)
|
|
|
|
# Override in Make.defs if linker is not 'ld'
|
|
|
|
LDSTARTGROUP ?= --start-group
|
|
LDENDGROUP ?= --end-group
|
|
LDFLAGS += $(ARCHSCRIPT)
|
|
|
|
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
|
|
|
|
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
|
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)$(DELIM)staging"}"
|
|
ifeq ($(BOARDMAKE),y)
|
|
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board"}"
|
|
endif
|
|
|
|
else
|
|
LIBPATHS += -L"$(TOPDIR)$(DELIM)staging"
|
|
ifeq ($(BOARDMAKE),y)
|
|
LIBPATHS += -L"$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board"
|
|
endif
|
|
|
|
endif
|
|
|
|
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
|
|
ifeq ($(BOARDMAKE),y)
|
|
LDLIBS += -lboard
|
|
endif
|
|
|
|
VPATH = chip:common:$(ARCH_SUBDIR)
|
|
|
|
all: $(STARTUP_OBJS) libarch$(LIBEXT)
|
|
|
|
.PHONY: board/libboard$(LIBEXT)
|
|
|
|
$(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %.S
|
|
$(call ASSEMBLE, $<, $@)
|
|
|
|
$(COBJS) $(HEAD_COBJ): %$(OBJEXT): %.c
|
|
$(call COMPILE, $<, $@)
|
|
|
|
libarch$(LIBEXT): $(OBJS)
|
|
$(call ARCHIVE, $@, $(OBJS))
|
|
|
|
board/libboard$(LIBEXT):
|
|
$(Q) $(MAKE) -C board libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)"
|
|
|
|
define LINK_ALLSYMS
|
|
$(Q) $(TOPDIR)/tools/mkallsyms.sh $(NUTTX) $(CROSSDEV) > allsyms.tmp
|
|
$(Q) $(call COMPILE, -x c allsyms.tmp, allsyms$(OBJEXT))
|
|
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
|
|
-o $(NUTTX) $(filter-out board/libboard$(LIBEXT), $1) allsyms$(OBJEXT) $(EXTRA_OBJS) \
|
|
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
|
|
$(Q) $(call DELFILE, allsyms.tmp allsyms$(OBJEXT))
|
|
endef
|
|
|
|
nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT)
|
|
@echo "LD: nuttx"
|
|
ifneq ($(CONFIG_ALLSYMS),y)
|
|
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
|
|
-o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \
|
|
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
|
|
else
|
|
$(Q) # Link and generate default table
|
|
$(Q) $(if $(wildcard $(shell echo $(NUTTX))),,$(call LINK_ALLSYMS,$^))
|
|
$(Q) # Extract all symbols
|
|
$(Q) $(call LINK_ALLSYMS, $^)
|
|
$(Q) # Extract again since the table offset may changed
|
|
$(Q) $(call LINK_ALLSYMS, $^)
|
|
endif
|
|
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
|
$(Q) $(NM) $(NUTTX) | \
|
|
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
|
sort > $(TOPDIR)/System.map
|
|
endif
|
|
|
|
# This is part of the top-level export target
|
|
|
|
export_startup: board/libboard$(LIBEXT) $(STARTUP_OBJS)
|
|
$(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \
|
|
cp -f $(STARTUP_OBJS) "$(EXPORT_DIR)/startup"; \
|
|
else \
|
|
echo "$(EXPORT_DIR)/startup does not exist"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
# Dependencies
|
|
|
|
makedepfile: $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds) $(HEAD_CSRC:.c=.ddc) $(HEAD_ASRC:.S=.dds)
|
|
$(call CATFILE, Make.dep, $^)
|
|
$(call DELFILE, $^)
|
|
|
|
.depend: Makefile chip/Make.defs $(SRCS) $(TOPDIR)$(DELIM).config
|
|
ifeq ($(BOARDMAKE),y)
|
|
$(Q) $(MAKE) -C board depend
|
|
endif
|
|
$(Q) $(MAKE) makedepfile DEPPATH="--dep-path chip --dep-path common --dep-path $(ARCH_SUBDIR)"
|
|
$(Q) touch $@
|
|
|
|
depend: .depend
|
|
|
|
context::
|
|
|
|
clean:
|
|
ifeq ($(BOARDMAKE),y)
|
|
$(Q) $(MAKE) -C board clean
|
|
endif
|
|
$(call DELFILE, libarch$(LIBEXT))
|
|
$(call CLEAN)
|
|
|
|
distclean:: clean
|
|
ifeq ($(BOARDMAKE),y)
|
|
$(Q) $(MAKE) -C board distclean
|
|
endif
|
|
$(call DELFILE, Make.dep)
|
|
$(call DELFILE, .depend)
|
|
|
|
-include Make.dep
|