apps/Application.mk: Convert object names to guarantee uniqueness.

This commit is contained in:
chao.an 2019-12-13 08:27:45 -06:00 committed by Gregory Nutt
parent 5ec8fc9427
commit e48a74f358

View File

@ -51,16 +51,18 @@ ifneq ($(MAINSRC),)
endif endif
endif endif
SUFFIX = $(subst $(DELIM),.,$(CURDIR))
# Object files # Object files
AOBJS = $(ASRCS:.S=$(OBJEXT)) AOBJS = $(ASRCS:.S=$(SUFFIX)$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT)) COBJS = $(CSRCS:.c=$(SUFFIX)$(OBJEXT))
CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT)) CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(SUFFIX)$(OBJEXT))
ifeq ($(suffix $(MAINSRC)),$(CXXEXT)) ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
MAINOBJ = $(MAINSRC:$(CXXEXT)=$(OBJEXT)) MAINOBJ = $(MAINSRC:$(CXXEXT)=$(SUFFIX)$(OBJEXT))
else else
MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) MAINOBJ = $(MAINSRC:.c=$(SUFFIX)$(OBJEXT))
endif endif
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC) SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
@ -71,6 +73,8 @@ ifneq ($(BUILD_MODULE),y)
endif endif
ROOTDEPPATH += --dep-path . ROOTDEPPATH += --dep-path .
ROOTDEPPATH += --obj-path .
ROOTDEPPATH += --obj-suffix $(SUFFIX)$(OBJEXT)
VPATH += :. VPATH += :.
@ -102,15 +106,15 @@ define ELFLD
$(Q) chmod +x $2 $(Q) chmod +x $2
endef endef
$(AOBJS): %$(OBJEXT): %.S $(AOBJS): %$(SUFFIX)$(OBJEXT): %.S
$(if $(and $(CONFIG_BUILD_LOADABLE),$(AELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(AELFFLAGS)), \
$(call ELFASSEMBLE, $<, $@), $(call ASSEMBLE, $<, $@)) $(call ELFASSEMBLE, $<, $@), $(call ASSEMBLE, $<, $@))
$(COBJS): %$(OBJEXT): %.c $(COBJS): %$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@)) $(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
$(CXXOBJS): %$(OBJEXT): %$(CXXEXT) $(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@)) $(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
@ -125,11 +129,11 @@ endif
ifeq ($(BUILD_MODULE),y) ifeq ($(BUILD_MODULE),y)
ifeq ($(suffix $(MAINSRC)),$(CXXEXT)) ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT) $(MAINOBJ): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@)) $(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
else else
$(MAINOBJ): %$(OBJEXT): %.c $(MAINOBJ): %$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@)) $(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
endif endif
@ -154,14 +158,14 @@ else
MAINNAME := $(addsuffix _main,$(PROGNAME)) MAINNAME := $(addsuffix _main,$(PROGNAME))
ifeq ($(suffix $(MAINSRC)),$(CXXEXT)) ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT) $(MAINOBJ): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))}) $(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))}) $(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME))) $(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \ $(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@)) $(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
else else
$(MAINOBJ): %$(OBJEXT): %.c $(MAINOBJ): %$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))}) $(eval $<_CFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval $<_CELFFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))}) $(eval $<_CELFFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME))) $(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))