Merge branch 'tizen_base' into tizen
[platform/upstream/libxml2.git] / win32 / Makefile.mingw
1 # Makefile for libxml2, specific for Windows, GCC (mingw) and GNU make.
2 #
3 # Take a look at the beginning and modify the variables to suit your 
4 # environment. Having done that, you can do a
5 #
6 # nmake [all]     to build the libxml and the accompanying utilities.
7 # nmake clean     to remove all compiler output files and return to a
8 #                 clean state.
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.
12 #
13 # November 2002, Igor Zlatkovic <igor@zlatkovic.com>
14
15 # There should never be a need to modify anything below this line.
16 # ----------------------------------------------------------------
17
18 AUTOCONF = .\config.mingw
19 include $(AUTOCONF)
20
21 # Names of various input and output components.
22 XML_NAME = xml2
23 XML_BASENAME = lib$(XML_NAME)
24 XML_SO = $(XML_BASENAME).dll
25 XML_IMP = $(XML_BASENAME).lib
26 XML_A = $(XML_BASENAME).a
27
28 # Place where we let the compiler put its output.
29 BINDIR = bin.mingw
30 XML_INTDIR = int.mingw
31 XML_INTDIR_A = int.a.mingw
32 UTILS_INTDIR = int.utils.mingw
33
34 # The preprocessor and its options.
35 CPP = gcc.exe -E
36 CPPFLAGS += -I$(XML_SRCDIR)/include -DNOLIBTOOL 
37 ifeq ($(WITH_THREADS),1)
38 CPPFLAGS += -D_REENTRANT
39 endif
40
41 # The compiler and its options.
42 CC = gcc.exe
43 CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS -DNOLIBTOOL 
44 CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX) $(INCLUDE)
45 ifneq ($(WITH_THREADS),no)
46 CFLAGS += -D_REENTRANT
47 endif
48 ifeq ($(WITH_THREADS),yes) 
49 CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
50 endif
51 ifeq ($(WITH_THREADS),ctls)
52 CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
53 endif
54 ifeq ($(WITH_THREADS),native)
55 CFLAGS += -DHAVE_WIN32_THREADS
56 endif
57 ifeq ($(WITH_THREADS),posix)
58 CFLAGS += -DHAVE_PTHREAD_H
59 endif
60 ifeq ($(WITH_ZLIB),1)
61 CFLAGS += -DHAVE_ZLIB_H
62 endif
63 ifeq ($(WITH_LZMA),1)
64 CFLAGS += -DHAVE_LZMA_H
65 endif
66
67 # The linker and its options.
68 LD = gcc.exe
69 LDFLAGS += -Wl,--major-image-version,$(LIBXML_MAJOR_VERSION)
70 LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION)
71 LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX)
72 LIBS =
73 ifeq ($(WITH_FTP),1)
74 LIBS += -lwsock32 -lws2_32
75 endif 
76 ifeq ($(WITH_HTTP),1)
77 LIBS += -lwsock32 -lws2_32
78 endif 
79 ifeq ($(WITH_ICONV),1)
80 LIBS += -liconv
81 endif 
82 ifeq ($(WITH_ZLIB),1)
83 # Could be named differently
84 # LIBS += -lzdll
85 LIBS += -lz
86 endif
87 ifeq ($(WITH_LZMA),1)
88 LIBS += -llzma
89 endif
90 ifeq ($(WITH_THREADS),posix)
91 LIBS += -lpthreadGC
92 endif
93 ifeq ($(WITH_MODULES),1)
94 LIBS += -lkernel32
95 endif
96
97 LIBS += $(LIB)
98
99 # The archiver and its options.
100 AR = ar.exe
101 ARFLAGS = -r
102
103 # Optimisation and debug symbols.
104 ifeq ($(DEBUG),1)
105 CFLAGS += -D_DEBUG -g
106 LDFLAGS += 
107 else
108 CFLAGS += -DNDEBUG -O2 
109 LDFLAGS += 
110 endif
111
112
113 # Libxml object files.
114 XML_OBJS = $(XML_INTDIR)/buf.o\
115         $(XML_INTDIR)/c14n.o\
116         $(XML_INTDIR)/catalog.o\
117         $(XML_INTDIR)/chvalid.o\
118         $(XML_INTDIR)/debugXML.o\
119         $(XML_INTDIR)/dict.o\
120         $(XML_INTDIR)/DOCBparser.o\
121         $(XML_INTDIR)/encoding.o\
122         $(XML_INTDIR)/entities.o\
123         $(XML_INTDIR)/error.o\
124         $(XML_INTDIR)/globals.o\
125         $(XML_INTDIR)/hash.o\
126         $(XML_INTDIR)/HTMLparser.o\
127         $(XML_INTDIR)/HTMLtree.o\
128         $(XML_INTDIR)/legacy.o\
129         $(XML_INTDIR)/list.o\
130         $(XML_INTDIR)/nanoftp.o\
131         $(XML_INTDIR)/nanohttp.o\
132         $(XML_INTDIR)/parser.o\
133         $(XML_INTDIR)/parserInternals.o\
134         $(XML_INTDIR)/pattern.o\
135         $(XML_INTDIR)/relaxng.o\
136         $(XML_INTDIR)/SAX.o\
137         $(XML_INTDIR)/SAX2.o\
138         $(XML_INTDIR)/schematron.o\
139         $(XML_INTDIR)/threads.o\
140         $(XML_INTDIR)/tree.o\
141         $(XML_INTDIR)/uri.o\
142         $(XML_INTDIR)/valid.o\
143         $(XML_INTDIR)/xinclude.o\
144         $(XML_INTDIR)/xlink.o\
145         $(XML_INTDIR)/xmlIO.o\
146         $(XML_INTDIR)/xmlmemory.o\
147         $(XML_INTDIR)/xmlreader.o\
148         $(XML_INTDIR)/xmlregexp.o\
149         $(XML_INTDIR)/xmlmodule.o\
150         $(XML_INTDIR)/xmlsave.o\
151         $(XML_INTDIR)/xmlschemas.o\
152         $(XML_INTDIR)/xmlschemastypes.o\
153         $(XML_INTDIR)/xmlunicode.o\
154         $(XML_INTDIR)/xmlwriter.o\
155         $(XML_INTDIR)/xpath.o\
156         $(XML_INTDIR)/xpointer.o\
157         $(XML_INTDIR)/xmlstring.o
158
159 XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS)))
160
161 # Static libxml object files.
162 XML_OBJS_A = $(XML_INTDIR_A)/buf.o\
163         $(XML_INTDIR_A)/c14n.o\
164         $(XML_INTDIR_A)/catalog.o\
165         $(XML_INTDIR_A)/chvalid.o\
166         $(XML_INTDIR_A)/debugXML.o\
167         $(XML_INTDIR_A)/dict.o\
168         $(XML_INTDIR_A)/DOCBparser.o\
169         $(XML_INTDIR_A)/encoding.o\
170         $(XML_INTDIR_A)/entities.o\
171         $(XML_INTDIR_A)/error.o\
172         $(XML_INTDIR_A)/globals.o\
173         $(XML_INTDIR_A)/hash.o\
174         $(XML_INTDIR_A)/HTMLparser.o\
175         $(XML_INTDIR_A)/HTMLtree.o\
176         $(XML_INTDIR_A)/legacy.o\
177         $(XML_INTDIR_A)/list.o\
178         $(XML_INTDIR_A)/nanoftp.o\
179         $(XML_INTDIR_A)/nanohttp.o\
180         $(XML_INTDIR_A)/parser.o\
181         $(XML_INTDIR_A)/parserInternals.o\
182         $(XML_INTDIR_A)/pattern.o\
183         $(XML_INTDIR_A)/relaxng.o\
184         $(XML_INTDIR_A)/SAX.o\
185         $(XML_INTDIR_A)/SAX2.o\
186         $(XML_INTDIR_A)/schematron.o\
187         $(XML_INTDIR_A)/threads.o\
188         $(XML_INTDIR_A)/tree.o\
189         $(XML_INTDIR_A)/uri.o\
190         $(XML_INTDIR_A)/valid.o\
191         $(XML_INTDIR_A)/xinclude.o\
192         $(XML_INTDIR_A)/xlink.o\
193         $(XML_INTDIR_A)/xmlIO.o\
194         $(XML_INTDIR_A)/xmlmemory.o\
195         $(XML_INTDIR_A)/xmlreader.o\
196         $(XML_INTDIR_A)/xmlregexp.o\
197         $(XML_INTDIR_A)/xmlmodule.o\
198         $(XML_INTDIR_A)/xmlsave.o\
199         $(XML_INTDIR_A)/xmlschemas.o\
200         $(XML_INTDIR_A)/xmlschemastypes.o\
201         $(XML_INTDIR_A)/xmlunicode.o\
202         $(XML_INTDIR_A)/xmlwriter.o\
203         $(XML_INTDIR_A)/xpath.o\
204         $(XML_INTDIR_A)/xpointer.o\
205         $(XML_INTDIR_A)/xmlstring.o
206
207 XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)))
208
209 # Xmllint and friends executables.
210 UTILS = $(BINDIR)/xmllint.exe\
211         $(BINDIR)/xmlcatalog.exe\
212         $(BINDIR)/testAutomata.exe\
213         $(BINDIR)/testC14N.exe\
214         $(BINDIR)/testDocbook.exe\
215         $(BINDIR)/testHTML.exe\
216         $(BINDIR)/testReader.exe\
217         $(BINDIR)/testRegexp.exe\
218         $(BINDIR)/testModule.exe\
219         $(BINDIR)/testRelax.exe\
220         $(BINDIR)/testSAX.exe\
221         $(BINDIR)/testSchemas.exe\
222         $(BINDIR)/testURI.exe\
223         $(BINDIR)/testXPath.exe\
224         $(BINDIR)/runtest.exe\
225         $(BINDIR)/runsuite.exe\
226         $(BINDIR)/testapi.exe\
227         $(BINDIR)/testlimits.exe
228
229 ifeq ($(WITH_THREADS),yes)
230 UTILS += $(BINDIR)/testThreadsWin32.exe
231 endif
232 ifeq ($(WITH_THREADS),ctls) 
233 UTILS += $(BINDIR)/testThreadsWin32.exe
234 endif
235 ifeq ($(WITH_THREADS),native)
236 UTILS += $(BINDIR)/testThreadsWin32.exe
237 endif
238 ifeq ($(WITH_THREADS),posix)
239 UTILS += $(BINDIR)/testThreads.exe
240 endif
241
242 all : dep libxml libxmla utils
243
244 libxml : $(BINDIR)/$(XML_SO) 
245
246 libxmla : $(BINDIR)/$(XML_A)
247
248 utils : $(UTILS)
249
250 clean :
251         cmd.exe /C "if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)"
252         cmd.exe /C "if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)"
253         cmd.exe /C "if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)"
254         cmd.exe /C "if exist $(BINDIR) rmdir /S /Q $(BINDIR)"
255         cmd.exe /C "if exist depends.mingw del depends.mingw"
256
257 distclean : clean
258         cmd.exe /C "if exist config.* del config.*"
259         cmd.exe /C "if exist Makefile del Makefile"
260
261 rebuild : clean all
262
263 install-libs : all
264         cmd.exe /C "if not exist $(INCPREFIX)\libxml2 mkdir $(INCPREFIX)\libxml2"
265         cmd.exe /C "if not exist $(INCPREFIX)\libxml2\libxml mkdir $(INCPREFIX)\libxml2\libxml"
266         cmd.exe /C "if not exist $(BINPREFIX) mkdir $(BINPREFIX)"
267         cmd.exe /C "if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)"
268         cmd.exe /C "copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml2\libxml"
269         cmd.exe /C "copy $(BINDIR)\$(XML_SO) $(SOPREFIX)"
270         cmd.exe /C "copy $(BINDIR)\$(XML_A) $(LIBPREFIX)"
271         cmd.exe /C "copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)"
272         cmd.exe /C "copy $(BINDIR)\xml*.exe $(BINPREFIX)"
273
274 install : install-libs
275         cmd.exe /C "copy $(BINDIR)\*.exe $(BINPREFIX)"
276
277 install-dist : install-libs
278         cmd.exe /C "copy $(BINDIR)\xml*.exe $(BINPREFIX)"
279
280 # This is a target for me, to make a binary distribution. Not for the public use,
281 # keep your hands off :-)
282 BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
283 BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
284 bindist : all
285         $(MAKE) PREFIX=$(BDPREFIX) SOPREFIX=$(BDPREFIX)/bin install-dist
286         cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
287
288
289 # Creates the dependency file
290 dep :
291         $(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw
292
293
294 # Makes the output directory.
295 $(BINDIR) :
296         cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR)
297
298
299 # Makes the libxml intermediate directory.
300 $(XML_INTDIR) :
301         cmd.exe /C if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
302
303 # Makes the static libxml intermediate directory.
304 $(XML_INTDIR_A) :
305         cmd.exe /C if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
306
307 # An implicit rule for libxml compilation.
308 $(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c
309         $(CC) $(CFLAGS) -o $@ -c $<
310
311 # An implicit rule for static libxml compilation.
312 $(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c
313         $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $<
314
315
316 # Compiles libxml source. Uses the implicit rule for commands.
317 $(XML_OBJS) : $(XML_INTDIR)
318
319 # Compiles static libxml source. Uses the implicit rule for commands.
320 $(XML_OBJS_A) : $(XML_INTDIR_A) 
321
322 # Creates the libxml shared object.
323 XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP)
324 $(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS)
325         $(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS)
326
327 # Creates the libxml archive.
328 $(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A)
329         $(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A)
330
331
332 # Makes the utils intermediate directory.
333 $(UTILS_INTDIR) :
334         cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
335
336 # An implicit rule for xmllint and friends.
337 ifeq ($(STATIC),1)
338 $(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
339         $(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
340         $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS) 
341 else
342 $(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
343         $(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $< 
344         $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS) 
345 endif
346
347 # Builds xmllint and friends. Uses the implicit rule for commands.
348 $(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
349
350 # Source dependencies
351 #-include depends.mingw
352