WORKS
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
mbd_os/features/FEATURE_COMMON_PAL/nanostack-libservice/test/libService/unittest/MakefileWorker.mk@9:6bb35cef007d, 2016-10-22 (annotated)
- Committer:
- cyberjoey
- Date:
- Sat Oct 22 01:31:58 2016 +0000
- Revision:
- 9:6bb35cef007d
- Parent:
- 1:55a6170b404f
WORKING
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 1:55a6170b404f | 1 | #--------- |
nexpaq | 1:55a6170b404f | 2 | # |
nexpaq | 1:55a6170b404f | 3 | # MakefileWorker.mk |
nexpaq | 1:55a6170b404f | 4 | # |
nexpaq | 1:55a6170b404f | 5 | # Include this helper file in your makefile |
nexpaq | 1:55a6170b404f | 6 | # It makes |
nexpaq | 1:55a6170b404f | 7 | # A static library |
nexpaq | 1:55a6170b404f | 8 | # A test executable |
nexpaq | 1:55a6170b404f | 9 | # |
nexpaq | 1:55a6170b404f | 10 | # See this example for parameter settings |
nexpaq | 1:55a6170b404f | 11 | # examples/Makefile |
nexpaq | 1:55a6170b404f | 12 | # |
nexpaq | 1:55a6170b404f | 13 | #---------- |
nexpaq | 1:55a6170b404f | 14 | # Inputs - these variables describe what to build |
nexpaq | 1:55a6170b404f | 15 | # |
nexpaq | 1:55a6170b404f | 16 | # INCLUDE_DIRS - Directories used to search for include files. |
nexpaq | 1:55a6170b404f | 17 | # This generates a -I for each directory |
nexpaq | 1:55a6170b404f | 18 | # SRC_DIRS - Directories containing source file to built into the library |
nexpaq | 1:55a6170b404f | 19 | # SRC_FILES - Specific source files to build into library. Helpful when not all code |
nexpaq | 1:55a6170b404f | 20 | # in a directory can be built for test (hopefully a temporary situation) |
nexpaq | 1:55a6170b404f | 21 | # TEST_SRC_DIRS - Directories containing unit test code build into the unit test runner |
nexpaq | 1:55a6170b404f | 22 | # These do not go in a library. They are explicitly included in the test runner |
nexpaq | 1:55a6170b404f | 23 | # TEST_SRC_FILES - Specific source files to build into the unit test runner |
nexpaq | 1:55a6170b404f | 24 | # These do not go in a library. They are explicitly included in the test runner |
nexpaq | 1:55a6170b404f | 25 | # MOCKS_SRC_DIRS - Directories containing mock source files to build into the test runner |
nexpaq | 1:55a6170b404f | 26 | # These do not go in a library. They are explicitly included in the test runner |
nexpaq | 1:55a6170b404f | 27 | #---------- |
nexpaq | 1:55a6170b404f | 28 | # You can adjust these variables to influence how to build the test target |
nexpaq | 1:55a6170b404f | 29 | # and where to put and name outputs |
nexpaq | 1:55a6170b404f | 30 | # See below to determine defaults |
nexpaq | 1:55a6170b404f | 31 | # COMPONENT_NAME - the name of the thing being built |
nexpaq | 1:55a6170b404f | 32 | # TEST_TARGET - name the test executable. By default it is |
nexpaq | 1:55a6170b404f | 33 | # $(COMPONENT_NAME)_tests |
nexpaq | 1:55a6170b404f | 34 | # Helpful if you want 1 > make files in the same directory with different |
nexpaq | 1:55a6170b404f | 35 | # executables as output. |
nexpaq | 1:55a6170b404f | 36 | # CPPUTEST_HOME - where CppUTest home dir found |
nexpaq | 1:55a6170b404f | 37 | # TARGET_PLATFORM - Influences how the outputs are generated by modifying the |
nexpaq | 1:55a6170b404f | 38 | # CPPUTEST_OBJS_DIR and CPPUTEST_LIB_DIR to use a sub-directory under the |
nexpaq | 1:55a6170b404f | 39 | # normal objs and lib directories. Also modifies where to search for the |
nexpaq | 1:55a6170b404f | 40 | # CPPUTEST_LIB to link against. |
nexpaq | 1:55a6170b404f | 41 | # CPPUTEST_OBJS_DIR - a directory where o and d files go |
nexpaq | 1:55a6170b404f | 42 | # CPPUTEST_LIB_DIR - a directory where libs go |
nexpaq | 1:55a6170b404f | 43 | # CPPUTEST_ENABLE_DEBUG - build for debug |
nexpaq | 1:55a6170b404f | 44 | # CPPUTEST_USE_MEM_LEAK_DETECTION - Links with overridden new and delete |
nexpaq | 1:55a6170b404f | 45 | # CPPUTEST_USE_STD_CPP_LIB - Set to N to keep the standard C++ library out |
nexpaq | 1:55a6170b404f | 46 | # of the test harness |
nexpaq | 1:55a6170b404f | 47 | # CPPUTEST_USE_GCOV - Turn on coverage analysis |
nexpaq | 1:55a6170b404f | 48 | # Clean then build with this flag set to Y, then 'make gcov' |
nexpaq | 1:55a6170b404f | 49 | # CPPUTEST_MAPFILE - generate a map file |
nexpaq | 1:55a6170b404f | 50 | # CPPUTEST_WARNINGFLAGS - overly picky by default |
nexpaq | 1:55a6170b404f | 51 | # OTHER_MAKEFILE_TO_INCLUDE - a hook to use this makefile to make |
nexpaq | 1:55a6170b404f | 52 | # other targets. Like CSlim, which is part of fitnesse |
nexpaq | 1:55a6170b404f | 53 | # CPPUTEST_USE_VPATH - Use Make's VPATH functionality to support user |
nexpaq | 1:55a6170b404f | 54 | # specification of source files and directories that aren't below |
nexpaq | 1:55a6170b404f | 55 | # the user's Makefile in the directory tree, like: |
nexpaq | 1:55a6170b404f | 56 | # SRC_DIRS += ../../lib/foo |
nexpaq | 1:55a6170b404f | 57 | # It defaults to N, and shouldn't be necessary except in the above case. |
nexpaq | 1:55a6170b404f | 58 | #---------- |
nexpaq | 1:55a6170b404f | 59 | # |
nexpaq | 1:55a6170b404f | 60 | # Other flags users can initialize to sneak in their settings |
nexpaq | 1:55a6170b404f | 61 | # CPPUTEST_CXXFLAGS - flags for the C++ compiler |
nexpaq | 1:55a6170b404f | 62 | # CPPUTEST_CPPFLAGS - flags for the C++ AND C preprocessor |
nexpaq | 1:55a6170b404f | 63 | # CPPUTEST_CFLAGS - flags for the C complier |
nexpaq | 1:55a6170b404f | 64 | # CPPUTEST_LDFLAGS - Linker flags |
nexpaq | 1:55a6170b404f | 65 | #---------- |
nexpaq | 1:55a6170b404f | 66 | |
nexpaq | 1:55a6170b404f | 67 | # Some behavior is weird on some platforms. Need to discover the platform. |
nexpaq | 1:55a6170b404f | 68 | |
nexpaq | 1:55a6170b404f | 69 | # Platforms |
nexpaq | 1:55a6170b404f | 70 | UNAME_OUTPUT = "$(shell uname -a)" |
nexpaq | 1:55a6170b404f | 71 | MACOSX_STR = Darwin |
nexpaq | 1:55a6170b404f | 72 | MINGW_STR = MINGW |
nexpaq | 1:55a6170b404f | 73 | CYGWIN_STR = CYGWIN |
nexpaq | 1:55a6170b404f | 74 | LINUX_STR = Linux |
nexpaq | 1:55a6170b404f | 75 | SUNOS_STR = SunOS |
nexpaq | 1:55a6170b404f | 76 | UNKNWOWN_OS_STR = Unknown |
nexpaq | 1:55a6170b404f | 77 | |
nexpaq | 1:55a6170b404f | 78 | # Compilers |
nexpaq | 1:55a6170b404f | 79 | CC_VERSION_OUTPUT ="$(shell $(CXX) -v 2>&1)" |
nexpaq | 1:55a6170b404f | 80 | CLANG_STR = clang |
nexpaq | 1:55a6170b404f | 81 | SUNSTUDIO_CXX_STR = SunStudio |
nexpaq | 1:55a6170b404f | 82 | |
nexpaq | 1:55a6170b404f | 83 | UNAME_OS = $(UNKNWOWN_OS_STR) |
nexpaq | 1:55a6170b404f | 84 | |
nexpaq | 1:55a6170b404f | 85 | ifeq ($(findstring $(MINGW_STR),$(UNAME_OUTPUT)),$(MINGW_STR)) |
nexpaq | 1:55a6170b404f | 86 | UNAME_OS = $(MINGW_STR) |
nexpaq | 1:55a6170b404f | 87 | endif |
nexpaq | 1:55a6170b404f | 88 | |
nexpaq | 1:55a6170b404f | 89 | ifeq ($(findstring $(CYGWIN_STR),$(UNAME_OUTPUT)),$(CYGWIN_STR)) |
nexpaq | 1:55a6170b404f | 90 | UNAME_OS = $(CYGWIN_STR) |
nexpaq | 1:55a6170b404f | 91 | endif |
nexpaq | 1:55a6170b404f | 92 | |
nexpaq | 1:55a6170b404f | 93 | ifeq ($(findstring $(LINUX_STR),$(UNAME_OUTPUT)),$(LINUX_STR)) |
nexpaq | 1:55a6170b404f | 94 | UNAME_OS = $(LINUX_STR) |
nexpaq | 1:55a6170b404f | 95 | endif |
nexpaq | 1:55a6170b404f | 96 | |
nexpaq | 1:55a6170b404f | 97 | ifeq ($(findstring $(MACOSX_STR),$(UNAME_OUTPUT)),$(MACOSX_STR)) |
nexpaq | 1:55a6170b404f | 98 | UNAME_OS = $(MACOSX_STR) |
nexpaq | 1:55a6170b404f | 99 | #lion has a problem with the 'v' part of -a |
nexpaq | 1:55a6170b404f | 100 | UNAME_OUTPUT = "$(shell uname -pmnrs)" |
nexpaq | 1:55a6170b404f | 101 | endif |
nexpaq | 1:55a6170b404f | 102 | |
nexpaq | 1:55a6170b404f | 103 | ifeq ($(findstring $(SUNOS_STR),$(UNAME_OUTPUT)),$(SUNOS_STR)) |
nexpaq | 1:55a6170b404f | 104 | UNAME_OS = $(SUNOS_STR) |
nexpaq | 1:55a6170b404f | 105 | |
nexpaq | 1:55a6170b404f | 106 | SUNSTUDIO_CXX_ERR_STR = CC -flags |
nexpaq | 1:55a6170b404f | 107 | ifeq ($(findstring $(SUNSTUDIO_CXX_ERR_STR),$(CC_VERSION_OUTPUT)),$(SUNSTUDIO_CXX_ERR_STR)) |
nexpaq | 1:55a6170b404f | 108 | CC_VERSION_OUTPUT ="$(shell $(CXX) -V 2>&1)" |
nexpaq | 1:55a6170b404f | 109 | COMPILER_NAME = $(SUNSTUDIO_CXX_STR) |
nexpaq | 1:55a6170b404f | 110 | endif |
nexpaq | 1:55a6170b404f | 111 | endif |
nexpaq | 1:55a6170b404f | 112 | |
nexpaq | 1:55a6170b404f | 113 | ifeq ($(findstring $(CLANG_STR),$(CC_VERSION_OUTPUT)),$(CLANG_STR)) |
nexpaq | 1:55a6170b404f | 114 | COMPILER_NAME = $(CLANG_STR) |
nexpaq | 1:55a6170b404f | 115 | endif |
nexpaq | 1:55a6170b404f | 116 | |
nexpaq | 1:55a6170b404f | 117 | #Kludge for mingw, it does not have cc.exe, but gcc.exe will do |
nexpaq | 1:55a6170b404f | 118 | ifeq ($(UNAME_OS),$(MINGW_STR)) |
nexpaq | 1:55a6170b404f | 119 | CC := gcc |
nexpaq | 1:55a6170b404f | 120 | endif |
nexpaq | 1:55a6170b404f | 121 | |
nexpaq | 1:55a6170b404f | 122 | #And another kludge. Exception handling in gcc 4.6.2 is broken when linking the |
nexpaq | 1:55a6170b404f | 123 | # Standard C++ library as a shared library. Unbelievable. |
nexpaq | 1:55a6170b404f | 124 | ifeq ($(UNAME_OS),$(MINGW_STR)) |
nexpaq | 1:55a6170b404f | 125 | CPPUTEST_LDFLAGS += -static |
nexpaq | 1:55a6170b404f | 126 | endif |
nexpaq | 1:55a6170b404f | 127 | ifeq ($(UNAME_OS),$(CYGWIN_STR)) |
nexpaq | 1:55a6170b404f | 128 | CPPUTEST_LDFLAGS += -static |
nexpaq | 1:55a6170b404f | 129 | endif |
nexpaq | 1:55a6170b404f | 130 | |
nexpaq | 1:55a6170b404f | 131 | |
nexpaq | 1:55a6170b404f | 132 | #Kludge for MacOsX gcc compiler on Darwin9 who can't handle pendantic |
nexpaq | 1:55a6170b404f | 133 | ifeq ($(UNAME_OS),$(MACOSX_STR)) |
nexpaq | 1:55a6170b404f | 134 | ifeq ($(findstring Version 9,$(UNAME_OUTPUT)),Version 9) |
nexpaq | 1:55a6170b404f | 135 | CPPUTEST_PEDANTIC_ERRORS = N |
nexpaq | 1:55a6170b404f | 136 | endif |
nexpaq | 1:55a6170b404f | 137 | endif |
nexpaq | 1:55a6170b404f | 138 | |
nexpaq | 1:55a6170b404f | 139 | ifndef COMPONENT_NAME |
nexpaq | 1:55a6170b404f | 140 | COMPONENT_NAME = name_this_in_the_makefile |
nexpaq | 1:55a6170b404f | 141 | endif |
nexpaq | 1:55a6170b404f | 142 | |
nexpaq | 1:55a6170b404f | 143 | # Debug on by default |
nexpaq | 1:55a6170b404f | 144 | ifndef CPPUTEST_ENABLE_DEBUG |
nexpaq | 1:55a6170b404f | 145 | CPPUTEST_ENABLE_DEBUG = Y |
nexpaq | 1:55a6170b404f | 146 | endif |
nexpaq | 1:55a6170b404f | 147 | |
nexpaq | 1:55a6170b404f | 148 | # new and delete for memory leak detection on by default |
nexpaq | 1:55a6170b404f | 149 | ifndef CPPUTEST_USE_MEM_LEAK_DETECTION |
nexpaq | 1:55a6170b404f | 150 | CPPUTEST_USE_MEM_LEAK_DETECTION = Y |
nexpaq | 1:55a6170b404f | 151 | endif |
nexpaq | 1:55a6170b404f | 152 | |
nexpaq | 1:55a6170b404f | 153 | # Use the standard C library |
nexpaq | 1:55a6170b404f | 154 | ifndef CPPUTEST_USE_STD_C_LIB |
nexpaq | 1:55a6170b404f | 155 | CPPUTEST_USE_STD_C_LIB = Y |
nexpaq | 1:55a6170b404f | 156 | endif |
nexpaq | 1:55a6170b404f | 157 | |
nexpaq | 1:55a6170b404f | 158 | # Use the standard C++ library |
nexpaq | 1:55a6170b404f | 159 | ifndef CPPUTEST_USE_STD_CPP_LIB |
nexpaq | 1:55a6170b404f | 160 | CPPUTEST_USE_STD_CPP_LIB = Y |
nexpaq | 1:55a6170b404f | 161 | endif |
nexpaq | 1:55a6170b404f | 162 | |
nexpaq | 1:55a6170b404f | 163 | # Use gcov, off by default |
nexpaq | 1:55a6170b404f | 164 | ifndef CPPUTEST_USE_GCOV |
nexpaq | 1:55a6170b404f | 165 | CPPUTEST_USE_GCOV = N |
nexpaq | 1:55a6170b404f | 166 | endif |
nexpaq | 1:55a6170b404f | 167 | |
nexpaq | 1:55a6170b404f | 168 | ifndef CPPUTEST_PEDANTIC_ERRORS |
nexpaq | 1:55a6170b404f | 169 | CPPUTEST_PEDANTIC_ERRORS = Y |
nexpaq | 1:55a6170b404f | 170 | endif |
nexpaq | 1:55a6170b404f | 171 | |
nexpaq | 1:55a6170b404f | 172 | # Default warnings |
nexpaq | 1:55a6170b404f | 173 | ifndef CPPUTEST_WARNINGFLAGS |
nexpaq | 1:55a6170b404f | 174 | CPPUTEST_WARNINGFLAGS = -Wall -Wextra -Wshadow -Wswitch-default -Wswitch-enum -Wconversion |
nexpaq | 1:55a6170b404f | 175 | ifeq ($(CPPUTEST_PEDANTIC_ERRORS), Y) |
nexpaq | 1:55a6170b404f | 176 | # CPPUTEST_WARNINGFLAGS += -pedantic-errors |
nexpaq | 1:55a6170b404f | 177 | CPPUTEST_WARNINGFLAGS += -pedantic |
nexpaq | 1:55a6170b404f | 178 | endif |
nexpaq | 1:55a6170b404f | 179 | ifeq ($(UNAME_OS),$(LINUX_STR)) |
nexpaq | 1:55a6170b404f | 180 | CPPUTEST_WARNINGFLAGS += -Wsign-conversion |
nexpaq | 1:55a6170b404f | 181 | endif |
nexpaq | 1:55a6170b404f | 182 | CPPUTEST_CXX_WARNINGFLAGS = -Woverloaded-virtual |
nexpaq | 1:55a6170b404f | 183 | CPPUTEST_C_WARNINGFLAGS = -Wstrict-prototypes |
nexpaq | 1:55a6170b404f | 184 | endif |
nexpaq | 1:55a6170b404f | 185 | |
nexpaq | 1:55a6170b404f | 186 | #Wonderful extra compiler warnings with clang |
nexpaq | 1:55a6170b404f | 187 | ifeq ($(COMPILER_NAME),$(CLANG_STR)) |
nexpaq | 1:55a6170b404f | 188 | # -Wno-disabled-macro-expansion -> Have to disable the macro expansion warning as the operator new overload warns on that. |
nexpaq | 1:55a6170b404f | 189 | # -Wno-padded -> I sort-of like this warning but if there is a bool at the end of the class, it seems impossible to remove it! (except by making padding explicit) |
nexpaq | 1:55a6170b404f | 190 | # -Wno-global-constructors Wno-exit-time-destructors -> Great warnings, but in CppUTest it is impossible to avoid as the automatic test registration depends on the global ctor and dtor |
nexpaq | 1:55a6170b404f | 191 | # -Wno-weak-vtables -> The TEST_GROUP macro declares a class and will automatically inline its methods. Thats ok as they are only in one translation unit. Unfortunately, the warning can't detect that, so it must be disabled. |
nexpaq | 1:55a6170b404f | 192 | CPPUTEST_CXX_WARNINGFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables |
nexpaq | 1:55a6170b404f | 193 | CPPUTEST_C_WARNINGFLAGS += -Weverything -Wno-padded |
nexpaq | 1:55a6170b404f | 194 | endif |
nexpaq | 1:55a6170b404f | 195 | |
nexpaq | 1:55a6170b404f | 196 | # Uhm. Maybe put some warning flags for SunStudio here? |
nexpaq | 1:55a6170b404f | 197 | ifeq ($(COMPILER_NAME),$(SUNSTUDIO_CXX_STR)) |
nexpaq | 1:55a6170b404f | 198 | CPPUTEST_CXX_WARNINGFLAGS = |
nexpaq | 1:55a6170b404f | 199 | CPPUTEST_C_WARNINGFLAGS = |
nexpaq | 1:55a6170b404f | 200 | endif |
nexpaq | 1:55a6170b404f | 201 | |
nexpaq | 1:55a6170b404f | 202 | # Default dir for temporary files (d, o) |
nexpaq | 1:55a6170b404f | 203 | ifndef CPPUTEST_OBJS_DIR |
nexpaq | 1:55a6170b404f | 204 | ifndef TARGET_PLATFORM |
nexpaq | 1:55a6170b404f | 205 | CPPUTEST_OBJS_DIR = objs |
nexpaq | 1:55a6170b404f | 206 | else |
nexpaq | 1:55a6170b404f | 207 | CPPUTEST_OBJS_DIR = objs/$(TARGET_PLATFORM) |
nexpaq | 1:55a6170b404f | 208 | endif |
nexpaq | 1:55a6170b404f | 209 | endif |
nexpaq | 1:55a6170b404f | 210 | |
nexpaq | 1:55a6170b404f | 211 | # Default dir for the outout library |
nexpaq | 1:55a6170b404f | 212 | ifndef CPPUTEST_LIB_DIR |
nexpaq | 1:55a6170b404f | 213 | ifndef TARGET_PLATFORM |
nexpaq | 1:55a6170b404f | 214 | CPPUTEST_LIB_DIR = lib |
nexpaq | 1:55a6170b404f | 215 | else |
nexpaq | 1:55a6170b404f | 216 | CPPUTEST_LIB_DIR = lib/$(TARGET_PLATFORM) |
nexpaq | 1:55a6170b404f | 217 | endif |
nexpaq | 1:55a6170b404f | 218 | endif |
nexpaq | 1:55a6170b404f | 219 | |
nexpaq | 1:55a6170b404f | 220 | # No map by default |
nexpaq | 1:55a6170b404f | 221 | ifndef CPPUTEST_MAP_FILE |
nexpaq | 1:55a6170b404f | 222 | CPPUTEST_MAP_FILE = N |
nexpaq | 1:55a6170b404f | 223 | endif |
nexpaq | 1:55a6170b404f | 224 | |
nexpaq | 1:55a6170b404f | 225 | # No extentions is default |
nexpaq | 1:55a6170b404f | 226 | ifndef CPPUTEST_USE_EXTENSIONS |
nexpaq | 1:55a6170b404f | 227 | CPPUTEST_USE_EXTENSIONS = N |
nexpaq | 1:55a6170b404f | 228 | endif |
nexpaq | 1:55a6170b404f | 229 | |
nexpaq | 1:55a6170b404f | 230 | # No VPATH is default |
nexpaq | 1:55a6170b404f | 231 | ifndef CPPUTEST_USE_VPATH |
nexpaq | 1:55a6170b404f | 232 | CPPUTEST_USE_VPATH := N |
nexpaq | 1:55a6170b404f | 233 | endif |
nexpaq | 1:55a6170b404f | 234 | # Make empty, instead of 'N', for usage in $(if ) conditionals |
nexpaq | 1:55a6170b404f | 235 | ifneq ($(CPPUTEST_USE_VPATH), Y) |
nexpaq | 1:55a6170b404f | 236 | CPPUTEST_USE_VPATH := |
nexpaq | 1:55a6170b404f | 237 | endif |
nexpaq | 1:55a6170b404f | 238 | |
nexpaq | 1:55a6170b404f | 239 | ifndef TARGET_PLATFORM |
nexpaq | 1:55a6170b404f | 240 | #CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib |
nexpaq | 1:55a6170b404f | 241 | CPPUTEST_LIB_LINK_DIR = /usr/lib/x86_64-linux-gnu |
nexpaq | 1:55a6170b404f | 242 | else |
nexpaq | 1:55a6170b404f | 243 | CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM) |
nexpaq | 1:55a6170b404f | 244 | endif |
nexpaq | 1:55a6170b404f | 245 | |
nexpaq | 1:55a6170b404f | 246 | # -------------------------------------- |
nexpaq | 1:55a6170b404f | 247 | # derived flags in the following area |
nexpaq | 1:55a6170b404f | 248 | # -------------------------------------- |
nexpaq | 1:55a6170b404f | 249 | |
nexpaq | 1:55a6170b404f | 250 | # Without the C library, we'll need to disable the C++ library and ... |
nexpaq | 1:55a6170b404f | 251 | ifeq ($(CPPUTEST_USE_STD_C_LIB), N) |
nexpaq | 1:55a6170b404f | 252 | CPPUTEST_USE_STD_CPP_LIB = N |
nexpaq | 1:55a6170b404f | 253 | CPPUTEST_USE_MEM_LEAK_DETECTION = N |
nexpaq | 1:55a6170b404f | 254 | CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED |
nexpaq | 1:55a6170b404f | 255 | CPPUTEST_CPPFLAGS += -nostdinc |
nexpaq | 1:55a6170b404f | 256 | endif |
nexpaq | 1:55a6170b404f | 257 | |
nexpaq | 1:55a6170b404f | 258 | CPPUTEST_CPPFLAGS += -DCPPUTEST_COMPILATION |
nexpaq | 1:55a6170b404f | 259 | |
nexpaq | 1:55a6170b404f | 260 | ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N) |
nexpaq | 1:55a6170b404f | 261 | CPPUTEST_CPPFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED |
nexpaq | 1:55a6170b404f | 262 | else |
nexpaq | 1:55a6170b404f | 263 | ifndef CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE |
nexpaq | 1:55a6170b404f | 264 | CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h |
nexpaq | 1:55a6170b404f | 265 | endif |
nexpaq | 1:55a6170b404f | 266 | ifndef CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE |
nexpaq | 1:55a6170b404f | 267 | CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h |
nexpaq | 1:55a6170b404f | 268 | endif |
nexpaq | 1:55a6170b404f | 269 | endif |
nexpaq | 1:55a6170b404f | 270 | |
nexpaq | 1:55a6170b404f | 271 | ifeq ($(CPPUTEST_ENABLE_DEBUG), Y) |
nexpaq | 1:55a6170b404f | 272 | CPPUTEST_CXXFLAGS += -g |
nexpaq | 1:55a6170b404f | 273 | CPPUTEST_CFLAGS += -g |
nexpaq | 1:55a6170b404f | 274 | CPPUTEST_LDFLAGS += -g |
nexpaq | 1:55a6170b404f | 275 | endif |
nexpaq | 1:55a6170b404f | 276 | |
nexpaq | 1:55a6170b404f | 277 | ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N) |
nexpaq | 1:55a6170b404f | 278 | CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED |
nexpaq | 1:55a6170b404f | 279 | ifeq ($(CPPUTEST_USE_STD_C_LIB), Y) |
nexpaq | 1:55a6170b404f | 280 | CPPUTEST_CXXFLAGS += -nostdinc++ |
nexpaq | 1:55a6170b404f | 281 | endif |
nexpaq | 1:55a6170b404f | 282 | endif |
nexpaq | 1:55a6170b404f | 283 | |
nexpaq | 1:55a6170b404f | 284 | ifdef $(GMOCK_HOME) |
nexpaq | 1:55a6170b404f | 285 | GTEST_HOME = $(GMOCK_HOME)/gtest |
nexpaq | 1:55a6170b404f | 286 | CPPUTEST_CPPFLAGS += -I$(GMOCK_HOME)/include |
nexpaq | 1:55a6170b404f | 287 | GMOCK_LIBRARY = $(GMOCK_HOME)/lib/.libs/libgmock.a |
nexpaq | 1:55a6170b404f | 288 | LD_LIBRARIES += $(GMOCK_LIBRARY) |
nexpaq | 1:55a6170b404f | 289 | CPPUTEST_CPPFLAGS += -DINCLUDE_GTEST_TESTS |
nexpaq | 1:55a6170b404f | 290 | CPPUTEST_WARNINGFLAGS = |
nexpaq | 1:55a6170b404f | 291 | CPPUTEST_CPPFLAGS += -I$(GTEST_HOME)/include -I$(GTEST_HOME) |
nexpaq | 1:55a6170b404f | 292 | GTEST_LIBRARY = $(GTEST_HOME)/lib/.libs/libgtest.a |
nexpaq | 1:55a6170b404f | 293 | LD_LIBRARIES += $(GTEST_LIBRARY) |
nexpaq | 1:55a6170b404f | 294 | endif |
nexpaq | 1:55a6170b404f | 295 | |
nexpaq | 1:55a6170b404f | 296 | |
nexpaq | 1:55a6170b404f | 297 | ifeq ($(CPPUTEST_USE_GCOV), Y) |
nexpaq | 1:55a6170b404f | 298 | CPPUTEST_CXXFLAGS += -fprofile-arcs -ftest-coverage |
nexpaq | 1:55a6170b404f | 299 | CPPUTEST_CFLAGS += -fprofile-arcs -ftest-coverage |
nexpaq | 1:55a6170b404f | 300 | endif |
nexpaq | 1:55a6170b404f | 301 | |
nexpaq | 1:55a6170b404f | 302 | CPPUTEST_CXXFLAGS += $(CPPUTEST_WARNINGFLAGS) $(CPPUTEST_CXX_WARNINGFLAGS) |
nexpaq | 1:55a6170b404f | 303 | CPPUTEST_CPPFLAGS += $(CPPUTEST_WARNINGFLAGS) |
nexpaq | 1:55a6170b404f | 304 | CPPUTEST_CXXFLAGS += $(CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE) |
nexpaq | 1:55a6170b404f | 305 | CPPUTEST_CPPFLAGS += $(CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE) |
nexpaq | 1:55a6170b404f | 306 | CPPUTEST_CFLAGS += $(CPPUTEST_C_WARNINGFLAGS) |
nexpaq | 1:55a6170b404f | 307 | |
nexpaq | 1:55a6170b404f | 308 | TARGET_MAP = $(COMPONENT_NAME).map.txt |
nexpaq | 1:55a6170b404f | 309 | ifeq ($(CPPUTEST_MAP_FILE), Y) |
nexpaq | 1:55a6170b404f | 310 | CPPUTEST_LDFLAGS += -Wl,-map,$(TARGET_MAP) |
nexpaq | 1:55a6170b404f | 311 | endif |
nexpaq | 1:55a6170b404f | 312 | |
nexpaq | 1:55a6170b404f | 313 | # Link with CppUTest lib |
nexpaq | 1:55a6170b404f | 314 | CPPUTEST_LIB = $(CPPUTEST_LIB_LINK_DIR)/libCppUTest.a |
nexpaq | 1:55a6170b404f | 315 | |
nexpaq | 1:55a6170b404f | 316 | ifeq ($(CPPUTEST_USE_EXTENSIONS), Y) |
nexpaq | 1:55a6170b404f | 317 | CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libCppUTestExt.a |
nexpaq | 1:55a6170b404f | 318 | endif |
nexpaq | 1:55a6170b404f | 319 | |
nexpaq | 1:55a6170b404f | 320 | ifdef CPPUTEST_STATIC_REALTIME |
nexpaq | 1:55a6170b404f | 321 | LD_LIBRARIES += -lrt |
nexpaq | 1:55a6170b404f | 322 | endif |
nexpaq | 1:55a6170b404f | 323 | |
nexpaq | 1:55a6170b404f | 324 | TARGET_LIB = \ |
nexpaq | 1:55a6170b404f | 325 | $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a |
nexpaq | 1:55a6170b404f | 326 | |
nexpaq | 1:55a6170b404f | 327 | ifndef TEST_TARGET |
nexpaq | 1:55a6170b404f | 328 | ifndef TARGET_PLATFORM |
nexpaq | 1:55a6170b404f | 329 | TEST_TARGET = $(COMPONENT_NAME)_tests |
nexpaq | 1:55a6170b404f | 330 | else |
nexpaq | 1:55a6170b404f | 331 | TEST_TARGET = $(COMPONENT_NAME)_$(TARGET_PLATFORM)_tests |
nexpaq | 1:55a6170b404f | 332 | endif |
nexpaq | 1:55a6170b404f | 333 | endif |
nexpaq | 1:55a6170b404f | 334 | |
nexpaq | 1:55a6170b404f | 335 | #Helper Functions |
nexpaq | 1:55a6170b404f | 336 | get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c) |
nexpaq | 1:55a6170b404f | 337 | get_dirs_from_dirspec = $(wildcard $1) |
nexpaq | 1:55a6170b404f | 338 | get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir))) |
nexpaq | 1:55a6170b404f | 339 | __src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1,$(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2)))) |
nexpaq | 1:55a6170b404f | 340 | src_to = $(addprefix $(CPPUTEST_OBJS_DIR)/,$(call __src_to,$1,$2)) |
nexpaq | 1:55a6170b404f | 341 | src_to_o = $(call src_to,.o,$1) |
nexpaq | 1:55a6170b404f | 342 | src_to_d = $(call src_to,.d,$1) |
nexpaq | 1:55a6170b404f | 343 | src_to_gcda = $(call src_to,.gcda,$1) |
nexpaq | 1:55a6170b404f | 344 | src_to_gcno = $(call src_to,.gcno,$1) |
nexpaq | 1:55a6170b404f | 345 | time = $(shell date +%s) |
nexpaq | 1:55a6170b404f | 346 | delta_t = $(eval minus, $1, $2) |
nexpaq | 1:55a6170b404f | 347 | debug_print_list = $(foreach word,$1,echo " $(word)";) echo; |
nexpaq | 1:55a6170b404f | 348 | |
nexpaq | 1:55a6170b404f | 349 | #Derived |
nexpaq | 1:55a6170b404f | 350 | STUFF_TO_CLEAN += $(TEST_TARGET) $(TEST_TARGET).exe $(TARGET_LIB) $(TARGET_MAP) |
nexpaq | 1:55a6170b404f | 351 | |
nexpaq | 1:55a6170b404f | 352 | SRC += $(call get_src_from_dir_list, $(SRC_DIRS)) $(SRC_FILES) |
nexpaq | 1:55a6170b404f | 353 | OBJ = $(call src_to_o,$(SRC)) |
nexpaq | 1:55a6170b404f | 354 | |
nexpaq | 1:55a6170b404f | 355 | STUFF_TO_CLEAN += $(OBJ) |
nexpaq | 1:55a6170b404f | 356 | |
nexpaq | 1:55a6170b404f | 357 | TEST_SRC += $(call get_src_from_dir_list, $(TEST_SRC_DIRS)) $(TEST_SRC_FILES) |
nexpaq | 1:55a6170b404f | 358 | TEST_OBJS = $(call src_to_o,$(TEST_SRC)) |
nexpaq | 1:55a6170b404f | 359 | STUFF_TO_CLEAN += $(TEST_OBJS) |
nexpaq | 1:55a6170b404f | 360 | |
nexpaq | 1:55a6170b404f | 361 | |
nexpaq | 1:55a6170b404f | 362 | MOCKS_SRC += $(call get_src_from_dir_list, $(MOCKS_SRC_DIRS)) |
nexpaq | 1:55a6170b404f | 363 | MOCKS_OBJS = $(call src_to_o,$(MOCKS_SRC)) |
nexpaq | 1:55a6170b404f | 364 | STUFF_TO_CLEAN += $(MOCKS_OBJS) |
nexpaq | 1:55a6170b404f | 365 | |
nexpaq | 1:55a6170b404f | 366 | ALL_SRC = $(SRC) $(TEST_SRC) $(MOCKS_SRC) |
nexpaq | 1:55a6170b404f | 367 | |
nexpaq | 1:55a6170b404f | 368 | # If we're using VPATH |
nexpaq | 1:55a6170b404f | 369 | ifeq ($(CPPUTEST_USE_VPATH), Y) |
nexpaq | 1:55a6170b404f | 370 | # gather all the source directories and add them |
nexpaq | 1:55a6170b404f | 371 | VPATH += $(sort $(dir $(ALL_SRC))) |
nexpaq | 1:55a6170b404f | 372 | # Add the component name to the objs dir path, to differentiate between same-name objects |
nexpaq | 1:55a6170b404f | 373 | CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR)) |
nexpaq | 1:55a6170b404f | 374 | endif |
nexpaq | 1:55a6170b404f | 375 | |
nexpaq | 1:55a6170b404f | 376 | #Test coverage with gcov |
nexpaq | 1:55a6170b404f | 377 | GCOV_OUTPUT = gcov_output.txt |
nexpaq | 1:55a6170b404f | 378 | GCOV_REPORT = gcov_report.txt |
nexpaq | 1:55a6170b404f | 379 | GCOV_ERROR = gcov_error.txt |
nexpaq | 1:55a6170b404f | 380 | GCOV_GCDA_FILES = $(call src_to_gcda, $(ALL_SRC)) |
nexpaq | 1:55a6170b404f | 381 | GCOV_GCNO_FILES = $(call src_to_gcno, $(ALL_SRC)) |
nexpaq | 1:55a6170b404f | 382 | TEST_OUTPUT = $(TEST_TARGET).txt |
nexpaq | 1:55a6170b404f | 383 | STUFF_TO_CLEAN += \ |
nexpaq | 1:55a6170b404f | 384 | $(GCOV_OUTPUT)\ |
nexpaq | 1:55a6170b404f | 385 | $(GCOV_REPORT)\ |
nexpaq | 1:55a6170b404f | 386 | $(GCOV_REPORT).html\ |
nexpaq | 1:55a6170b404f | 387 | $(GCOV_ERROR)\ |
nexpaq | 1:55a6170b404f | 388 | $(GCOV_GCDA_FILES)\ |
nexpaq | 1:55a6170b404f | 389 | $(GCOV_GCNO_FILES)\ |
nexpaq | 1:55a6170b404f | 390 | $(TEST_OUTPUT) |
nexpaq | 1:55a6170b404f | 391 | |
nexpaq | 1:55a6170b404f | 392 | #The gcda files for gcov need to be deleted before each run |
nexpaq | 1:55a6170b404f | 393 | #To avoid annoying messages. |
nexpaq | 1:55a6170b404f | 394 | GCOV_CLEAN = $(SILENCE)rm -f $(GCOV_GCDA_FILES) $(GCOV_OUTPUT) $(GCOV_REPORT) $(GCOV_ERROR) |
nexpaq | 1:55a6170b404f | 395 | RUN_TEST_TARGET = $(SILENCE) $(GCOV_CLEAN) ; echo "Running $(TEST_TARGET)"; ./$(TEST_TARGET) $(CPPUTEST_EXE_FLAGS) -ojunit |
nexpaq | 1:55a6170b404f | 396 | |
nexpaq | 1:55a6170b404f | 397 | ifeq ($(CPPUTEST_USE_GCOV), Y) |
nexpaq | 1:55a6170b404f | 398 | |
nexpaq | 1:55a6170b404f | 399 | ifeq ($(COMPILER_NAME),$(CLANG_STR)) |
nexpaq | 1:55a6170b404f | 400 | LD_LIBRARIES += --coverage |
nexpaq | 1:55a6170b404f | 401 | else |
nexpaq | 1:55a6170b404f | 402 | LD_LIBRARIES += -lgcov |
nexpaq | 1:55a6170b404f | 403 | endif |
nexpaq | 1:55a6170b404f | 404 | endif |
nexpaq | 1:55a6170b404f | 405 | |
nexpaq | 1:55a6170b404f | 406 | |
nexpaq | 1:55a6170b404f | 407 | INCLUDES_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(INCLUDE_DIRS)) |
nexpaq | 1:55a6170b404f | 408 | INCLUDES += $(foreach dir, $(INCLUDES_DIRS_EXPANDED), -I$(dir)) |
nexpaq | 1:55a6170b404f | 409 | MOCK_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(MOCKS_SRC_DIRS)) |
nexpaq | 1:55a6170b404f | 410 | INCLUDES += $(foreach dir, $(MOCK_DIRS_EXPANDED), -I$(dir)) |
nexpaq | 1:55a6170b404f | 411 | |
nexpaq | 1:55a6170b404f | 412 | CPPUTEST_CPPFLAGS += $(INCLUDES) $(CPPUTESTFLAGS) |
nexpaq | 1:55a6170b404f | 413 | |
nexpaq | 1:55a6170b404f | 414 | DEP_FILES = $(call src_to_d, $(ALL_SRC)) |
nexpaq | 1:55a6170b404f | 415 | STUFF_TO_CLEAN += $(DEP_FILES) $(PRODUCTION_CODE_START) $(PRODUCTION_CODE_END) |
nexpaq | 1:55a6170b404f | 416 | STUFF_TO_CLEAN += $(STDLIB_CODE_START) $(MAP_FILE) cpputest_*.xml junit_run_output |
nexpaq | 1:55a6170b404f | 417 | |
nexpaq | 1:55a6170b404f | 418 | # We'll use the CPPUTEST_CFLAGS etc so that you can override AND add to the CppUTest flags |
nexpaq | 1:55a6170b404f | 419 | CFLAGS = $(CPPUTEST_CFLAGS) $(CPPUTEST_ADDITIONAL_CFLAGS) |
nexpaq | 1:55a6170b404f | 420 | CPPFLAGS = $(CPPUTEST_CPPFLAGS) $(CPPUTEST_ADDITIONAL_CPPFLAGS) |
nexpaq | 1:55a6170b404f | 421 | CXXFLAGS = $(CPPUTEST_CXXFLAGS) $(CPPUTEST_ADDITIONAL_CXXFLAGS) |
nexpaq | 1:55a6170b404f | 422 | LDFLAGS = $(CPPUTEST_LDFLAGS) $(CPPUTEST_ADDITIONAL_LDFLAGS) |
nexpaq | 1:55a6170b404f | 423 | |
nexpaq | 1:55a6170b404f | 424 | # Don't consider creating the archive a warning condition that does STDERR output |
nexpaq | 1:55a6170b404f | 425 | ARFLAGS := $(ARFLAGS)c |
nexpaq | 1:55a6170b404f | 426 | |
nexpaq | 1:55a6170b404f | 427 | DEP_FLAGS=-MMD -MP |
nexpaq | 1:55a6170b404f | 428 | |
nexpaq | 1:55a6170b404f | 429 | # Some macros for programs to be overridden. For some reason, these are not in Make defaults |
nexpaq | 1:55a6170b404f | 430 | RANLIB = ranlib |
nexpaq | 1:55a6170b404f | 431 | |
nexpaq | 1:55a6170b404f | 432 | # Targets |
nexpaq | 1:55a6170b404f | 433 | |
nexpaq | 1:55a6170b404f | 434 | .PHONY: all |
nexpaq | 1:55a6170b404f | 435 | all: start $(TEST_TARGET) |
nexpaq | 1:55a6170b404f | 436 | $(RUN_TEST_TARGET) |
nexpaq | 1:55a6170b404f | 437 | |
nexpaq | 1:55a6170b404f | 438 | .PHONY: start |
nexpaq | 1:55a6170b404f | 439 | start: $(TEST_TARGET) |
nexpaq | 1:55a6170b404f | 440 | $(SILENCE)START_TIME=$(call time) |
nexpaq | 1:55a6170b404f | 441 | |
nexpaq | 1:55a6170b404f | 442 | .PHONY: all_no_tests |
nexpaq | 1:55a6170b404f | 443 | all_no_tests: $(TEST_TARGET) |
nexpaq | 1:55a6170b404f | 444 | |
nexpaq | 1:55a6170b404f | 445 | .PHONY: flags |
nexpaq | 1:55a6170b404f | 446 | flags: |
nexpaq | 1:55a6170b404f | 447 | @echo |
nexpaq | 1:55a6170b404f | 448 | @echo "OS ${UNAME_OS}" |
nexpaq | 1:55a6170b404f | 449 | @echo "Compile C and C++ source with CPPFLAGS:" |
nexpaq | 1:55a6170b404f | 450 | @$(call debug_print_list,$(CPPFLAGS)) |
nexpaq | 1:55a6170b404f | 451 | @echo "Compile C++ source with CXXFLAGS:" |
nexpaq | 1:55a6170b404f | 452 | @$(call debug_print_list,$(CXXFLAGS)) |
nexpaq | 1:55a6170b404f | 453 | @echo "Compile C source with CFLAGS:" |
nexpaq | 1:55a6170b404f | 454 | @$(call debug_print_list,$(CFLAGS)) |
nexpaq | 1:55a6170b404f | 455 | @echo "Link with LDFLAGS:" |
nexpaq | 1:55a6170b404f | 456 | @$(call debug_print_list,$(LDFLAGS)) |
nexpaq | 1:55a6170b404f | 457 | @echo "Link with LD_LIBRARIES:" |
nexpaq | 1:55a6170b404f | 458 | @$(call debug_print_list,$(LD_LIBRARIES)) |
nexpaq | 1:55a6170b404f | 459 | @echo "Create libraries with ARFLAGS:" |
nexpaq | 1:55a6170b404f | 460 | @$(call debug_print_list,$(ARFLAGS)) |
nexpaq | 1:55a6170b404f | 461 | |
nexpaq | 1:55a6170b404f | 462 | TEST_DEPS = $(TEST_OBJS) $(MOCKS_OBJS) $(PRODUCTION_CODE_START) $(TARGET_LIB) $(USER_LIBS) $(PRODUCTION_CODE_END) $(CPPUTEST_LIB) $(STDLIB_CODE_START) |
nexpaq | 1:55a6170b404f | 463 | test-deps: $(TEST_DEPS) |
nexpaq | 1:55a6170b404f | 464 | |
nexpaq | 1:55a6170b404f | 465 | $(TEST_TARGET): $(TEST_DEPS) |
nexpaq | 1:55a6170b404f | 466 | @echo Linking $@ |
nexpaq | 1:55a6170b404f | 467 | $(SILENCE)$(CXX) -o $@ $^ $(LD_LIBRARIES) $(LDFLAGS) |
nexpaq | 1:55a6170b404f | 468 | |
nexpaq | 1:55a6170b404f | 469 | $(TARGET_LIB): $(OBJ) |
nexpaq | 1:55a6170b404f | 470 | @echo Building archive $@ |
nexpaq | 1:55a6170b404f | 471 | $(SILENCE)mkdir -p $(dir $@) |
nexpaq | 1:55a6170b404f | 472 | $(SILENCE)$(AR) $(ARFLAGS) $@ $^ |
nexpaq | 1:55a6170b404f | 473 | $(SILENCE)$(RANLIB) $@ |
nexpaq | 1:55a6170b404f | 474 | |
nexpaq | 1:55a6170b404f | 475 | test: $(TEST_TARGET) |
nexpaq | 1:55a6170b404f | 476 | $(RUN_TEST_TARGET) | tee $(TEST_OUTPUT) |
nexpaq | 1:55a6170b404f | 477 | |
nexpaq | 1:55a6170b404f | 478 | vtest: $(TEST_TARGET) |
nexpaq | 1:55a6170b404f | 479 | $(RUN_TEST_TARGET) -v | tee $(TEST_OUTPUT) |
nexpaq | 1:55a6170b404f | 480 | |
nexpaq | 1:55a6170b404f | 481 | $(CPPUTEST_OBJS_DIR)/%.o: %.cc |
nexpaq | 1:55a6170b404f | 482 | @echo compiling $(notdir $<) |
nexpaq | 1:55a6170b404f | 483 | $(SILENCE)mkdir -p $(dir $@) |
nexpaq | 1:55a6170b404f | 484 | $(SILENCE)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $< |
nexpaq | 1:55a6170b404f | 485 | |
nexpaq | 1:55a6170b404f | 486 | $(CPPUTEST_OBJS_DIR)/%.o: %.cpp |
nexpaq | 1:55a6170b404f | 487 | @echo compiling $(notdir $<) |
nexpaq | 1:55a6170b404f | 488 | $(SILENCE)mkdir -p $(dir $@) |
nexpaq | 1:55a6170b404f | 489 | $(SILENCE)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $< |
nexpaq | 1:55a6170b404f | 490 | |
nexpaq | 1:55a6170b404f | 491 | $(CPPUTEST_OBJS_DIR)/%.o: %.c |
nexpaq | 1:55a6170b404f | 492 | @echo compiling $(notdir $<) |
nexpaq | 1:55a6170b404f | 493 | $(SILENCE)mkdir -p $(dir $@) |
nexpaq | 1:55a6170b404f | 494 | $(SILENCE)$(COMPILE.c) $(DEP_FLAGS) $(OUTPUT_OPTION) $< |
nexpaq | 1:55a6170b404f | 495 | |
nexpaq | 1:55a6170b404f | 496 | ifneq "$(MAKECMDGOALS)" "clean" |
nexpaq | 1:55a6170b404f | 497 | -include $(DEP_FILES) |
nexpaq | 1:55a6170b404f | 498 | endif |
nexpaq | 1:55a6170b404f | 499 | |
nexpaq | 1:55a6170b404f | 500 | .PHONY: clean |
nexpaq | 1:55a6170b404f | 501 | clean: |
nexpaq | 1:55a6170b404f | 502 | @echo Making clean |
nexpaq | 1:55a6170b404f | 503 | $(SILENCE)$(RM) $(STUFF_TO_CLEAN) |
nexpaq | 1:55a6170b404f | 504 | $(SILENCE)rm -rf gcov objs #$(CPPUTEST_OBJS_DIR) |
nexpaq | 1:55a6170b404f | 505 | $(SILENCE)rm -rf $(CPPUTEST_LIB_DIR) |
nexpaq | 1:55a6170b404f | 506 | $(SILENCE)find . -name "*.gcno" | xargs rm -f |
nexpaq | 1:55a6170b404f | 507 | $(SILENCE)find . -name "*.gcda" | xargs rm -f |
nexpaq | 1:55a6170b404f | 508 | |
nexpaq | 1:55a6170b404f | 509 | #realclean gets rid of all gcov, o and d files in the directory tree |
nexpaq | 1:55a6170b404f | 510 | #not just the ones made by this makefile |
nexpaq | 1:55a6170b404f | 511 | .PHONY: realclean |
nexpaq | 1:55a6170b404f | 512 | realclean: clean |
nexpaq | 1:55a6170b404f | 513 | $(SILENCE)rm -rf gcov |
nexpaq | 1:55a6170b404f | 514 | $(SILENCE)find . -name "*.gdcno" | xargs rm -f |
nexpaq | 1:55a6170b404f | 515 | $(SILENCE)find . -name "*.[do]" | xargs rm -f |
nexpaq | 1:55a6170b404f | 516 | |
nexpaq | 1:55a6170b404f | 517 | gcov: test |
nexpaq | 1:55a6170b404f | 518 | ifeq ($(CPPUTEST_USE_VPATH), Y) |
nexpaq | 1:55a6170b404f | 519 | $(SILENCE)gcov --object-directory $(CPPUTEST_OBJS_DIR) $(SRC) >> $(GCOV_OUTPUT) 2>> $(GCOV_ERROR) |
nexpaq | 1:55a6170b404f | 520 | else |
nexpaq | 1:55a6170b404f | 521 | $(SILENCE)for d in $(SRC_DIRS) ; do \ |
nexpaq | 1:55a6170b404f | 522 | gcov --object-directory $(CPPUTEST_OBJS_DIR)/$$d $$d/*.c $$d/*.cpp >> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \ |
nexpaq | 1:55a6170b404f | 523 | done |
nexpaq | 1:55a6170b404f | 524 | $(SILENCE)for f in $(SRC_FILES) ; do \ |
nexpaq | 1:55a6170b404f | 525 | gcov --object-directory $(CPPUTEST_OBJS_DIR)/$$f $$f >> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \ |
nexpaq | 1:55a6170b404f | 526 | done |
nexpaq | 1:55a6170b404f | 527 | endif |
nexpaq | 1:55a6170b404f | 528 | # $(CPPUTEST_HOME)/scripts/filterGcov.sh $(GCOV_OUTPUT) $(GCOV_ERROR) $(GCOV_REPORT) $(TEST_OUTPUT) |
nexpaq | 1:55a6170b404f | 529 | /usr/share/cpputest/scripts/filterGcov.sh $(GCOV_OUTPUT) $(GCOV_ERROR) $(GCOV_REPORT) $(TEST_OUTPUT) |
nexpaq | 1:55a6170b404f | 530 | $(SILENCE)cat $(GCOV_REPORT) |
nexpaq | 1:55a6170b404f | 531 | $(SILENCE)mkdir -p gcov |
nexpaq | 1:55a6170b404f | 532 | $(SILENCE)mv *.gcov gcov |
nexpaq | 1:55a6170b404f | 533 | $(SILENCE)mv gcov_* gcov |
nexpaq | 1:55a6170b404f | 534 | @echo "See gcov directory for details" |
nexpaq | 1:55a6170b404f | 535 | |
nexpaq | 1:55a6170b404f | 536 | .PHONEY: format |
nexpaq | 1:55a6170b404f | 537 | format: |
nexpaq | 1:55a6170b404f | 538 | $(CPPUTEST_HOME)/scripts/reformat.sh $(PROJECT_HOME_DIR) |
nexpaq | 1:55a6170b404f | 539 | |
nexpaq | 1:55a6170b404f | 540 | .PHONEY: debug |
nexpaq | 1:55a6170b404f | 541 | debug: |
nexpaq | 1:55a6170b404f | 542 | @echo |
nexpaq | 1:55a6170b404f | 543 | @echo "Target Source files:" |
nexpaq | 1:55a6170b404f | 544 | @$(call debug_print_list,$(SRC)) |
nexpaq | 1:55a6170b404f | 545 | @echo "Target Object files:" |
nexpaq | 1:55a6170b404f | 546 | @$(call debug_print_list,$(OBJ)) |
nexpaq | 1:55a6170b404f | 547 | @echo "Test Source files:" |
nexpaq | 1:55a6170b404f | 548 | @$(call debug_print_list,$(TEST_SRC)) |
nexpaq | 1:55a6170b404f | 549 | @echo "Test Object files:" |
nexpaq | 1:55a6170b404f | 550 | @$(call debug_print_list,$(TEST_OBJS)) |
nexpaq | 1:55a6170b404f | 551 | @echo "Mock Source files:" |
nexpaq | 1:55a6170b404f | 552 | @$(call debug_print_list,$(MOCKS_SRC)) |
nexpaq | 1:55a6170b404f | 553 | @echo "Mock Object files:" |
nexpaq | 1:55a6170b404f | 554 | @$(call debug_print_list,$(MOCKS_OBJS)) |
nexpaq | 1:55a6170b404f | 555 | @echo "All Input Dependency files:" |
nexpaq | 1:55a6170b404f | 556 | @$(call debug_print_list,$(DEP_FILES)) |
nexpaq | 1:55a6170b404f | 557 | @echo Stuff to clean: |
nexpaq | 1:55a6170b404f | 558 | @$(call debug_print_list,$(STUFF_TO_CLEAN)) |
nexpaq | 1:55a6170b404f | 559 | @echo Includes: |
nexpaq | 1:55a6170b404f | 560 | @$(call debug_print_list,$(INCLUDES)) |
nexpaq | 1:55a6170b404f | 561 | |
nexpaq | 1:55a6170b404f | 562 | -include $(OTHER_MAKEFILE_TO_INCLUDE) |