Commit cf98ba14 authored by Ruslan Bukin's avatar Ruslan Bukin
Browse files

Import OpenCSD -- an ARM CoreSight Trace Decode library.

Git ID a1961c91b02a92f3c6ed8b145c636ac4c5565aca

Sponsored by:	DARPA, AFRL
parent a6157d81
......@@ -21,10 +21,10 @@ supplemented with modifications to the CoreSight framework and drivers to be
usable by the Perf core. The remaining out of tree patches are being
upstreamed incrementally.
From there compiling the perf tools with `make -C tools/perf` will yield a
`perf` executable that will support CoreSight trace collection. Note that if
traces are to be decompressed *off* target, there is no need to download and
compile the openCSD library (on the target).
From there compiling the perf tools with `make -C tools/perf CORESIGHT=1` will
yield a `perf` executable that will support CoreSight trace collection. Note
that if traces are to be decompressed *off* target, there is no need to download
and compile the openCSD library (on the target).
Before launching a trace run a sink that will collect trace data needs to be
identified. All CoreSight blocks identified by the framework are registed in
......@@ -306,7 +306,7 @@ and needs to be installed on a system prior to compilation. Information about
the status of the openCSD library on a system is given at compile time by the
perf tools build script:
linaro@t430:~/linaro/linux-kernel$ make VF=1 -C tools/perf
linaro@t430:~/linaro/linux-kernel$ make CORESIGHT=1 VF=1 -C tools/perf
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
......@@ -376,8 +376,8 @@ build script where to get the header file and libraries, namely CSINCLUDES and
CSLIBS:
linaro@t430:~/linaro/linux-kernel$ export CSINCLUDES=~/linaro/coresight/my-opencsd/decoder/include/
linaro@t430:~/linaro/linux-kernel$ export CSLIBS=~/linaro/coresight/my-opencsd/decoder/lib/linux64-rel/
linaro@t430:~/linaro/linux-kernel$ make VF=1 -C tools/perf
linaro@t430:~/linaro/linux-kernel$ export CSLIBS=~/linaro/coresight/my-opencsd/decoder/lib/builddir/
linaro@t430:~/linaro/linux-kernel$ make CORESIGHT=1 VF=1 -C tools/perf
This will have the effect of compiling and linking against the provided library.
Since the system's openCSD library is in the loader's search patch the
......@@ -611,37 +611,12 @@ will add the --dump option to the end of the command line and run
Generating coverage files for Feedback Directed Optimization: AutoFDO
---------------------------------------------------------------------
Below is an example of using ARM ETM for autoFDO. The updates to the perf
support for this is experimental and available on the 'autoFDO' branch of
the [perf-opencsd github repository][1].
It also requires autofdo (https://github.com/google/autofdo) and gcc version 5. The bubble
sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tutorial).
$ gcc-5 -O3 sort.c -o sort_optimized
$ taskset -c 2 ./sort_optimized
Bubble sorting array of 30000 elements
5910 ms
$ perf record -e cs_etm/@20070000.etr/u --per-thread taskset -c 2 ./sort
Bubble sorting array of 30000 elements
12543 ms
[ perf record: Woken up 35 times to write data ]
[ perf record: Captured and wrote 69.640 MB perf.data ]
$ perf inject -i perf.data -o inj.data --itrace=il64 --strip
$ create_gcov --binary=./sort --profile=inj.data --gcov=sort.gcov -gcov_version=1
$ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo
$ taskset -c 2 ./sort_autofdo
Bubble sorting array of 30000 elements
5806 ms
See autofdo.md (@ref AutoFDO) for details and scripts.
The Linaro CoreSight Team
-------------------------
- Mike Leach
- Tor Jeremiassen
- Chunyan Zang
- Mathieu Poirier
......
......@@ -27,11 +27,11 @@ Releases will appear on the master branch in the git repository with an appropri
CoreSight Trace Component Support.
----------------------------------
_Current Version 0.8.2_
_Current Version 0.12.0_
### Current support:
- ETMv4 (v4.1) instruction trace - packet processing and packet decode.
- ETMv4 (v4.4) instruction trace - packet processing and packet decode.
- PTM (v1.1) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) data trace - packet processing.
......@@ -73,12 +73,20 @@ Run `doxygen` on the `./doxygen_config.dox` file located in the `./docs` directo
This will produce the documentation in the `./docs/html` directory. The doxygen configuration also includes
the `*.md` files as part of the documentation.
Application Programming using the Library
-----------------------------------------
Building the Library
--------------------
See the [programmers guide](@ref prog_guide) for details on usage of the library in custom applications.
(`./docs/prog_guide/prog_guide_main.md`).
Building and Installing the Library
-----------------------------------
See [build_libs.md](@ref build_lib) in the `./docs` directory for build details.
The linux build makefile now contains options to install the library for a linux environment.
How the Library is used in Linux `perf`
---------------------------------------
......@@ -88,6 +96,15 @@ with the standard linux perfomance analysis tool `perf`.
See [HOWTO.md](@ref howto_perf) for details.
How to use the Library, perf and Trace for AutoFDO
--------------------------------------------------
Capturing trace using perf and decoding using the library can
generate profiles for AutoFDO.
See [autofdo.md](@ref AutoFDO) for details and scripts.
(`./tests/auto-fdo/autofdo.md`).
Version and Modification Information
====================================
......@@ -116,6 +133,39 @@ Version and Modification Information
Library output naming changed from 'cstraced' to 'opencsd'.
- _Version 0.8.1_: Minor updates: Use install tool to copy headers. Changes to HOWTO for perf usage.
- _Version 0.8.2_: Bugfix: C++ init errors fixed for CLANG build process.
- _Version 0.8.3_: Bugfix: ETMv4 decoder issues fixed.
- _Version 0.8.4_: build: makefile updates and improvements to get build process compatible with Debian packaging.
- _Version 0.9.0_: Performance improvements for perf: Additional info in instruction range output packet. Caching memory accesses.
Added Programmers guide to documentation.
- _Version 0.9.1_: Bugfix: Crash during decode when first memory access is to address where no image provided.
- _Version 0.9.2_: Bugfix: ETMv4: Incorrect Exception number output for Genric exception packets.
AutoFDO: update documentation for AutoFDO usage and add in "record.sh" script
- _Version 0.9.3_: Bugfix: Test snapshot library not handling 'offset' parameters in dump file sections.
Install: ocsd_if_version.h moved to opencsd/include to allow installation on OS & use in compiling client apps.
- _Version 0.10.0_: __Updates__: Add additional information about the last instruction to the generic output packet.
__Docs__: update docs for updated output packet.
__Bugfix__: typecast removed from OCSD_VER_NUM in ocsd_if_version.h to allow use in C pre-processor.
__Bugfix__: ETMV4: Interworking ISA change between A32-T32 occasionally missed during instruction decode.
- _Version 0.10.1_: __Updates__: Build update - allow multi-thread make (make -j<N>).
__Docs__: Minor update to AutoFDO documentation.
- _Version 0.11.0_: __Update__: ETM v4 decoder updated to support ETM version up to v4.4
__Update__: Memory access callback function - added new callback signature to provide TraceID to client when requesting memory.
__Update__: Created new example program to demonstrate using memory buffer in APIs.
__Bugfix__: Typos in docs and source.
__Bugfix__: Memory accessor - validate callback return values.
- _Version 0.11.1_: __Update__: build:- change -fpic to -fPIC to allow Debian build on sparc.
__Bugfix__: build:- remove unused variable
- _Version 0.11.2_: __Update__: docs:- HOWTO.md update to match new perf build requirements.
__Bugfix__: Minor spelling typos fixed.
- _Version 0.12.0_: __Update__: Frame deformatter - TPIU FSYNC and HSYNC support added.
__Update__: ETM v4: Bugfix & clarification on Exception trace handling. Where exception occurs at a branch target before any instructions
have been executed, the preferred return address is also the target address of the branch instruction. This case now includes as specific flag in
the packet. Additionally any context change associated with this target address was being applied incorrectly.
__Update__: Core / Architecture mapping to core names as used by test programs / snapshots updated to include additional recent ARM cores.
__Update__: Docs: Update to reflect new exception flag. Update test program example to reflect latest output.
__Bugfix__: ETM v4: Valid trace info packet was not handled correctly (0x01, 0x00).
__Bugfix__: ETM v4: Error messaging on commit stack overflow.
Licence Information
===================
......
......@@ -33,9 +33,9 @@
# DEBUG=1 create a debug build
#
# Set project root - relative to build directory
# Set project root - relative to build makefile
ifeq ($(OCSD_ROOT),)
OCSD_ROOT := $(shell pwd | sed 's,/build/linux.*,,')
OCSD_ROOT := $(shell echo $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | sed 's,/build/linux.*,,')
export OCSD_ROOT
endif
......@@ -45,14 +45,6 @@ export LIB_BASE_NAME
LIB_CAPI_NAME=$(LIB_BASE_NAME)_c_api
export LIB_CAPI_NAME
# determine base architecture, heavily borrowed from the Linux kernel v4.4's
# tools/perf/config/Makefile.arch
# For example, to compile for arm64 on a X86 PC, you can issue the command:
# "export ARCH=arm64"
ifndef ARCH
ARCH := $(shell uname -m 2>/dev/null || echo not)
endif
# source root directories
export OCSD_LIB_ROOT=$(OCSD_ROOT)/lib
......@@ -60,71 +52,61 @@ export OCSD_INCLUDE=$(OCSD_ROOT)/include
export OCSD_SOURCE=$(OCSD_ROOT)/source
export OCSD_TESTS=$(OCSD_ROOT)/tests
export LIB_UAPI_INC_DIR=opencsd
# tools
export MASTER_CC=$(CROSS_COMPILE)gcc
export MASTER_CPP=$(CROSS_COMPILE)g++
export MASTER_CXX=$(CROSS_COMPILE)g++
export MASTER_LINKER=$(CROSS_COMPILE)g++
export MASTER_LIB=$(CROSS_COMPILE)ar
export INSTALL=install
# installation directory
INSTALL_LIB_DIR=/usr/lib/
export INSTALL_INCLUDE_DIR=/usr/include/
PREFIX ?=/usr
LIB_PATH ?= lib
INSTALL_LIB_DIR=$(PREFIX)/$(LIB_PATH)
INSTALL_BIN_DIR=$(PREFIX)/bin
export INSTALL_INCLUDE_DIR=$(PREFIX)/include/
# compile flags
MASTER_CC_FLAGS := -c -Wall -DLINUX
MASTER_CPP_FLAGS := -c -Wall -DLINUX -std=c++11
MASTER_LINKER_FLAGS := -Wl,-z,defs
MASTER_LIB_FLAGS := rcs
CFLAGS += $(CPPFLAGS) -c -Wall -DLINUX -Wno-switch -fPIC
CXXFLAGS += $(CPPFLAGS) -c -Wall -DLINUX -Wno-switch -fPIC -std=c++11
LDFLAGS += -Wl,-z,defs
ARFLAGS ?= rcs
# debug variant
ifdef DEBUG
MASTER_CC_FLAGS += -g -O0 -DDEBUG
MASTER_CPP_FLAGS += -g -O0 -DDEBUG
CFLAGS += -g -O0 -DDEBUG
CXXFLAGS += -g -O0 -DDEBUG
BUILD_VARIANT=dbg
else
MASTER_CC_FLAGS += -g -O2 -DNDEBUG
MASTER_CPP_FLAGS += -g -O2 -DNDEBUG
CFLAGS += -g -O2 -DNDEBUG
CXXFLAGS += -g -O2 -DNDEBUG
BUILD_VARIANT=rel
endif
# platform bit size variant
ifeq ($(ARCH),x86)
MFLAG:="-m32"
BIT_VARIANT=32
else ifeq ($(ARCH),x86_64)
MFLAG:="-m64"
BIT_VARIANT=64
else ifeq ($(ARCH),arm)
BIT_VARIANT=-arm
else ifeq ($(ARCH),arm64)
BIT_VARIANT=-arm64
else ifeq ($(ARCH),aarch64)
BIT_VARIANT=-arm64
else ifeq ($(ARCH),aarch32)
BIT_VARIANT=-arm
endif
MASTER_CC_FLAGS += $(MFLAG)
MASTER_CPP_FLAGS += $(MFLAG)
MASTER_LINKER_FLAGS += $(MFLAG)
# export build flags
export MASTER_CC_FLAGS
export MASTER_CPP_FLAGS
export MASTER_LINKER_FLAGS
export MASTER_LIB_FLAGS
# target directories
export PLAT_DIR=linux$(BIT_VARIANT)/$(BUILD_VARIANT)
export CFLAGS
export CXXFLAGS
export LDFLAGS
export ARFLAGS
# target directories - fixed for default packaging build
PLAT_DIR ?= builddir
export PLAT_DIR
export LIB_TARGET_DIR=$(OCSD_LIB_ROOT)/$(PLAT_DIR)
export LIB_TEST_TARGET_DIR=$(OCSD_TESTS)/lib/$(PLAT_DIR)
export BIN_TEST_TARGET_DIR=$(OCSD_TESTS)/bin/$(PLAT_DIR)
# Fish version out of header file (converting from hex)
getver:=printf "%d" $$(awk '/\#define VARNAME/ { print $$3 }' $(OCSD_ROOT)/include/opencsd/ocsd_if_version.h)
export SO_MAJOR_VER := $(shell $(subst VARNAME,OCSD_VER_MAJOR,$(getver)))
SO_MINOR_VER := $(shell $(subst VARNAME,OCSD_VER_MINOR,$(getver)))
SO_PATCH_VER := $(shell $(subst VARNAME,OCSD_VER_PATCH,$(getver)))
export SO_VER := $(SO_MAJOR_VER).$(SO_MINOR_VER).$(SO_PATCH_VER)
###########################################################
# build targets
......@@ -132,10 +114,19 @@ all: libs tests
libs: $(LIB_BASE_NAME)_lib $(LIB_CAPI_NAME)_lib
install: libs
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so $(INSTALL_LIB_DIR)/
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so $(INSTALL_LIB_DIR)/
install: libs tests
mkdir -p $(INSTALL_LIB_DIR) $(INSTALL_INCLUDE_DIR) $(INSTALL_BIN_DIR)
cp -d $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so $(INSTALL_LIB_DIR)/
cp -d $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so.$(SO_MAJOR_VER) $(INSTALL_LIB_DIR)/
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so.$(SO_VER) $(INSTALL_LIB_DIR)/
cp -d $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so $(INSTALL_LIB_DIR)/
cp -d $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so.$(SO_MAJOR_VER) $(INSTALL_LIB_DIR)/
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so.$(SO_VER) $(INSTALL_LIB_DIR)/
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a $(INSTALL_LIB_DIR)/
$(INSTALL) --mode=644 $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a $(INSTALL_LIB_DIR)/
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make install_inc
$(INSTALL) --mode=755 $(BIN_TEST_TARGET_DIR)/trc_pkt_lister $(INSTALL_BIN_DIR)/
################################
# build OpenCSD trace decode library
......@@ -148,7 +139,7 @@ $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a: $(LIB_BASE_NAME)_all
# single command builds both .a and .so targets in sub-makefile
$(LIB_BASE_NAME)_all:
mkdir -p $(LIB_TARGET_DIR)
cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make
cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && $(MAKE)
################################
# build OpenCSD trace decode C API library
......@@ -161,36 +152,49 @@ $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a: $(LIB_CAPI_NAME)_all
# single command builds both .a and .so targets in sub-makefile
$(LIB_CAPI_NAME)_all: $(LIB_BASE_NAME)_lib
mkdir -p $(LIB_TARGET_DIR)
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && $(MAKE)
#################################
# build tests
.PHONY: tests
tests: libs
cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && make
cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make
cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make
cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make
cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && $(MAKE)
cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && $(MAKE)
cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE)
cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE)
cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE)
#
# build docs
.PHONY: docs
docs:
(cd $(OCSD_ROOT)/docs; doxygen doxygen_config.dox)
#############################################################
# clean targets
#
clean: clean_libs clean_tests
clean: clean_libs clean_tests clean_docs
.PHONY: clean_libs clean_tests
.PHONY: clean_libs clean_tests clean_docs clean_install
clean_libs:
cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make clean
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make clean
cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && $(MAKE) clean
cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && $(MAKE) clean
clean_tests:
cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && make clean
cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make clean
cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make clean
cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make clean
cd $(OCSD_ROOT)/tests/build/linux/echo_test_dcd_lib && $(MAKE) clean
cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && $(MAKE) clean
cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && $(MAKE) clean
cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && $(MAKE) clean
cd $(OCSD_ROOT)/tests/build/linux/mem_buffer_eg && $(MAKE) clean
-rmdir $(OCSD_TESTS)/lib
clean_docs:
-rm -r $(OCSD_ROOT)/docs/html
clean_install:
rm -f $(INSTALL_LIB_DIR)/lib$(LIB_BASE_NAME).so
rm -f $(INSTALL_LIB_DIR)/lib$(LIB_CAPI_NAME).so
rm -rf $(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
-rm $(INSTALL_LIB_DIR)/lib$(LIB_BASE_NAME).*
-rm $(INSTALL_LIB_DIR)/lib$(LIB_CAPI_NAME).*
-rm -r $(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
########################################################
# Copyright 2018 ARM Limited. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#################################################################################
## Set up some addtional parameters for development environment builds. ##
## define arch/build sub-dirs for non installed dev builds
ifndef ARCH
ARCH := $(shell dpkg-architecture -q DEB_HOST_GNU_CPU || echo not)
endif
# platform bit size variant
ifeq ($(ARCH),x86)
MFLAG:="-m32"
BIT_VARIANT=32
else ifeq ($(ARCH),x86_64)
MFLAG:="-m64"
BIT_VARIANT=64
else ifeq ($(ARCH),arm)
BIT_VARIANT=-arm
else ifeq ($(ARCH),arm64)
BIT_VARIANT=-arm64
else ifeq ($(ARCH),aarch64)
BIT_VARIANT=-arm64
else ifeq ($(ARCH),aarch32)
BIT_VARIANT=-arm
endif
CXXFLAGS += $(MFLAG)
CFLAGS += $(MFLAG)
LDFLAGS += $(MFLAG)
PLAT_DIR=linux$(BIT_VARIANT)/$(BUILD_VARIANT)
# include the main makefile
include makefile
......@@ -30,14 +30,10 @@
# OpenCSD - makefile for C API wrapper library
#
CPP := $(MASTER_CPP)
CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch
LIB_FLAGS := $(MASTER_LIB_FLAGS)
LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared
LIB_NAME = lib$(LIB_CAPI_NAME)
SO_LIB_DEPS= -L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
......@@ -45,7 +41,7 @@ BUILD_DIR=./$(PLAT_DIR)
VPATH= $(OCSD_SOURCE)/c_api
CPP_INCLUDES= \
CXX_INCLUDES= \
-I$(OCSD_INCLUDE) \
-I$(OCSD_SOURCE)/c_api
......@@ -55,14 +51,32 @@ OBJECTS=$(BUILD_DIR)/ocsd_c_api.o \
INST_INC_SRC=$(OCSD_INCLUDE)/$(LIB_UAPI_INC_DIR)
INST_INC_DST=$(INSTALL_INCLUDE_DIR)/$(LIB_UAPI_INC_DIR)
all: build_dir $(OBJECTS)
mkdir -p $(LIB_TARGET_DIR)
$(LIB) $(LIB_FLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
$(LINKER) $(LINKER_FLAGS) -o $(LIB_TARGET_DIR)/$(LIB_NAME).so -Wl,-soname,$(LIB_NAME).so $(OBJECTS) $(SO_LIB_DEPS)
all: links
links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
.PHONY: links
LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
build_dir:
$(LIB_TARGET_DIR):
mkdir -p $(LIB_TARGET_DIR)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
$(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
$(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS) $(SO_LIB_DEPS)
$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
##### build rules
## object dependencies
......@@ -71,8 +85,8 @@ DEPS := $(OBJECTS:%.o=%.d)
-include $(DEPS)
## object compile
$(BUILD_DIR)/%.o : %.cpp
$(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean
......@@ -81,13 +95,15 @@ clean:
rm -f $(OBJECTS)
rm -f $(DEPS)
rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).a
rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so
rm -f $(LIB_TARGET_DIR)/$(LIB_NAME).so*
-rmdir $(BUILD_DIR)
#### install the necessary include files for the c-api library on linux
install_inc:
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_gen_elem_types.h $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_types.h $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/ocsd_if_version.h $(INST_INC_DST)/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/trc_pkt_types.h $(INST_INC_DST)/
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/ptm
$(INSTALL) --mode=0644 $(INST_INC_SRC)/ptm/trc_pkt_types_ptm.h $(INST_INC_DST)/ptm/
......
......@@ -30,14 +30,10 @@
# OpenCSD - makefile for main trace decode library
#
CPP := $(MASTER_CPP)
CXX := $(MASTER_CXX)
LINKER := $(MASTER_LINKER)
LIB := $(MASTER_LIB)
CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch
LIB_FLAGS := $(MASTER_LIB_FLAGS)
LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared
LIB_NAME= lib$(LIB_BASE_NAME)
BUILD_DIR=./$(PLAT_DIR)
......@@ -52,7 +48,7 @@ VPATH= $(OCSD_SOURCE) \
$(OCSD_SOURCE)/pkt_printers
CPP_INCLUDES= \
CXX_INCLUDES= \
-I$(OCSD_INCLUDE) \
-I$(OCSD_SOURCE)
......@@ -82,7 +78,8 @@ MEMACCOBJ= $(BUILD_DIR)/trc_mem_acc_mapper.o \
$(BUILD_DIR)/trc_mem_acc_bufptr.o \
$(BUILD_DIR)/trc_mem_acc_file.o \
$(BUILD_DIR)/trc_mem_acc_base.o \
$(BUILD_DIR)/trc_mem_acc_cb.o
$(BUILD_DIR)/trc_mem_acc_cb.o \
$(BUILD_DIR)/trc_mem_acc_cache.o
STMOBJ= $(BUILD_DIR)/trc_pkt_elem_stm.o \
$(BUILD_DIR)/trc_pkt_proc_stm.o \
......@@ -114,14 +111,32 @@ OBJECTS=$(BUILD_DIR)/ocsd_code_follower.o \
$(PTMOBJ) \
$(PKTPRNTOBJ)
all: build_dir $(OBJECTS)
all: links
links: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_TARGET_DIR)/$(LIB_NAME).so
.PHONY: links
LIBS:= $(LIB_TARGET_DIR)/$(LIB_NAME).a $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER)
$(LIB_TARGET_DIR):
mkdir -p $(LIB_TARGET_DIR)
$(LIB) $(LIB_FLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
$(LINKER) $(LINKER_FLAGS) -o $(LIB_TARGET_DIR)/$(LIB_NAME).so -Wl,-soname,$(LIB_NAME).so $(OBJECTS)
build_dir:
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(LIB_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
$(LIB) $(ARFLAGS) $(LIB_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER): $(OBJECTS) | $(BUILD_DIR) $(LIB_TARGET_DIR)
$(LINKER) $(LDFLAGS) -shared -o $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_VER) -Wl,-soname,$(LIB_NAME).so.$(SO_MAJOR_VER) $(OBJECTS)
$(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER): $(LIBS) | $(LIB_TARGET_DIR)
( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_VER) $(LIB_NAME).so.$(SO_MAJOR_VER) )
$(LIB_TARGET_DIR)/$(LIB_NAME).so: $(LIB_TARGET_DIR)/$(LIB_NAME).so.$(SO_MAJOR_VER) | $(LIB_TARGET_DIR)
( cd $(LIB_TARGET_DIR); ln -sf $(LIB_NAME).so.$(SO_MAJOR_VER) $(LIB_NAME).so )
##### build rules
## object dependencies
......@@ -130,8 +145,8 @@ DEPS := $(OBJECTS:%.o=%.d)
-include $(DEPS)
## object compile
$(BUILD_DIR)/%.o : %.cpp
$(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@
$(BUILD_DIR)/%.o : %.cpp | $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean
......@@ -140,4 +155,5 @@ clean:
rm -f $(OBJECTS)
rm -f $(DEPS)
rm -f $(LIB_TARGET_DIR)/