dhcp cross compile

来源:互联网 发布:8086汇编软件 编辑:程序博客网 时间:2024/05/01 11:08

This document describes how to cross-compile DHCP package, providedby Internet
Software Consortium (www.isc.org), for powerpc platform.

1. Getting the package


Get the latest package from http://www.isc.org/products/DHCP/(at the time
of writing it is dhcp-3.0pl2.tar.gz) and untar it to your home directory:

> cd /home/gorjup
> tar xzvf dhcp-3.0pl2.tar.gz

2. Cross-compiling


After you have installed your development kit (I used DTDK-0.3 toolchain,built by
Markus Haag ), set the proper environment variables:

> export CROSS_COMPILE=ppc-linux-
> PATH=$PATH:/opt/dtdk-0.3/mpc860/bin
> export CC=ppc-linux-gcc
> export AR=ppc-linux-ar
> export STRIP=ppc-linux-strip
> export RANLIB=ppc-linux-ranlib
> export LD=ppc-linux-ld
> export NM=ppc-linux-nm

Go to the dhcp directory and configure the dhcp package:

> cd /home/gorjup/dhcp-3.0pl2
> ./configure

Now a new directory, named work.linux-2.2, has been created. Go to thisdirectory
and edit Makefiles. In all makefiles (in the main one and in all thesubdirectories)
you need to do some changes:

> cd work.linux-2.2

- add the destination directory for cross-compiled files and man pages:

DESTDIR = /home/gorjup/target_ppc_dhcp

- change line, beginning with RANLIB:

- RANLIB = ranlib
+ RANLIB = ppc-linux-ranlib

- add the definition for CC variable:
+ CC = ppc-linux-gcc

In following makefiles:
common/Makefile, dhcpctl/Makefile, dst/Makefile, minires/Makefile andomapip/Makefile
you need to replace ar binutility with ppc-linux-ar.
You find ar binutility at the end of Makefiles.
Now cross-compile the package:

> make
> make install

At the end you can strip the binaries by using ppc-linux-strip.

3. Testing


In directory /home/gorjup/target_ppc_dhcp you will find all necessaryfiles that
you need to add to the file system of your target.
Then you can test the client, server and relay agent:

Starting client:

# dhclient -q

Option -q disables printing out copyrights on the screen.

Starting server:

# dhcpd -q

Starting relay agent:

# dhcrelay -q x.x.x.x

x.x.x.x is an IP address of the remote DHCP server.

===========================================================================

# dhclient ra0                                                                 
Internet Systems Consortium DHCP Client V3.0.3                                 
Copyright 2004-2005 Internet Systems Consortium.                               
All rights reserved.                                                           
For info, please visit http://www.isc.org/products/DHCP                        
                                                                               
execve (/sbin/dhclient-script, ...): No such file or directory                 
Listening on LPF/ra0/00:24:a5:21:05:d6                                         
Sending on   LPF/ra0/00:24:a5:21:05:d6                                         
Sending on   Socket/fallback                                                   
DHCPREQUEST on ra0 to 255.255.255.255 porRcv Wcid(1) AddBAReq                  
t 67                                                                           
Start Seq = 00000000                                                           
DHCPACK from 192.168.7.1                                                       
execve (/sbin/dhclient-script, ...): No such file or directory                 
bound to 192.168.7.100 -- renewal in 3369 seconds.

--------------------------------------------------------------------------

There isn't "bash" in the directory "/bin/bash" belonging to your file system. So you should modify words "#!/bin/bash" in file "/sbin/dhclient-script" to "#!/bin/sh"

原创粉丝点击