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 \
57 /I$(LIBRARY_SOURCE_DIRECTORY)\google $(CFLAGS) $(**) /Fo$(@)
58 CC_COMMAND_UNIT_TEST=$(CC_COMMAND) /DUNIT_TESTING=1 \
59 /I$(EXAMPLE_SOURCE_DIRECTORY)
63 # Library archiver flags and command.
64 LIB_COMMAND=$(LIBTOOL) $(LIBLINKFLAGS) $(LIBFLAGS) $(**) /OUT:$(@)
66 # Linker flags and command.
67 LINK_COMMAND=$(LINK) $(LIBLINKFLAGS) /SUBSYSTEM:console \
68 libcmt.lib kernel32.lib /NODEFAULTLIB:libc.lib \
69 $(LFLAGS) $(**) /OUT:$(@)
71 .SUFFIXES: .exe .lib .obj .c
73 all: $(EXECUTABLE_DIR) $(LIBRARY_DIR) $(OBJECT_DIR) \
74 $(LIBRARY_DIR)\cmockery.lib examples
79 !IF "$(LIBRARY_DIR)" != "$(EXECUTABLE_DIR)"
84 !IF "$(OBJECT_DIR)" != "$(LIBRARY_DIR)" && \
85 "$(OBJECT_DIR)" != "$(EXECUTABLE_DIR)"
91 $(EXECUTABLE_DIR)\calculator.exe \
92 $(EXECUTABLE_DIR)\calculator_test.exe \
93 $(EXECUTABLE_DIR)\allocate_module_test.exe \
94 $(EXECUTABLE_DIR)\assert_macro_test.exe \
95 $(EXECUTABLE_DIR)\customer_database_test.exe \
96 $(EXECUTABLE_DIR)\key_value_test.exe \
97 $(EXECUTABLE_DIR)\product_database_test.exe \
98 $(EXECUTABLE_DIR)\run_tests.exe
101 -cmd /c "@for %A in (\
102 $(LIBRARY_DIR)\cmockery.lib \
103 $(OBJECT_DIR)\cmockery.obj \
104 $(EXECUTABLE_DIR)\calculator.exe \
105 $(OBJECT_DIR)\calculator.obj \
106 $(EXECUTABLE_DIR)\calculator_test.exe \
107 $(OBJECT_DIR)\calculator_test.obj \
108 $(OBJECT_DIR)\calculator_test-calculator.obj \
109 $(EXECUTABLE_DIR)\allocate_module_test.exe \
110 $(OBJECT_DIR)\allocate_module_test.obj \
111 $(OBJECT_DIR)\allocate_module.obj \
112 $(EXECUTABLE_DIR)\assert_macro_test.exe \
113 $(OBJECT_DIR)\assert_macro_test.obj \
114 $(OBJECT_DIR)\assert_macro.obj \
115 $(EXECUTABLE_DIR)\customer_database_test.exe \
116 $(OBJECT_DIR)\customer_database_test.obj \
117 $(OBJECT_DIR)\customer_database.obj \
118 $(EXECUTABLE_DIR)\key_value_test.exe \
119 $(OBJECT_DIR)\key_value_test.obj \
120 $(OBJECT_DIR)\key_value.obj \
121 $(EXECUTABLE_DIR)\product_database_test.exe \
122 $(OBJECT_DIR)\product_database_test.obj \
123 $(OBJECT_DIR)\product_database.obj \
124 $(EXECUTABLE_DIR)\run_tests.exe \
125 $(OBJECT_DIR)\run_tests.obj) do @del %A 2>NUL"
126 -rmdir $(EXECUTABLE_DIR) $(OBJECT_DIR) $(LIBRARY_DIR) 2>NUL
128 # Rules for the cmockery library.
129 $(LIBRARY_DIR)\cmockery.lib: $(OBJECT_DIR)\cmockery.obj
130 $(OBJECT_DIR)\cmockery.obj: $(LIBRARY_SOURCE_DIRECTORY)\cmockery.c
132 # Rules for the calculator application.
133 $(EXECUTABLE_DIR)\calculator.exe: $(OBJECT_DIR)\calculator.obj
135 $(OBJECT_DIR)\calculator.obj: $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
138 # Rules for the calculator test application.
139 $(EXECUTABLE_DIR)\calculator_test.exe: \
140 $(OBJECT_DIR)\calculator_test.obj \
141 $(OBJECT_DIR)\calculator_test-calculator.obj \
142 $(LIBRARY_DIR)\cmockery.lib
145 $(OBJECT_DIR)\calculator_test.obj: \
146 $(EXAMPLE_SOURCE_DIRECTORY)\calculator_test.c
148 $(OBJECT_DIR)\calculator_test-calculator.obj: \
149 $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
150 $(CC_COMMAND_UNIT_TEST)
152 # Sample code applications.
153 $(EXECUTABLE_DIR)\allocate_module_test.exe: \
154 $(OBJECT_DIR)\allocate_module_test.obj \
155 $(OBJECT_DIR)\allocate_module.obj \
156 $(LIBRARY_DIR)\cmockery.lib
159 $(OBJECT_DIR)\allocate_module_test.obj: \
160 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module_test.c
161 $(OBJECT_DIR)\allocate_module.obj: \
162 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module.c
164 $(EXECUTABLE_DIR)\assert_macro_test.exe: \
165 $(OBJECT_DIR)\assert_macro_test.obj \
166 $(OBJECT_DIR)\assert_macro.obj \
167 $(LIBRARY_DIR)\cmockery.lib
170 $(OBJECT_DIR)\assert_macro_test.obj: \
171 $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro_test.c
172 $(OBJECT_DIR)\assert_macro.obj: $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro.c
174 $(EXECUTABLE_DIR)\customer_database_test.exe: \
175 $(OBJECT_DIR)\customer_database_test.obj \
176 $(OBJECT_DIR)\customer_database.obj \
177 $(LIBRARY_DIR)\cmockery.lib
180 $(OBJECT_DIR)\customer_database_test.obj: \
181 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database_test.c
182 $(OBJECT_DIR)\customer_database.obj: \
183 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database.c
185 $(EXECUTABLE_DIR)\key_value_test.exe: \
186 $(OBJECT_DIR)\key_value_test.obj \
187 $(OBJECT_DIR)\key_value.obj \
188 $(LIBRARY_DIR)\cmockery.lib
191 $(OBJECT_DIR)\key_value_test.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value_test.c
192 $(OBJECT_DIR)\key_value.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value.c
194 $(EXECUTABLE_DIR)\product_database_test.exe: \
195 $(OBJECT_DIR)\product_database_test.obj \
196 $(OBJECT_DIR)\product_database.obj \
197 $(LIBRARY_DIR)\cmockery.lib
200 $(OBJECT_DIR)\product_database_test.obj: \
201 $(EXAMPLE_SOURCE_DIRECTORY)\product_database_test.c
202 $(OBJECT_DIR)\product_database.obj: \
203 $(EXAMPLE_SOURCE_DIRECTORY)\product_database.c
205 $(EXECUTABLE_DIR)\run_tests.exe: \
206 $(OBJECT_DIR)\run_tests.obj $(LIBRARY_DIR)\cmockery.lib
209 $(OBJECT_DIR)\run_tests.obj: $(EXAMPLE_SOURCE_DIRECTORY)\run_tests.c
212 {$(OBJECT_DIR)\}.obj{$(EXECUTABLE_DIR)\}.exe:
215 {$(OBJECT_DIR)\}.obj{$(LIBRARY_DIR)\}.lib:
218 {$(LIBRARY_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
221 {$(EXAMPLE_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
222 $(CC_COMMAND_UNIT_TEST)