diff --git a/apps/app.mk b/apps/app.mk index 2fa2111e..3531c266 100644 --- a/apps/app.mk +++ b/apps/app.mk @@ -27,88 +27,6 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(APP_NAME) +override TARGET = $(OUT)/bin/$(APP_NAME) -APP := $(OUT)/bin/$(APP_NAME) - -# create a separate list of objects per source type - -LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS)) -LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS)) -LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS)) -LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS)) -LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS)) - -LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS)) -LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS)) -LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS)) -LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2)) -LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS)) - -LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS) - -LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS)) -LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS)) - -all : $(APP) - -define ECHO = -ifeq ($$(HIDE),@) -_$(1) := $($(1)) -$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1)) -endif -endef -$(foreach cmd,CC GPP AS,$(eval $(call ECHO,$(cmd)))) - -LOCAL_FLAGS += -MD -MP --include $(LOCAL_OBJS:%.o=%.d) - -$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ - -$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ - -$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ - -$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(AS) $(ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ - -$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ - -$(LOCAL_CGCH): %.h.gch : %.h - $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^ - -$(LOCAL_CPPGCH): %.h.gch : %.h - $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^ - -LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH) - -$(LOCAL_OBJS): $(LOCAL_GCH) -$(APP): $(LOCAL_OBJS) - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(GPP) $(LDFLAGS) -o $@ $^ - -clean: - $(HIDE)$(RM) $(APP) $(OBJOUT) $(LOCAL_GCH) *.bak *~ - -.PHONY: all clean - -# clear some variables we set here -LOCAL_CSRCS := -LOCAL_CPPSRCS := -LOCAL_ASMSRCS := -LOCAL_COBJS := -LOCAL_CPPOBJS := -LOCAL_ASMOBJS := -LOCAL_ASMOBJS2 := - -# LOCAL_OBJS is passed back -#LOCAL_OBJS := +include $(MODULE) diff --git a/apps/config.mk b/apps/config.mk index bf0c698e..3862ce07 100644 --- a/apps/config.mk +++ b/apps/config.mk @@ -69,12 +69,3 @@ endif ifeq ($(LOSCFG_DRIVERS_TRACE), y) APP_SUBDIRS += trace endif - -# clear all local variables -LOCAL_FLAGS := -LOCAL_CFLAGS := -LOCAL_CPPFLAGS := -LOCAL_ASFLAGS := -LOCAL_SRCS := -LOCAL_CHS := -LOCAL_CPPHS := diff --git a/arch/arm/arm.mk b/arch/arm/arm.mk index 4ea755ed..248ef5ee 100644 --- a/arch/arm/arm.mk +++ b/arch/arm/arm.mk @@ -74,12 +74,3 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \ -I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE) - -# expose FPU info to assembly code -ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y) - LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_DISABLE -else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y) - LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D16 -else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y) - LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32 -endif diff --git a/config.mk b/config.mk index a72ba1e1..a4fd387b 100644 --- a/config.mk +++ b/config.mk @@ -52,10 +52,17 @@ LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \ $(LITEOS_LD_SCRIPT) # clear all local variables -LOCAL_FLAGS := -LOCAL_CFLAGS := -LOCAL_CPPFLAGS := -LOCAL_ASFLAGS := -LOCAL_SRCS := -LOCAL_CHS := -LOCAL_CPPHS := +LOCAL_FLAGS = +LOCAL_CFLAGS = +LOCAL_CPPFLAGS = +LOCAL_ASFLAGS = +LOCAL_SRCS = +LOCAL_CHS = +LOCAL_CPPHS = + +# basic build flags +CFLAGS := $(LITEOS_CFLAGS) +CXXFLAGS := $(LITEOS_CXXFLAGS) +ASFLAGS := $(LITEOS_ASFLAGS) +LDFLAGS := $(LITEOS_LDFLAGS) +ARFLAGS := rc diff --git a/kernel/user/Makefile b/kernel/user/Makefile index 8a7c03a3..3136ff5b 100644 --- a/kernel/user/Makefile +++ b/kernel/user/Makefile @@ -44,7 +44,7 @@ include $(MODULE) USERINIT := $(OUT)/lib/lib$(MODULE_NAME).O -$(USERINIT): $(MODULE) +$(USERINIT): $(TARGET) $(HIDE)$(LD) -r -o $@ --whole-archive $< --no-whole-archive clean_userinit: diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index 31f7e71a..13306c66 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -36,14 +36,9 @@ endif ## variable define ## HIDE = @ RM = -rm -rf -ARFLAGS = cr -OS := $(shell uname -s) -OBJ_MKDIR = if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi OUT = $(or $(OUTDIR),$(LITEOSTOPDIR)/out/$(LOSCFG_PRODUCT_NAME:"%"=%)) -BUILD = $(OUT)/obj MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk LITEOS_SCRIPTPATH = $(LITEOSTOPDIR)/tools/scripts -LITEOS_PLATFORM = $(LOSCFG_PLATFORM:"%"=%) LITEOSTHIRDPARTY = $(LITEOSTOPDIR)/../../third_party ## compiler relative ## @@ -328,8 +323,6 @@ ifeq ($(LOSCFG_NET_LWIP_SACK_2_1), y) -I $(LITEOSTOPDIR)/net/lwip-2.1/porting/include \ -I $(LWIPDIR)/include \ -I $(LITEOSTOPDIR)/net/mac - - LITEOS_CMACRO += $(LWIP_MACROS) else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y) LWIPDIR := $(LITEOSTHIRDPARTY)/lwip_enhanced/src LITEOS_BASELIB += -llwip @@ -337,8 +330,7 @@ else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y) LITEOS_LWIP_SACK_INCLUDE += \ -I $(LWIPDIR)/include \ -I $(LITEOSTOPDIR)/net/mac - LWIP_MACROS += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT - LITEOS_CMACRO += $(LWIP_MACROS) + LITEOS_CMACRO += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT else $(error "unknown lwip version") endif diff --git a/tools/build/mk/module.mk b/tools/build/mk/module.mk index c4378f6b..23820b6d 100644 --- a/tools/build/mk/module.mk +++ b/tools/build/mk/module.mk @@ -27,88 +27,50 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(MODULE_NAME) +OBJOUT = $(OUT)/obj +TOPDIR = $(abspath $(LITEOSTOPDIR)/../..) -MODULE := $(OUT)/lib/lib$(MODULE_NAME).a +TARGET = $(OUT)/lib/lib$(MODULE_NAME).a -# create a separate list of objects per source type +LOCAL_OBJS = $(addprefix $(OBJOUT)/,$(addsuffix .o,$(basename $(subst $(TOPDIR)/,,$(abspath $(LOCAL_SRCS)))))) -LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS)) -LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS)) -LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS)) -LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS)) -LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS)) +all : $(TARGET) -LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS)) -LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS)) -LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS)) -LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2)) -LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS)) - -LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS) - -LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS)) -LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS)) - -all : $(MODULE) - -define ECHO = -ifeq ($$(HIDE),@) -_$(1) := $($(1)) -$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1)) +ifeq ($(HIDE),@) +ECHO = $1 = echo " $1" $$(patsubst $$(OUT)/%,%,$$@) && $($1) +$(foreach cmd,CC GPP AS AR LD,$(eval $(call ECHO,$(cmd)))) endif -endef -$(foreach cmd,CC GPP AS AR,$(eval $(call ECHO,$(cmd)))) LOCAL_FLAGS += -MD -MP -include $(LOCAL_OBJS:%.o=%.d) -$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ +$(OBJOUT)/%.o: $(TOPDIR)/%.c + $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ -$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ +$(OBJOUT)/%.o: $(TOPDIR)/%.cpp + $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ -$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ +$(OBJOUT)/%.o: $(TOPDIR)/%.S + $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ -$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(AS) $(LITEOS_ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ +$(OBJOUT)/%.o: $(TOPDIR)/%.s + $(HIDE)$(AS) $(ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@ -$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc - $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ +$(OBJOUT)/%.o: $(TOPDIR)/%.cc + $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@ -$(LOCAL_CGCH): %.h.gch : %.h - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^ - -$(LOCAL_CPPGCH): %.h.gch : %.h - $(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^ - -LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH) - -$(LOCAL_OBJS): $(LOCAL_GCH) -$(MODULE): $(LOCAL_OBJS) - $(HIDE)$(OBJ_MKDIR) +$(OUT)/lib/lib%.a: $(LOCAL_OBJS) $(HIDE)$(AR) $(ARFLAGS) $@ $^ +$(OUT)/bin/%: $(LOCAL_OBJS) + $(HIDE)$(GPP) $(LDFLAGS) -o $@ $^ + +$(OUT)/%/:;$(HIDE)mkdir -p $@ + +$(LOCAL_OBJS): | $(dir $(LOCAL_OBJS)) +$(TARGET): | $(dir $(TARGET)) + clean: - $(HIDE)$(RM) $(MODULE) $(OBJOUT) $(LOCAL_GCH) *.bak *~ + $(HIDE)$(RM) $(TARGET) $(LOCAL_OBJS) .PHONY: all clean - -# clear some variables we set here -LOCAL_CSRCS := -LOCAL_CPPSRCS := -LOCAL_ASMSRCS := -LOCAL_COBJS := -LOCAL_CPPOBJS := -LOCAL_ASMOBJS := -LOCAL_ASMOBJS2 := - -# LOCAL_OBJS is passed back -#LOCAL_OBJS :=