Makefile.mingw 9.3 KB

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