mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 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 | ################################################################################# |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 30 | # OpenCSD - master makefile for libraries and tests |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 31 | # |
| 32 | # command line options |
| 33 | # DEBUG=1 create a debug build |
| 34 | # LINUX64=1 create a 64 bit build |
| 35 | |
| 36 | # Set project root - relative to build directory |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 37 | ifeq ($(OCSD_ROOT),) |
| 38 | OCSD_ROOT := $(shell pwd | sed 's,/build/linux.*,,') |
| 39 | export OCSD_ROOT |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 40 | endif |
| 41 | |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 42 | # library names |
mleach | 31a7ed8 | 2015-12-08 12:13:28 +0000 | [diff] [blame] | 43 | LIB_BASE_NAME=cstraced |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 44 | export LIB_BASE_NAME |
| 45 | LIB_CAPI_NAME=$(LIB_BASE_NAME)_c_api |
| 46 | export LIB_CAPI_NAME |
| 47 | |
Mathieu Poirier | 859ef9a | 2016-02-15 12:24:30 -0700 | [diff] [blame] | 48 | # determine base architecture, heavily borrowed from the Linux kernel v4.4's |
| 49 | # tools/perf/config/Makefile.arch |
| 50 | ARCH := $(shell uname -m 2>/dev/null || echo not) |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 51 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 52 | # source root directories |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 53 | export OCSD_LIB_ROOT=$(OCSD_ROOT)/lib |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 54 | |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 55 | export OCSD_INCLUDE=$(OCSD_ROOT)/include |
| 56 | export OCSD_SOURCE=$(OCSD_ROOT)/source |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 57 | |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 58 | export OCSD_TESTS=$(OCSD_ROOT)/tests |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 59 | |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 60 | # tools |
| 61 | export MASTER_CC=gcc |
| 62 | export MASTER_CPP=g++ |
| 63 | export MASTER_LINKER=g++ |
| 64 | export MASTER_LIB=ar |
| 65 | |
| 66 | # compile flags |
| 67 | MASTER_CC_FLAGS := -c -Wall -DLINUX |
| 68 | MASTER_CPP_FLAGS := -c -Wall -DLINUX -std=c++11 |
| 69 | MASTER_LINKER_FLAGS := -Wl,-z,defs |
| 70 | MASTER_LIB_FLAGS := rcs |
| 71 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 72 | # debug variant |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 73 | ifdef DEBUG |
| 74 | MASTER_CC_FLAGS += -g -O0 -DDEBUG |
| 75 | MASTER_CPP_FLAGS += -g -O0 -DDEBUG |
| 76 | BUILD_VARIANT=dbg |
| 77 | else |
| 78 | MASTER_CC_FLAGS += -g -O2 -DNDEBUG |
| 79 | MASTER_CPP_FLAGS += -g -O2 -DNDEBUG |
| 80 | BUILD_VARIANT=rel |
| 81 | endif |
| 82 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 83 | # platform bit size variant |
Mathieu Poirier | 859ef9a | 2016-02-15 12:24:30 -0700 | [diff] [blame] | 84 | ifeq ($(ARCH),x86) |
| 85 | MFLAG:="-m32" |
| 86 | BIT_VARIANT=32 |
| 87 | else ifeq ($(ARCH),x86_64) |
| 88 | MFLAG:="-m64" |
| 89 | BIT_VARIANT=64 |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 90 | endif |
| 91 | |
Mathieu Poirier | 859ef9a | 2016-02-15 12:24:30 -0700 | [diff] [blame] | 92 | MASTER_CC_FLAGS += $(MFLAG) |
| 93 | MASTER_CPP_FLAGS += $(MFLAG) |
| 94 | MASTER_LINKER_FLAGS += $(MFLAG) |
| 95 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 96 | # export build flags |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 97 | export MASTER_CC_FLAGS |
| 98 | export MASTER_CPP_FLAGS |
| 99 | export MASTER_LINKER_FLAGS |
| 100 | export MASTER_LIB_FLAGS |
| 101 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 102 | # target directories |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 103 | export PLAT_DIR=linux$(BIT_VARIANT)/$(BUILD_VARIANT) |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 104 | export LIB_TARGET_DIR=$(OCSD_LIB_ROOT)/$(PLAT_DIR) |
| 105 | export LIB_TEST_TARGET_DIR=$(OCSD_TESTS)/lib/$(PLAT_DIR) |
| 106 | export BIN_TEST_TARGET_DIR=$(OCSD_TESTS)/bin/$(PLAT_DIR) |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 107 | |
| 108 | ########################################################### |
| 109 | # build targets |
| 110 | |
| 111 | all: libs tests |
| 112 | |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 113 | libs: $(LIB_BASE_NAME)_lib $(LIB_BASE_NAME)_so $(LIB_CAPI_NAME)_lib $(LIB_CAPI_NAME)_so |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 114 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 115 | ################################ |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 116 | # build static OpenCSD trace decode library |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 117 | # |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 118 | $(LIB_BASE_NAME)_lib: $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 119 | |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 120 | $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).a: |
| 121 | mkdir -p $(LIB_TARGET_DIR) |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 122 | cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 123 | |
| 124 | |
| 125 | ################################ |
| 126 | # build shared OpenCSD trace decode library |
| 127 | # |
| 128 | $(LIB_BASE_NAME)_so: $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so |
| 129 | |
| 130 | $(LIB_TARGET_DIR)/lib$(LIB_BASE_NAME).so: |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 131 | mkdir -p $(LIB_TARGET_DIR) |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 132 | cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 133 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 134 | ################################ |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 135 | # build static OpenCSD trace decode C API library |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 136 | # |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 137 | $(LIB_CAPI_NAME)_lib: $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 138 | |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 139 | $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).a: |
| 140 | mkdir -p $(LIB_TARGET_DIR) |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 141 | cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make |
mleach | 38da0c7 | 2015-12-07 10:08:56 +0000 | [diff] [blame] | 142 | |
| 143 | ################################ |
| 144 | # build shared OpenCSD trace decode C API library |
| 145 | # |
| 146 | $(LIB_CAPI_NAME)_so: $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so |
| 147 | |
| 148 | $(LIB_TARGET_DIR)/lib$(LIB_CAPI_NAME).so: $(LIB_BASE_NAME)_lib |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 149 | mkdir -p $(LIB_TARGET_DIR) |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 150 | cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 151 | |
| 152 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 153 | ################################# |
| 154 | # build tests |
mleach | 228a5e0 | 2015-07-27 17:38:00 +0100 | [diff] [blame] | 155 | |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 156 | .PHONY: tests |
| 157 | tests: libs |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 158 | cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make |
| 159 | cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make |
| 160 | cd $(OCSD_ROOT)/tests/build/linux/simple_pkt_print_c_api && make |
Mike Leach | 459d06e | 2016-07-18 17:17:15 +0100 | [diff] [blame^] | 161 | cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 162 | |
| 163 | ############################################################# |
| 164 | # clean targets |
| 165 | # |
| 166 | clean: clean_libs clean_tests |
| 167 | |
| 168 | .PHONY: clean_libs clean_tests |
| 169 | |
| 170 | clean_libs: |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 171 | cd $(OCSD_ROOT)/build/linux/ref_trace_decode_lib && make clean |
| 172 | cd $(OCSD_ROOT)/build/linux/rctdl_c_api_lib && make clean |
mleach | bdcc5e8 | 2015-08-03 18:03:04 +0100 | [diff] [blame] | 173 | |
| 174 | clean_tests: |
mleach | 48d83a6 | 2016-03-18 15:38:08 +0000 | [diff] [blame] | 175 | cd $(OCSD_ROOT)/tests/build/linux/snapshot_parser_lib && make clean |
| 176 | cd $(OCSD_ROOT)/tests/build/linux/trc_pkt_lister && make clean |
| 177 | cd $(OCSD_ROOT)/tests/build/linux/simple_pkt_print_c_api && make clean |
Mike Leach | 459d06e | 2016-07-18 17:17:15 +0100 | [diff] [blame^] | 178 | cd $(OCSD_ROOT)/tests/build/linux/c_api_pkt_print_test && make clean |