Merge from vendor branch TNF:
[pkgsrcv2.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 Terminology:
13 ------------
14
15 There are multiple terminologies in use for cross building.  In pkgsrc, we use
16
17   build platform: the system on which you are doing the compilation of packages
18
19   target platform: the system on which you will run the packages
20
21 (An alternative terminology is that used by autoconf:
22
23   build: as above
24   host: as "target", above
25   target: the architecture that the cross-built compiler produces code for
26
27 pkgsrc chooses the more simple build/target terms because the Canadian
28 Cross situation is not common in pkgsrc.  Partially because of the
29 potential for confusion with autoconf's terminology, we avoid the word
30 "host".
31
32 Target machine setup:
33 ---------------------
34 1) install `pkgsrc/devel/distcc' package.
35
36 2) install helper script "use-distcc" in f.e. /usr/local/bin/:
37         ---------
38         #!/usr/pkg/bin/tcsh
39
40         setenv PATH "/usr/distcc/bin:$PATH"
41         setenv CC gcc
42         ---------
43
44 3) create directory "/usr/distcc/bin" contents with softlinks :
45         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:58 c++@ -> ../../pkg/bin/distcc
46         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:57 cc@ -> ../../pkg/bin/distcc
47         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:58 g++@ -> ../../pkg/bin/distcc
48         lrwxr-xr-x  1 root  wheel   20 Sep 16 02:57 gcc@ -> ../../pkg/bin/distcc
49
50
51 Helper machine setup:
52 ---------------------
53 1) install `pkgsrc/devel/distcc' package.
54
55 2) create a crosscompiler to compile from any architecture to NetBSD/sparc, 
56 go to the NetBSD src dir and run :
57         ./build.sh -a sparc -m sparc -T /usr/gcc-cross-sparc/ tools
58
59 this will create a directory called /usr/gcc-cross-sparc/ with the 
60 crosscompilation tools.
61
62 3) install helper script "START-distcc' 
63         ------------
64         #!/usr/pkg/bin/tcsh
65
66         setenv PATH "/usr/gcc-cross-sparc/sparc--netbsdelf/bin/:$PATH"
67         setenv DISTCC_VERBOSE 1
68
69         distccd -a 192.168.0.137/24  --listen 192.168.0.137 -p 3632
70         -----------
71 this will start the `distcc' daemon to listen on the 192.168.0/24 network 
72 and listen on 192.168.0.137 specificly and on port 3632 (why doesn't it do 
73 this on default?)
74
75
76 Compilation of sources (not pkgsrc):
77 ------------------------------------
78 1) on each helper machine run the `START-distcc' script
79
80 2) on the target machine (replace helper1, helper2 etc. by the names/ip 
81 addresses of the helper machines) :
82         -----------
83         source /usr/local/bin/use-distcc
84         setenv DISTCC_HOSTS "helper1 helper2 helper3"
85         cd .../sourcedir
86         make -j2 target
87         -----------
88
89
90 Compilation of pkgsrc packages:
91 -------------------------------
92 1) on each helper machine run the `START-distcc' script
93
94 2) on the target machine, do NOT run the `use-distcc' script, go to the
95 package dir and set :
96
97 set the helpers (,lzo addition sets compression of the data transport):
98         setenv DISTCC_HOSTS "helper1 helper2 helper3,lzo"
99
100 instruct pkgsrc to use distcc:
101         setenv PKGSRC_COMPILER "distcc gcc"
102
103 set the concurrency level (not all packages allow this)
104         setenv BUILD_MAKE_FLAGS "-j2"
105
106 compile/update package
107         make update
108
109 thats all :)
110