]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/README.mingw64
ebl update win64 doc and add paches
[bacula/bacula] / bacula / src / win32 / README.mingw64
1 Instructions to build Bacula using the MinGW64 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 Ubuntu 8.04 so building on that system should definitely work.  But there
7 shouldn't be any issues on other Linux distributions.
8
9 We don't officially support this method, 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 We expect that there may be problems on systems other than Linux where you
14 are pretty much on your own.  However, we will try to provide responses to
15 your questions on the bacula-devel list, but we can't guarantee anything.
16
17 Directory Structure
18 =====================
19 The new directory structure is:
20
21   bacula-top                 Top level directory -- any name
22     bacula                   Top level Bacula source directory -- any name
23       src
24         win32                Main directory where Windows version is built.
25
26     docs                     Top level Bacula documentation directory
27
28     depkgs-mingw32 (MinGW32) 3rd Party Dependencies for MinGW32 build
29       bin              --    NOTE!  depkgs-msvc is no longer suppored
30       include            |
31       lib                |
32       man                |   Created by script
33       nsis               |-- .../bacula/src/win32/build-depkgs-mingw32
34       scons              |
35       share              |
36       src                |
37       ssl              --
38       vss
39         inc                  A copy of the Windows VSS/inc directory
40
41
42     depkgs-mingw-w64 (MinGW64) 3rd Party Dependencies for MinGW64 build
43       bin              --
44       include            |
45       lib                |
46       man                |
47       nsis               |
48       scons              |
49       share              |
50       src                |
51       ssl              --
52       vss
53         inc                  A copy of the Windows VSS/inc directory
54
55     cross-tools (MinGW64/32)  Cross compilation tools (gcc, g++, mingw32, ...)
56       binutils-mingw32 --
57       gcc-mingw32        |   Created by script
58       mingw32            |-- .../bacula/src/win32/build-win32-cross-tools
59       mingw-utils        |
60       source           --
61       mingw-w64/x86_64-pc-mingw32  \ Taken from http://sf.net/projects/mingw-w64
62       mingw-w64/bin/               / 
63
64
65
66 One-time Setup
67 ==============
68
69 If you're reading this file you've probably already enlisted in the SVN tree or
70 extracted the contents of the source tar.  If not you need to do that first.
71
72 You also need to download one of the doc tar balls and extract to your
73 top level Bacula directory. 
74
75 The extracted doc directory name will be bacula-docs-version where version
76 is the version number.  The directory must be renamed to docs (ie remove
77 the leading bacula- and the -version portion of the name).
78
79 Note, a number of packages must be installed to build the cross-tools
80 and the depkgs files.  Most are rather standard such as gcc, g++,
81 make, ...  However a few that you may not have are:
82
83   texinfo
84   flex
85   bison
86   patch (Debian)
87   m4
88   postgresql (at least client)
89   mysql (at least client)
90   SQLite3 (from depkgs or as package)
91   readline (readlineN-dev on Debian)
92   ...
93
94 NB: On Debian, I had to remove /usr/bin/lorder for
95 postresql to build correctly.
96
97 Once the source is on your system, change to the win32 directory
98         cd .../bacula/src/win32
99
100 Download and build the cross compiler tools
101         ./build-win32-cross-tools
102
103 Download and build the 3rd party dependencies
104         ./build-depkgs-mingw32
105
106 Note, that during the build process you will see a moderate amount of
107 output. If something fails, it is probably because you don't have one
108 of the build dependencies (hopefully all mentioned above) loaded on your  
109 system. To find out what is going wrong, do the following:
110
111   cd .../depkgs-mingw32/src/<package-name>
112    
113 where <package-name> is where the package is unpacked and built. Normally
114 it is relatively obvious when looking at the src directory.             
115
116 In that directory, you should find a make.log, which has the full details
117 of the compiles, links, and installs done for that package.
118
119 When building the mingw64 environment and all dependencies (cross-tools, and depkgs-mingw64)
120 should be compiled by hand with host=x86_64-pc-linux and target=x86_64-pc-mingw32.
121 For that, use this configure line :
122
123 ./configure --host=x86_64-pc-linux --target=x86_64-pc-mingw32 --prefix=$ROOT/cross-tools
124
125 (It can work with other setup). We are using binutils-2.19, gcc-4.3.2,
126 gmp-4.2.4, mpfr-2.3.2. The mingw64 project delivers binaries that should do the
127 work.
128
129 Internal scripts and patches are using mingw32-xxx binaries, so you need to
130 make links in the gcc bin ($ROOT/cross-tools/mingw-w64/bin) directory.
131
132 ---8<------8<-------8<--------
133
134 for i in x86_64-pc-mingw32-*
135 do
136     ln -s $i ${i##x86_64-pc-}
137 done
138
139 ---8<------8<-------8<--------
140
141 They provide also a pthread lib but we aren't sure that they will work, you
142 can compile it yourself using the pthreads-snap-2004-06-22.tar.gz (same as
143 mingw32) + pthread-win64.patch.
144
145 The openssl lib version is openssl-0.9.8j.tar.gz + openssl-win64.patch
146
147 See External-mingw-w64 for download location (available on www.bacula.org).
148
149 You need the header files from the Microsoft VSS SDK.  Unfortunately the SDK
150 can only be downloaded and installed on a Windows system.  We do not have
151 the right to distribute it, so you must download it yourself.
152 You can find it on Microsoft's web-site at:
153
154 http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
155
156 If that link doesn't work then go to http://www.microsoft.com and search for
157
158         "download volume shadow copy service sdk"
159
160 we are currently using version 7.2 released 8/3/2005.
161
162 Normally the files will be installed in:
163
164         c:\Program Files\Microsoft\VSSSDK72
165
166 You only need to copy everything under the c:\Program Files\Microsoft\VSSSDK72\inc
167 directory into .../depkgs-mingw32/vss/inc. and .../depkgs-mingw-w64/vss/inc 
168 In doing so, please ensure that
169 the case in maintained on the directory and filenames -- some contain uppercase 
170 characters !!!
171
172 The above only needs to be done once unless we change the cross-tools
173 or the dependencies versions.  In general, you can run the script multiple
174 times with no problem.  For it to work, you must have at a minimum the
175 following:
176
177         gcc
178         g++
179         wget
180         texinfo
181         bison
182         flex
183         python
184         unzip
185         tar
186
187 and possibly other packages.
188
189
190 Building
191 ========
192
193 Finally, to build the Microsoft Windows version of Bacula, do the following:
194
195    cd .../bacula/src/win32
196    make clean
197    make WIN64=yes
198
199 At this time, the installer doesn't work, binaries are located in 
200 .../bacula/src/win32/release
201
202 If you have an older build environment, you might do the following
203 to ensure that you pick up all the new Win32 changes:
204
205    cd .../bacula
206    make clean
207    svn update
208    cd src/win32
209    make WIN64=yes
210
211 To build the win32 version (director/storage/filed) you need to clean all
212 objects from a previous build.
213
214
215 Updating the 3rd party package patches
216 ======================================
217
218 If one of the patches changes in .../bacula/src/win32/patches, you will
219 need to update the corresponding dependency.
220
221 Adding a new global function or global data
222 ===========================================
223
224 bacula.dll
225 ----------
226
227 The code from the following directories is built into bacula.dll:
228
229    .../bacula/src/lib
230    .../bacula/src/libfind
231    .../bacula/src/win32/compat
232
233 A new function or data variable which must be accessed from outside
234 of bacula.dll requires special treatment.  It must be specifically
235 exported.
236
237 New data variables are exported by adding the macro DLL_IMP_EXP to
238 the variable declaration in the header file.  All exported variables
239 must be declared in a header file and MUST NOT be declared in a
240 source file referencing the variable. Example, src/lib/runscript.h:
241
242 extern DLL_IMP_EXP bool (*console_command)(JCR *jcr, const char *cmd);
243
244 or src/jcr.h
245
246 extern int DLL_IMP_EXP num_jobs_run;
247 extern DLL_IMP_EXP dlist * last_jobs;
248 ...
249
250
251 Exporting functions is now more or less automated.  If you find that
252 a function name has been added, changed, or an argument modified,    
253 simply do the following:
254
255    cd .../bacula/src/win32/lib
256    make                  (to build the .o files, note the link will fail)
257    ./make_def >bacula64.def
258
259 This should rebuild the bacula.def file, but it uses relative paths
260 and assumes you have the directory structure noted above. If you 
261 are using something different, you can set the NM variable at the
262 top of the make_def file to use an absolute path to the correct
263 directory.
264
265 ===== manual changing of bacula32.def or bacula64.def no longer necessary =====
266 If you want to do it manually, please see below:
267 Exporting a function requires a bit more work.  You must determine the
268 C++ mangled name of the new function.
269
270    strings .../bacula/src/win32/lib/<file>.o | grep <symbol>
271
272 Note, strings often will not show the desired symbol. In that case,
273 use:
274    
275    nm .../bacula/src/win32/lib/<file>.o
276
277 Replace <file> with the base part of the name of the source code file
278 which contains the new function.  Replace <symbol> with the name of
279 the new function.  Remove the leading underscore and place the result
280 in the file
281
282    .../bacula/src/win32/lib/bacula64.def
283 === end manual changing of bacula64.def ==========
284
285 If you add a new file, you will need to specify its name in
286
287    .../bacula/src/win32/lib/Makefile
288 and
289    .../bacula/src/win32/libbac/Makefile
290
291
292 Running gdb on the Win32 files
293 ==================================================
294 You can use the mingw64 gdb to debug Bacula on Win64 by downloading
295 it from Source Forge:
296
297 http://sourceforge.net/project/showfiles.php?group_id=202880&package_id=311650
298
299
300 Download one of their .exe versions, which is an installer that you
301 can run on Win32 to install gdb.  This gdb is built with mingw64 so will
302 run independently of any cygwin installation.  Note, not all the releases
303 come with an installer. I had to go back 3 or 4 versions to find it.  Otherwise
304 you can download the source and build it.  Thanks to Eric Bollengier for
305 this tip.
306
307
308 Structure of the MinGW64/32 build environment
309 ==========================================
310
311 The basic strategy is each Makefile in the various subdirectories includes
312 Makefile.inc, defines variables and rules specific to what is being built,
313 then includes Makefile.rules which defines all the rules.
314
315 Makefile.inc defines the locations of all the dependencies and the compiler
316 and linker flags.  It is automatically created from Makefile.inc.in.  Any
317 changes must be made to Makefile.inc.in not Makefile.inc or they will be
318 overwritten the next time Makefile.inc.in is updated.
319
320 Makefile.rules defines a bunch of macros to simplify building.  It also
321 includes all the basic rules for building objects, GUI and console
322 executables, etc.
323
324 Makefile.template is a template for creating new Makefiles, if you are
325 creating a new directory, copy Makefile.template to Makefile in that
326 directory and edit to suit.