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