Project

General

Profile

Howto build » History » Version 7

Oleksandr Rybalko, 01/17/2012 11:29 AM

1 1 Eric Krausser
h1. Howto build
2 1 Eric Krausser
3 1 Eric Krausser
h2. Fetch sources
4 1 Eric Krausser
5 4 Eric Krausser
Check out the ZRouter source code with Mercurial hg or by fetching "the latest ZRouter sources":http://zrouter.org/hg/zrouter/archive/tip.tar.bz2 ("as zip":http://zrouter.org/hg/zrouter/archive/tip.zip)
6 1 Eric Krausser
7 1 Eric Krausser
For this tutorial we expect you check out / unpack the sources to @/projects/ZRouter/zrouter@.
8 1 Eric Krausser
9 1 Eric Krausser
For now you also need our patched FreeBSD sources. We work on getting this patches back to official FreeBSD-HEAD, so one day this step will be obsolete.
10 1 Eric Krausser
11 3 Eric Krausser
Get it via Mercurial or by fetching "ZRouter's patched FreeBSD sources":http://archive.zrouter.org/nightly/FreeBSD-zrouter-head-latest.tgz
12 5 Eric Krausser
13 5 Eric Krausser
For this tutorial we expect you check out / unpack the modified FreeBSD sources to @/projects/ZRouter/FreeBSD@.
14 5 Eric Krausser
15 5 Eric Krausser
h2. Build
16 5 Eric Krausser
17 5 Eric Krausser
For this tutorial we expect you want to build a firmware for a device from vendor D-Link, the model is DIR-320 (see [[Supported devices]]). 
18 5 Eric Krausser
19 5 Eric Krausser
As root do:
20 5 Eric Krausser
<pre>
21 5 Eric Krausser
cd /projects/ZRouter/zrouter
22 5 Eric Krausser
make FREEBSD_SRC_TREE=/projects/ZRouter/FreeBSD/head TARGET_PAIR=D-Link/DIR-320
23 5 Eric Krausser
</pre>
24 6 Eric Krausser
25 6 Eric Krausser
h2. Customize the build
26 6 Eric Krausser
27 6 Eric Krausser
You can create the file _Makefile.local.opts_ in your ZRouter's home with predefined variables, so you can skip to specify them with every make run:
28 6 Eric Krausser
29 6 Eric Krausser
e.g. /projects/ZRouter/zrouter/Makefile.local.opts
30 6 Eric Krausser
<pre>
31 6 Eric Krausser
FREEBSD_SRC_TREE=/projects/ZRouter/FreeBSD/head
32 6 Eric Krausser
33 6 Eric Krausser
# override default /usr/obj
34 6 Eric Krausser
OBJ_DIR=/projects/ZRouter/obj
35 6 Eric Krausser
36 6 Eric Krausser
TARGET_PAIR=D-Link/DIR-320
37 6 Eric Krausser
</pre>
38 6 Eric Krausser
39 6 Eric Krausser
Now just run @make@.
40 7 Oleksandr Rybalko
If you want to have ability to override that variable, assign it with *?=*,
41 7 Oleksandr Rybalko
this will allow you to set variable at @make@(1) command line.
42 7 Oleksandr Rybalko
43 7 Oleksandr Rybalko
For example, very useful to have TARGET_PAIR override-able, then you
44 7 Oleksandr Rybalko
will be able build image for different devices by call @make@(1) with
45 7 Oleksandr Rybalko
additional variable TARGET_PAIR=other/device. So place into
46 7 Oleksandr Rybalko
Makefile.local.opts following line:
47 7 Oleksandr Rybalko
<pre>
48 7 Oleksandr Rybalko
TARGET_PAIR?=D-Link/DIR-320
49 7 Oleksandr Rybalko
</pre>
50 7 Oleksandr Rybalko
and now if you run @make@(1) w/o variables you will have image for D-Link DIR-320.
51 7 Oleksandr Rybalko
But if you run @make TARGET_PAIR?=D-Link/DIR-620@, you will have image for DIR-620.