2 # Copyright 2008 Google Inc.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Microsoft Windows namke file which builds the cmockery library and example
19 # To use this makefile...
20 # Select Start->Run and run "cmd.exe" to open the command line.
21 # Run "vsvars.bat" located in Microsoft Visual Studio's directory.
22 # Run "nmake" to build the cmockery library and example applications.
23 # Run "nmake clean" to delete all files built by this makefile.
26 !IFNDEF EXECUTABLE_DIR
28 !ENDIF # EXECUTABLE_DIR
48 !IFNDEF LIBRARY_SOURCE_DIRECTORY
49 LIBRARY_SOURCE_DIRECTORY=..\src
50 !ENDIF # LIBRARY_SOURCE_DIRECTORY
51 !IFNDEF EXAMPLE_SOURCE_DIRECTORY
52 EXAMPLE_SOURCE_DIRECTORY=..\src\example
53 !ENDIF # EXAMPLE_SOURCE_DIRECTORY
55 # Compiler flags and commands.
56 CC_COMMAND=$(CC) /nologo /c /D_WIN32_WINNT=0x501 /DHAVE_MALLOC_H \
57 /I$(LIBRARY_SOURCE_DIRECTORY)\google $(CFLAGS) $(**) /Fo$(@)
58 CC_COMMAND_UNIT_TEST=$(CC_COMMAND) /DUNIT_TESTING=1 \
59 /I$(EXAMPLE_SOURCE_DIRECTORY)
61 # If debugging is enabled compile with symbols and stop on exceptions.
62 !IFDEF UNIT_TESTING_DEBUG
63 CC_COMMAND=$(CC_COMMAND) /DUNIT_TESTING_DEBUG=1 /Zi /Od
64 LFLAGS=$(LFLAGS) /DEBUG
65 !ENDIF # UNIT_TESTING_DEBUG
69 # Library archiver flags and command.
70 LIB_COMMAND=$(LIBTOOL) $(LIBLINKFLAGS) $(LIBFLAGS) $(**) /OUT:$(@)
72 # Linker flags and command.
73 LINK_COMMAND=$(LINK) $(LIBLINKFLAGS) /SUBSYSTEM:console \
74 libcmt.lib kernel32.lib /NODEFAULTLIB:libc.lib \
75 $(LFLAGS) $(**) /OUT:$(@)
77 .SUFFIXES: .exe .lib .obj .c
79 all: $(EXECUTABLE_DIR) $(LIBRARY_DIR) $(OBJECT_DIR) \
80 $(LIBRARY_DIR)\cmockery.lib examples
85 !IF "$(LIBRARY_DIR)" != "$(EXECUTABLE_DIR)"
90 !IF "$(OBJECT_DIR)" != "$(LIBRARY_DIR)" && \
91 "$(OBJECT_DIR)" != "$(EXECUTABLE_DIR)"
97 $(EXECUTABLE_DIR)\calculator.exe \
98 $(EXECUTABLE_DIR)\calculator_test.exe \
99 $(EXECUTABLE_DIR)\allocate_module_test.exe \
100 $(EXECUTABLE_DIR)\assert_macro_test.exe \
101 $(EXECUTABLE_DIR)\customer_database_test.exe \
102 $(EXECUTABLE_DIR)\key_value_test.exe \
103 $(EXECUTABLE_DIR)\product_database_test.exe \
104 $(EXECUTABLE_DIR)\run_tests.exe
107 -cmd /c "@for %A in (\
108 $(LIBRARY_DIR)\cmockery.lib \
109 $(OBJECT_DIR)\cmockery.obj \
110 $(EXECUTABLE_DIR)\calculator.exe \
111 $(OBJECT_DIR)\calculator.obj \
112 $(EXECUTABLE_DIR)\calculator_test.exe \
113 $(OBJECT_DIR)\calculator_test.obj \
114 $(OBJECT_DIR)\calculator_test-calculator.obj \
115 $(EXECUTABLE_DIR)\allocate_module_test.exe \
116 $(OBJECT_DIR)\allocate_module_test.obj \
117 $(OBJECT_DIR)\allocate_module.obj \
118 $(EXECUTABLE_DIR)\assert_macro_test.exe \
119 $(OBJECT_DIR)\assert_macro_test.obj \
120 $(OBJECT_DIR)\assert_macro.obj \
121 $(EXECUTABLE_DIR)\customer_database_test.exe \
122 $(OBJECT_DIR)\customer_database_test.obj \
123 $(OBJECT_DIR)\customer_database.obj \
124 $(EXECUTABLE_DIR)\key_value_test.exe \
125 $(OBJECT_DIR)\key_value_test.obj \
126 $(OBJECT_DIR)\key_value.obj \
127 $(EXECUTABLE_DIR)\product_database_test.exe \
128 $(OBJECT_DIR)\product_database_test.obj \
129 $(OBJECT_DIR)\product_database.obj \
130 $(EXECUTABLE_DIR)\run_tests.exe \
131 $(OBJECT_DIR)\run_tests.obj) do @del %A 2>NUL"
132 -rmdir $(EXECUTABLE_DIR) $(OBJECT_DIR) $(LIBRARY_DIR) 2>NUL
134 # Rules for the cmockery library.
135 $(LIBRARY_DIR)\cmockery.lib: $(OBJECT_DIR)\cmockery.obj
136 $(OBJECT_DIR)\cmockery.obj: $(LIBRARY_SOURCE_DIRECTORY)\cmockery.c
138 # Rules for the calculator application.
139 $(EXECUTABLE_DIR)\calculator.exe: $(OBJECT_DIR)\calculator.obj
141 $(OBJECT_DIR)\calculator.obj: $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
144 # Rules for the calculator test application.
145 $(EXECUTABLE_DIR)\calculator_test.exe: \
146 $(OBJECT_DIR)\calculator_test.obj \
147 $(OBJECT_DIR)\calculator_test-calculator.obj \
148 $(LIBRARY_DIR)\cmockery.lib
151 $(OBJECT_DIR)\calculator_test.obj: \
152 $(EXAMPLE_SOURCE_DIRECTORY)\calculator_test.c
154 $(OBJECT_DIR)\calculator_test-calculator.obj: \
155 $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
156 $(CC_COMMAND_UNIT_TEST)
158 # Sample code applications.
159 $(EXECUTABLE_DIR)\allocate_module_test.exe: \
160 $(OBJECT_DIR)\allocate_module_test.obj \
161 $(OBJECT_DIR)\allocate_module.obj \
162 $(LIBRARY_DIR)\cmockery.lib
165 $(OBJECT_DIR)\allocate_module_test.obj: \
166 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module_test.c
167 $(OBJECT_DIR)\allocate_module.obj: \
168 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module.c
170 $(EXECUTABLE_DIR)\assert_macro_test.exe: \
171 $(OBJECT_DIR)\assert_macro_test.obj \
172 $(OBJECT_DIR)\assert_macro.obj \
173 $(LIBRARY_DIR)\cmockery.lib
176 $(OBJECT_DIR)\assert_macro_test.obj: \
177 $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro_test.c
178 $(OBJECT_DIR)\assert_macro.obj: $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro.c
180 $(EXECUTABLE_DIR)\customer_database_test.exe: \
181 $(OBJECT_DIR)\customer_database_test.obj \
182 $(OBJECT_DIR)\customer_database.obj \
183 $(LIBRARY_DIR)\cmockery.lib
186 $(OBJECT_DIR)\customer_database_test.obj: \
187 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database_test.c
188 $(OBJECT_DIR)\customer_database.obj: \
189 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database.c
191 $(EXECUTABLE_DIR)\key_value_test.exe: \
192 $(OBJECT_DIR)\key_value_test.obj \
193 $(OBJECT_DIR)\key_value.obj \
194 $(LIBRARY_DIR)\cmockery.lib
197 $(OBJECT_DIR)\key_value_test.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value_test.c
198 $(OBJECT_DIR)\key_value.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value.c
200 $(EXECUTABLE_DIR)\product_database_test.exe: \
201 $(OBJECT_DIR)\product_database_test.obj \
202 $(OBJECT_DIR)\product_database.obj \
203 $(LIBRARY_DIR)\cmockery.lib
206 $(OBJECT_DIR)\product_database_test.obj: \
207 $(EXAMPLE_SOURCE_DIRECTORY)\product_database_test.c
208 $(OBJECT_DIR)\product_database.obj: \
209 $(EXAMPLE_SOURCE_DIRECTORY)\product_database.c
211 $(EXECUTABLE_DIR)\run_tests.exe: \
212 $(OBJECT_DIR)\run_tests.obj $(LIBRARY_DIR)\cmockery.lib
215 $(OBJECT_DIR)\run_tests.obj: $(EXAMPLE_SOURCE_DIRECTORY)\run_tests.c
218 {$(OBJECT_DIR)\}.obj{$(EXECUTABLE_DIR)\}.exe:
221 {$(OBJECT_DIR)\}.obj{$(LIBRARY_DIR)\}.lib:
224 {$(LIBRARY_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
227 {$(EXAMPLE_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
228 $(CC_COMMAND_UNIT_TEST)