arch/makefile: preprocess link script to make configure more flexibly

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-09-28 16:32:02 +08:00 committed by Xiang Xiao
parent 5c9b094d65
commit 6bc4baa4ca
3 changed files with 24 additions and 6 deletions

View File

@ -109,7 +109,8 @@ else
endif
LDFLAGS += $(addprefix $(SCRIPT_OPT),$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
ARCHSCRIPT := $(call CONVERT_PATH,$(ARCHSCRIPT))
LDFLAGS += $(addprefix $(SCRIPT_OPT),$(ARCHSCRIPT).tmp) $(EXTRALINKCMDS)
LIBPATHS += $(LIBPATH_OPT) $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
@ -165,7 +166,10 @@ define LINK_ALLSYMS
$(Q) $(call DELFILE, allsyms.tmp allsyms$(OBJEXT))
endef
nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(ARCHSCRIPT)
$(addsuffix .tmp,$(ARCHSCRIPT)): $(ARCHSCRIPT)
$(call PREPROCESS, $(patsubst %.tmp,%,$@), $@)
nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(addsuffix .tmp,$(ARCHSCRIPT))
$(Q) echo "LD: nuttx"
ifneq ($(CONFIG_ALLSYMS),y)
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
@ -184,6 +188,7 @@ ifneq ($(CONFIG_WINDOWS_NATIVE),y)
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)$(DELIM)System.map
endif
$(Q) $(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
# This is part of the top-level export target
# Note that there may not be a head object if layout is handled
@ -220,6 +225,7 @@ clean:
ifeq ($(BOARDMAKE),y)
$(Q) $(MAKE) -C board clean
endif
$(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
$(call DELFILE, $(KBIN))
$(call DELFILE, $(BIN))
ifneq ($(EXTRADELFILE),)

View File

@ -79,7 +79,8 @@ UOBJS = $(UAOBJS) $(UCOBJS)
KBIN = libkarch$(LIBEXT)
BIN = libarch$(LIBEXT)
LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
ARCHSCRIPT := $(call CONVERT_PATH,$(ARCHSCRIPT))
LDFLAGS += $(addprefix -T,$(ARCHSCRIPT).tmp) $(EXTRALINKCMDS)
ifeq ($(LD),$(CC))
LDSTARTGROUP ?= -Wl,--start-group
@ -145,7 +146,10 @@ define LINK_ALLSYMS
$(Q) $(call DELFILE, allsyms.tmp allsyms$(OBJEXT))
endef
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(ARCHSCRIPT)
$(addsuffix .tmp,$(ARCHSCRIPT)): $(ARCHSCRIPT)
$(call PREPROCESS, $(patsubst %.tmp,%,$@), $@)
nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(addsuffix .tmp,$(ARCHSCRIPT))
$(Q) echo "LD: nuttx"
ifneq ($(CONFIG_ALLSYMS),y)
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
@ -164,6 +168,7 @@ ifneq ($(CONFIG_WINDOWS_NATIVE),y)
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
endif
$(Q) $(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
# This is part of the top-level export target
# Note that there may not be a head object if layout is handled
@ -200,6 +205,7 @@ clean:
ifeq ($(BOARDMAKE),y)
$(Q) $(MAKE) -C board clean
endif
$(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
$(call DELFILE, $(KBIN))
$(call DELFILE, $(BIN))
$(call DELFILE, $(HEAD_OBJ))

View File

@ -80,7 +80,8 @@ BIN = libarch$(LIBEXT)
# Override in Make.defs if linker is not 'ld'
LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
ARCHSCRIPT := $(call CONVERT_PATH,$(ARCHSCRIPT))
LDFLAGS += $(addprefix -T,$(ARCHSCRIPT).tmp) $(EXTRALINKCMDS)
ifeq ($(LD),$(CC))
LDSTARTGROUP ?= -Wl,--start-group
@ -142,7 +143,10 @@ define LINK_ALLSYMS
$(Q) $(call DELFILE, allsyms.tmp allsyms$(OBJEXT))
endef
nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT) $(ARCHSCRIPT)
$(addsuffix .tmp,$(ARCHSCRIPT)): $(ARCHSCRIPT)
$(call PREPROCESS, $(patsubst %.tmp,%,$@), $@)
nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT) $(addsuffix .tmp,$(ARCHSCRIPT))
$(Q) echo "LD: nuttx"
ifneq ($(CONFIG_ALLSYMS),y)
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
@ -161,6 +165,7 @@ ifneq ($(CONFIG_WINDOWS_NATIVE),y)
grep -v '\(compiled\)\|\(\$(OBJEXT)$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
endif
$(Q) $(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
# This is part of the top-level export target
@ -193,6 +198,7 @@ clean:
ifeq ($(BOARDMAKE),y)
$(Q) $(MAKE) -C board clean
endif
$(call DELFILE, $(addsuffix .tmp,$(ARCHSCRIPT)))
$(call DELFILE, $(KBIN))
$(call DELFILE, $(BIN))
$(call CLEAN)