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