xref: /utopia/UTPA2-700.0.x/mxlib/sys_rule.mk (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1
2################################################################################
3#
4# Copyright (c) 2008-2009 MStar Semiconductor, Inc.
5# All rights reserved.
6#
7# Unless otherwise stipulated in writing, any and all information contained
8# herein regardless in any format shall remain the sole proprietary of
9# MStar Semiconductor Inc. and be kept in strict confidence
10# ("MStar Confidential Information") by the recipient.
11# Any unauthorized act including without limitation unauthorized disclosure,
12# copying, use, reproduction, sale, distribution, modification, disassembling,
13# reverse engineering and compiling of the contents of MStar Confidential
14# Information is unlawful and strictly prohibited. MStar hereby reserves the
15# rights to any and all damages, losses, costs and expenses resulting therefrom.
16#
17#
18# Makefile used for building DDI
19#
20#
21################################################################################
22
23export
24unexport SYS_SRC
25unexport SYS_CC_INCS
26unexport VPATH
27
28
29# **********************************************
30# Rules
31# **********************************************
32LIB_NAME = $(SYS_NAME)
33
34SYS_SRC     = $(wildcard $(CURDIR)/*.c)
35SYS_OBJ     = $(foreach file, $(notdir $(patsubst %.c, %.o, $(SYS_SRC))), $(OBJ_PATH)/$(file))
36SYS_IMPORT_SRC = $(wildcard $(CURDIR)/obj_import/$(OS_TYPE)/$(MCU_TYPE)/*.src)
37SYS_IMPORT_OBJ = $(foreach file, $(notdir $(patsubst %.src, %.o, $(SYS_IMPORT_SRC))), $(OBJ_PATH)/$(file))
38SYS_CC_INCS = $(foreach dir,$(SYS_INCDIR),-I$(dir))
39
40ifeq ($(MAKE_TYPE),lint)
41ifeq ($(shell uname -o),Cygwin)
42LINT_INC   += $(foreach dir,$(shell cygpath -m $(SYS_INCDIR)),-i"$(dir)")
43else
44LINT_INC   += $(foreach dir,$(SYS_INCDIR),-i"$(dir)")
45endif
46endif
47
48VPATH =
49
50ifeq ("$(UTOPIA_BSP_VERSION)", "")
51UTOPIA_BSP_VERSION = 000000
52endif
53
54ifeq ("$(P4PORT)", "")
55SW_VERSION_SYS_$(SYS_NAME) = 0
56else
57SW_VERSION_SYS_$(SYS_NAME) := $(shell p4 changes -m1 "./...\#have" | egrep Change | awk '{print $$2}')
58ifeq ("$(SW_VERSION_SYS_$(SYS_NAME))", "")
59SW_VERSION_SYS_$(SYS_NAME) = 0
60endif
61endif
62SW_SYS_FLOW_ENABLE = TRUE
63CC_DEFS += -DSW_VERSION_SYS_$(SYS_NAME)=$(SW_VERSION_SYS_$(SYS_NAME))
64
65.PHONY : all clean depend
66
67all : $(SYS_OBJ) $(SYS_IMPORT_OBJ)
68
69lib : setup all
70ifeq ($(LINK_TYPE),dynamic)
71	@$(CC) $(CFG_CC_OPTS) $(LD_OPTS) $(wildcard $(OBJ_PATH)/*.T) $(SYS_OBJ) $(SYS_IMPORT_OBJ) -o $(DDI_PATH)/lib$(LIB_NAME).$(LIB_EXT) ;
72	@rm -f $(OBJ_PATH)/*.T
73endif
74
75ifeq ($(TOOLCHAIN),mips-linux-gnu)
76ifeq ($(OS_TYPE),nos)
77SW_MBOOT_FLOW = TRUE
78endif
79endif
80
81	@$(OBJCOPY) --add-section .mmodule_version=../version_info $(DDI_PATH)/lib$(LIB_NAME).$(LIB_EXT)
82
83ifeq ($(PARA), 1)
84	@if [ ! -f $(DDIDRV)/$@/cpptestscan.bdf ]; then						\
85		echo ERROR! No $(DDIDRV)/$@/cpptestscan.bdf;					\
86	fi
87	@if [ -f $(DDIDRV)/$@/cpptestscan.bdf ]; then						\
88		cat $(DDIDRV)/$@/cpptestscan.bdf >> $(PROJ)/cpptestscan.bdf;	\
89		rm -f $(DDIDRV)/$@/cpptestscan.bdf;								\
90	fi
91endif
92
93$(SYS_IMPORT_OBJ) :
94	echo find api import_obj cp from $(filter %$(notdir $*).src,$(SYS_IMPORT_SRC)) to $@
95	cp $(filter %$(notdir $*).src,$(SYS_IMPORT_SRC)) $@
96ifneq ($(LINK_TYPE),dynamic)
97	@$(AR) cru $(DDI_PATH)/lib$(LIB_NAME).$(LIB_EXT) $@;
98ifeq ($(BLT_TYPE),retail)
99	@$(STRIP) -S $(DDI_PATH)/lib$(LIB_NAME).$(LIB_EXT)
100endif
101endif
102
103$(SYS_OBJ) : $(OBJ_PATH)/%.o : %.c
104ifneq ($(MAKE_TYPE),lint)
105	@echo [CC] $(notdir $<)
106	@$(CC) $(CC_OPTS) $(CC_DEFS) $(CC_INCS) $(SYS_CC_INCS) -o $@ $<;
107ifneq ($(LINK_TYPE),dynamic)
108	@$(AR) cru $(DDI_PATH)/lib$(LIB_NAME).$(LIB_EXT) $@;
109endif
110else
111	@echo [LINT] $(notdir $<)
112ifeq ($(shell uname -o),Cygwin)
113	@$(LINT_CMD) $(CC_DEFS) $(LINT_INC) $(shell cygpath -m $<) >>$(LINT_LOG)
114#	echo $(shell cygpath -m $<) >>$(LINT_FILES)
115else
116	@$(LINT_CMD) $(CC_DEFS) $(LINT_INC) $< >>$(LINT_LOG)
117#	echo $< >>$(LINT_FILES)
118endif
119endif
120
121setup :
122ifeq ($(LINK_TYPE),dynamic)
123	@echo [api_rule.mk][lib$(LIB_NAME).$(LIB_EXT)]
124	@rm -f $(OBJ_PATH)/*.T
125else
126	@echo [api_rule.mk][lib$(LIB_NAME).$(LIB_EXT)]
127endif
128
129clean :
130	@rm -f $(SYS_OBJ)
131	@rm -f $(SYS_IMPORT_OBJ)
132	@rm -f $(DDI_PATH)/lib$(LIB_NAME).a
133	@rm -f $(DDI_PATH)/lib$(LIB_NAME).so
134
135
136