]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/README.mingw32
Update win32 readme
[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 Directory Structure
19 =====================
20 The new directory structure is:
21
22   bacula-top                 Top level directory -- any name
23     bacula                   Top level Bacula source directory -- any name
24       src
25         win32                Main directory where Windows version is built.
26
27     docs                     Top level Bacula documentation directory
28
29     depkgs-mingw32 (MinGW32) 3rd Party Dependencies for MinGW32 build
30 or
31     depkgs-msvc (MS VC++)    3rd Party Dependencies for Microsoft VC++ build.
32       bin              --
33       include            |
34       lib                |
35       man                |   Created by script
36       nsis               |-- .../bacula/src/win32/build-depkgs-mingw32
37       scons              |
38       share              |
39       src                |
40       ssl              --
41       vss
42         inc                  A copy of the Windows VSS/inc directory
43
44     cross-tools (MinGW32)    Cross compilation tools (gcc, g++, mingw32, ...)
45       binutils-mingw32 --
46       gcc-mingw32        |   Created by script
47       mingw32            |-- .../bacula/src/win32/build-win32-cross-tools
48       mingw-utils        |
49       source           --
50
51
52 One-time Setup
53 ==============
54
55 If you're reading this file you've probably already enlisted in the SVN tree or
56 extracted the contents of the source tar.  If not you need to do that first.
57
58 You also need to download one of the doc tar balls and extract to your
59 top level Bacula directory.  It is referred to as bacula-top in the
60 diagram located in README.win32.  It will be signified in this file as ...
61
62 The extracted doc directory name will be bacula-docs-version where version
63 is the version number.  The directory must be renamed to docs (ie remove
64 the leading bacula- and the -version portion of the name).
65
66 Note, a number of packages must be installed to build the cross-tools
67 and the depkgs files.  Most are rather standard such as gcc, g++,
68 make, ...  However a few that you may not have are:
69
70   texinfo
71   flex
72   bison
73   patch (Debian)
74   m4
75   postgresql (at least client)
76   mysql (at least client)
77   SQLite3 (from depkgs or as package)
78   ...
79
80 Once the source is on your system, change to the win32 directory
81         cd .../bacula/src/win32
82
83 Download and build the cross compiler tools
84         ./build-win32-cross-tools
85
86 Download and build the 3rd party dependencies
87         ./build-depkgs-mingw32
88
89 Note, that during the build process you will see a moderate amount of
90 output. If something fails, it is probably because you don't have one
91 of the build dependencies (hopefully all mentioned above) loaded on your  
92 system. To find out what is going wrong, do the following:
93
94   cd .../depkgs-mingw32/src/<package-name>
95    
96 where <package-name> is where the package is unpacked and built. Normally
97 it is relatively obvious when looking at the src directory.             
98
99 In that directory, you should find a make.log, which has the full details
100 of the compiles, links, and installs done for that package.
101
102 Note, if you are building on a 64 bit machine, please know that
103 the build for the depkgs-mingw32/scons puts the python scons libraries
104 in depkgs-mingw32/scons/lib64 but when running scons it looks for the
105 libs in depkgs-mingw32/scons/lib. So adding symlink from
106 depkgs-mingw32/scons/lib64 to depkgs-mingw32/scons/lib will fix the
107 problem.
108
109 You need the header files from the Microsoft VSS SDK.  Unfortunately the SDK
110 can only be downloaded and installed on a Windows system.  You can find it on
111 Microsoft's web-site at:
112
113 http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
114
115 If that link doesn't work then go to http://www.microsoft.com and search for
116
117         "download volume shadow copy service sdk"
118
119 we are currently using version 7.2 released 8/3/2005.
120
121 Normally the files will be installed in:
122
123         c:\Program Files\Microsoft\VSSSDK72
124
125 You only need to copy everything under the c:\Program Files\Microsoft\VSSSDK72\inc
126 directory into .../depkgs-mingw32/vss/inc.  In doing so, please ensure that
127 the case in maintained on the directory and filenames -- some contain uppercase 
128 characters !!!
129
130 The above only needs to be done once unless we change the cross-tools
131 or the dependencies versions.  In general, you can run the script multiple
132 times with no problem.  For it to work, you must have at a minimum the
133 following:
134
135         gcc
136         g++
137         wget
138         texinfo
139         bison
140         flex
141
142 and possibly other packages.
143
144
145 Building
146 ========
147
148 Finally, to build the Microsoft Windows version of Bacula, do the following:
149
150    cd .../bacula/src/win32
151    make
152
153 If all goes well, you will end with all the executables in the
154 .../bacula/src/win32/release directory.
155
156 If you have an older build environment, you might do the following
157 to ensure that you pick up all the new Win32 changes:
158
159    cd .../bacula
160    make clean
161    svn update
162    cd src/win32
163    make
164
165 The installer is now built as part of the default rule when you
166 say "make" in the src/win32 directory.
167
168
169 Updating the 3rd party package patches
170 ======================================
171
172 If one of the patches changes in .../bacula/src/win32/patches, you will
173 need to update the corresponding dependency.  You can install new patches
174 by doing the following (we assume the patch in question is for openssl).
175
176    cd .../bacula/src/win32
177    ./build-depkgs-mingw32 -C openssl
178
179 NOTE: The -C means clobber.  Any local changes to the source code in
180       the .../depkgs-mingw32/src directory will be lost.  The source
181       will be reextracted from the archive and the current patches
182       will be applied.
183
184
185 Adding a new global function or global data
186 ===========================================
187
188 bacula.dll
189 ----------
190
191 The code from the following directories is built into bacula.dll:
192
193    .../bacula/src/lib
194    .../bacula/src/libfind
195    .../bacula/src/win32/compat
196
197 A new function or data variable which must be accessed from outside
198 of bacula.dll requires special treatment.  It must be specifically
199 exported.
200
201 New data variables are exported by adding the macro DLL_IMP_EXP to
202 the variable declaration in the header file.  All exported variables
203 must be declared in a header file and MUST NOT be declared in a
204 source file referencing the variable.
205
206 Exporting functions is now more or less automated.  If you find that
207 a function name has been added, changed, or an argument modified,    
208 simply do the following:
209
210    cd .../bacula/src/win32/dll 
211    make                  (to build the .o files, note the link will fail)
212    ./make_def >bacula.def
213
214 This should rebuild the bacula.def file, but it uses relative paths
215 and assumes you have the directory structure noted above. If you 
216 are using something different, you can set the NM variable at the
217 top of the make_def file to use an absolute path to the correct
218 directory.
219
220 ===== manual changing of bacula.def no longer necessary =====
221 If you want to do it manually, please see below:
222 Exporting a function requires a bit more work.  You must determine the
223 C++ mangled name of the new function.
224
225    strings .../bacula/src/win32/dll/<file>.o | grep <symbol>
226
227 Note, strings often will not show the desired symbol. In that case,
228 use:
229    
230    nm .../bacula/src/win32/dll/<file>.o
231
232 Replace <file> with the base part of the name of the source code file
233 which contains the new function.  Replace <symbol> with the name of
234 the new function.  Remove the leading underscore and place the result
235 in the file
236
237    .../bacula/src/win32/dll/bacula.def
238 === end manual changing of bacula.def ==========
239
240 If you add a new file, you will need to specify its name in
241
242    .../bacula/src/win32/dll/Makefile
243 and
244    .../bacula/src/win32/libbac/Makefile
245
246 bacula_cats.dll
247 ---------------
248
249 The code from the .../bacula/src/cats directory is built into database
250 provider specific libraries of the form cats_<db>.dll.
251
252 The database specific portion <db> is mysql for MySQL, pgsql for
253 PostgreSQL, sqlite for SQLite, and bdb for the built-in Bacula database.
254
255 During installation of the Director, one of the database libraries is
256 copied to the system and renamed bacula_cats.dll.
257
258 A new function or data variable which must be accessed from outside
259 of bacula_cats.dll requires special treatment.  It must be specifically
260 exported.
261
262 New data variables are exported by placing their name in the file
263 .../bacula/src/win32/cats/bacula_cats.def.
264
265 As with the bacula.def file above, this is now more or less automated.
266 When the link dies, simply do the following:
267
268    cd .../bacula/src/win32
269    make                  (to build the .o files, note the link will fail)
270    cd cats
271    ./make_def >bacula_cats.def
272
273 This should rebuild the bacula_cats.def file. Note, if you have
274 changed any data entry points, you will need to modify the make_def
275 script -- it should be rather obvious.
276
277
278 ===== manual changing of bacula_cats.def no longer necessary =====
279 Exporting a function requires a bit more work.  You must determine the
280 C++ mangled name of the new function.
281
282    strings .../bacula/src/win32/cats/cats_*/<file>.o | grep <symbol>
283
284 Note, strings often will not show the desired symbol. In that case,
285 use:
286
287    nm .../bacula/src/win32/dll/<file>.o
288
289 Replace <file> with the base part of the name of the source code file
290 which contains the new function.  Replace <symbol> with the name of
291 the new function.  Remove the leading underscore and place the result
292 in the .../bacula/src/win32/cats/bacula_cats.def file.
293 === end manual changing of bacula_cats.def ==========
294
295
296 Structure of the MinGW32 build environment
297 ==========================================
298
299 The basic strategy is each Makefile in the various subdirectories includes
300 Makefile.inc, defines variables and rules specific to what is being built,
301 then includes Makefile.rules which defines all the rules.
302
303 Makefile.inc defines the locations of all the dependencies and the compiler
304 and linker flags.  It is automatically created from Makefile.inc.in.  Any
305 changes must be made to Makefile.inc.in not Makefile.inc or they will be
306 overwritten the next time Makefile.inc.in is updated.
307
308 Makefile.rules defines a bunch of macros to simplify building.  It also
309 includes all the basic rules for building objects, GUI and console
310 executables, etc.
311
312 Makefile.template is a template for creating new Makefiles, if you are
313 creating a new directory, copy Makefile.template to Makefile in that
314 directory and edit to suit.