1 # Makefile for libxml2, specific for Windows, MSVC and NMAKE.
3 # Take a look at the beginning and modify the variables to suit your
4 # environment. Having done that, you can do a
6 # nmake [all] to build the libxml and the accompanying utilities.
7 # nmake clean to remove all compiler output files and return to a
9 # nmake rebuild to rebuild everything from scratch. This basically does
10 # a 'nmake clean' and then a 'nmake all'.
11 # nmake install to install the library and its header files.
13 # March 2002, Igor Zlatkovic <igor@zlatkovic.com>
15 # There should never be a need to modify anything below this line.
16 # ----------------------------------------------------------------
18 AUTOCONF = .\config.msvc
21 # Names of various input and output components.
23 XML_BASENAME = lib$(XML_NAME)
24 XML_SO = $(XML_BASENAME).dll
25 XML_IMP = $(XML_BASENAME).lib
26 XML_DEF = $(XML_BASENAME).def
27 XML_A = $(XML_BASENAME)_a.lib
28 XML_A_DLL = $(XML_BASENAME)_a_dll.lib
30 # Place where we let the compiler put its output.
33 XML_INTDIR_A = int.a.msvc
34 XML_INTDIR_A_DLL = int.a.dll.msvc
35 UTILS_INTDIR = int.utils.msvc
37 # The preprocessor and its options.
39 CPPFLAGS = /nologo /I$(XML_SRCDIR)\include
40 !if "$(WITH_THREADS)" != "no"
41 CPPFLAGS = $(CPPFLAGS) /D "_REENTRANT"
44 # The compiler and its options.
46 CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /W1 $(CRUNTIME)
47 CFLAGS = $(CFLAGS) /I$(XML_SRCDIR) /I$(XML_SRCDIR)\include /I$(INCPREFIX)
48 !if "$(WITH_THREADS)" != "no"
49 CFLAGS = $(CFLAGS) /D "_REENTRANT"
51 !if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls"
52 CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS" /D "HAVE_COMPILER_TLS"
53 !else if "$(WITH_THREADS)" == "native"
54 CFLAGS = $(CFLAGS) /D "HAVE_WIN32_THREADS"
55 !else if "$(WITH_THREADS)" == "posix"
56 CFLAGS = $(CFLAGS) /D "HAVE_PTHREAD_H"
58 !if "$(WITH_ZLIB)" == "1"
59 CFLAGS = $(CFLAGS) /D "HAVE_ZLIB_H"
61 CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
63 # The linker and its options.
65 LDFLAGS = /nologo /VERSION:$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
66 LDFLAGS = $(LDFLAGS) /LIBPATH:$(BINDIR) /LIBPATH:$(LIBPREFIX)
68 !if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1"
69 LIBS = $(LIBS) wsock32.lib ws2_32.lib
71 !if "$(WITH_ICONV)" == "1"
72 LIBS = $(LIBS) iconv.lib
74 !if "$(WITH_ICU)" == "1"
75 LIBS = $(LIBS) icu.lib
77 !if "$(WITH_ZLIB)" == "1"
78 LIBS = $(LIBS) zdll.lib
80 !if "$(WITH_THREADS)" == "posix"
81 LIBS = $(LIBS) pthreadVC.lib
83 !if "$(WITH_MODULES)" == "1"
84 LIBS = $(LIBS) kernel32.lib
87 # The archiver and its options.
91 # Optimisation and debug symbols.
93 CFLAGS = $(CFLAGS) /D "_DEBUG" /Od /Z7
94 LDFLAGS = $(LDFLAGS) /DEBUG
96 CFLAGS = $(CFLAGS) /D "NDEBUG" /O2
97 LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
100 # Libxml object files.
101 XML_OBJS = $(XML_INTDIR)\c14n.obj\
102 $(XML_INTDIR)\catalog.obj\
103 $(XML_INTDIR)\chvalid.obj\
104 $(XML_INTDIR)\debugXML.obj\
105 $(XML_INTDIR)\dict.obj\
106 $(XML_INTDIR)\DOCBparser.obj\
107 $(XML_INTDIR)\encoding.obj\
108 $(XML_INTDIR)\entities.obj\
109 $(XML_INTDIR)\error.obj\
110 $(XML_INTDIR)\globals.obj\
111 $(XML_INTDIR)\hash.obj\
112 $(XML_INTDIR)\HTMLparser.obj\
113 $(XML_INTDIR)\HTMLtree.obj\
114 $(XML_INTDIR)\legacy.obj\
115 $(XML_INTDIR)\list.obj\
116 $(XML_INTDIR)\nanoftp.obj\
117 $(XML_INTDIR)\nanohttp.obj\
118 $(XML_INTDIR)\parser.obj\
119 $(XML_INTDIR)\parserInternals.obj\
120 $(XML_INTDIR)\pattern.obj\
121 $(XML_INTDIR)\relaxng.obj\
122 $(XML_INTDIR)\SAX2.obj\
123 $(XML_INTDIR)\SAX.obj\
124 $(XML_INTDIR)\schematron.obj\
125 $(XML_INTDIR)\threads.obj\
126 $(XML_INTDIR)\tree.obj\
127 $(XML_INTDIR)\uri.obj\
128 $(XML_INTDIR)\valid.obj\
129 $(XML_INTDIR)\xinclude.obj\
130 $(XML_INTDIR)\xlink.obj\
131 $(XML_INTDIR)\xmlIO.obj\
132 $(XML_INTDIR)\xmlmemory.obj\
133 $(XML_INTDIR)\xmlreader.obj\
134 $(XML_INTDIR)\xmlregexp.obj\
135 $(XML_INTDIR)\xmlmodule.obj\
136 $(XML_INTDIR)\xmlsave.obj\
137 $(XML_INTDIR)\xmlschemas.obj\
138 $(XML_INTDIR)\xmlschemastypes.obj\
139 $(XML_INTDIR)\xmlunicode.obj\
140 $(XML_INTDIR)\xmlwriter.obj\
141 $(XML_INTDIR)\xpath.obj\
142 $(XML_INTDIR)\xpointer.obj\
143 $(XML_INTDIR)\xmlstring.obj
145 # Static libxml object files.
146 XML_OBJS_A = $(XML_INTDIR_A)\c14n.obj\
147 $(XML_INTDIR_A)\catalog.obj\
148 $(XML_INTDIR_A)\chvalid.obj\
149 $(XML_INTDIR_A)\debugXML.obj\
150 $(XML_INTDIR_A)\dict.obj\
151 $(XML_INTDIR_A)\DOCBparser.obj\
152 $(XML_INTDIR_A)\encoding.obj\
153 $(XML_INTDIR_A)\entities.obj\
154 $(XML_INTDIR_A)\error.obj\
155 $(XML_INTDIR_A)\globals.obj\
156 $(XML_INTDIR_A)\hash.obj\
157 $(XML_INTDIR_A)\HTMLparser.obj\
158 $(XML_INTDIR_A)\HTMLtree.obj\
159 $(XML_INTDIR_A)\legacy.obj\
160 $(XML_INTDIR_A)\list.obj\
161 $(XML_INTDIR_A)\nanoftp.obj\
162 $(XML_INTDIR_A)\nanohttp.obj\
163 $(XML_INTDIR_A)\parser.obj\
164 $(XML_INTDIR_A)\parserInternals.obj\
165 $(XML_INTDIR_A)\pattern.obj\
166 $(XML_INTDIR_A)\relaxng.obj\
167 $(XML_INTDIR_A)\SAX2.obj\
168 $(XML_INTDIR_A)\SAX.obj\
169 $(XML_INTDIR_A)\schematron.obj\
170 $(XML_INTDIR_A)\threads.obj\
171 $(XML_INTDIR_A)\tree.obj\
172 $(XML_INTDIR_A)\uri.obj\
173 $(XML_INTDIR_A)\valid.obj\
174 $(XML_INTDIR_A)\xinclude.obj\
175 $(XML_INTDIR_A)\xlink.obj\
176 $(XML_INTDIR_A)\xmlIO.obj\
177 $(XML_INTDIR_A)\xmlmemory.obj\
178 $(XML_INTDIR_A)\xmlreader.obj\
179 $(XML_INTDIR_A)\xmlregexp.obj\
180 $(XML_INTDIR_A)\xmlmodule.obj\
181 $(XML_INTDIR_A)\xmlsave.obj\
182 $(XML_INTDIR_A)\xmlschemas.obj\
183 $(XML_INTDIR_A)\xmlschemastypes.obj\
184 $(XML_INTDIR_A)\xmlunicode.obj\
185 $(XML_INTDIR_A)\xmlwriter.obj\
186 $(XML_INTDIR_A)\xpath.obj\
187 $(XML_INTDIR_A)\xpointer.obj\
188 $(XML_INTDIR_A)\xmlstring.obj
190 # Static libxml object files.
191 XML_OBJS_A_DLL = $(XML_INTDIR_A_DLL)\c14n.obj\
192 $(XML_INTDIR_A_DLL)\catalog.obj\
193 $(XML_INTDIR_A_DLL)\chvalid.obj\
194 $(XML_INTDIR_A_DLL)\debugXML.obj\
195 $(XML_INTDIR_A_DLL)\dict.obj\
196 $(XML_INTDIR_A_DLL)\DOCBparser.obj\
197 $(XML_INTDIR_A_DLL)\encoding.obj\
198 $(XML_INTDIR_A_DLL)\entities.obj\
199 $(XML_INTDIR_A_DLL)\error.obj\
200 $(XML_INTDIR_A_DLL)\globals.obj\
201 $(XML_INTDIR_A_DLL)\hash.obj\
202 $(XML_INTDIR_A_DLL)\HTMLparser.obj\
203 $(XML_INTDIR_A_DLL)\HTMLtree.obj\
204 $(XML_INTDIR_A_DLL)\legacy.obj\
205 $(XML_INTDIR_A_DLL)\list.obj\
206 $(XML_INTDIR_A_DLL)\nanoftp.obj\
207 $(XML_INTDIR_A_DLL)\nanohttp.obj\
208 $(XML_INTDIR_A_DLL)\parser.obj\
209 $(XML_INTDIR_A_DLL)\parserInternals.obj\
210 $(XML_INTDIR_A_DLL)\pattern.obj\
211 $(XML_INTDIR_A_DLL)\relaxng.obj\
212 $(XML_INTDIR_A_DLL)\SAX2.obj\
213 $(XML_INTDIR_A_DLL)\SAX.obj\
214 $(XML_INTDIR_A_DLL)\schematron.obj\
215 $(XML_INTDIR_A_DLL)\threads.obj\
216 $(XML_INTDIR_A_DLL)\tree.obj\
217 $(XML_INTDIR_A_DLL)\uri.obj\
218 $(XML_INTDIR_A_DLL)\valid.obj\
219 $(XML_INTDIR_A_DLL)\xinclude.obj\
220 $(XML_INTDIR_A_DLL)\xlink.obj\
221 $(XML_INTDIR_A_DLL)\xmlIO.obj\
222 $(XML_INTDIR_A_DLL)\xmlmemory.obj\
223 $(XML_INTDIR_A_DLL)\xmlreader.obj\
224 $(XML_INTDIR_A_DLL)\xmlregexp.obj\
225 $(XML_INTDIR_A_DLL)\xmlmodule.obj\
226 $(XML_INTDIR_A_DLL)\xmlsave.obj\
227 $(XML_INTDIR_A_DLL)\xmlschemas.obj\
228 $(XML_INTDIR_A_DLL)\xmlschemastypes.obj\
229 $(XML_INTDIR_A_DLL)\xmlunicode.obj\
230 $(XML_INTDIR_A_DLL)\xmlwriter.obj\
231 $(XML_INTDIR_A_DLL)\xpath.obj\
232 $(XML_INTDIR_A_DLL)\xpointer.obj\
233 $(XML_INTDIR_A_DLL)\xmlstring.obj
235 # Xmllint and friends executables.
236 UTILS = $(BINDIR)\xmllint.exe\
237 $(BINDIR)\xmlcatalog.exe\
238 $(BINDIR)\testAutomata.exe\
239 $(BINDIR)\testC14N.exe\
240 $(BINDIR)\testDocbook.exe\
241 $(BINDIR)\testHTML.exe\
242 $(BINDIR)\testReader.exe\
243 $(BINDIR)\testRelax.exe\
244 $(BINDIR)\testRegexp.exe\
245 $(BINDIR)\testModule.exe\
246 $(BINDIR)\testSAX.exe\
247 $(BINDIR)\testSchemas.exe\
248 $(BINDIR)\testURI.exe\
249 $(BINDIR)\testXPath.exe\
250 $(BINDIR)\runtest.exe\
251 $(BINDIR)\runsuite.exe\
252 $(BINDIR)\testapi.exe
254 !if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls" || "$(WITH_THREADS)" == "native"
255 UTILS = $(UTILS) $(BINDIR)\testThreadsWin32.exe
256 !else if "$(WITH_THREADS)" == "posix"
257 UTILS = $(UTILS) $(BINDIR)\testThreads.exe
260 !if "$(VCMANIFEST)" == "1"
261 _VC_MANIFEST_EMBED_EXE= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
262 _VC_MANIFEST_EMBED_DLL= if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
264 _VC_MANIFEST_EMBED_EXE=
265 _VC_MANIFEST_EMBED_DLL=
268 all : libxml libxmla libxmladll utils
270 libxml : $(BINDIR)\$(XML_SO)
272 libxmla : $(BINDIR)\$(XML_A)
274 libxmladll : $(BINDIR)\$(XML_A_DLL)
279 if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
280 if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
281 if exist $(XML_INTDIR_A_DLL) rmdir /S /Q $(XML_INTDIR_A_DLL)
282 if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
283 if exist $(BINDIR) rmdir /S /Q $(BINDIR)
286 if exist config.* del config.*
287 if exist Makefile del Makefile
292 if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
293 if not exist $(BINPREFIX) mkdir $(BINPREFIX)
294 if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
295 if not exist $(SOPREFIX) mkdir $(SOPREFIX)
296 copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
297 copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
298 copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
299 copy $(BINDIR)\$(XML_A_DLL) $(LIBPREFIX)
300 copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
302 install : install-libs
303 copy $(BINDIR)\*.exe $(BINPREFIX)
304 -copy $(BINDIR)\*.pdb $(BINPREFIX)
306 install-dist : install-libs
307 copy $(BINDIR)\xml*.exe $(BINPREFIX)
308 -copy $(BINDIR)\xml*.pdb $(BINPREFIX)
310 # This is a target for me, to make a binary distribution. Not for the public use,
311 # keep your hands off :-)
312 BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
313 BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
315 $(MAKE) /nologo PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)\bin install-dist
316 cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
319 # Makes the output directory.
321 if not exist $(BINDIR) mkdir $(BINDIR)
324 # Makes the libxml intermediate directory.
326 if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
328 # Makes the static libxml intermediate directory.
330 if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
332 # Makes the static for dll libxml intermediate directory.
333 $(XML_INTDIR_A_DLL) :
334 if not exist $(XML_INTDIR_A_DLL) mkdir $(XML_INTDIR_A_DLL)
336 # An implicit rule for libxml compilation.
337 {$(XML_SRCDIR)}.c{$(XML_INTDIR)}.obj::
338 $(CC) $(CFLAGS) /Fo$(XML_INTDIR)\ /c $<
340 # An implicit rule for static libxml compilation.
341 {$(XML_SRCDIR)}.c{$(XML_INTDIR_A)}.obj::
342 $(CC) $(CFLAGS) /D "LIBXML_STATIC" /Fo$(XML_INTDIR_A)\ /c $<
344 # An implicit rule for static for dll libxml compilation.
345 {$(XML_SRCDIR)}.c{$(XML_INTDIR_A_DLL)}.obj::
346 $(CC) $(CFLAGS) /D "LIBXML_STATIC" /D "LIBXML_STATIC_FOR_DLL" /Fo$(XML_INTDIR_A_DLL)\ /c $<
348 # Compiles libxml source. Uses the implicit rule for commands.
349 $(XML_OBJS) : $(XML_INTDIR)
351 # Compiles static libxml source. Uses the implicit rule for commands.
352 $(XML_OBJS_A) : $(XML_INTDIR_A)
354 # Compiles static for dll libxml source. Uses the implicit rule for commands.
355 $(XML_OBJS_A_DLL) : $(XML_INTDIR_A_DLL)
357 # Creates the export definition file (DEF) for libxml.
358 $(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR) $(XML_DEF).src
359 $(CPP) $(CPPFLAGS) $(XML_DEF).src > $(XML_INTDIR)\$(XML_DEF)
361 # Creates the libxml shared object.
362 $(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF)
363 $(LD) $(LDFLAGS) /DLL \
364 /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(LIBS)
365 @$(_VC_MANIFEST_EMBED_DLL)
367 #$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS) $(XML_INTDIR)\$(XML_DEF)
368 # $(LD) $(LDFLAGS) /DLL /DEF:$(XML_INTDIR)\$(XML_DEF) \
369 # /IMPLIB:$(BINDIR)\$(XML_IMP) /OUT:$(BINDIR)\$(XML_SO) $(XML_OBJS) $(LIBS)
371 # Creates the libxml archive.
372 $(BINDIR)\$(XML_A) : $(BINDIR) $(XML_OBJS_A)
373 $(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XML_A) $(XML_OBJS_A)
375 # Creates the libxml static for dll archive.
376 $(BINDIR)\$(XML_A_DLL) : $(BINDIR) $(XML_OBJS_A_DLL)
377 $(AR) $(ARFLAGS) /OUT:$(BINDIR)\$(XML_A_DLL) $(XML_OBJS_A_DLL)
379 # Makes the utils intermediate directory.
381 if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
383 # An implicit rule for xmllint and friends.
384 !if "$(STATIC)" == "1"
385 {$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
386 $(CC) /D "LIBXML_STATIC" $(CFLAGS) /Fo$(UTILS_INTDIR)\ /c $<
387 $(LD) $(LDFLAGS) /OUT:$@ $(XML_A) $(LIBS) $(UTILS_INTDIR)\$(<B).obj
388 @$(_VC_MANIFEST_EMBED_EXE)
390 {$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
391 $(CC) $(CFLAGS) /Fo$(UTILS_INTDIR)\ /c $<
392 $(LD) $(LDFLAGS) /OUT:$@ $(XML_IMP) $(LIBS) $(UTILS_INTDIR)\$(<B).obj
393 @$(_VC_MANIFEST_EMBED_EXE)
396 # Builds xmllint and friends. Uses the implicit rule for commands.
397 $(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla libxmladll
399 # Source dependences should be autogenerated somehow here, but how to
400 # do it? I have no clue.
406 XPathtests : $(BINDIR)\testXPath.exe
408 @echo ## XPath regression tests
409 @-$(BINDIR)\testXPath.exe | find /C "support not compiled in" 1>nul
410 @if %ERRORLEVEL% NEQ 0 @( \
411 echo Skipping debug not compiled in\
414 @for %%I in ($(XML_SRCDIR)\test\XPath\expr\*.*) do @( \
415 @IF NOT EXIST $(XML_SRCDIR)\result\XPath\expr\%%~nxI ( \
416 @echo New test %%~nxI &&\
418 $(BINDIR)\testXPath.exe -f --expr %%I > $(XML_SRCDIR)/result/XPath/expr/%%~nxI &&\
419 findstr /C:"MEMORY ALLOCATED : 0" \
421 $(BINDIR)\testXPath.exe -f --expr %%I 2>&1 > result.%%~nxI &&\
422 fc $(XML_SRCDIR)\result\XPath\expr\%%~nxI result.%%~nxI >nul &\
423 iF ERRORLEVEL 1 exit 1 & \
424 findstr "MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" >nul &&\
428 @for %%I in ($(XML_SRCDIR)\test\XPath\docs\*.*) do @( \
429 for %%J in ($(XML_SRCDIR)\test\XPath\tests\%%~nxI*.*) do @( \
430 if not exist $(XML_SRCDIR)\result\XPath\tests\%%~nxJ ( \
431 $(BINDIR)\testXPath.exe -f -i %%I %%J > $(XML_SRCDIR)\result\XPath\tests\%%~nxJ &&\
432 findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > nul \
434 $(BINDIR)\testXPAth.exe -f -i %%I %%J 2>&1 > result.%%~nxJ &&\
435 findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0">null &&\
436 fc $(XML_SRCDIR)\result\XPath\tests\%%~nxJ result.%%~nxJ >null & \
437 IF ERRORLEVEL 1 (echo Error: %%I %%J & exit 1) & \
443 XMLtests : $(BINDIR)\xmllint.exe
445 @echo ## XML regression tests
446 -@for %%I in ($(XML_SRCDIR)\test\*) do @( \
447 if not exist $(XML_SRCDIR)\result\%%~nxI ( \
448 echo New test file %%~nxI &\
449 $(BINDIR)\xmllint.exe %%I > $(XML_SRCDIR)\result\%%~nxI && \
450 findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null \
452 $(BINDIR)\xmllint.exe %%I 2>&1 > result.%%~nxI && \
453 findstr /C:"MEMORY ALLOC" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null && \
454 fc $(XML_SRCDIR)\result\%%~nxI result.%%~nxI > null && \
455 $(BINDIR)\xmllint.exe result.%%~nxI 2>&1 > result2.%%~nxI | findstr /V /C:"failed to load external entity" && \
456 fc result.%%~nxI result2.%%~nxI & \
457 del result.%%~nxI result2.%%~nxI\