]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/README.mingw32
Replace explicit checks for "/" with calls to IsPathSeparator, strchr with first_path...
[bacula/bacula] / bacula / src / win32 / README.mingw32
1 Instructions to build Bacula using the MinGW32 on Linux
2 =======================================================
3
4 This file documents the tools (scripts) we use for building Bacula for
5 Microsoft Windows using the cross-compiler tools on a Linux system.  We
6 use Fedora Core 5 and SuSE so those should definitely work.  But there
7 shouldn't be any issues on other Linux distributions.
8
9 We don't officially support this script, but it is what we use, and it should
10 build on any Linux machine if you carefully follow the instructions and have
11 all the prerequisite programs loaded on your machine.
12
13 It has also been tested on other systems such as FreeBSD and CentOS.  We
14 expect that there may be problems on systems other than Linux where you
15 are pretty much on your own.  However, we will try to provide responses to
16 your questions on the bacula-devel list, but we can't guarantee anything.
17
18 One-time Setup
19 ==============
20
21 If you're reading this file you've probably already enlisted in the CVS tree or
22 extracted the contents of the source tar.  If not you need to do that first.
23
24 You also need to download one of the doc tar balls and extract to your
25 top level Bacula directory.  It is referred to as bacula-top in the
26 diagram located in README.win32.  It will be signified in this file as ...
27
28 The extracted doc directory name will be bacula-docs-version where version
29 is the version number.  The directory must be renamed to docs (ie remove
30 the leading bacula- and the -version portion of the name).
31
32 Once the source is on your system, change to the win32 directory
33         cd .../bacula/src/win32
34
35 Download and build the cross compiler tools
36         ./build-win32-cross-tools
37
38 Download and build the 3rd party dependencies
39         ./build-depkgs-mingw32
40
41 You need the header files from the Microsoft VSS SDK.  Unfortunately the SDK
42 can only be downloaded and installed on a Windows system.  You can find it on
43 Microsoft's web-site at:
44
45 http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
46
47 If that link doesn't work then go to http://www.microsoft.com and search for
48
49         "download volume shadow copy service sdk"
50
51 Normally the files will be installed in:
52
53         c:\Program Files\Microsoft\VSSSDK72
54
55 You only need to copy everything under the c:\Program Files\Microsoft\VSSSDK72\inc
56 directory into .../depkgs-mingw32/vss/inc.
57
58 The above only needs to be done once unless we change the cross-tools
59 or the dependencies versions.  In general, you can run the script multiple
60 times with no problem.  For it to work, you must have at a minimum the
61 following:
62
63         gcc
64         g++
65         wget
66         texinfo
67         bison
68
69 and possibly other packages.
70
71
72 Building
73 ========
74
75 Finally, to build the Microsoft Windows version of Bacula, do the following:
76
77    cd .../bacula/src/win32
78    make
79
80 If all goes well, you will end with all the executables in the
81 .../bacula/src/win32/release directory.
82
83 If you have an older build environment, you might do the following
84 to ensure that you pick up all the new Win32 changes:
85
86    cd .../bacula
87    make clean
88    cvs -q update -d -P
89    cd src/win32
90    make
91
92 The installer is now built as part of the default rule when you
93 say "make" in the src/win32 directory.
94
95
96 Updating the 3rd party package patches
97 ======================================
98
99 If one of the patches changes in .../bacula/src/win32/patches, you will
100 need to update the corresponding dependency.  You can install new patches
101 by doing the following (we assume the patch in question is for openssl).
102
103    cd .../bacula/src/win32
104    ./build-depkgs-mingw32 -C openssl
105
106 NOTE: The -C means clobber.  Any local changes to the source code in
107       the .../depkgs-mingw32/src directory will be lost.  The source
108       will be reextracted from the archive and the current patches
109       will be applied.
110
111
112 Adding a new global function or global data
113 ===========================================
114
115 bacula.dll
116 ----------
117
118 The code from the following directories is built into bacula.dll:
119
120    .../bacula/src/lib
121    .../bacula/src/libfind
122    .../bacula/src/win32/compat
123
124 A new function or data variable which must be accessed from outside
125 of bacula.dll requires special treatment.  It must be specifically
126 exported.
127
128 New data variables are exported by adding the macro DLL_IMP_EXP to
129 the variable declaration in the header file.  All exported variables
130 must be declared in a header file and MUST NOT be declared in a
131 source file referencing the variable.
132
133 Exporting a function requires a bit more work.  You must determine the
134 C++ mangled name of the new function.
135
136    strings .../bacula/src/win32/dll/<file>.o | grep <symbol>
137
138 Replace <file> with the base part of the name of the source code file
139 which contains the new function.  Replace <symbol> with the name of
140 the new function.  Remove the leading underscore and place the result
141 in the .../bacula/src/win32/dll/bacula.def file.
142
143 bacula_cats.dll
144 ---------------
145
146 The code from the .../bacula/src/cats directory is built into database
147 provider specific libraries of the form cats_<db>.dll.
148
149 The database specific portion <db> is mysql for MySQL, pgsql for
150 PostgreSQL, sqlite for SQLite, and bdb for the built-in Bacula database.
151
152 During installation of the Director, one of the database libraries is
153 copied to the system and renamed bacula_cats.dll.
154
155 A new function or data variable which must be accessed from outside
156 of bacula_cats.dll requires special treatment.  It must be specifically
157 exported.
158
159 New data variables are exported by placing their name in the file
160 .../bacula/src/win32/cats/bacula_cats.def.
161
162 Exporting a function requires a bit more work.  You must determine the
163 C++ mangled name of the new function.
164
165    strings .../bacula/src/win32/cats/cats_*/<file>.o | grep <symbol>
166
167 Replace <file> with the base part of the name of the source code file
168 which contains the new function.  Replace <symbol> with the name of
169 the new function.  Remove the leading underscore and place the result
170 in the .../bacula/src/win32/cats/bacula_cats.def file.
171
172
173 Structure of the MinGW32 build environment
174 ==========================================
175
176 The basic strategy is each Makefile in the various subdirectories includes
177 Makefile.inc, defines variables and rules specific to what is being built,
178 then includes Makefile.rules which defines all the rules.
179
180 Makefile.inc defines the locations of all the dependencies and the compiler
181 and linker flags.  It is automatically created from Makefile.inc.in.  Any
182 changes must be made to Makefile.inc.in not Makefile.inc or they will be
183 overwritten the next time Makefile.inc.in is updated.
184
185 Makefile.rules defines a bunch of macros to simplify building.  It also
186 includes all the basic rules for building objects, GUI and console
187 executables, etc.
188
189 Makefile.template is a template for creating new Makefiles, if you are
190 creating a new directory, copy Makefile.template to Makefile in that
191 directory and edit to suit.