cross-compile dhcp-4.2.5 and bind-9.8.4-P1
Trevor Bowen
trevorbowen at gmail.com
Fri Feb 8 23:43:28 UTC 2013
Well, I finally succeeded in cross-compiling dhcp-4.2.5, including
bind-9.8.4-P1. However, I did have to make a minor patch to BIND. BIND-9
was determined to use the cross-compiler instead of the native compiler to
build the dns/gen program, which is run locally during the build process.
So, the following patch is required, AFAICT:
#########################################
# BTW: modified "whitespace" is supposed to be a "TAB-space".
#########################################
diff --git a/bind/bind-9.8.4-P1/lib/export/dns/Makefile.in
b/packages/dhcp-4.2.5-brand-new/bind/bind-9.8.4-P1/lib/export/dns/Makefile.in
index 6df36fe..5e334d8 100644
--- a/bind/bind-9.8.4-P1/lib/export/dns/Makefile.in
+++ b/bind/bind-9.8.4-P1/lib/export/dns/Makefile.in
@@ -166,7 +166,7 @@ code.h: gen
./gen -s ${srcdir} > code.h
gen: ${srcdir}/gen.c
- ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ ${srcdir}/gen.c ${LIBS}
+ ${BUILD_CC} ${ALL_CFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c
${BUILD_LIBS}
#We don't need rbtdb64 for this library
#rbtdb64. at O@: rbtdb.c
#########################################
I have stored the above patch in a local file, called
dhcp-4.2.5_cross-compile.patch. Using the above patch and the following
recipe (see below), I have successfully built and installed the complete
DHCP-4.2.5 suite on 2 Linux i686 and x86_64 machines.
Can the above patch please be applied upstream? I don't think there is any
way "gen" can be executed, if it is compiled with cross-compiler.
( Reference:
http://www.jonisdumb.com/2011/02/compiling-isc-dhcp-420-dd-wrt.html )
Hopefully, this process will help someone else.
Thanks!
Trevor
-------------------------------------------------------------------
#!/bin/bash
####################################
# Trevor's DHCP build recipe
####################################
cd ~
wget ftp://ftp.isc.org/isc/dhcp/4.2.5/dhcp-4.2.5.tar.gz
tar -zxvf dhcp-4.2.5.tar.gz
cd dhcp-4.2.5
# Setup cross-compile environment
export
TOOLCHAIN_BASE=/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe
# Specific to DHCP and BIND
export BUILD_CC=`which gcc`
# Add cross-compile toolchain to path (Note: requires matching --host
configuration.)
export PATH="${TOOLCHAIN_BASE}/bin:${PATH}"
# Include already built libraries and headers for my cross-compiled target -
necessary for my other packages, not DHCP.
RFS="$( cd ../../ltib/rootfs && pwd )"
export CFLAGS="-I${RFS}/usr/local/include -I${RFS}/usr/include
-I${RFS}/include/python2.7 ${CFLAGS}"
export LDFLAGS="-L${RFS}/lib -L${RFS}/usr/lib ${LDFLAGS}"
export PKG_CONFIG_LIBDIR="${RFS}/lib/pkgconfig"
# Clean up build space
if [ -f Makefile ]
then
make distclean
fi
rm -rf bind/bind-* >& /dev/null
# Patch sources for cross-compile
tar -zxf bind/bind.tar.gz -C bind
# Depends on patch file - adjust reference to local storage
patch -p1 < ~/dhcp-4.2.5_cross-compile.patch
# Configure build environment, Makefiles, etc.
# May need to change "yes" to "no", depending on target's capabilities
./configure \
--host=powerpc-none-linux-gnuspe \
--exec-prefix=/ \
--prefix=/usr/local \
--sysconfdir=/etc \
--mandir=/usr/share/man \
ac_cv_file__dev_random=yes
# Compile
make
# Install into root-owned filespace:
#sudo PATH="${TOOLCHAIN_BASE}/bin:${PATH}" make install DESTDIR=${RFS}
# Install into user space
make install DESTDIR=${RFS}
====================================================
Are you in search of ultimate truth?
http://www.insearchoftruth.org
http://www.wordsfitlyspoken.org
On 02/07/2013 03:54 PM, Trevor Bowen wrote:
> Hi,
>
> I have seen several posts on this subject, which have helped me over
> several hurdles; however, I am still having trouble cross-compiling the
> latest dhcp-4.2.5, specifically the subdir, bind (bind-9.8.4-P1). It
> seems that my cross-compile settings are not being properly handed down to
> the bind sub-build.
>
> Does anyone have a working cross-compile for dhcp-4.2.5? Could you share
> your configuration? Here is what I am doing (see below).
>
> It seems some serious hacking is required on the Makefile and Makefile.in
> files all throughout the code tree to either manually propagate the
> cross-compile settings or to hard-code them. Have I overlooked something?
>
> Thanks!
>
> Trevor
>
> -----------------------------------------------------------------------
> $ wget ftp://ftp.isc.org/isc/dhcp/4.2.5/dhcp-4.2.5.tar.gz
> $ tar -zxvf dhcp-4.2.5.tar.gz
> $ cd dhcp-4.2.5
> $ ## Define cross-compile variables globally
> $ export ARCH=powerpc
> $ export TOOLCHAIN_BASE=/opt/freescale
> $ export
> TOOLCHAIN_BIN=${TOOLCHAIN_BASE}/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin
> $ export CROSS_COMPILE=${TOOLCHAIN_BIN}/powerpc-none-linux-gnuspe-
> $ export
> PATH="${TOOLCHAIN_BASE}/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/powerpc-none-linux-gnuspe/bin:${TOOLCHAIN_BASE}/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/libexec/gcc/powerpc-none-linux-gnuspe/4.3.2:${PATH}"
> $ export AS=${CROSS_COMPILE}as
> $ export LD=${CROSS_COMPILE}ld
> $ export CC=${CROSS_COMPILE}gcc
> $ export CXX=${CROSS_COMPILE}g++
> $ export AR=${CROSS_COMPILE}ar
> $ export NM=${CROSS_COMPILE}nm
> $ export STRIP=${CROSS_COMPILE}strip
> $ export SSTRIP=${CROSS_COMPILE}sstrip
> $ export RANLIB=${CROSS_COMPILE}ranlib
> $ export READELF=${CROSS_COMPILE}readelf
> $ export OBJCOPY=${CROSS_COMPILE}objcopy
> $ export OBJDUMP=${CROSS_COMPILE}objdump
> $ export BLDSHARED="${CROSS_COMPILE}gcc -shared"
> $ export LDSHARED="${CROSS_COMPILE}gcc -shared"
> $ export HOSTARCH=ppc-linux
> $ export BUILDARCH=i686-linux-gnu
> $ CROSS_COMPILE=${CROSS_COMPILE} \
> AS=${AS} \
> LD=${LD} \
> CC=${CC} \
> CXX=${CXX} \
> AR=${AR} \
> NM=${NM} \
> STRIP=${STRIP} \
> SSTRIP=${SSTRIP} \
> RANLIB=${RANLIB} \
> READELF=${READELF} \
> OBJCOPY=${OBJCOPY} \
> OBJDUMP=${OBJDUMP} \
> BLDSHARED="${BLDSHARED}" \
> LDSHARED="${LDSHARED}" \
> HOSTARCH=powerpc-linux \
> BUILDARCH=i686-linux-gnu \
> ./configure \
> --host=powerpc-linux \
> --build=i686-linux-gnu \
> --exec-prefix=/ \
> --prefix=/usr/local \
> --sysconfdir=/etc \
> --mandir=/usr/share/man \
> ac_cv_file__dev_random=yes
> ## Apply cross-compile variables to MAKE command line
> $ CROSS_COMPILE=${CROSS_COMPILE} \
> AS=${AS} \
> LD=${LD} \
> CC=${CC} \
> CXX=${CXX} \
> AR=${AR} \
> NM=${NM} \
> STRIP=${STRIP} \
> SSTRIP=${SSTRIP} \
> RANLIB=${RANLIB} \
> READELF=${READELF} \
> OBJCOPY=${OBJCOPY} \
> OBJDUMP=${OBJDUMP} \
> BLDSHARED="${BLDSHARED}" \
> LDSHARED="${LDSHARED}" \
> HOSTARCH=powerpc-linux \
> BUILDARCH=i686-linux-gnu \
> make V=1
> Making all in bind
> make[1]: Entering directory `/home/tbowen/dhcp-4.2.5/bind'
> Configuring BIND Export libraries for DHCP.
> configure: error: in `/home/tbowen/dhcp-4.2.5/bind/bind-9.8.4-P1':
> configure: error: cannot run C compiled programs.
> If you meant to cross compile, use `--host'.
> See `config.log' for more details
> make[1]: *** [all] Error 1
> make[1]: Leaving directory `/home/tbowen/dhcp-4.2.5/bind'
> make: *** [all-recursive] Error 1
> $ cd bind/
> CROSS_COMPILE=${CROSS_COMPILE} \
> AS=${AS} \
> LD=${LD} \
> CC=${CC} \
> CXX=${CXX} \
> AR=${AR} \
> NM=${NM} \
> STRIP=${STRIP} \
> SSTRIP=${SSTRIP} \
> RANLIB=${RANLIB} \
> READELF=${READELF} \
> OBJCOPY=${OBJCOPY} \
> OBJDUMP=${OBJDUMP} \
> BLDSHARED="${BLDSHARED}" \
> LDSHARED="${LDSHARED}" \
> HOSTARCH=powerpc-linux \
> BUILDARCH=i686-linux-gnu \
> make V=1
> bind-9.8.4-P1 already unpacked...
> Configuring BIND Export libraries for DHCP.
> configure: error: in `/home/tbowen/dhcp-4.2.5/bind/bind-9.8.4-P1':
> configure: error: cannot run C compiled programs.
> If you meant to cross compile, use `--host'.
> See `config.log' for more details
> make: *** [all] Error 1
>
More information about the dhcp-users
mailing list