summaryrefslogtreecommitdiff
path: root/alarm-svc/Build/build_c.mk
blob: d818ab60863c060fd236ec1ec69b6a7a9a04acb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# C/C++ build script


_FUNC_EXT2O = $(patsubst %.$(3),$(1)/%.o,$(2))
_FUNC_C2O = $(call _FUNC_EXT2O,$(1),$(2),c)
_FUNC_CPP2O = $(call _FUNC_EXT2O,$(1),$(2),cpp)


# parameter :
#  $(1) - C/C++ soruce file
#  $(2) - output path
#  $(3) - .ext
CONVERT_ESC_EXT_TO_O = $(addprefix $(2)/,$(call CONVERT_4MAKE_TO_OUT,$(patsubst %.$(3),%.o,$(1))))

CONVERT_ESC_C_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),c)
CONVERT_ESC_CPP_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),cpp)


# parameter :
#  $(1) - encoded one C/C++ soruce file
#  $(2) - output path
#  $(3) - ext title (C/C++)
#  $(4) - ext (c/cpp)
#  $(5) - compiler ($(CC)/$(CXX))
#  $(6) - build opt
#  $(7) - build opt file
# output :
#  $(8) - output files list
define C_BUILD_PROC_RAW
$(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) : $(call DECODE_4MAKE,$(1)) $(7)
	@echo '  Building file: $$<'
	@echo '  Invoking: $(3) Compiler'
	$$(call MAKEDIRS,$$(@D))
	$(5) -c "$$<" -o "$$@" $(6) -Wp,@$(7)
	@echo '  Finished building: $$<'
$(8) += $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4))
endef


# parameter :
#  $(1) - output paths
#  $(2) - src paths
#  $(3) - inc paths
#  $(4) - inc files
#  $(5) - Defs
#  $(6) - UnDefs
#  $(7) - compiler opt
#  $(8) - compiler opt file
#  $(9) - ext title (C/C++)
#  $(10) - ext (c/cpp)
#  $(11) - compiler ($(CC)/$(CXX))
# output :
#  $(12) - OBJS 
# return :
#  none
define C_PROC_RAW

_OUTPUT_DIR := $$(strip $(1))#
_SRCS := $(2)# 
_INCS := $(3)# 
_INC_FILES := $(4)# 
_DEFS := $(5)# 
_UNDEFS := $(6)# 

_OPT := $(7)
_OPT_FILE := $(8)

_EXT_TITLE := $(9)
_EXT := $(10)
_COMPILER := $(11)

#_OUTPUT_FILES := $(12)

_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) 
_ENC_SRCS := $$(filter %.$$(_EXT),$$(_ENC_SRCS))

ifneq ($$(strip $$(_SRCS)),)

_NORMAL_SRCS := $$(filter-out %*.$$(_EXT),$$(_ENC_SRCS))
_WIDLCARD_SRCS := $$(filter %*.$$(_EXT),$$(_ENC_SRCS))

_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \
             $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var))))

ifneq ($$(strip $$(_ALL_SRCS)),)

_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) 

_CDEFS := $$(CDEFS)
_CDEFS += $$(addprefix -D,$$(_DEFS))
_CDEFS += $$(addprefix -U,$$(_UNDEFS))

_ENC_C_INCS := $$(call ENCODE_4MAKE,$$(_INCS))
_ENC_C_INCS := $$(addprefix -I,$$(_ENC_C_INCS))
 
_ENC_INC_FILES := $$(call ENCODE_4MAKE,$$(_INC_FILES)) 
_ENC_INC_FILES += $$(addprefix -include,$$(_ENC_INC_FILES))

_C_INCS := $$(call DECODE_4MAKE,$$(_ENC_C_INCS) $$(_ENC_C_INC_FILES))

_DEFS := $$(_CDEFS) $$(_C_INCS) -I"pch" $$(_OPT)

$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call C_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_EXT_TITLE),$$(_EXT),$$(_COMPILER),$$(_DEFS),$$(_OPT_FILE),$(12))))

endif  # (_(strip _(_ALL_SRCS)),)

endif  # (_(strip _(_SRCS)),)


endef