Re-organized sub-directory by category
[staging/basesystem.git] / service / native / framework_unified / client / NativeServices / cfg / common.mk
1 #
2 # @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 ####################################################################
18 # DO NOT EDIT THIS FILE
19 # Common Project Makefile definitions shared by all types of makefiles
20 #
21 #
22 # Please use project.mk in your build folder to customize your build
23 #######################################################################
24
25 include $(PRJ_ROOT)cfg/depends.mk
26
27 ifndef COMPONENT_ROOT
28 export COMPONENT_ROOT=$(COMPONENT_NAME)
29 endif
30
31 # Additive Compile Flags (Flags from initiating make process will still apply)
32 DEFS += $(PROJECT_FLAGS)
33
34 # Set local includes and then the reference includes (priority order determines search path)
35 INCLUDES = \
36         $(CC_IFLAG)./ \
37         $(CC_IFLAG)$(TEAM_ROOT)$(COMPONENT_ROOT)/inc \
38         $(addprefix $(CC_IFLAG),$(PROJECT_INCLUDE_PATHS)) \
39         $(DEPENDS_INCLUDES) \
40
41
42 # Do the same if you need to include library paths as well
43 LIB_PATHS += \
44         $(PROJECT_LIB_PATHS) \
45         $(DEPENDS_LIB_PATHS) \
46
47
48 LD_STATIC_LIBS += \
49         $(PROJECT_STATIC_LIBS)
50
51 LD_DYNAMIC_LIBS += \
52         $(PROJECT_DYNAMIC_LIBS)
53
54 ## Sources Section
55
56 # Define Library & Executable Sources (on a per deliverable basis)
57 #  This includes sources located in subdirectories.
58
59 # Define generic line that pulls all c, cc, cpp files
60 # since your in the src folder is pull only files from there
61 COMPONENT_SRCS = \
62         $(wildcard *.cpp)
63
64 # Define sources that my not be local to your component
65 # here, you can define indivial files or wildcard from
66 # a different folder.
67 NON_LOCAL_SRCS = \
68
69
70 # List of all sources to be built.  Can be assembled from the other defintitions.
71 #  This only defines sources for the current directory, so if there are subdirectories
72 #  those are not included.  (Those are found in simple subdirectory makefiles that only
73 #  direct the building of sources, but no linking into a binary)
74 SOURCES = \
75         $(COMPONENT_SRCS) \
76         $(NON_LOCAL_SRCS) \
77
78
79 # Convert the source files to object files with correct folder location.
80 C_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.c ,$(SOURCES) ) ) ) )
81 CPP_LANG_OBJECTS = $(addprefix $(BLD_PATH),$(addsuffix .$(OBJ_EXT),$(basename $(filter %.cpp %.cc %.cxx,$(SOURCES) ) ) ) )
82
83
84 # List of all sources to be generated.  Can be assembled from the other defintitions.
85 OBJECTS = \
86         $(C_LANG_OBJECTS) \
87         $(CPP_LANG_OBJECTS)
88
89 D_FILES = $(OBJECTS:.o=.d)
90
91 # pull in dependency info for existing .o files
92 -include $(D_FILES)
93
94
95 ifeq ($(BUILDTYPE),APP)
96 COMPONENT_EXEC = $(BIN_PATH)$(COMPONENT_NAME)$(DEBUG_EXT)
97 BINARIES = \
98         $(COMPONENT_EXEC)
99
100 $(COMPONENT_EXEC): $(OBJECTS)
101         $(LD_CMD) $(LD_OFLAG) $(@) $(OBJECTS) $(addprefix -L , $(LIB_PATHS)) -Bstatic $(addprefix -l , $(LD_STATIC_LIBS)) -Bdynamic $(addprefix -l , $(LD_DYNAMIC_LIBS))
102
103 endif
104
105 ifeq ($(BUILDTYPE),DLL)
106 COMPONENT_SOLIB = $(SLIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(SO_EXT)
107 LIBRARIES = \
108         $(COMPONENT_SOLIB) \
109
110 $(COMPONENT_SOLIB): $(OBJECTS)
111         $(SO_CMD) $(OBJECTS) $(LD_OFLAG) $(@) $(addprefix -L, $(LIB_PATHS)) \
112                 -Bstatic $(addprefix -l,$(STATIC_LIBS)) -Bdynamic $(addprefix -l,$(DYNAMIC_LIBS))
113
114 endif
115
116 ifeq ($(BUILDTYPE),LIB)
117 COMPONENT_LIB = $(LIB_PATH)$(LIB_PREFIX)$(COMPONENT_NAME)$(DEBUG_EXT).$(LIB_EXT)
118 LIBRARIES = \
119         $(COMPONENT_LIB) \
120
121 $(COMPONENT_LIB): $(OBJECTS)
122         $(AR_CMD)
123
124 endif
125
126
127
128 # Make targets
129 #  Standard
130 all: banner module_dirs subdirs local library binary
131
132 base: banner module_dirs subdirs local
133
134
135 $(BLD_PATH)/%.o: %.cpp
136         $(CPP_CMD)
137         $(CPP_D_CMD)
138         @mv -f $(@:.o=.d) $(@:.o=.d).tmp
139         @sed -e 's|.*: |$@: |' < $(@:.o=.d).tmp > $(@:.o=.d)
140         @rm -f $(@:.o=.d).tmp
141
142 local: $(OBJECTS)
143
144 # Standard set of derived targets
145 library: base \
146         $(LIBRARIES)
147         @echo "***** `date` Done building library: $(COMPONENT_NAME) ******"
148
149 binary: base \
150         $(BINARIES)
151
152 # Subdirs should be to jump to subdirectories
153 #  standard form is of
154 #  $(MAKE) -C subdirectory_name $(MAKECMDGOALS)
155 subdirs:
156
157 clean:
158         -rm -f $(BINARIES)
159         -rm -f $(LIBRARIES)
160         -rm -f $(OBJECTS)
161         -rm -f $(D_FILES)
162
163 -v:
164         @echo "objs: --> $(OBJECTS)"
165         @echo "sources: --> $(SOURCES)"
166         @echo "headers: --> $(HEADERS)"
167         @echo "includes: --> $(INCLUDES)"
168         @echo "lib paths: --> $(LIB_PATHS)"
169         @echo "static libs: --> $(LD_STATIC_LIBS)"
170         @echo "dynamic libs: --> $(LD_DYNAMIC_LIBS)"
171         @echo "lib: --> $(LIBRARIES)"
172         @echo "bin: --> $(BINARIES)"
173
174
175 module_dirs: build_dirs