Added support for Borland C++

This commit is contained in:
Igor Zlatkovic 2003-08-28 12:34:00 +00:00
parent 19b8764833
commit 9e0acaa03f
2 changed files with 466 additions and 50 deletions

335
win32/Makefile.bcb Normal file
View File

@ -0,0 +1,335 @@
# Makefile for libxml2, specific for Windows, BCB6 and Borland make.
#
# Take a look at the beginning and modify the variables to suit your
# environment. Having done that, you can do a
#
# make [all] to build the libxml and the accompanying utilities.
# make clean to remove all compiler output files and return to a
# clean state.
# make rebuild to rebuild everything from scratch. This basically does
# a 'nmake clean' and then a 'nmake all'.
# make install to install the library and its header files.
#
# June 2003, Eric Zurcher <Eric.Zurcher@csiro.au>
# based on the MSVC version of
# March 2002, Igor Zlatkovic <igor@zlatkovic.com>
AUTOCONF = .\config.bcb
# If you cannot run the configuration script, which would take the burden of
# editing this file from your back, then remove the following line...
!include $(AUTOCONF)
# ...and enable the following lines and adapt them to your environment.
#XML_SRCDIR = ..
#UTILS_SRCDIR = ..
#BINDIR = binaries
#LIBXML_MAJOR_VERSION = 0 # set this to the right value.
#LIBXML_MINOR_VERSION = 0 # set this to the right value.
#LIBXML_MICRO_VERSION = 0 # set this to the right value.
#WITH_TRIO = 0
#WITH_THREADS = 0
#WITH_FTP = 1
#WITH_HTTP = 1
#WITH_HTML = 1
#WITH_C14N = 1
#WITH_CATALOG = 1
#WITH_DOCB = 1
#WITH_XPATH = 1
#WITH_XPTR = 1
#WITH_XINCLUDE = 1
#WITH_ICONV = 1
#WITH_ZLIB = 0
#WITH_DEBUG = 1
#WITH_MEM_DEBUG = 0
#WITH_SCHEMAS = 1
#DEBUG = 0
#STATIC = 0
#PREFIX = . # set this to the right value.
#BINPREFIX = $(PREFIX)\bin
#INCPREFIX = $(PREFIX)\include
#LIBPREFIX = $(PREFIX)\lib
#SOPREFIX = $(PREFIX)\lib
#INCLUDE = $(INCLUDE);$(INCPREFIX)
#LIB = $(LIB);$(LIBPREFIX)
# There should never be a need to modify anything below this line.
# ----------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# Names of various input and output components.
XML_NAME = xml2
XML_BASENAME = Lib$(XML_NAME)
XML_SO = $(XML_BASENAME).dll
XML_IMP = $(XML_BASENAME).lib
XML_DEF = $(XML_BASENAME).def
XML_A = $(XML_BASENAME)_a.lib
# Place where we let the compiler put its intermediate trash.
XML_INTDIR = $(XML_BASENAME).int
XML_INTDIR_A = $(XML_BASENAME)_a.int
UTILS_INTDIR = utils.int
# The preprocessor and its options.
CPP = cpp32.exe -P- -DWIN32
CPPFLAGS = -I$(XML_SRCDIR)\include
!if "$(WITH_THREADS)" != "no"
CPPFLAGS = $(CPPFLAGS) -D_REENTRANT -D__MT__
!endif
# The compiler and its options.
CC = bcc32.exe
CFLAGS = -q -DWIN32 -D_NO_VCL -D_WINDOWS -D_MBCS -DEILSEQ=2 -w-
CFLAGS = $(CFLAGS) -I$(XML_SRCDIR) -I$(XML_SRCDIR)\include -I$(INCPREFIX) -I$(INCLUDE)
!if "$(WITH_THREADS)" != "no"
CFLAGS = $(CFLAGS) -D_REENTRANT -tWM
!endif
!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls"
CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
!else if "$(WITH_THREADS)" == "native"
CFLAGS = $(CFLAGS) -DHAVE_WIN32_THREADS
!else if "$(WITH_THREADS)" == "posix"
CFLAGS = $(CFLAGS) -DHAVE_PTHREAD_H
!endif
!if "$(WITH_ZLIB)" == "1"
CFLAGS = $(CFLAGS) -DHAVE_ZLIB_H
!endif
# The linker and its options.
LD = ilink32.exe
LDFLAGS = -q -U$(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION)
LDFLAGS = $(LDFLAGS) -L$(BINDIR);$(LIBPREFIX);$(LIB);$(BCB)\lib\PSdk
LIBS = import32.lib
!if "$(WITH_THREADS)" != "no"
LIBS = $(LIBS) cw32mti.lib
!else
LIBS = $(LIBS) cw32i.lib
!endif
!if "$(WITH_FTP)" == "1" || "$(WITH_HTTP)" == "1"
LIBS = $(LIBS) wsock32.lib
!endif
!if "$(WITH_ICONV)" == "1"
LIBS = $(LIBS) iconv-omf.lib
!endif
!if "$(WITH_ZLIB)" == "1"
LIBS = $(LIBS) zlib-omf.lib
!endif
!if "$(WITH_THREADS)" == "posix"
LIBS = $(LIBS) pthreadVC.lib
!endif
# The archiver and its options.
AR = tlib.exe
ARFLAGS = /P64 /0
# Optimisation and debug symbols.
!if "$(DEBUG)" == "1"
CFLAGS = $(CFLAGS) -D_DEBUG -Od -v
LDFLAGS = $(LDFLAGS) -v
!else
CFLAGS = $(CFLAGS) -DNDEBUG -O2
LDFLAGS = $(LDFLAGS)
!endif
# Libxml object files.
XML_OBJS = $(XML_INTDIR)\c14n.obj\
$(XML_INTDIR)\catalog.obj\
$(XML_INTDIR)\debugXML.obj\
$(XML_INTDIR)\dict.obj\
$(XML_INTDIR)\DOCBparser.obj\
$(XML_INTDIR)\encoding.obj\
$(XML_INTDIR)\entities.obj\
$(XML_INTDIR)\error.obj\
$(XML_INTDIR)\globals.obj\
$(XML_INTDIR)\hash.obj\
$(XML_INTDIR)\HTMLparser.obj\
$(XML_INTDIR)\HTMLtree.obj\
$(XML_INTDIR)\list.obj\
$(XML_INTDIR)\nanoftp.obj\
$(XML_INTDIR)\nanohttp.obj\
$(XML_INTDIR)\parser.obj\
$(XML_INTDIR)\parserInternals.obj\
$(XML_INTDIR)\relaxng.obj\
$(XML_INTDIR)\SAX.obj\
$(XML_INTDIR)\SAX2.obj\
$(XML_INTDIR)\threads.obj\
$(XML_INTDIR)\tree.obj\
$(XML_INTDIR)\uri.obj\
$(XML_INTDIR)\valid.obj\
$(XML_INTDIR)\xinclude.obj\
$(XML_INTDIR)\xlink.obj\
$(XML_INTDIR)\xmlIO.obj\
$(XML_INTDIR)\xmlmemory.obj\
$(XML_INTDIR)\xmlreader.obj\
$(XML_INTDIR)\xmlregexp.obj\
$(XML_INTDIR)\xmlschemas.obj\
$(XML_INTDIR)\xmlschemastypes.obj\
$(XML_INTDIR)\xmlunicode.obj\
$(XML_INTDIR)\xpath.obj\
$(XML_INTDIR)\xpointer.obj
# Static libxml object files.
XML_OBJS_A = $(XML_INTDIR_A)\c14n.obj\
$(XML_INTDIR_A)\catalog.obj\
$(XML_INTDIR_A)\debugXML.obj\
$(XML_INTDIR_A)\dict.obj\
$(XML_INTDIR_A)\DOCBparser.obj\
$(XML_INTDIR_A)\encoding.obj\
$(XML_INTDIR_A)\entities.obj\
$(XML_INTDIR_A)\error.obj\
$(XML_INTDIR_A)\globals.obj\
$(XML_INTDIR_A)\hash.obj\
$(XML_INTDIR_A)\HTMLparser.obj\
$(XML_INTDIR_A)\HTMLtree.obj\
$(XML_INTDIR_A)\list.obj\
$(XML_INTDIR_A)\nanoftp.obj\
$(XML_INTDIR_A)\nanohttp.obj\
$(XML_INTDIR_A)\parser.obj\
$(XML_INTDIR_A)\parserInternals.obj\
$(XML_INTDIR_A)\relaxng.obj\
$(XML_INTDIR_A)\SAX.obj\
$(XML_INTDIR_A)\SAX2.obj\
$(XML_INTDIR_A)\threads.obj\
$(XML_INTDIR_A)\tree.obj\
$(XML_INTDIR_A)\uri.obj\
$(XML_INTDIR_A)\valid.obj\
$(XML_INTDIR_A)\xinclude.obj\
$(XML_INTDIR_A)\xlink.obj\
$(XML_INTDIR_A)\xmlIO.obj\
$(XML_INTDIR_A)\xmlmemory.obj\
$(XML_INTDIR_A)\xmlreader.obj\
$(XML_INTDIR_A)\xmlregexp.obj\
$(XML_INTDIR_A)\xmlschemas.obj\
$(XML_INTDIR_A)\xmlschemastypes.obj\
$(XML_INTDIR_A)\xmlunicode.obj\
$(XML_INTDIR_A)\xpath.obj\
$(XML_INTDIR_A)\xpointer.obj
# Xmllint and friends executables.
UTILS = $(BINDIR)\xmllint.exe\
$(BINDIR)\xmlcatalog.exe\
$(BINDIR)\testAutomata.exe\
$(BINDIR)\testC14N.exe\
$(BINDIR)\testDocbook.exe\
$(BINDIR)\testHTML.exe\
$(BINDIR)\testReader.exe\
$(BINDIR)\testRelax.exe\
$(BINDIR)\testRegexp.exe\
$(BINDIR)\testSAX.exe\
$(BINDIR)\testSchemas.exe\
$(BINDIR)\testURI.exe\
$(BINDIR)\testXPath.exe
!if "$(WITH_THREADS)" == "yes" || "$(WITH_THREADS)" == "ctls" || "$(WITH_THREADS)" == "native"
UTILS = $(UTILS) $(BINDIR)\testThreadsWin32.exe
!else if "$(WITH_THREADS)" == "posix"
UTILS = $(UTILS) $(BINDIR)\testThreads.exe
!endif
all : libxml libxmla utils
libxml : $(BINDIR)\$(XML_SO)
libxmla : $(BINDIR)\$(XML_A)
utils : $(UTILS)
clean :
if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
if exist $(BINDIR) rmdir /S /Q $(BINDIR)
distclean : clean
if exist config.* del config.*
if exist Makefile del Makefile
rebuild : clean all
install : all
if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
if not exist $(BINPREFIX) mkdir $(BINPREFIX)
if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
copy $(BINDIR)\*.exe $(BINPREFIX)
-copy $(BINDIR)\*.pdb $(BINPREFIX)
# This is a target for me, to make a binary distribution. Not for the public use,
# keep your hands off :-)
BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
bindist : all
$(MAKE) /nologo PREFIX=$(BDPREFIX) BINPREFIX=$(BDPREFIX)\util install
cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
# Makes the output directory.
$(BINDIR) :
if not exist $(BINDIR) mkdir $(BINDIR)
# Makes the libxml intermediate directory.
$(XML_INTDIR) :
if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
# Makes the static libxml intermediate directory.
$(XML_INTDIR_A) :
if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
# An implicit rule for libxml compilation.
{$(XML_SRCDIR)}.c{$(XML_INTDIR)}.obj:
$(CC) $(CFLAGS) -n$(XML_INTDIR) -c $<
# An implicit rule for static libxml compilation.
{$(XML_SRCDIR)}.c{$(XML_INTDIR_A)}.obj:
$(CC) $(CFLAGS) -DLIBXML_STATIC -n$(XML_INTDIR_A)\ -c $<
# Compiles libxml source. Uses the implicit rule for commands.
$(XML_OBJS) : $(XML_INTDIR)
# Compiles static libxml source. Uses the implicit rule for commands.
$(XML_OBJS_A) : $(XML_INTDIR_A)
#def4bcb.exe : def4bcb.c
# Creates the export definition file (DEF) for libxml.
$(XML_INTDIR)\$(XML_DEF) : $(XML_INTDIR) $(XML_DEF).src
$(CPP) $(CPPFLAGS) -o $(XML_INTDIR)\$(XML_DEF).tmp $(XML_DEF).src
def4bcb -msnames < $(XML_INTDIR)\$(XML_DEF).tmp > $(XML_INTDIR)\$(XML_DEF)
# Creates the libxml shared object.
$(BINDIR)\$(XML_SO) : $(BINDIR) $(XML_OBJS)
$(LD) $(LDFLAGS) -Tpd -Gi c0d32.obj $(XML_OBJS),$(BINDIR)\$(XML_SO),,$(LIBS),,
# Creates the libxml archive.
$(BINDIR)\$(XML_A) : $(BINDIR) $(XML_OBJS_A)
$(AR) $(BINDIR)\$(XML_A) $(ARFLAGS) /u $(XML_OBJS_A)
# Makes the utils intermediate directory.
$(UTILS_INTDIR) :
if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
# An implicit rule for xmllint and friends.
!if "$(STATIC)" == "1"
{$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
$(CC) -DLIBXML_STATIC -w -D_RTLDLL -tWC $(CFLAGS) -o$(UTILS_INTDIR)\$&.obj -c $<
$(LD) $(LDFLAGS) c0x32.obj $(UTILS_INTDIR)\$&.obj,$@,,$(LIBS) $(XML_A)
!else
{$(UTILS_SRCDIR)}.c{$(BINDIR)}.exe:
$(CC) $(CFLAGS) -D_RTLDLL -tWC -o$(UTILS_INTDIR)\$&.obj -c $<
$(LD) $(LDFLAGS) c0x32.obj $(UTILS_INTDIR)\$&.obj $(XML_IMP),$@,,$(LIBS)
!endif
# Builds xmllint and friends. Uses the implicit rule for commands.
$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
# Source dependences should be autogenerated somehow here, but how to
# do it? I have no clue.

View File

@ -1,19 +1,45 @@
Windows port
------------
============
This directory contains the files required to build this software on the
native Windows platform.
As a rule of thumb, the root of this directory contains files needed
to build the library using the command-line tools, while various
subdirectories contain project files for various IDEs.
native Windows platform. This is not a place to look for help if you are
using a POSIX emulator, such as Cygwin. Check the Unix instructions for
that.
1. Building from the command-line
=================================
This is the easiest, preferred and currently supported method.
CONTENTS
========
1. General
1.1 Building From the Command-Line
1.2 Configuring The Source
1.3 Compiling
1.4 Installing
2. Compiler Specifics
2.1 Microsoft Visual C/C++
2.1 GNU C/C++, Mingw Edition
2.2 Borland C++ Builder
2.2.1 Building with iconv support
2.2.2 Compatability problems with MSVC (and probably CYGWIN)
2.2.3 Other caveats
1. General
==========
1.1 Building From The Command-Line
----------------------------------
This is the easiest, preferred and currently supported method. It can
be that a subdirectory of the directory where this file resides
contains project files for some IDE. If you want to use that, please
refer to the readme file within that subdirectory.
In order to build from the command-line you need to make sure that
your compiler works from the command line. This is not always the
@ -28,14 +54,14 @@ configuration script is written in JScript, a Microsoft's
implementation of the ECMA scripting language. Almost every Windows
machine can execute this through the Windows Scripting Host. If your
system lacks the ability to execute JScript for some reason, you must
perform the configuration manually.
perform the configuration manually and you are on your own with that.
The second step is compiling the source and, optionally, installing it
to the location of your choosing.
1.1 Configuring the source automatically
----------------------------------------
1.2 Configuring The Source
--------------------------
The configuration script accepts numerous options. Some of these
affect features which will be available in the compiled software,
@ -70,35 +96,14 @@ who need this, or if a single one has a very good reason, I will
modify the Makefile to allow spaces in paths.
1.2 (Not) Configuring the source manually
-----------------------------------------
The manual configuration is pretty straightforward, but I would
suggest rather to get a JScript engine and let the configure script do
it for you. This process involves editing the apropriate Makefile to
suit your needs, as well as manually generating certain *.h files from
their *.h.in sources.
If you really have no idea what I am talking about and ask yourself
what in Gods name do I mean with '*.h files and their *.h.in sources',
then you really should do an automatic configuration. Which files must
be generated and what needs to be done with their sources in order to
generate them is something people who have built this software before
allready know. You will not find any explanations for that
here. Please configure the source manually only if you allready know
what you must do. Otherwise, you have the choice of either getting a
precompiled binary distribution, or performing the automatic
configuration.
1.3 Compiling
-------------
1.3 Compiling
-------------
After the configuration stage has been completed, you want to build
the software. You will have to use the make tool which comes with
your compiler. If you, for example, configured the source to build
with Microsoft's MSVC compiler, you would use the NMAKE utility. If
ýou configured it to build with GNU C compiler, mingw edition, you
you configured it to build with GNU C compiler, mingw edition, you
would use the GNU make. Assuming you use MSVC, type
nmake
@ -106,6 +111,10 @@ would use the GNU make. Assuming you use MSVC, type
in the win32 subdirectory. When the building completes, you will find
the executable files in win32\binaries directory.
1.4 Installing
--------------
You can install the software into the directory you specified to the
configure script during the configure stage by typing
@ -114,20 +123,92 @@ configure script during the configure stage by typing
That would be it, enjoy.
2. Building with the IDE
========================
Each supported IDE has its project files placed in a subdirectory of
win32. If you use a particular IDE, you should be able to
instinctively recognise its project files. When you have found your
favourites, load them into the IDE and do whatever you would do with
any other project files. If you are a novice and puzzled about how to
use particular project files with a particular IDE, check for a readme
file in that IDEs subdirectory. I won't discuss any particular IDE
here, because I would like to keep this document as general as
possible, and there is also a chance that support exists for IDEs
which I have never seen.
November 2002, Igor Zlatkovic <igor@zlatkovic.com>
2. Compiler Specifics
=====================
2.1 Microsoft Visual C/C++
--------------------------
If you use the compiler which comes with Visual Studio .NET, note that
it will link to its own C-runtime named msvcr70.dll. This file is not
available on any machine which doesn't have .NET installed.
2.2 GNU C/C++, Mingw edition
----------------------------
When specifying paths to configure.js, please use slashes instead of
backslashes for directory separation. Sometimes Mingw needs this. If
this is the case, then 'make install' won't work correctly and you'll
have to install manually.
2.2 Borland C++ Builder
-----------------------
To compile libxml2 with the BCB6 compiler and associated tools, just follow
the basic instructions found in this file file. Be sure to specify
the "compiler=bcb" option when running the configure script. To compile the
library and test programs, just type
make -fMakefile.bcb
That should be all that's required. But there are a few other things to note:
2.2.1 Building with iconv support
If you configure libxml2 to include iconv support, you will obviously need to
obtain the iconv library and include files. To get them, just follow the links
at http://www.gnu.org/software/libiconv/ - there are pre-compiled Win32
versions available, but note that these where built with MSVC. Hence the
supplied import library is in COFF format rather than OMF format. You can
convert this library by using Borland's COFF2OMF utility, or use IMPLIB to
build a new import library from the DLL. Alternatively, it is possible to
obtain the iconv source, and build the DLL using the Borland compiler.
There is a minor problem with the header files for iconv - they expect a
macro named "EILSEQ" in errno.h, but this is not defined in the Borland
headers, and its absence can cause problems. To circumvent this problem, I
define EILSEQ=2 in Makefile.bcb. The value "2" is the value for ENOFILE (file
not found). This should not have any disastrous side effects beyond possibly
displaying a misleading error message in certain situations.
2.2.2 Compatability problems with MSVC (and probably CYGWIN)
A libxml2 DLL generated by BCB is callable from MSVC programs, but there is a
minor problem with the names of the symbols exported from the library. The
Borland compiler, by default, prepends an underscore character to global
identifiers (functions and global variables) when generating object files.
Hence the function "xmlAddChild" is added to the DLL with the name
"_xmlAddChild". The MSVC compiler does not have this behaviour, and looks for
the unadorned name. I currently circumvent this problem by writing a .def file
which causes BOTH the adorned and unadorned names to be exported from the DLL.
This behaviour may not be supported in the future.
An even worse problem is that of generating an import library for the DLL. The
Borland-generated DLL is in OMF format. MSVC expects libraries in COFF format,
but they don't provide a "OMF2COFF" utility, or even the equivalent of
Borland's IMPLIB utility. But it is possible to create an import lib from the
.def file, using the command:
LIB /DEF:libxml2.def
If you don't have the .def file, it's possible to create one manually. Use
DUMPBIN /EXPORTS /OUT:libxml2.tmp libxml2.dll to get a list of the exported
names, and edit this into .def file format.
A similar problem is likely with Cygwin.
2.2.3 Other caveats
I have tested this only with BCB6, Professional Edition.
Authors: Igor Zlatkovic <igor@zlatkovic.com>
Eric Zurcher <Eric.Zurcher@csiro.au>