1 Instructions to build Bacula using the MinGW32 on Linux
2 =======================================================
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.
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.
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.
21 If you're reading this file you've probably already enlisted in the SVN tree or
22 extracted the contents of the source tar. If not you need to do that first.
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 ...
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).
32 Once the source is on your system, change to the win32 directory
33 cd .../bacula/src/win32
35 Download and build the cross compiler tools
36 ./build-win32-cross-tools
38 Download and build the 3rd party dependencies
39 ./build-depkgs-mingw32
41 Note, that during the build process you will see a moderate amount of
42 output. If something fails, it is probably because you don't have one
43 of the build dependencies (hopefully all mentioned above) loaded on your
44 system. To find out what is going wrong, do the following:
46 cd .../depkgs-mingw32/src/<package-name>
48 where <package-name> is where the package is unpacked and built. Normally
49 it is relatively obvious when looking at the src directory.
51 In that directory, you should find a make.log, which has the full details
52 of the compiles, links, and installs done for that package.
55 You need the header files from the Microsoft VSS SDK. Unfortunately the SDK
56 can only be downloaded and installed on a Windows system. You can find it on
57 Microsoft's web-site at:
59 http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
61 If that link doesn't work then go to http://www.microsoft.com and search for
63 "download volume shadow copy service sdk"
65 we are currently using version 7.2 released 8/3/2005.
67 Normally the files will be installed in:
69 c:\Program Files\Microsoft\VSSSDK72
71 You only need to copy everything under the c:\Program Files\Microsoft\VSSSDK72\inc
72 directory into .../depkgs-mingw32/vss/inc. In doing so, please ensure that
73 the case in maintained on the directory and filenames -- some contain uppercase
76 The above only needs to be done once unless we change the cross-tools
77 or the dependencies versions. In general, you can run the script multiple
78 times with no problem. For it to work, you must have at a minimum the
87 and possibly other packages.
93 Finally, to build the Microsoft Windows version of Bacula, do the following:
95 cd .../bacula/src/win32
98 If all goes well, you will end with all the executables in the
99 .../bacula/src/win32/release directory.
101 If you have an older build environment, you might do the following
102 to ensure that you pick up all the new Win32 changes:
110 The installer is now built as part of the default rule when you
111 say "make" in the src/win32 directory.
114 Updating the 3rd party package patches
115 ======================================
117 If one of the patches changes in .../bacula/src/win32/patches, you will
118 need to update the corresponding dependency. You can install new patches
119 by doing the following (we assume the patch in question is for openssl).
121 cd .../bacula/src/win32
122 ./build-depkgs-mingw32 -C openssl
124 NOTE: The -C means clobber. Any local changes to the source code in
125 the .../depkgs-mingw32/src directory will be lost. The source
126 will be reextracted from the archive and the current patches
130 Adding a new global function or global data
131 ===========================================
136 The code from the following directories is built into bacula.dll:
139 .../bacula/src/libfind
140 .../bacula/src/win32/compat
142 A new function or data variable which must be accessed from outside
143 of bacula.dll requires special treatment. It must be specifically
146 New data variables are exported by adding the macro DLL_IMP_EXP to
147 the variable declaration in the header file. All exported variables
148 must be declared in a header file and MUST NOT be declared in a
149 source file referencing the variable.
151 Exporting functions is now more or less automated. If you find that
152 a function name has been added, changed, or an argument modified,
153 simply do the following:
155 cd .../bacula/src/win32/dll
156 make (to build the .o files, note the link will fail)
157 ./make_def >bacula.def
159 This should rebuild the bacula.def file.
161 ===== manual changing of bacula.def no longer necessary =====
162 If you want to do it manually, please see below:
163 Exporting a function requires a bit more work. You must determine the
164 C++ mangled name of the new function.
166 strings .../bacula/src/win32/dll/<file>.o | grep <symbol>
168 Note, strings often will not show the desired symbol. In that case,
171 nm .../bacula/src/win32/dll/<file>.o
173 Replace <file> with the base part of the name of the source code file
174 which contains the new function. Replace <symbol> with the name of
175 the new function. Remove the leading underscore and place the result
178 .../bacula/src/win32/dll/bacula.def
179 === end manual changing of bacula.def ==========
181 If you add a new file, you will need to specify its name in
183 .../bacula/src/win32/dll/Makefile
185 .../bacula/src/win32/libbac/Makefile
190 The code from the .../bacula/src/cats directory is built into database
191 provider specific libraries of the form cats_<db>.dll.
193 The database specific portion <db> is mysql for MySQL, pgsql for
194 PostgreSQL, sqlite for SQLite, and bdb for the built-in Bacula database.
196 During installation of the Director, one of the database libraries is
197 copied to the system and renamed bacula_cats.dll.
199 A new function or data variable which must be accessed from outside
200 of bacula_cats.dll requires special treatment. It must be specifically
203 New data variables are exported by placing their name in the file
204 .../bacula/src/win32/cats/bacula_cats.def.
206 As with the bacula.def file above, this is now more or less automated.
207 When the link dies, simply do the following:
209 cd .../bacula/src/win32/cats
210 make (to build the .o files, note the link will fail)
211 ./make_def >bacula_cats.def
213 This should rebuild the bacula_cats.def file. Note, if you have
214 changed any data entry points, you will need to modify the make_def
215 script -- it should be rather obvious.
218 ===== manual changing of bacula_cats.def no longer necessary =====
219 Exporting a function requires a bit more work. You must determine the
220 C++ mangled name of the new function.
222 strings .../bacula/src/win32/cats/cats_*/<file>.o | grep <symbol>
224 Note, strings often will not show the desired symbol. In that case,
227 nm .../bacula/src/win32/dll/<file>.o
229 Replace <file> with the base part of the name of the source code file
230 which contains the new function. Replace <symbol> with the name of
231 the new function. Remove the leading underscore and place the result
232 in the .../bacula/src/win32/cats/bacula_cats.def file.
233 === end manual changing of bacula_cats.def ==========
236 Structure of the MinGW32 build environment
237 ==========================================
239 The basic strategy is each Makefile in the various subdirectories includes
240 Makefile.inc, defines variables and rules specific to what is being built,
241 then includes Makefile.rules which defines all the rules.
243 Makefile.inc defines the locations of all the dependencies and the compiler
244 and linker flags. It is automatically created from Makefile.inc.in. Any
245 changes must be made to Makefile.inc.in not Makefile.inc or they will be
246 overwritten the next time Makefile.inc.in is updated.
248 Makefile.rules defines a bunch of macros to simplify building. It also
249 includes all the basic rules for building objects, GUI and console
252 Makefile.template is a template for creating new Makefiles, if you are
253 creating a new directory, copy Makefile.template to Makefile in that
254 directory and edit to suit.