提交 a627cdba 编写于 作者: C Caoruihong

chore(make): simplify build scripts

remove redundant script codes
Signed-off-by: NCaoruihong <crh.cao@huawei.com>
Change-Id: I67695a69cccefc220ede55add9372bce0c59d7f5
上级 ba977dd5
...@@ -27,88 +27,6 @@ ...@@ -27,88 +27,6 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # 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) include $(MODULE)
# 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 :=
...@@ -69,12 +69,3 @@ endif ...@@ -69,12 +69,3 @@ endif
ifeq ($(LOSCFG_DRIVERS_TRACE), y) ifeq ($(LOSCFG_DRIVERS_TRACE), y)
APP_SUBDIRS += trace APP_SUBDIRS += trace
endif endif
# clear all local variables
LOCAL_FLAGS :=
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_ASFLAGS :=
LOCAL_SRCS :=
LOCAL_CHS :=
LOCAL_CPPHS :=
...@@ -74,12 +74,3 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \ ...@@ -74,12 +74,3 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include -I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
LITEOS_PLATFORM_INCLUDE += $(ARCH_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
...@@ -52,10 +52,17 @@ LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \ ...@@ -52,10 +52,17 @@ LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
$(LITEOS_LD_SCRIPT) $(LITEOS_LD_SCRIPT)
# clear all local variables # clear all local variables
LOCAL_FLAGS := LOCAL_FLAGS =
LOCAL_CFLAGS := LOCAL_CFLAGS =
LOCAL_CPPFLAGS := LOCAL_CPPFLAGS =
LOCAL_ASFLAGS := LOCAL_ASFLAGS =
LOCAL_SRCS := LOCAL_SRCS =
LOCAL_CHS := LOCAL_CHS =
LOCAL_CPPHS := LOCAL_CPPHS =
# basic build flags
CFLAGS := $(LITEOS_CFLAGS)
CXXFLAGS := $(LITEOS_CXXFLAGS)
ASFLAGS := $(LITEOS_ASFLAGS)
LDFLAGS := $(LITEOS_LDFLAGS)
ARFLAGS := rc
...@@ -44,7 +44,7 @@ include $(MODULE) ...@@ -44,7 +44,7 @@ include $(MODULE)
USERINIT := $(OUT)/lib/lib$(MODULE_NAME).O USERINIT := $(OUT)/lib/lib$(MODULE_NAME).O
$(USERINIT): $(MODULE) $(USERINIT): $(TARGET)
$(HIDE)$(LD) -r -o $@ --whole-archive $< --no-whole-archive $(HIDE)$(LD) -r -o $@ --whole-archive $< --no-whole-archive
clean_userinit: clean_userinit:
......
...@@ -36,14 +36,9 @@ endif ...@@ -36,14 +36,9 @@ endif
## variable define ## ## variable define ##
HIDE = @ HIDE = @
RM = -rm -rf 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:"%"=%)) OUT = $(or $(OUTDIR),$(LITEOSTOPDIR)/out/$(LOSCFG_PRODUCT_NAME:"%"=%))
BUILD = $(OUT)/obj
MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk MODULE = $(LITEOSTOPDIR)/tools/build/mk/module.mk
LITEOS_SCRIPTPATH = $(LITEOSTOPDIR)/tools/scripts LITEOS_SCRIPTPATH = $(LITEOSTOPDIR)/tools/scripts
LITEOS_PLATFORM = $(LOSCFG_PLATFORM:"%"=%)
LITEOSTHIRDPARTY = $(LITEOSTOPDIR)/../../third_party LITEOSTHIRDPARTY = $(LITEOSTOPDIR)/../../third_party
## compiler relative ## ## compiler relative ##
...@@ -328,8 +323,6 @@ ifeq ($(LOSCFG_NET_LWIP_SACK_2_1), y) ...@@ -328,8 +323,6 @@ ifeq ($(LOSCFG_NET_LWIP_SACK_2_1), y)
-I $(LITEOSTOPDIR)/net/lwip-2.1/porting/include \ -I $(LITEOSTOPDIR)/net/lwip-2.1/porting/include \
-I $(LWIPDIR)/include \ -I $(LWIPDIR)/include \
-I $(LITEOSTOPDIR)/net/mac -I $(LITEOSTOPDIR)/net/mac
LITEOS_CMACRO += $(LWIP_MACROS)
else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y) else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y)
LWIPDIR := $(LITEOSTHIRDPARTY)/lwip_enhanced/src LWIPDIR := $(LITEOSTHIRDPARTY)/lwip_enhanced/src
LITEOS_BASELIB += -llwip LITEOS_BASELIB += -llwip
...@@ -337,8 +330,7 @@ else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y) ...@@ -337,8 +330,7 @@ else ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y)
LITEOS_LWIP_SACK_INCLUDE += \ LITEOS_LWIP_SACK_INCLUDE += \
-I $(LWIPDIR)/include \ -I $(LWIPDIR)/include \
-I $(LITEOSTOPDIR)/net/mac -I $(LITEOSTOPDIR)/net/mac
LWIP_MACROS += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT LITEOS_CMACRO += -DLWIP_CONFIG_FILE=\"lwip/lwipopts.h\" -DLWIP_LITEOS_A_COMPAT
LITEOS_CMACRO += $(LWIP_MACROS)
else else
$(error "unknown lwip version") $(error "unknown lwip version")
endif endif
......
...@@ -27,88 +27,50 @@ ...@@ -27,88 +27,50 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # 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)) all : $(TARGET)
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)) ifeq ($(HIDE),@)
LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS)) ECHO = $1 = echo " $1" $$(patsubst $$(OUT)/%,%,$$@) && $($1)
LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS)) $(foreach cmd,CC GPP AS AR LD,$(eval $(call ECHO,$(cmd))))
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))
endif endif
endef
$(foreach cmd,CC GPP AS AR,$(eval $(call ECHO,$(cmd))))
LOCAL_FLAGS += -MD -MP LOCAL_FLAGS += -MD -MP
-include $(LOCAL_OBJS:%.o=%.d) -include $(LOCAL_OBJS:%.o=%.d)
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c $(OBJOUT)/%.o: $(TOPDIR)/%.c
$(HIDE)$(OBJ_MKDIR) $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp $(OBJOUT)/%.o: $(TOPDIR)/%.cpp
$(HIDE)$(OBJ_MKDIR) $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S $(OBJOUT)/%.o: $(TOPDIR)/%.S
$(HIDE)$(OBJ_MKDIR) $(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s $(OBJOUT)/%.o: $(TOPDIR)/%.s
$(HIDE)$(OBJ_MKDIR) $(HIDE)$(AS) $(ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(HIDE)$(AS) $(LITEOS_ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc $(OBJOUT)/%.o: $(TOPDIR)/%.cc
$(HIDE)$(OBJ_MKDIR) $(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_CGCH): %.h.gch : %.h $(OUT)/lib/lib%.a: $(LOCAL_OBJS)
$(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^ $(HIDE)$(AR) $(ARFLAGS) $@ $^
$(LOCAL_CPPGCH): %.h.gch : %.h $(OUT)/bin/%: $(LOCAL_OBJS)
$(HIDE)$(GPP) $(LITEOS_CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^ $(HIDE)$(GPP) $(LDFLAGS) -o $@ $^
LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH) $(OUT)/%/:;$(HIDE)mkdir -p $@
$(LOCAL_OBJS): $(LOCAL_GCH) $(LOCAL_OBJS): | $(dir $(LOCAL_OBJS))
$(MODULE): $(LOCAL_OBJS) $(TARGET): | $(dir $(TARGET))
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(AR) $(ARFLAGS) $@ $^
clean: clean:
$(HIDE)$(RM) $(MODULE) $(OBJOUT) $(LOCAL_GCH) *.bak *~ $(HIDE)$(RM) $(TARGET) $(LOCAL_OBJS)
.PHONY: all clean .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 :=
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册