1########################################################
2# Copyright 2015 ARM Limited. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without modification,
5# are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# 3. Neither the name of the copyright holder nor the names of its contributors
15# may be used to endorse or promote products derived from this software without
16# specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29#################################################################################
30# OpenCSD - makefile for main trace decode library
31#
32
33CXX := $(MASTER_CXX)
34LINKER := $(MASTER_LINKER)
35LIB := $(MASTER_LIB)
36
37LIB_NAME= lib$(LIB_BASE_NAME)
38
39BUILD_DIR=./$(PLAT_DIR)
40
41VPATH=	$(OCSD_SOURCE) \
42		$(OCSD_SOURCE)/etmv3 \
43		$(OCSD_SOURCE)/etmv4 \
44		$(OCSD_SOURCE)/ete \
45		$(OCSD_SOURCE)/ptm \
46		$(OCSD_SOURCE)/i_dec \
47		$(OCSD_SOURCE)/mem_acc \
48		$(OCSD_SOURCE)/stm \
49		$(OCSD_SOURCE)/pkt_printers
50
51
52CXX_INCLUDES= \
53				-I$(OCSD_INCLUDE) \
54				-I$(OCSD_SOURCE)
55
56ETMV3OBJ=	$(BUILD_DIR)/trc_cmp_cfg_etmv3.o \
57			$(BUILD_DIR)/trc_pkt_decode_etmv3.o \
58			$(BUILD_DIR)/trc_pkt_elem_etmv3.o \
59			$(BUILD_DIR)/trc_pkt_proc_etmv3.o \
60			$(BUILD_DIR)/trc_pkt_proc_etmv3_impl.o
61
62ETMV4OBJ=	$(BUILD_DIR)/trc_cmp_cfg_etmv4.o \
63			$(BUILD_DIR)/trc_etmv4_stack_elem.o \
64			$(BUILD_DIR)/trc_pkt_proc_etmv4i.o \
65			$(BUILD_DIR)/trc_pkt_decode_etmv4i.o \
66			$(BUILD_DIR)/trc_pkt_elem_etmv4i.o \
67			$(BUILD_DIR)/trc_cmp_cfg_ete.o
68
69PTMOBJ=		$(BUILD_DIR)/trc_cmp_cfg_ptm.o \
70			$(BUILD_DIR)/trc_pkt_elem_ptm.o \
71			$(BUILD_DIR)/trc_pkt_proc_ptm.o \
72			$(BUILD_DIR)/trc_pkt_decode_ptm.o
73
74IDECOBJ=	$(BUILD_DIR)/trc_i_decode.o \
75			$(BUILD_DIR)/trc_idec_arminst.o
76
77MEMACCOBJ=	$(BUILD_DIR)/trc_mem_acc_mapper.o \
78			$(BUILD_DIR)/trc_mem_acc_bufptr.o \
79			$(BUILD_DIR)/trc_mem_acc_file.o \
80			$(BUILD_DIR)/trc_mem_acc_base.o \
81			$(BUILD_DIR)/trc_mem_acc_cb.o \
82			$(BUILD_DIR)/trc_mem_acc_cache.o
83
84STMOBJ=		$(BUILD_DIR)/trc_pkt_elem_stm.o \
85			$(BUILD_DIR)/trc_pkt_proc_stm.o \
86			$(BUILD_DIR)/trc_pkt_decode_stm.o
87
88PKTPRNTOBJ=	$(BUILD_DIR)/raw_frame_printer.o \
89			$(BUILD_DIR)/trc_print_fact.o
90
91
92OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \
93		$(BUILD_DIR)/ocsd_dcd_tree.o \
94		$(BUILD_DIR)/ocsd_error.o \
95		$(BUILD_DIR)/ocsd_error_logger.o \
96		$(BUILD_DIR)/ocsd_gen_elem_list.o \
97		$(BUILD_DIR)/ocsd_gen_elem_stack.o \
98		$(BUILD_DIR)/ocsd_lib_dcd_register.o \
99		$(BUILD_DIR)/ocsd_msg_logger.o \
100		$(BUILD_DIR)/ocsd_version.o \
101		$(BUILD_DIR)/trc_component.o \
102		$(BUILD_DIR)/trc_core_arch_map.o \
103		$(BUILD_DIR)/trc_frame_deformatter.o \
104		$(BUILD_DIR)/trc_gen_elem.o \
105		$(BUILD_DIR)/trc_printable_elem.o \
106		$(BUILD_DIR)/trc_ret_stack.o \
107		$(ETMV3OBJ) \
108		$(ETMV4OBJ) \
109		$(IDECOBJ) \
110		$(MEMACCOBJ) \
111		$(STMOBJ) \
112		$(PTMOBJ) \
113		$(PKTPRNTOBJ)
114
115all: links
116
117links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
118.PHONY: links
119
120LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
121
122$(LIB_TARGET_DIR):
123	mkdir -p $(LIB_TARGET_DIR)
124
125$(BUILD_DIR):
126	mkdir -p $(BUILD_DIR)
127
128$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
129	$(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
130
131$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
132	$(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS)
133
134$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
135	( cd $(LIB_TARGET_DIR);  ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
136
137$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
138	( cd $(LIB_TARGET_DIR);  ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
139
140
141##### build rules
142
143## object dependencies
144DEPS := $(OBJECTS:%.o=%.d)
145
146-include $(DEPS)
147
148## object compile
149$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
150	$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD  $< -o $@
151
152
153#### clean
154.PHONY: clean
155clean:
156	rm -f $(OBJECTS)
157	rm -f $(DEPS)
158	rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).a
159	rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so*
160	-rmdir $(BUILD_DIR)
161