chore(make): simplify build scripts
remove redundant script codes Signed-off-by: Caoruihong <crh.cao@huawei.com> Change-Id: I67695a69cccefc220ede55add9372bce0c59d7f5
This commit is contained in:
parent
ba977dd5ab
commit
a627cdba0c
86
apps/app.mk
86
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)
|
||||
|
|
|
@ -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 :=
|
||||
|
|
|
@ -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
|
||||
|
|
21
config.mk
21
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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 :=
|
||||
|
|
Loading…
Reference in New Issue