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 LIBRARY_SOURCE_DIRECTORY=..\src
49 EXAMPLE_SOURCE_DIRECTORY=..\src\example
51 # Compiler flags and commands.
52 CC_COMMAND=$(CC) /nologo /c /D_WIN32_WINNT=0x501 \
53 /I$(LIBRARY_SOURCE_DIRECTORY)\google $(CFLAGS) $(**) /Fo$(@)
54 CC_COMMAND_UNIT_TEST=$(CC_COMMAND) /DUNIT_TESTING=1 \
55 /I$(EXAMPLE_SOURCE_DIRECTORY)
59 # Library archiver flags and command.
60 LIB_COMMAND=$(LIBTOOL) $(LIBLINKFLAGS) $(LIBFLAGS) $(**) /OUT:$(@)
62 # Linker flags and command.
63 LINK_COMMAND=$(LINK) $(LIBLINKFLAGS) /SUBSYSTEM:console \
64 libcmt.lib kernel32.lib /NODEFAULTLIB:libc.lib \
65 $(LFLAGS) $(**) /OUT:$(@)
67 .SUFFIXES: .exe .lib .obj .c
69 all: $(EXECUTABLE_DIR) $(LIBRARY_DIR) $(OBJECT_DIR) \
70 $(LIBRARY_DIR)\cmockery.lib examples
75 !IF "$(LIBRARY_DIR)" != "$(EXECUTABLE_DIR)"
80 !IF "$(OBJECT_DIR)" != "$(LIBRARY_DIR)" && \
81 "$(OBJECT_DIR)" != "$(EXECUTABLE_DIR)"
87 $(EXECUTABLE_DIR)\calculator.exe \
88 $(EXECUTABLE_DIR)\calculator_test.exe \
89 $(EXECUTABLE_DIR)\allocate_module_test.exe \
90 $(EXECUTABLE_DIR)\assert_macro_test.exe \
91 $(EXECUTABLE_DIR)\customer_database_test.exe \
92 $(EXECUTABLE_DIR)\key_value_test.exe \
93 $(EXECUTABLE_DIR)\product_database_test.exe \
94 $(EXECUTABLE_DIR)\run_tests.exe
97 -cmd /c "@for %A in (\
98 $(LIBRARY_DIR)\cmockery.lib \
99 $(OBJECT_DIR)\cmockery.obj \
100 $(EXECUTABLE_DIR)\calculator.exe \
101 $(OBJECT_DIR)\calculator.obj \
102 $(EXECUTABLE_DIR)\calculator_test.exe \
103 $(OBJECT_DIR)\calculator_test.obj \
104 $(OBJECT_DIR)\calculator_test-calculator.obj \
105 $(EXECUTABLE_DIR)\allocate_module_test.exe \
106 $(OBJECT_DIR)\allocate_module_test.obj \
107 $(OBJECT_DIR)\allocate_module.obj \
108 $(EXECUTABLE_DIR)\assert_macro_test.exe \
109 $(OBJECT_DIR)\assert_macro_test.obj \
110 $(OBJECT_DIR)\assert_macro.obj \
111 $(EXECUTABLE_DIR)\customer_database_test.exe \
112 $(OBJECT_DIR)\customer_database_test.obj \
113 $(OBJECT_DIR)\customer_database.obj \
114 $(EXECUTABLE_DIR)\key_value_test.exe \
115 $(OBJECT_DIR)\key_value_test.obj \
116 $(OBJECT_DIR)\key_value.obj \
117 $(EXECUTABLE_DIR)\product_database_test.exe \
118 $(OBJECT_DIR)\product_database_test.obj \
119 $(OBJECT_DIR)\product_database.obj \
120 $(EXECUTABLE_DIR)\run_tests.exe \
121 $(OBJECT_DIR)\run_tests.obj) do @del %A 2>NUL"
122 -rmdir $(EXECUTABLE_DIR) $(OBJECT_DIR) $(LIBRARY_DIR) 2>NUL
124 # Rules for the cmockery library.
125 $(LIBRARY_DIR)\cmockery.lib: $(OBJECT_DIR)\cmockery.obj
126 $(OBJECT_DIR)\cmockery.obj: $(LIBRARY_SOURCE_DIRECTORY)\cmockery.c
128 # Rules for the calculator application.
129 $(EXECUTABLE_DIR)\calculator.exe: $(OBJECT_DIR)\calculator.obj
131 $(OBJECT_DIR)\calculator.obj: $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
134 # Rules for the calculator test application.
135 $(EXECUTABLE_DIR)\calculator_test.exe: \
136 $(OBJECT_DIR)\calculator_test.obj \
137 $(OBJECT_DIR)\calculator_test-calculator.obj \
138 $(LIBRARY_DIR)\cmockery.lib
141 $(OBJECT_DIR)\calculator_test.obj: \
142 $(EXAMPLE_SOURCE_DIRECTORY)\calculator_test.c
144 $(OBJECT_DIR)\calculator_test-calculator.obj: \
145 $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
146 $(CC_COMMAND_UNIT_TEST)
148 # Sample code applications.
149 $(EXECUTABLE_DIR)\allocate_module_test.exe: \
150 $(OBJECT_DIR)\allocate_module_test.obj \
151 $(OBJECT_DIR)\allocate_module.obj \
152 $(LIBRARY_DIR)\cmockery.lib
155 $(OBJECT_DIR)\allocate_module_test.obj: \
156 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module_test.c
157 $(OBJECT_DIR)\allocate_module.obj: \
158 $(EXAMPLE_SOURCE_DIRECTORY)\allocate_module.c
160 $(EXECUTABLE_DIR)\assert_macro_test.exe: \
161 $(OBJECT_DIR)\assert_macro_test.obj \
162 $(OBJECT_DIR)\assert_macro.obj \
163 $(LIBRARY_DIR)\cmockery.lib
166 $(OBJECT_DIR)\assert_macro_test.obj: \
167 $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro_test.c
168 $(OBJECT_DIR)\assert_macro.obj: $(EXAMPLE_SOURCE_DIRECTORY)\assert_macro.c
170 $(EXECUTABLE_DIR)\customer_database_test.exe: \
171 $(OBJECT_DIR)\customer_database_test.obj \
172 $(OBJECT_DIR)\customer_database.obj \
173 $(LIBRARY_DIR)\cmockery.lib
176 $(OBJECT_DIR)\customer_database_test.obj: \
177 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database_test.c
178 $(OBJECT_DIR)\customer_database.obj: \
179 $(EXAMPLE_SOURCE_DIRECTORY)\customer_database.c
181 $(EXECUTABLE_DIR)\key_value_test.exe: \
182 $(OBJECT_DIR)\key_value_test.obj \
183 $(OBJECT_DIR)\key_value.obj \
184 $(LIBRARY_DIR)\cmockery.lib
187 $(OBJECT_DIR)\key_value_test.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value_test.c
188 $(OBJECT_DIR)\key_value.obj: $(EXAMPLE_SOURCE_DIRECTORY)\key_value.c
190 $(EXECUTABLE_DIR)\product_database_test.exe: \
191 $(OBJECT_DIR)\product_database_test.obj \
192 $(OBJECT_DIR)\product_database.obj \
193 $(LIBRARY_DIR)\cmockery.lib
196 $(OBJECT_DIR)\product_database_test.obj: \
197 $(EXAMPLE_SOURCE_DIRECTORY)\product_database_test.c
198 $(OBJECT_DIR)\product_database.obj: \
199 $(EXAMPLE_SOURCE_DIRECTORY)\product_database.c
201 $(EXECUTABLE_DIR)\run_tests.exe: \
202 $(OBJECT_DIR)\run_tests.obj $(LIBRARY_DIR)\cmockery.lib
205 $(OBJECT_DIR)\run_tests.obj: $(EXAMPLE_SOURCE_DIRECTORY)\run_tests.c
208 {$(OBJECT_DIR)\}.obj{$(EXECUTABLE_DIR)\}.exe:
211 {$(OBJECT_DIR)\}.obj{$(LIBRARY_DIR)\}.lib:
214 {$(LIBRARY_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
217 {$(EXAMPLE_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
218 $(CC_COMMAND_UNIT_TEST)