update Mon Jun 14 06:37:00 PDT 2010
[pkgsrc.git] / doc / HOWTO-crosscompile
1 Crosscompiling with distcc HOWTO
2 ================================
3
4 Purpose:
5 --------
6 croscompiling of sourcecode in general including NetBSD's source 
7 tree and NetBSD's pkgsrc packages using `pkgsrc/devel/distcc'
8
9 Note that this current setup is not intended for build builds as it might
10 confuse the buildbuild system.
11
12 Target machine setup:
13 ---------------------
14 1) install `pkgsrc/devel/distcc' package.
15
16 2) install helper script "use-distcc" in f.e. /usr/local/bin/:
17         ---------
18         #!/usr/pkg/bin/tcsh
19
20         setenv PATH "/usr/distcc/bin:$PATH"
21         setenv CC gcc
22         ---------
23
24 3) create directory "/usr/distcc/bin" contents with softlinks :
25         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:58 c++@ -> ../../pkg/bin/distcc
26         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:57 cc@ -> ../../pkg/bin/distcc
27         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:58 g++@ -> ../../pkg/bin/distcc
28         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:57 gcc@ -> ../../pkg/bin/distcc
29
30
31 Helper machine setup:
32 ---------------------
33 1) install `pkgsrc/devel/distcc' package.
34
35 2) create a crosscompiler to compile from any architecture to NetBSD/sparc, 
36 go to the NetBSD src dir and run :
37         ./build.sh -a sparc -m sparc -T /usr/gcc-cross-sparc/ tools
38
39 this will create a directory called /usr/gcc-cross-sparc/ with the 
40 crosscompilation tools.
41
42 3) install helper script "START-distcc' 
43         ------------
44         #!/usr/pkg/bin/tcsh
45
46         setenv PATH "/usr/gcc-cross-sparc/sparc--netbsdelf/bin/:$PATH"
47         setenv DISTCC_VERBOSE 1
48
49         distccd -a 192.168.0.137/24  --listen 192.168.0.137 -p 3632
50         -----------
51 this will start the `distcc' daemon to listen on the 192.168.0/24 network 
52 and listen on 192.168.0.137 specificly and on port 3632 (why doesn't it do 
53 this on default?)
54
55
56 Compilation of sources (not pkgsrc):
57 ------------------------------------
58 1) on each helper machine run the `START-distcc' script
59
60 2) on the target machine (replace helper1, helper2 etc. by the names/ip 
61 addresses of the helper machines) :
62         -----------
63         source /usr/local/bin/use-distcc
64         setenv DISTCC_HOSTS "helper1 helper2 helper3"
65         cd .../sourcedir
66         make -j2 target
67         -----------
68
69
70 Compilation of pkgsrc packages:
71 -------------------------------
72 1) on each helper machine run the `START-distcc' script
73
74 2) on the target machine, do NOT run the `use-distcc' script, go to the
75 package dir and set :
76
77 set the helpers (,lzo addition sets compression of the data transport):
78         setenv DISTCC_HOSTS "helper1 helper2 helper3,lzo"
79
80 instruct pkgsrc to use distcc:
81         setenv PKGSRC_COMPILER "distcc gcc"
82
83 set the concurrency level (not all packages allow this)
84         setenv BUILD_MAKE_FLAGS "-j2"
85
86 compile/update package
87         make update
88
89 thats all :)
90