Skip to content

Commit

Permalink
apps/Application.mk: Convert object names to guarantee uniqueness.
Browse files Browse the repository at this point in the history
  • Loading branch information
anchao authored and gregory-nutt committed Dec 13, 2019
1 parent 5ec8fc9 commit e48a74f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ ifneq ($(MAINSRC),)
endif
endif

SUFFIX = $(subst $(DELIM),.,$(CURDIR))

# Object files

AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT))
AOBJS = $(ASRCS:.S=$(SUFFIX)$(OBJEXT))
COBJS = $(CSRCS:.c=$(SUFFIX)$(OBJEXT))
CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(SUFFIX)$(OBJEXT))

ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
MAINOBJ = $(MAINSRC:$(CXXEXT)=$(OBJEXT))
MAINOBJ = $(MAINSRC:$(CXXEXT)=$(SUFFIX)$(OBJEXT))
else
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(SUFFIX)$(OBJEXT))
endif

SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
Expand All @@ -71,6 +73,8 @@ ifneq ($(BUILD_MODULE),y)
endif

ROOTDEPPATH += --dep-path .
ROOTDEPPATH += --obj-path .
ROOTDEPPATH += --obj-suffix $(SUFFIX)$(OBJEXT)

VPATH += :.

Expand Down Expand Up @@ -102,15 +106,15 @@ define ELFLD
$(Q) chmod +x $2
endef

$(AOBJS): %$(OBJEXT): %.S
$(AOBJS): %$(SUFFIX)$(OBJEXT): %.S
$(if $(and $(CONFIG_BUILD_LOADABLE),$(AELFFLAGS)), \
$(call ELFASSEMBLE, $<, $@), $(call ASSEMBLE, $<, $@))

$(COBJS): %$(OBJEXT): %.c
$(COBJS): %$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))

$(CXXOBJS): %$(OBJEXT): %$(CXXEXT)
$(CXXOBJS): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))

Expand All @@ -125,11 +129,11 @@ endif
ifeq ($(BUILD_MODULE),y)

ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT)
$(MAINOBJ): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
else
$(MAINOBJ): %$(OBJEXT): %.c
$(MAINOBJ): %$(SUFFIX)$(OBJEXT): %.c
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CELFFLAGS)), \
$(call ELFCOMPILE, $<, $@), $(call COMPILE, $<, $@))
endif
Expand All @@ -154,14 +158,14 @@ else
MAINNAME := $(addsuffix _main,$(PROGNAME))

ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT)
$(MAINOBJ): %$(SUFFIX)$(OBJEXT): %$(CXXEXT)
$(eval $<_CXXFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval $<_CXXELFFLAGS += ${shell $(DEFINE) "$(CXX)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
$(if $(and $(CONFIG_BUILD_LOADABLE),$(CXXELFFLAGS)), \
$(call ELFCOMPILEXX, $<, $@), $(call COMPILEXX, $<, $@))
else
$(MAINOBJ): %$(OBJEXT): %.c
$(MAINOBJ): %$(SUFFIX)$(OBJEXT): %.c
$(eval $<_CFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval $<_CELFFLAGS += ${shell $(DEFINE) "$(CC)" main=$(firstword $(MAINNAME))})
$(eval MAINNAME=$(filter-out $(firstword $(MAINNAME)),$(MAINNAME)))
Expand Down

0 comments on commit e48a74f

Please sign in to comment.