blob: e0337db3e81f219eda404b5c333e606c7e322abe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
# fee is hereby granted, provided that the above copyright
# notice appear in all copies and that both that copyright
# notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in
# advertising or publicity pertaining to distribution of the
# software without specific, written prior permission.
# M.I.T. makes no representations about the suitability of
# this software for any purpose. It is provided "as is"
# without express or implied warranty.
# ------------------------------------------------------------------------------
#
# Makefile for building c-ares test suite with MSVC.
#
# Usage: nmake /f makefile.msvc CFG=<config> <target>
#
# <config> can be one of: [ lib-release | lib-debug | dll-release | dll-debug }
# <target> can be one of: [ all | arestest | clean }
#
# If <target> is not specified then all targets are built.
# If <config> is not specified then lib-debug will be assumed.
#
# This makefile must be processed from the subdir where it is located.
#
# All results are generated below a subdirectory named msvcXXX.
#
# ------------------------------------------------------------------------------
# ------------------------------------------------
# c-ares static and dynamic libraries common base
# file names for release and debug configurations
# ------------------------------------------------
LIBNAME = cares
STA_LIB_REL = lib$(LIBNAME)
DYN_LIB_REL = $(LIBNAME)
STA_LIB_DBG = $(STA_LIB_REL)d
DYN_LIB_DBG = $(DYN_LIB_REL)d
# -------------------------------------------
# Base names for c-ares DLL import libraries
# -------------------------------------------
IMP_LIB_REL = $(DYN_LIB_REL)
IMP_LIB_DBG = $(DYN_LIB_DBG)
# --------------------------
# Runtime library selection
# --------------------------
RTLIB = /MD
RTLIBD = /MDd
!IF "$(RTLIBCFG)" == "static"
RTLIB = /MT
RTLIBD = /MTd
!ENDIF
# --------------------------------------------------------
# Detect compiler version.
# --------------------------------------------------------
!INCLUDE ..\msvc_ver.inc
# ---------------------------------------------------------
# Verify that current subdir is below the c-ares source one
# ---------------------------------------------------------
!IF ! EXIST(..\src\lib\ares_init.c)
! MESSAGE Can not process Makefile.msvc from outside of c-ares test subdirectory.
! MESSAGE Change to the subdirectory where Makefile.msvc is found, and try again.
! ERROR See previous message.
!ENDIF
# ------------------------------------------------------------------
# Base subdir is the common root from which other subdirs will hang,
# the name depends on MSVC version being used when building c-ares.
# ------------------------------------------------------------------
BASE_DIR = .\msvc
# Look for a built library of the same configuration in the directory above.
LIB_BASE_DIR = ..\msvc
# ----------------------------------------
# Subdir holding sources for all projects
# ----------------------------------------
SRCDIR = .
# -------------------------
# Configuration validation
# -------------------------
!IF "$(CFG)" == ""
CFG = lib-debug
!ENDIF
VALID_CFGSET = FALSE
!IF "$(CFG)" == "lib-release" || "$(CFG)" == "lib-debug" || \
"$(CFG)" == "dll-release" || "$(CFG)" == "dll-debug"
VALID_CFGSET = TRUE
!ENDIF
!IF "$(VALID_CFGSET)" == "FALSE"
! MESSAGE MSVC c-ares makefile
! MESSAGE
! MESSAGE Usage: nmake /f makefile.msvc CFG=<config> <target>
! MESSAGE
! MESSAGE <config> can be one of: [ lib-release | lib-debug | dll-release | dll-debug }
! MESSAGE <target> can be one of: [ all | arestest | aresfuzz | aresfuzzname | dnsdump | clean }
! MESSAGE
! MESSAGE If <target> is not specified then all targets are built.
! MESSAGE If <config> is not specified then lib-debug will be assumed.
! MESSAGE
! ERROR Choose a valid configuration.
!ENDIF
# --------------------------------------------------------
# Project subdirs independent of configuration being used
# --------------------------------------------------------
PROG_DIR = $(BASE_DIR)\arestest
LIB_DIR = $(LIB_BASE_DIR)\cares
GMOCK_DIR = gmock-1.8.0
# ---------------------------------------------------
# Subdirs which are configuration dependent are only
# defined when a valid configuration has been given.
# ---------------------------------------------------
PROG_OUTDIR = $(PROG_DIR)\$(CFG)
PROG_OBJDIR = $(PROG_OUTDIR)\obj
LIB_OUTDIR = $(LIB_DIR)\$(CFG)
# -------------------------------------
# TCP/IP stack settings
# -------------------------------------
CFLAGS = /DWIN32
EX_LIBS_REL = ws2_32.lib advapi32.lib kernel32.lib
EX_LIBS_DBG = ws2_32.lib advapi32.lib kernel32.lib
# -------------------------------------------------
# Switches that depend on ancient compiler versions
# -------------------------------------------------
!IF $(CC_VERS_NUM) == 60
PDB_NONE = /pdb:none
PDBTYPE_CONSOLIDATE = /pdbtype:consolidate
!ELSE
!UNDEF PDB_NONE
!UNDEF PDBTYPE_CONSOLIDATE
!ENDIF
!IF $(CC_VERS_NUM) <= 70
RT_ERROR_CHECKING = /GZ
!ELSE
RT_ERROR_CHECKING = /RTCsu
!ENDIF
# ----------------------------
# Assorted commands and flags
# ----------------------------
CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2 /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS $(RT_ERROR_CHECKING)
CC_CFLAGS = $(CFLAGS) /I. /I../src/lib /I../include /I $(GMOCK_DIR) /W3 /EHsc /FD
RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
LINK_CMD_LIB = link.exe /lib /nologo
LINK_CMD_DLL = link.exe /dll /nologo /incremental:no /fixed:no
LINK_CMD_EXE = link.exe /nologo /incremental:no /fixed:no /subsystem:console
LINK_CMD_EXE_REL = $(LINK_CMD_EXE) /release $(PDB_NONE)
LINK_CMD_EXE_DBG = $(LINK_CMD_EXE) /debug $(PDBTYPE_CONSOLIDATE)
# ---------------------------------
# Configuration dependent settings
# ---------------------------------
!IF "$(CFG)" == "lib-release"
CARES_TARGET = $(STA_LIB_REL).lib
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DCARES_STATICLIB
CARES_LFLAGS =
SPROG_CFLAGS = /DCARES_STATICLIB
SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_REL) $(STA_LIB_REL).lib
CARES_LINK = $(LINK_CMD_LIB)
SPROG_LINK = $(LINK_CMD_EXE_REL)
CC_CMD = $(CC_CMD_REL)
!ENDIF
!IF "$(CFG)" == "lib-debug"
CARES_TARGET = $(STA_LIB_DBG).lib
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DCARES_STATICLIB /DDEBUGBUILD
CARES_LFLAGS =
SPROG_CFLAGS = /DCARES_STATICLIB
SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_DBG) $(STA_LIB_DBG).lib
CARES_LINK = $(LINK_CMD_LIB)
SPROG_LINK = $(LINK_CMD_EXE_DBG)
CC_CMD = $(CC_CMD_DBG)
!ENDIF
!IF "$(CFG)" == "dll-release"
CARES_TARGET = $(DYN_LIB_REL).dll
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY
CARES_LFLAGS = /release $(EX_LIBS_REL) /implib:$(PROG_OUTDIR)\$(IMP_LIB_REL).lib $(PDB_NONE)
SPROG_CFLAGS =
SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_REL) $(IMP_LIB_REL).lib
CARES_LINK = $(LINK_CMD_DLL)
SPROG_LINK = $(LINK_CMD_EXE_REL)
CC_CMD = $(CC_CMD_REL)
USE_RES_FILE = TRUE
RC_CMD = $(RC_CMD_REL)
!ENDIF
!IF "$(CFG)" == "dll-debug"
CARES_TARGET = $(DYN_LIB_DBG).dll
CARES_CFLAGS = /DCARES_BUILDING_LIBRARY /DDEBUGBUILD
CARES_LFLAGS = /debug $(EX_LIBS_DBG) /implib:$(PROG_OUTDIR)\$(IMP_LIB_DBG).lib /pdb:$(PROG_OUTDIR)\$(DYN_LIB_DBG).pdb $(PDBTYPE_CONSOLIDATE)
SPROG_CFLAGS =
SPROG_LFLAGS = /libpath:$(LIB_OUTDIR) $(EX_LIBS_DBG) $(IMP_LIB_DBG).lib
CARES_LINK = $(LINK_CMD_DLL)
SPROG_LINK = $(LINK_CMD_EXE_DBG)
CC_CMD = $(CC_CMD_DBG)
USE_RES_FILE = TRUE
RC_CMD = $(RC_CMD_DBG)
!ENDIF
# --------------------------------------------
# Makefile.inc provides lists of source files
# --------------------------------------------
!INCLUDE .\Makefile.inc
# ----------------------------
# Build lists of object files
# ----------------------------
!IF [ECHO PROG_OBJS=^$(PROG_OBJDIR)\$(TESTSOURCES: = $(PROG_OBJDIR^)\) > .\prog_objs.inc] == 0
!INCLUDE .\prog_objs.inc
!IF [DEL .\prog_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating PROG_OBJS list.
!ENDIF
PROG_OBJS = $(PROG_OBJS:.cc=.obj)
!IF [ECHO FUZZ_OBJS=^$(PROG_OBJDIR)\$(FUZZSOURCES: = $(PROG_OBJDIR^)\) > .\fuzz_objs.inc] == 0
!INCLUDE .\fuzz_objs.inc
!IF [DEL .\fuzz_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating FUZZ_OBJS list.
!ENDIF
FUZZ_OBJS = $(FUZZ_OBJS:.c=.obj)
!IF [ECHO FUZZNAME_OBJS=^$(PROG_OBJDIR)\$(FUZZNAMESOURCES: = $(PROG_OBJDIR^)\) > .\fuzzname_objs.inc] == 0
!INCLUDE .\fuzzname_objs.inc
!IF [DEL .\fuzzname_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating FUZZNAME_OBJS list.
!ENDIF
FUZZNAME_OBJS = $(FUZZNAME_OBJS:.c=.obj)
!IF [ECHO DNSDUMP_OBJS=^$(PROG_OBJDIR)\$(DUMPSOURCES: = $(PROG_OBJDIR^)\) > .\dnsdump_objs.inc] == 0
!INCLUDE .\dnsdump_objs.inc
!IF [DEL .\dnsdump_objs.inc]
!ENDIF
!ELSE
!ERROR Problem generating DNSDUMP_OBJS list.
!ENDIF
DNSDUMP_OBJS = $(DNSDUMP_OBJS:.cc=.obj)
GMOCK_GTEST_OBJ = $(PROG_OBJDIR)\gmock-gtest-all.obj
# --------------------------------
# Only our custom inference rules
# --------------------------------
.SUFFIXES:
.SUFFIXES: .cc .c
{$(SRCDIR)}.cc{$(PROG_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
{$(SRCDIR)}.c{$(PROG_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /Fo$@ /Fd$(@D)\ /c $<
{$(GMOCK_DIR)}.cc{$(PROG_OBJDIR)}.obj:
$(CC_CMD) $(CC_CFLAGS) $(SPROG_CFLAGS) /I $(GMOCK_DIR) /Fo$@ /Fd$(@D)\ /c $<
# ---------------------------------------------------------------------
# Main targets
# ---------------------------------------------------------------------
ALL: arestest aresfuzz aresfuzzname dnsdump
@
test: arestest
$(PROG_OUTDIR)\arestest
vtest: arestest
$(PROG_OUTDIR)\arestest -v
arestest: $(TESTSOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(PROG_OBJS) $(GMOCK_GTEST_OBJ)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\arestest.exe $(PROG_OBJS) $(GMOCK_GTEST_OBJ)
@if exist $(PROG_OUTDIR)\arestest.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\arestest.exe.manifest -outputresource:$(PROG_OUTDIR)\arestest.exe;1
aresfuzz: $(FUZZSOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(FUZZ_OBJS)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\aresfuzz.exe $(FUZZ_OBJS)
@if exist $(PROG_OUTDIR)\aresfuzz.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\aresfuzz.exe.manifest -outputresource:$(PROG_OUTDIR)\aresfuzz.exe;1
aresfuzzname: $(FUZZNAMESOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(FUZZNAME_OBJS)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\aresfuzzname.exe $(FUZZNAME_OBJS)
@if exist $(PROG_OUTDIR)\aresfuzzname.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\aresfuzzname.exe.manifest -outputresource:$(PROG_OUTDIR)\aresfuzzname.exe;1
dnsdump: $(DUMPSOURCES) $(PROG_OUTDIR) $(PROG_OBJDIR) $(DNSDUMP_OBJS)
$(SPROG_LINK) $(SPROG_LFLAGS) /out:$(PROG_OUTDIR)\dnsdump.exe $(DNSDUMP_OBJS)
@if exist $(PROG_OUTDIR)\dnsdump.exe.manifest mt -nologo -manifest $(PROG_OUTDIR)\dnsdump.exe.manifest -outputresource:$(PROG_OUTDIR)\dnsdump.exe;1
$(PROG_OUTDIR): $(PROG_DIR)
@if not exist $(PROG_OUTDIR) mkdir $(PROG_OUTDIR)
$(PROG_OBJDIR): $(PROG_OUTDIR)
@if not exist $(PROG_OBJDIR) mkdir $(PROG_OBJDIR)
clean:
@-RMDIR /S /Q $(PROG_OUTDIR) >NUL 2>&1
$(BASE_DIR):
@if not exist $(BASE_DIR) mkdir $(BASE_DIR)
$(PROG_DIR): $(BASE_DIR)
@if not exist $(PROG_DIR) mkdir $(PROG_DIR)
# End of Makefile.msvc
|