From original patchset created-by: Wookey wookey@wookware.org
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c b/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c index 32365ef..e2ad045 100644 --- a/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c +++ b/decoder/tests/ext_dcd_test_eg/c_api_echo_test/ext_dcd_echo_test.c @@ -330,7 +330,7 @@ void print_test_cov_results(echo_decoder_t *decoder) if (coverage[TEST_COV_MSGLOG_CB] == TEST_RES_OK) /* check we can use the msg logger for outputting the results */ lib_cb_LogMsg(p_fns, OCSD_ERR_SEV_ERROR, coverage_message); else - printf(coverage_message); + printf("%s", coverage_message); } }
Adjust default path for standard build dir structure.
Add in command line option -ss_path to allow user to supply the path to the snapshots directory. Removes requirement to always run from fixed path relative to snapshots
From original patchset created-by: Wookey wookey@wookware.org
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/tests/source/c_api_pkt_print_test.c | 61 +++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 11 deletions(-)
diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c index 85bd9bf..16761cb 100644 --- a/decoder/tests/source/c_api_pkt_print_test.c +++ b/decoder/tests/source/c_api_pkt_print_test.c @@ -63,12 +63,17 @@
/* path to test snapshots, relative to tests/bin/<plat>/<dbg|rel> build output dir */ #ifdef _WIN32 -const char *default_path_to_snapshot = "..\..\..\snapshots\juno_r1_1\"; -const char *tc2_snapshot = "..\..\..\snapshots\TC2\"; +const char *default_base_snapshot_path="..\..\..\snapshots"; +const char *juno_snapshot = "\juno_r1_1\"; +const char *tc2_snapshot = "\TC2\"; #else -const char *default_path_to_snapshot = "../../../snapshots/juno_r1_1/"; -const char *tc2_snapshot = "../../../snapshots/TC2/"; +const char *default_base_snapshot_path = "../../snapshots"; +const char *juno_snapshot = "/juno_r1_1/"; +const char *tc2_snapshot = "/TC2/"; #endif +static const char *selected_snapshot; +static const char *usr_snapshot_path = 0; +#define MAX_TRACE_FILE_PATH_LEN 512
/* trace data and memory file dump names and values - taken from snapshot metadata */ const char *trace_data_filename = "cstrace.bin"; @@ -114,6 +119,7 @@ static int test_lib_printers = 0; static int process_cmd_line(int argc, char *argv[]) { int idx = 1; + int len = 0;
while(idx < argc) { @@ -137,13 +143,13 @@ static int process_cmd_line(int argc, char *argv[]) else if(strcmp(argv[idx],"-etmv3") == 0) { test_protocol = OCSD_PROTOCOL_ETMV3; - default_path_to_snapshot = tc2_snapshot; + selected_snapshot = tc2_snapshot; mem_dump_address = mem_dump_address_tc2; } else if(strcmp(argv[idx],"-ptm") == 0) { test_protocol = OCSD_PROTOCOL_PTM; - default_path_to_snapshot = tc2_snapshot; + selected_snapshot = tc2_snapshot; mem_dump_address = mem_dump_address_tc2; } else if(strcmp(argv[idx],"-stm") == 0) @@ -181,6 +187,26 @@ static int process_cmd_line(int argc, char *argv[]) { test_lib_printers = 1; } + else if(strcmp(argv[idx],"-ss_path") == 0) + { + idx++; + if((idx >= argc) || (strlen(argv[idx]) == 0)) + { + printf("-ss_path: Missing path parameter or zero length\n"); + return -1; + } + else + { + len = strlen(argv[idx]); + if(len > (MAX_TRACE_FILE_PATH_LEN - 32)) + { + printf("-ss_path: path too long\n"); + return -1; + } + usr_snapshot_path = argv[idx]; + } + + } else if(strcmp(argv[idx],"-help") == 0) { return -1; @@ -200,6 +226,7 @@ static void print_cmd_line_help() printf("-raw / -raw_packed: print raw unpacked / packed data;\n"); printf("-test_printstr | -test_libprint : ttest lib printstr callback | test lib based packet printers\n"); printf("-test_region_file | -test_cb : mem accessor - test multi region file API | test callback API (default single memory file)\n\n"); + printf("-ss_path <path> : path from cwd to /snapshots/ directory. Test prog will append required test subdir\n"); }
/************************************************************************/ @@ -290,15 +317,19 @@ static void destroy_mem_acc_cb(dcd_tree_handle_t dcd_tree_h) static ocsd_err_t create_test_memory_acc(dcd_tree_handle_t handle) { ocsd_err_t ret = OCSD_OK; - char mem_file_path[512]; + char mem_file_path[MAX_TRACE_FILE_PATH_LEN]; uint32_t i0adjust = 0x100; int i = 0; - + /* region list to test multi region memory file API */ ocsd_file_mem_region_t region_list[4];
/* path to the file containing the memory image traced - raw binary data in the snapshot */ - strcpy(mem_file_path,default_path_to_snapshot); + if(usr_snapshot_path != 0) + strcpy(mem_file_path,usr_snapshot_path); + else + strcpy(mem_file_path,default_base_snapshot_path); + strcat(mem_file_path,selected_snapshot); strcat(mem_file_path,memory_dump_filename);
/* @@ -899,10 +930,13 @@ int process_trace_data(FILE *pf) int main(int argc, char *argv[]) { FILE *trace_data; - char trace_file_path[512]; + char trace_file_path[MAX_TRACE_FILE_PATH_LEN]; int ret = 0, i, len; char message[512];
+ /* default to juno */ + selected_snapshot = juno_snapshot; + /* command line params */ if(process_cmd_line(argc,argv) != 0) { @@ -911,8 +945,13 @@ int main(int argc, char *argv[]) }
/* trace data file path */ - strcpy(trace_file_path,default_path_to_snapshot); + if(usr_snapshot_path != 0) + strcpy(trace_file_path,usr_snapshot_path); + else + strcpy(trace_file_path,default_base_snapshot_path); + strcat(trace_file_path,selected_snapshot); strcat(trace_file_path,trace_data_filename); + printf("opening %s trace data file\n",trace_file_path); trace_data = fopen(trace_file_path,"rb");
if(trace_data != NULL)
Rework makefile variables and some operations for compatibility with normal distribution pratices. Single build directory for all archs / rel /debug variants.
Extract lib .so versions based on ocsd_version.h
Add in development makefile to retain multiple simultaneous build arch / types in dir structure.
Based on original patchset created-by: Wookey wookey@wookware.org Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/build/linux/makefile | 120 +++++++++++---------- decoder/build/linux/makefile.dev | 62 +++++++++++ decoder/build/linux/rctdl_c_api_lib/makefile | 43 +++++--- decoder/build/linux/ref_trace_decode_lib/makefile | 41 ++++--- .../build/linux/c_api_pkt_print_test/makefile | 12 +-- .../tests/build/linux/echo_test_dcd_lib/makefile | 16 ++- .../tests/build/linux/snapshot_parser_lib/makefile | 18 ++-- decoder/tests/build/linux/trc_pkt_lister/makefile | 18 ++-- 8 files changed, 210 insertions(+), 120 deletions(-) create mode 100644 decoder/build/linux/makefile.dev
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile index 330829b..4cd2f5f 100644 --- a/decoder/build/linux/makefile +++ b/decoder/build/linux/makefile @@ -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/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 @@ -173,12 +164,19 @@ tests: libs cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && 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 @@ -189,8 +187,12 @@ clean_tests: 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 + -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) diff --git a/decoder/build/linux/makefile.dev b/decoder/build/linux/makefile.dev new file mode 100644 index 0000000..7c02328 --- /dev/null +++ b/decoder/build/linux/makefile.dev @@ -0,0 +1,62 @@ +######################################################## +# 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 diff --git a/decoder/build/linux/rctdl_c_api_lib/makefile b/decoder/build/linux/rctdl_c_api_lib/makefile index fb54d3a..d93db7d 100644 --- a/decoder/build/linux/rctdl_c_api_lib/makefile +++ b/decoder/build/linux/rctdl_c_api_lib/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,7 +95,8 @@ 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: diff --git a/decoder/build/linux/ref_trace_decode_lib/makefile b/decoder/build/linux/ref_trace_decode_lib/makefile index a356066..ad2aca9 100644 --- a/decoder/build/linux/ref_trace_decode_lib/makefile +++ b/decoder/build/linux/ref_trace_decode_lib/makefile @@ -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)
@@ -114,14 +110,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 +144,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 +154,5 @@ 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) diff --git a/decoder/tests/build/linux/c_api_pkt_print_test/makefile b/decoder/tests/build/linux/c_api_pkt_print_test/makefile index 9fe7247..ba4526d 100644 --- a/decoder/tests/build/linux/c_api_pkt_print_test/makefile +++ b/decoder/tests/build/linux/c_api_pkt_print_test/makefile @@ -33,9 +33,7 @@ #
CC := $(MASTER_CC) -CC_FLAGS := $(MASTER_CC_FLAGS) -Wno-switch LINKER := $(MASTER_LINKER) -LINKER_FLAGS := $(MASTER_LINKER_FLAGS)
PROG = c_api_pkt_print_test
@@ -60,7 +58,7 @@ test_app: $(OBJECTS) $(BIN_TEST_TARGET_DIR)/$(PROG)
$(BIN_TEST_TARGET_DIR)/$(PROG): mkdir -p $(BIN_TEST_TARGET_DIR) - $(LINKER) $(LINKER_FLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG) + $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG) cp $(LIB_TARGET_DIR)/*.so .
build_dir: @@ -81,12 +79,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile $(BUILD_DIR)/%.o : %.c - $(CC) $(CC_FLAGS) $(CC_INCLUDES) -MMD $< -o $@ + $(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@
#### clean .PHONY: clean clean : - rm -f $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) - rm -f $(DEPS) + -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) + -rm $(DEPS) + -rm ./*.so + -rmdir $(BUILD_DIR)
# end of file makefile diff --git a/decoder/tests/build/linux/echo_test_dcd_lib/makefile b/decoder/tests/build/linux/echo_test_dcd_lib/makefile index 2483170..2b26035 100644 --- a/decoder/tests/build/linux/echo_test_dcd_lib/makefile +++ b/decoder/tests/build/linux/echo_test_dcd_lib/makefile @@ -31,13 +31,8 @@ #
CC := $(MASTER_CC) -LINKER := $(MASTER_LINKER) LIB := $(MASTER_LIB)
-CC_FLAGS := $(MASTER_CC_FLAGS) -fpic -Wno-switch -LIB_FLAGS := $(MASTER_LIB_FLAGS) -LINKER_FLAGS := $(MASTER_LINKER_FLAGS) -shared - LIB_NAME = lib_echo_test_dcd
BUILD_DIR=./$(PLAT_DIR) @@ -57,7 +52,7 @@ all: build_dir $(OBJECTS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: mkdir -p $(LIB_TEST_TARGET_DIR) - $(LIB) $(LIB_FLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS) + $(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
build_dir: mkdir -p $(BUILD_DIR) @@ -76,13 +71,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile $(BUILD_DIR)/%.o : %.c - $(CC) $(CC_FLAGS) $(CC_INCLUDES) -MMD $< -o $@ + $(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@
#### clean .PHONY: clean clean: - rm -f $(OBJECTS) - rm -f $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a - rm -f $(DEPS) + -rm $(OBJECTS) + -rm $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a + -rm $(DEPS) + -rmdir $(BUILD_DIR) $(LIB_TEST_TARGET_DIR)
# end of file makefile diff --git a/decoder/tests/build/linux/snapshot_parser_lib/makefile b/decoder/tests/build/linux/snapshot_parser_lib/makefile index ae3863f..685e8d4 100644 --- a/decoder/tests/build/linux/snapshot_parser_lib/makefile +++ b/decoder/tests/build/linux/snapshot_parser_lib/makefile @@ -32,15 +32,14 @@ # ########################################################################
-CPP := $(MASTER_CPP) +CXX := $(MASTER_CXX) LINKER := $(MASTER_LINKER) LIB := $(MASTER_LIB)
# avoid build warnings in donated test code WSUPPRESS= -Wno-deprecated-declarations -Wno-unused-variable -Wno-reorder
-CPP_FLAGS := $(MASTER_CPP_FLAGS) -fpic -Wno-switch $(WSUPPRESS) -LIB_FLAGS := $(MASTER_LIB_FLAGS) +CXXFLAGS += $(WSUPPRESS)
LIB_NAME = libsnapshot_parser
@@ -53,7 +52,7 @@ PARSER_INCLUDE=$(PARSER_ROOT)/include VPATH= $(PARSER_SOURCE)
-CPP_INCLUDES= \ +CXX_INCLUDES= \ -I$(PARSER_INCLUDE) \ -I$(OCSD_INCLUDE)
@@ -68,7 +67,7 @@ all: build_dir $(OBJECTS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: mkdir -p $(LIB_TEST_TARGET_DIR) - $(LIB) $(LIB_FLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS) + $(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
build_dir: mkdir -p $(BUILD_DIR) @@ -82,11 +81,12 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile $(BUILD_DIR)/%.o : %.cpp - $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@ + $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
### clean .PHONY: clean clean: - rm -f $(OBJECTS) - rm -f $(DEPS) - rm -f $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a + -rm $(OBJECTS) + -rm $(DEPS) + -rm $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a + -rmdir $(BUILD_DIR) $(LIB_TEST_TARGET_DIR) diff --git a/decoder/tests/build/linux/trc_pkt_lister/makefile b/decoder/tests/build/linux/trc_pkt_lister/makefile index 3447b93..cd45758 100644 --- a/decoder/tests/build/linux/trc_pkt_lister/makefile +++ b/decoder/tests/build/linux/trc_pkt_lister/makefile @@ -32,10 +32,8 @@ # RCTDL - test makefile for snapshot lister test. #
-CPP := $(MASTER_CPP) -CPP_FLAGS := $(MASTER_CPP_FLAGS) -Wno-switch +CXX := $(MASTER_CXX) LINKER := $(MASTER_LINKER) -LINKER_FLAGS := $(MASTER_LINKER_FLAGS)
PROG = trc_pkt_lister
@@ -43,7 +41,7 @@ BUILD_DIR=./$(PLAT_DIR)
VPATH = $(OCSD_TESTS)/source
-CPP_INCLUDES = \ +CXX_INCLUDES = \ -I$(OCSD_TESTS)/source \ -I$(OCSD_INCLUDE) \ -I$(OCSD_TESTS)/snapshot_parser_lib/include @@ -60,7 +58,7 @@ test_app: $(OBJECTS) $(BIN_TEST_TARGET_DIR)/$(PROG)
$(BIN_TEST_TARGET_DIR)/$(PROG): mkdir -p $(BIN_TEST_TARGET_DIR) - $(LINKER) $(LINKER_FLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG) + $(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
build_dir: mkdir -p $(BUILD_DIR) @@ -68,7 +66,7 @@ build_dir: .PHONY: copy_libs
copy_libs: - cp $(LIB_TARGET_DIR)/*.so $(BIN_TEST_TARGET_DIR)/. + cp $(LIB_TARGET_DIR)/*.so* $(BIN_TEST_TARGET_DIR)/.
@@ -80,12 +78,14 @@ DEPS := $(OBJECTS:%.o=%.d)
## object compile $(BUILD_DIR)/%.o : %.cpp - $(CPP) $(CPP_FLAGS) $(CPP_INCLUDES) -MMD $< -o $@ + $(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
#### clean .PHONY: clean clean : - rm -f $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) - rm -f $(DEPS) + -rm $(BIN_TEST_TARGET_DIR)/$(PROG) $(OBJECTS) + -rm $(DEPS) + -rm $(BIN_TEST_TARGET_DIR)/*.so* + -rmdir $(BUILD_DIR)
# end of file makefile
Update README and version info with latest version. update build document to reflect new build processes.
Signed-off-by: Mike Leach mike.leach@linaro.org --- README.md | 3 +- decoder/docs/build_libs.md | 89 +++++++++++++++++++++++++++++++-------- decoder/include/ocsd_if_version.h | 4 +- 3 files changed, 76 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md index 96fd7cf..f6474bc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Releases will appear on the master branch in the git repository with an appropri CoreSight Trace Component Support. ----------------------------------
-_Current Version 0.8.3_ +_Current Version 0.8.4_
### Current support:
@@ -117,6 +117,7 @@ Version and Modification Information - _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.
Licence Information diff --git a/decoder/docs/build_libs.md b/decoder/docs/build_libs.md index b7c8536..dc7d85d 100644 --- a/decoder/docs/build_libs.md +++ b/decoder/docs/build_libs.md @@ -6,47 +6,102 @@ Building and using the Library {#build_lib} Platform Support ----------------
-The current makefiles and build projects support building the library on Linux and Windows, -x86 or x64 hosts. - -Support is expected for ARM linux and baremetal, AArch32 and AArch64 platforms. +The current makefiles and build projects support building the library on: + - Linux and Windows, x86 or x64 hosts. + - ARM linux - AArch32 and AArch64 + - ARM aarch32 and aarch64 libs, x-compiled on x86/64 hosts.
+In addition to building the library from the project, the library may be installed into the standard +`/usr/lib/` area in Linux, and will soon be available as a package from Linux Distros.
Building the Library --------------------
-The library and test programs are built from the library `./build/<platform>` directory. +The library and test programs are built from the library `./build/<platform>` directory, where +<platform> is either 'linux' or 'win-vs2015'
See [`./docs/test_progs.md`](@ref test_progs) for further information on use of the test programs.
-### Linux x86/x64 ### +### Linux x86/x64/ARM ### + +Libraries are built into a <tgt_dir>. This is used as the final output directory for the +libraries in `decoder/lib/<tgt_dir>`, and also as a sub-directory of the build process for +intermediate files - `decoder/build/linux/ref_trace_decode_lib/<tgt_dir>`. + +For a standard build, go to the `./build/linux/` and run `make` in that directory. + +This will set <tgt_dir> to `builddir` for all build variants of the library. Using this only one variant of the library can be built at any one time. + +For development, alternatively use `make -f makefile.dev` + +This will set <tgt_dir> to `linux<bit-variant>/<dbg|rel>` and therefore build libraries into the +`decoder/lib/linux<bit-variant>/<dbg|rel>` directories, allowing multiple variants of the library +to be present during development.
-Go to the `./build/linux/` and run `make` in that directory. +e.g.
-Options to pass to the makefile are:- -- `LINUX64=1` : build the 64 bit version of the library +`./lib/linux64/rel` will contain the linux 64 bit release libraries. + +`./lib/linux-arm64/dbg` will contain the linux aarch 64 debug libraries for ARM. + +Options to pass to both makefiles are:- - `DEBUG=1` : build the debug version of the library.
-Libraries are delivered to the `./lib/linux<bitsize>/<dbg\rel>` directories. -e.g. `./lib/linux64/rel` will contain the linux 64 bit release libraries. +Options to pass to makefile.dev are:- +- ARCH=<arch> : sets the bit variant in the delivery directories. Set if cross compilation for ARCH + other than host. Otherwise ARCH is auto-detected. + <arch> can be x86, x86_64, arm, arm64, aarch64, aarch32 + +For cross compilation, set the environment variable `CROSS_COMPILE` to the name path/prefix for the +compiler to use. The following would set the environment to cross-compile for ARM + + export PATH=$PATH:~/work/gcc-x-aarch64-6.2/bin + export ARCH=arm64 + export CROSS_COMPILE=aarch64-linux-gnu- + +The makefile will scan the `ocsd_if_version.h` to get the library version numbers and use these +in the form Major.minor.patch when naming the output .so files.
-The following libraries are built:- -- `libcstraced.so` : shared library containing the main C++ based decoder library -- `libcstraced_c_api.so` : shared library containing the C-API wrapper library. Dependent on `libcstraced.so` +Main C++ library names: +- `libcstraced.so.M.m.p` : shared library containing the main C++ based decoder library +- `libcstrace.so.M` : symbolic link name to library - major version only. +- `libcstrace.so` : symbolic link name to library - no version. + +C API wrapper library names: +- `libcstraced_c_api.so.M.m.p` : shared library containing the C-API wrapper library. Dependent on `libcstraced.so.M` +- `libcstraced_c_api.so.M` : symbolic link name to library - major version only. +- `libcstraced_c_api.so` : symbolic link name to library - no version. + +Static versions of the libraries: - `libcstraced.a` : static library containing the main C++ based decoder library. - `libcstraced_c_api.a` : static library containing the C-API wrapper library.
-Test programs are delivered to the `./tests/bin/linux<bitsize>/<dgb\rel>` directories. +Test programs are delivered to the `./tests/bin/<tgt_dir>` directories.
The test programs are built to used the .so versions of the libraries. - `trc_pkt_lister` - dependent on `libcstraced.so`. - `simple_pkt_print_c_api` - dependent on `libcstraced_c_api.so` & hence `libcstraced.so`.
The test program build for `trc_pkt_lister` also builds an auxiliary library used by this program for test purposes only. -This is the `libsnapshot_parser.a` library, delivered to the `./tests/lib/linux<bitsize>/<dgb\rel>` directories. +This is the `libsnapshot_parser.a` library, delivered to the `./tests/lib/<tgt_dir>` directories. + +__Installing on Linux__ + +The libraries can be installed on linux using the `make install` command. This will usually require root privileges. Installation will be the version in the `./lib/<tgt_dir>` directory, according to options chosen. + +e.g. ` make -f makefile.dev DEBUG=1 install` + +will install from `./lib/linux64/dbg` + +The libraries `libopencsd` and `libopencsd_c_api` are installed to `/usr/lib`. + +Sufficient header files to build using the C-API library will be installed to `/usr/include/opencsd`. + +The installation can be removed using `make clean_install`. No additional options are necessary. +
-### Windows ### +### Windows (x86/x64) ###
Use the `.\build\win\ref_trace_decode_lib\ref_trace_decode_lib.sln` file to load a solution which contains all library and test build projects. diff --git a/decoder/include/ocsd_if_version.h b/decoder/include/ocsd_if_version.h index b37ca07..dfebc0f 100644 --- a/decoder/include/ocsd_if_version.h +++ b/decoder/include/ocsd_if_version.h @@ -44,7 +44,7 @@ @{*/ #define OCSD_VER_MAJOR 0x0 /**< Library Major Version */ #define OCSD_VER_MINOR 0x8 /**< Library Minor Version */ -#define OCSD_VER_PATCH 0x3 /**< Library Patch Version */ +#define OCSD_VER_PATCH 0x4 /**< Library Patch Version */
/** Library version number - MMMMnnpp format. MMMM = major version, @@ -53,7 +53,7 @@ */ #define OCSD_VER_NUM (((uint32_t)OCSD_VER_MAJOR << 16) | ((uint32_t)OCSD_VER_MINOR << 8) | ((uint32_t)OCSD_VER_PATCH))
-#define OCSD_VER_STRING "0.8.3" /**< Library Version string */ +#define OCSD_VER_STRING "0.8.4" /**< Library Version string */ #define OCSD_LIB_NAME "OpenCSD Library" /**< Library name string */ #define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */ /** @}*/