2011-03-04 23:25:03 +01:00
|
|
|
############################################################################
|
|
|
|
# arch/x86/src/Makefile
|
|
|
|
#
|
2021-03-13 11:24:50 +01:00
|
|
|
# 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
|
2011-03-04 23:25:03 +01:00
|
|
|
#
|
2021-03-13 11:24:50 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2011-03-04 23:25:03 +01:00
|
|
|
#
|
2021-03-13 11:24:50 +01:00
|
|
|
# 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.
|
2011-03-04 23:25:03 +01:00
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
2020-05-18 21:42:11 +02:00
|
|
|
include $(TOPDIR)/Make.defs
|
2021-07-21 18:48:05 +02:00
|
|
|
include chip/Make.defs
|
2011-03-04 23:25:03 +01:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_ARCH_I486),y)
|
2012-11-11 14:52:31 +01:00
|
|
|
ARCH_SUBDIR = i486
|
2011-03-04 23:25:03 +01:00
|
|
|
endif
|
|
|
|
|
2020-05-19 11:43:29 +02:00
|
|
|
ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
|
|
|
|
|
2022-11-01 14:47:53 +01:00
|
|
|
INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)chip
|
|
|
|
INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)common
|
|
|
|
INCLUDES += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)$(ARCH_SUBDIR)
|
|
|
|
INCLUDES += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)sched
|
2020-05-19 11:43:29 +02:00
|
|
|
|
2020-09-14 00:14:28 +02:00
|
|
|
CPPFLAGS += $(INCLUDES)
|
|
|
|
CFLAGS += $(INCLUDES)
|
|
|
|
CXXFLAGS += $(INCLUDES)
|
|
|
|
AFLAGS += $(INCLUDES)
|
2020-05-19 11:43:29 +02:00
|
|
|
|
2022-02-20 03:34:50 +01:00
|
|
|
NUTTX = $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx$(EXEEXT))
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
HEAD_OBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
2014-09-04 21:31:34 +02:00
|
|
|
STARTUP_OBJS ?= $(HEAD_OBJ)
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
|
|
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
CSRCS = $(CHIP_CSRCS) $(CMN_CSRCS)
|
|
|
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
SRCS = $(ASRCS) $(CSRCS)
|
|
|
|
OBJS = $(AOBJS) $(COBJS)
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2016-05-17 18:43:15 +02:00
|
|
|
# Override in Make.defs if linker is not 'ld'
|
|
|
|
|
|
|
|
LDSTARTGROUP ?= --start-group
|
|
|
|
LDENDGROUP ?= --end-group
|
2022-02-14 22:29:40 +01:00
|
|
|
LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) -static
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2020-05-19 11:43:29 +02:00
|
|
|
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
|
2012-11-11 15:36:01 +01:00
|
|
|
|
2022-02-20 03:34:50 +01:00
|
|
|
LIBPATHS += -L $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
|
2012-11-12 02:54:54 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2022-02-20 03:34:50 +01:00
|
|
|
LIBPATHS += -L $(call CONVERT_PATH,$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board)
|
2012-11-11 15:36:01 +01:00
|
|
|
endif
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
|
2012-11-12 02:54:54 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
|
|
|
LDLIBS += -lboard
|
|
|
|
endif
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2020-07-15 14:51:26 +02:00
|
|
|
# Add the builtin library
|
|
|
|
|
2022-01-29 04:50:41 +01:00
|
|
|
EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}}
|
2020-07-15 14:51:26 +02:00
|
|
|
|
2023-02-17 22:21:13 +01:00
|
|
|
ifeq ($(CONFIG_LIBM_TOOLCHAIN),y)
|
2022-01-25 09:11:30 +01:00
|
|
|
EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}}
|
2020-07-15 14:51:26 +02:00
|
|
|
endif
|
|
|
|
|
2021-08-27 18:13:21 +02:00
|
|
|
ifeq ($(CONFIG_LIBSUPCXX),y)
|
2022-01-29 04:50:41 +01:00
|
|
|
EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}}
|
2011-08-27 16:58:42 +02:00
|
|
|
endif
|
|
|
|
|
2012-11-11 14:52:31 +01:00
|
|
|
VPATH = chip:common:$(ARCH_SUBDIR)
|
2011-03-04 23:25:03 +01:00
|
|
|
|
|
|
|
all: $(HEAD_OBJ) libarch$(LIBEXT)
|
|
|
|
|
2012-01-29 21:07:16 +01:00
|
|
|
.PHONY: board/libboard$(LIBEXT)
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
$(AOBJS) $(HEAD_OBJ): %$(OBJEXT): %.S
|
2011-03-04 23:25:03 +01:00
|
|
|
$(call ASSEMBLE, $<, $@)
|
|
|
|
|
|
|
|
$(COBJS): %$(OBJEXT): %.c
|
|
|
|
$(call COMPILE, $<, $@)
|
|
|
|
|
|
|
|
libarch$(LIBEXT): $(OBJS)
|
2012-11-15 18:43:29 +01:00
|
|
|
$(call ARCHIVE, $@, $(OBJS))
|
2011-03-04 23:25:03 +01:00
|
|
|
|
|
|
|
board/libboard$(LIBEXT):
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board libboard$(LIBEXT) EXTRAFLAGS="$(EXTRAFLAGS)"
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2022-02-14 22:29:40 +01:00
|
|
|
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(ARCHSCRIPT)
|
2011-03-05 01:01:21 +01:00
|
|
|
@echo "LD: nuttx$(EXEEXT)"
|
2020-07-15 14:51:26 +02:00
|
|
|
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
|
|
|
|
-o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \
|
|
|
|
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
|
2012-11-14 21:59:36 +01:00
|
|
|
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
|
2016-07-16 00:50:00 +02:00
|
|
|
$(Q) $(NM) $(NUTTX) | \
|
2011-03-04 23:25:03 +01:00
|
|
|
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
|
|
|
|
sort > $(TOPDIR)/System.map
|
2012-11-14 21:59:36 +01:00
|
|
|
endif
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
# This is part of the top-level export target
|
|
|
|
|
2022-05-12 12:41:27 +02:00
|
|
|
export_startup: $(STARTUP_OBJS)
|
2012-11-11 15:36:01 +01:00
|
|
|
$(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \
|
2014-09-04 21:31:34 +02:00
|
|
|
cp -f $(STARTUP_OBJS) "$(EXPORT_DIR)/startup"; \
|
2011-07-12 00:52:51 +02:00
|
|
|
else \
|
|
|
|
echo "$(EXPORT_DIR)/startup does not exist"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
2020-12-15 14:52:41 +01:00
|
|
|
makedepfile: $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds) $(HEAD_ASRC:.S=.dds)
|
2020-11-18 17:44:58 +01:00
|
|
|
$(call CATFILE, Make.dep, $^)
|
|
|
|
$(call DELFILE, $^)
|
|
|
|
|
2020-07-22 09:54:29 +02:00
|
|
|
.depend: Makefile chip/Make.defs $(SRCS) $(TOPDIR)$(DELIM).config
|
2012-11-12 02:54:54 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board depend
|
2012-11-11 15:36:01 +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 $@
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2020-03-23 03:44:03 +01:00
|
|
|
depend: .depend
|
2011-03-04 23:25:03 +01:00
|
|
|
|
2020-09-23 13:48:02 +02:00
|
|
|
context::
|
|
|
|
|
2011-03-04 23:25:03 +01:00
|
|
|
clean:
|
2012-11-12 02:54:54 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board clean
|
2012-11-11 15:36:01 +01:00
|
|
|
endif
|
2012-11-20 16:47:41 +01:00
|
|
|
$(call DELFILE, libarch$(LIBEXT))
|
2011-03-04 23:25:03 +01:00
|
|
|
$(call CLEAN)
|
|
|
|
|
2021-07-21 18:48:05 +02:00
|
|
|
distclean:: clean
|
2012-11-12 02:54:54 +01:00
|
|
|
ifeq ($(BOARDMAKE),y)
|
2020-09-14 18:53:37 +02:00
|
|
|
$(Q) $(MAKE) -C board distclean
|
2012-11-11 15:36:01 +01:00
|
|
|
endif
|
2012-11-20 16:47:41 +01:00
|
|
|
$(call DELFILE, Make.dep)
|
2020-03-23 03:44:03 +01:00
|
|
|
$(call DELFILE, .depend)
|
2011-03-04 23:25:03 +01:00
|
|
|
|
|
|
|
-include Make.dep
|