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