• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright 2008 Google Inc.
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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.
15#
16# Microsoft Windows namke file which builds the cmockery library and example
17# applications.
18#
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.
24
25# Target directories.
26!IFNDEF EXECUTABLE_DIR
27EXECUTABLE_DIR=.
28!ENDIF # EXECUTABLE_DIR
29
30!IFNDEF LIBRARY_DIR
31LIBRARY_DIR=.
32!ENDIF # LIBRARY_DIR
33
34!IFNDEF INSTALL_DIR
35INSTALL_DIR=..\0_1_2
36!ENDIF # INSTALL_DIR
37
38!IFNDEF OBJECT_DIR
39OBJECT_DIR=.
40!ENDIF # OBJECT_DIR
41
42# Tools
43!IFNDEF LIBTOOL
44LIBTOOL=lib.exe
45!ENDIF # LIBTOOL
46
47!IFNDEF LINK
48LINK=link.exe
49!ENDIF # LINK
50
51# Source directories.
52LIBRARY_SOURCE_DIRECTORY=..\src
53EXAMPLE_SOURCE_DIRECTORY=..\src\example
54
55# Compiler flags and commands.
56CC_COMMAND=$(CC) /nologo /c /D_WIN32_WINNT=0x501 \
57	/I$(LIBRARY_SOURCE_DIRECTORY)\google $(CFLAGS) $(**) /Fo$(@)
58CC_COMMAND_UNIT_TEST=$(CC_COMMAND) /DUNIT_TESTING=1 \
59	/I$(EXAMPLE_SOURCE_DIRECTORY)
60
61LIBLINKFLAGS=/NOLOGO
62
63# Library archiver flags and command.
64LIB_COMMAND=$(LIBTOOL) $(LIBLINKFLAGS) $(LIBFLAGS) $(**) /OUT:$(@)
65
66# Linker flags and command.
67LINK_COMMAND=$(LINK) $(LIBLINKFLAGS) /SUBSYSTEM:console \
68	libcmt.lib kernel32.lib /NODEFAULTLIB:libc.lib \
69	$(LFLAGS) $(**) /OUT:$(@)
70
71.SUFFIXES: .exe .lib .obj .c
72
73all: $(EXECUTABLE_DIR) $(LIBRARY_DIR) $(OBJECT_DIR) \
74	$(LIBRARY_DIR)\cmockery.lib examples
75
76$(EXECUTABLE_DIR):
77	mkdir $@
78
79!IF "$(LIBRARY_DIR)" != "$(EXECUTABLE_DIR)"
80$(LIBRARY_DIR):
81	mkdir $*
82!ENDIF
83
84!IF "$(OBJECT_DIR)" != "$(LIBRARY_DIR)" && \
85	"$(OBJECT_DIR)" != "$(EXECUTABLE_DIR)"
86$(OBJECT_DIR):
87	mkdir $@
88!ENDIF
89
90examples: \
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
99
100install:
101	mkdir -p $(INSTALL_DIR)\lib
102	mkdir -p $(INSTALL_DIR)\include\google
103	cp -f $(LIBRARY_DIR)\cmockery.lib $(INSTALL_DIR)\lib
104	cp -f $(LIBRARY_SOURCE_DIRECTORY)\google\cmockery.h $(INSTALL_DIR)\include\google
105
106clean:
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
133
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
137
138# Rules for the calculator application.
139$(EXECUTABLE_DIR)\calculator.exe: $(OBJECT_DIR)\calculator.obj
140
141$(OBJECT_DIR)\calculator.obj: $(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
142	$(CC_COMMAND)
143
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
149	$(LINK_COMMAND)
150
151$(OBJECT_DIR)\calculator_test.obj: \
152	$(EXAMPLE_SOURCE_DIRECTORY)\calculator_test.c
153
154$(OBJECT_DIR)\calculator_test-calculator.obj: \
155	$(EXAMPLE_SOURCE_DIRECTORY)\calculator.c
156	$(CC_COMMAND_UNIT_TEST)
157
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
163	$(LINK_COMMAND)
164
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
169
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
174	$(LINK_COMMAND)
175
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
179
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
184	$(LINK_COMMAND)
185
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
190
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
195	$(LINK_COMMAND)
196
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
199
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
204	$(LINK_COMMAND)
205
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
210
211$(EXECUTABLE_DIR)\run_tests.exe: \
212		$(OBJECT_DIR)\run_tests.obj $(LIBRARY_DIR)\cmockery.lib
213	$(LINK_COMMAND)
214
215$(OBJECT_DIR)\run_tests.obj: $(EXAMPLE_SOURCE_DIRECTORY)\run_tests.c
216
217# Inference rules.
218{$(OBJECT_DIR)\}.obj{$(EXECUTABLE_DIR)\}.exe:
219	$(LINK_COMMAND)
220
221{$(OBJECT_DIR)\}.obj{$(LIBRARY_DIR)\}.lib:
222	$(LIB_COMMAND)
223
224{$(LIBRARY_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
225	$(CC_COMMAND)
226
227{$(EXAMPLE_SOURCE_DIRECTORY)\}.c{$(OBJECT_DIR)\}.obj:
228	$(CC_COMMAND_UNIT_TEST)
229