2020-03-04 00:29:13 +01:00
|
|
|
############################################################################
|
|
|
|
# arch/x86_64/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.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
2020-05-18 21:42:11 +02:00
|
|
|
include $(TOPDIR)/Make.defs
|
2021-07-21 18:48:05 +02:00
|
|
|
include chip/Make.defs
|
2020-03-04 00:29:13 +01:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_ARCH_INTEL64),y)
|
|
|
|
ARCH_SUBDIR = intel64
|
|
|
|
endif
|
|
|
|
|
2020-05-19 11:43:29 +02:00
|
|
|
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}
|
|
|
|
|
2020-09-14 00:14:28 +02:00
|
|
|
CPPFLAGS += $(INCLUDES)
|
|
|
|
CFLAGS += $(INCLUDES)
|
|
|
|
CXXFLAGS += $(INCLUDES)
|
|
|
|
AFLAGS += $(INCLUDES)
|
2020-05-19 11:43:29 +02:00
|
|
|
|
2020-05-18 16:18:15 +02:00
|
|
|
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
2020-05-19 11:43:29 +02:00
|
|
|
NUTTX = "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx$(EXEEXT)}"
|
2020-03-04 00:29:13 +01:00
|
|
|
else
|
2020-05-19 11:43:29 +02:00
|
|
|
NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)"
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
|
|
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
|
|
|
|
|
|
|
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
|
|
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
|
|
|
|
|
|
|
SRCS = $(ASRCS) $(CSRCS)
|
|
|
|
OBJS = $(AOBJS) $(COBJS)
|
|
|
|
|
|
|
|
KBIN = libkarch$(LIBEXT)
|
|
|
|
BIN = libarch$(LIBEXT)
|
|
|
|
|
|
|
|
# Override in Make.defs if linker is not 'ld'
|
|
|
|
|
|
|
|
LDSTARTGROUP ?= --start-group
|
|
|
|
LDENDGROUP ?= --end-group
|
|
|
|
|
|
|
|
LDFLAGS += -z max-page-size=0x1000 $(ARCHSCRIPT)
|
|
|
|
LOADER_LDFLAGS += $(LOADER_ARCHSCRIPT)
|
|
|
|
|
2020-05-19 11:43:29 +02:00
|
|
|
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
|
2020-03-04 00:29:13 +01:00
|
|
|
|
2020-05-18 16:18:15 +02:00
|
|
|
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
2020-05-19 11:43:29 +02:00
|
|
|
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)$(DELIM)staging"}"
|
2020-03-04 00:29:13 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-05-19 11:43:29 +02:00
|
|
|
LIBPATHS += -L"${shell cygpath -w "$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board"}"
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
else
|
2020-05-19 11:43:29 +02:00
|
|
|
LIBPATHS += -L"$(TOPDIR)$(DELIM)staging"
|
2020-03-04 00:29:13 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-05-19 11:43:29 +02:00
|
|
|
LIBPATHS += -L"$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board"
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
2020-05-19 11:43:29 +02:00
|
|
|
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
|
|
|
|
ifeq ($(BOARDMAKE),y)
|
|
|
|
LDLIBS += -lboard
|
|
|
|
endif
|
|
|
|
|
2020-07-15 14:51:26 +02:00
|
|
|
# Add the builtin library
|
2020-03-04 00:29:13 +01:00
|
|
|
|
2020-07-15 14:51:26 +02:00
|
|
|
EXTRA_LIBS += -lgcc
|
2022-01-21 21:33:13 +01:00
|
|
|
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name`"}"
|
2020-07-15 14:51:26 +02:00
|
|
|
|
|
|
|
ifneq ($(CONFIG_LIBM),y)
|
2022-01-21 21:33:13 +01:00
|
|
|
LIBM_PATH = "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a`"}"
|
|
|
|
|
|
|
|
# Check if libm is provided by the compiler
|
|
|
|
|
|
|
|
ifneq ($(LIBM_PATH),".")
|
|
|
|
EXTRA_LIBS += -lm
|
|
|
|
EXTRA_LIBPATHS += -L $(LIBM_PATH)
|
|
|
|
endif
|
2020-07-15 14:51:26 +02:00
|
|
|
endif
|
|
|
|
|
2021-08-27 18:13:21 +02:00
|
|
|
ifeq ($(CONFIG_LIBSUPCXX),y)
|
2020-07-15 14:51:26 +02:00
|
|
|
EXTRA_LIBS += -lsupc++
|
2022-01-21 21:33:13 +01:00
|
|
|
EXTRA_LIBPATHS += -L "${shell dirname "`$(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a`"}"
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
VPATH = chip:common:$(ARCH_SUBDIR)
|
|
|
|
|
|
|
|
all: libarch$(LIBEXT)
|
|
|
|
|
|
|
|
.PHONY: board/libboard$(LIBEXT)
|
|
|
|
|
|
|
|
$(AOBJS): %$(OBJEXT): %.S
|
|
|
|
$(call ASSEMBLE, $<, $@)
|
|
|
|
|
|
|
|
$(COBJS): %$(OBJEXT): %.c
|
|
|
|
$(call COMPILE, $<, $@)
|
|
|
|
|
2020-05-01 21:23:04 +02:00
|
|
|
ifeq ($(CONFIG_BUILD_FLAT),y)
|
|
|
|
$(BIN): $(OBJS)
|
2020-03-04 00:29:13 +01:00
|
|
|
$(call ARCHIVE, $@, $(OBJS))
|
2020-05-01 21:23:04 +02:00
|
|
|
else
|
|
|
|
$(BIN): $(UOBJS)
|
2020-03-04 00:29:13 +01:00
|
|
|
$(call ARCHIVE, $@, $(UOBJS))
|
2020-05-01 21:23:04 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
$(KBIN): $(OBJS)
|
|
|
|
$(call ARCHIVE, $@, $(OBJS))
|
2020-03-04 00:29:13 +01:00
|
|
|
|
|
|
|
board/libboard$(LIBEXT):
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)"
|
2020-03-04 00:29:13 +01:00
|
|
|
|
|
|
|
nuttx$(EXEEXT): board/libboard$(LIBEXT)
|
|
|
|
@echo "LD: nuttx$(EXEEXT)"
|
2020-07-15 14:51:26 +02:00
|
|
|
$(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
|
|
|
|
-o $(NUTTX) $(EXTRA_OBJS) \
|
|
|
|
$(LDSTARTGROUP) $(EXTRA_LIBS) --whole-archive --no-relax $(LDLIBS) $(LDENDGROUP)
|
2020-03-04 00:29:13 +01:00
|
|
|
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
|
|
|
|
|
2020-11-18 17:44:58 +01:00
|
|
|
makedepfile: $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds)
|
|
|
|
$(call CATFILE, Make.dep, $^)
|
|
|
|
$(call DELFILE, $^)
|
|
|
|
|
2020-07-22 09:54:29 +02:00
|
|
|
.depend: Makefile chip/Make.defs $(SRCS) $(TOPDIR)$(DELIM).config
|
2020-03-04 00:29:13 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board depend
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
2020-11-28 04:43:30 +01:00
|
|
|
$(Q) $(MAKE) makedepfile DEPPATH="--dep-path chip --dep-path common --dep-path $(ARCH_SUBDIR)"
|
2020-03-23 03:44:03 +01:00
|
|
|
$(Q) touch $@
|
2020-03-04 00:29:13 +01:00
|
|
|
|
2020-03-23 03:44:03 +01:00
|
|
|
depend: .depend
|
2020-03-04 00:29:13 +01:00
|
|
|
|
2020-09-23 13:48:02 +02:00
|
|
|
context::
|
|
|
|
|
2020-03-04 00:29:13 +01:00
|
|
|
clean:
|
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board clean
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
$(call DELFILE, libarch$(LIBEXT))
|
|
|
|
$(call CLEAN)
|
|
|
|
|
2021-07-21 18:48:05 +02:00
|
|
|
distclean:: clean
|
2020-03-04 00:29:13 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board distclean
|
2020-03-04 00:29:13 +01:00
|
|
|
endif
|
|
|
|
$(call DELFILE, Make.dep)
|
2020-03-23 03:44:03 +01:00
|
|
|
$(call DELFILE, .depend)
|
2020-03-04 00:29:13 +01:00
|
|
|
|
|
|
|
-include Make.dep
|