• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 C API wrapper library
31#
32
33CXX := $(MASTER_CXX)
34LINKER := $(MASTER_LINKER)
35LIB := $(MASTER_LIB)
36
37LIB_NAME = lib$(LIB_CAPI_NAME)
38SO_LIB_DEPS= -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
39
40BUILD_DIR=./$(PLAT_DIR)
41
42VPATH=	$(OCSD_SOURCE)/c_api
43
44CXX_INCLUDES= \
45				-I$(OCSD_INCLUDE) \
46				-I$(OCSD_SOURCE)/c_api
47
48OBJECTS=$(BUILD_DIR)/ocsd_c_api.o \
49		$(BUILD_DIR)/ocsd_c_api_custom_obj.o
50
51INST_INC_SRC=$(OCSD_INCLUDE)/$(LIB_UAPI_INC_DIR)
52INST_INC_DST=$(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
53
54all: links
55
56links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
57.PHONY: links
58
59LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
60
61$(LIB_TARGET_DIR):
62	mkdir -p  $(LIB_TARGET_DIR)
63
64$(BUILD_DIR):
65	mkdir -p $(BUILD_DIR)
66
67$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
68	$(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
69
70$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
71	$(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS) $(SO_LIB_DEPS)
72
73$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
74	( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
75
76$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
77	( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
78
79
80##### build rules
81
82## object dependencies
83DEPS := $(OBJECTS:%.o=%.d)
84
85-include $(DEPS)
86
87## object compile
88$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
89	$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
90
91
92#### clean
93.PHONY: clean
94clean:
95	rm -f $(OBJECTS)
96	rm -f $(DEPS)
97	rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).a
98	rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so*
99	-rmdir $(BUILD_DIR)
100
101#### install the necessary include files for the c-api library on linux
102install_inc:
103	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/
104	$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_gen_elem_types.h $(INST_INC_DST)/
105	$(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_types.h $(INST_INC_DST)/
106	$(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_version.h $(INST_INC_DST)/
107	$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_pkt_types.h $(INST_INC_DST)/
108	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/ptm
109	$(INSTALL) --mode=0644 $(INST_INC_SRC)/ptm/trc_pkt_types_ptm.h $(INST_INC_DST)/ptm/
110	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/stm
111	$(INSTALL) --mode=0644 $(INST_INC_SRC)/stm/trc_pkt_types_stm.h $(INST_INC_DST)/stm/
112	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/etmv3
113	$(INSTALL) --mode=0644 $(INST_INC_SRC)/etmv3/trc_pkt_types_etmv3.h $(INST_INC_DST)/etmv3/
114	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/etmv4
115	$(INSTALL) --mode=0644 $(INST_INC_SRC)/etmv4/trc_pkt_types_etmv4.h $(INST_INC_DST)/etmv4/
116	$(INSTALL) -d --mode=0755 $(INST_INC_DST)/c_api
117	$(INSTALL) --mode=0644 $(INST_INC_SRC)/c_api/ocsd_c_api_types.h $(INST_INC_DST)/c_api/
118	$(INSTALL) --mode=0644 $(INST_INC_SRC)/c_api/opencsd_c_api.h $(INST_INC_DST)/c_api/
119	$(INSTALL) --mode=0644 $(INST_INC_SRC)/c_api/ocsd_c_api_custom.h $(INST_INC_DST)/c_api/
120
121
122