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