hostapd cross compilation error

Ben Greear greearb
Wed Jan 11 10:08:06 PST 2012


On 01/11/2012 10:02 AM, uday kiran wrote:
> Is it possible to cross compile hostapd for powerpc in CentOS5.0 ?
>
> I am not able to generate libraries nl and genl by cross compiling libnl.

I don't have time to provide more detailed info, but here is my
makefile that supports cross-compiling libnl, hostapd, etc.  I'm
cross-compiling to ARM, but it should give you an idea how to do power-pc
as well.

MakeInclude has this (among other things):

ifeq "${PLATFORM}" "ARM"
LPCAP=-Wl,-Bstatic -lpcap -Wl,-Bdynamic
GCCPREFIX=arm-unknown-linux-gnu
ARM_TC_BASE = /usr/local/arm/gcc-4.2.3-glibc-2.3.3/${GCCPREFIX}
#ARM_TC_VER = 2.95.3
ARM_TC_PATH = ${ARM_TC_BASE}
ARM_TC_BIN = ${ARM_TC_PATH}/bin
ARM_TC_LIB = ${ARM_TC_PATH}/lib
endif

ifeq "${PLATFORM}" "ARM"
    #echo "Building for ARM platform."
    DONE_ONE="true"
    LBYPASS=
    LPCI=
    CCFLAGS = $(BASIC_CCFLAGS) -DARM -I${HOME}/linux/include
    LDFLAGS += -L$(ARM_TC_LIB)
    STRIP=${ARM_TC_BIN}/${GCCPREFIX}-strip
    CC = ${ARM_TC_BIN}/${GCCPREFIX}-gcc       # this is generally the c compiler, unused AFAIK
    CCC = ${ARM_TC_BIN}/${GCCPREFIX}-g++      # this is generally the c++ compiler
    LD = ${ARM_TC_BIN}/${GCCPREFIX}-ld
    AR = ${ARM_TC_BIN}/${GCCPREFIX}-ar
    AS = ${ARM_TC_BIN}/${GCCPREFIX}-as
    NM = ${ARM_TC_BIN}/${GCCPREFIX}-nm
    STRIP = ${ARM_TC_BIN}/${GCCPREFIX}-strip
    RANLIB = ${ARM_TC_BIN}/${GCCPREFIX}-ranlib
endif
...




include ../MakeInclude

XML_VER=2.6.22
SNDFILE_VER=1.0.17
RADVD_VER=1.6
ZVER=1.2.5
PVER=1.2.0rc1

SSLVER=0.9.7g
SSLCFGARM=linux-elf-arm
#SSLVER=0.9.8g
#SSLCFGARM=linux-generic32

HLOCAL=${PROG_HOME}/server/local/
CROSSENV=
CCFGARGS=
HAPCFLAGS=
# For debugging builds..otherwise, leave it blank.
HAPCFLAGS=CFLAGS=" -MMD -O0 -Wall -g "
HAPSHA256=
HAPREADLINE=CONFIG_READLINE=y


ifeq "${SKIP_NFSUTILS}" "1"
NFS_LOCAL_TARG=
NFS_B1=
NFS_B2=
else
NFS_LOCAL_TARG=nfs-utils-ct/support/include/config.h
NFS_B1=(cd nfs-utils-ct; make)
NFS_B2=(mkdir -p ${HLOCAL}/sbin/; cp nfs-utils-ct/utils/mount/mount.nfs ${HLOCAL}/sbin/)
endif

ifeq "${WIN32}" "1"

#all: ../lib/libxml2nt.a  WpdPack
all:  tinyxml libsndfile buildsnd OpenSSL wpcap_oem

#../lib/libxml2nt.a: libxml2-${XML_VER}.tar.gz Makefile
#	rm -fr libxml2-${XML_VER}
#	rm -f libxml2
#	tar -xvzf libxml2-${XML_VER}.tar.gz
#	ln -s libxml2-${XML_VER} libxml2
#	cd libxml2-${XML_VER}; cross-configure.sh --without-zlib --without-threads --without-python
#	-cross-make.sh -C libxml2-${XML_VER}
#	cp libxml2-${XML_VER}/.libs/libxml2.a $@

tinyxml: tinyxml_2_4_2.tar.gz Makefile
	rm -fr tinyxml
	tar -xvzf tinyxml_2_4_2.tar.gz
	(cd tinyxml; cross-make.sh)

libsndfile: libsndfile-${SNDFILE_VER}.tar.gz Makefile
	rm -fr libsndfile-${SNDFILE_VER}
	tar -xvzf libsndfile-${SNDFILE_VER}.tar.gz
	rm -f libsndfile
	ln -s libsndfile-${SNDFILE_VER} libsndfile
	(cd libsndfile-${SNDFILE_VER}; cross-configure.sh --disable-sqlite)
	# We need to include <stdint.h> for newer mingws, line 37 of src/sfconfig.h
	(cd libsndfile; sed "37i\\${n}#include <stdint.h>" < src/sfconfig.h > /tmp/lsc.h; mv /tmp/lsc.h src/sfconfig.h)

buildsnd:
	(cd libsndfile-${SNDFILE_VER}; cross-make.sh)
	-mv libsndfile-${SNDFILE_VER}/src/.libs/libsndfile.dll.a libsndfile-${SNDFILE_VER}/src/.libs/libsndfile.a

# WinPcap developers pack.
#WpdPack:  wpdpack_3_1_beta4.zip
#	unzip wpdpack_3_1_beta4.zip
#	cd WpdPack/Include; ln -s Packet32.h packet32.h; ln -s Devioctl.h devioctl.h
#	cp misc/npf_2k.sys misc/npf_xp.sys ${PROG_HOME}/server/

OpenSSL: openssl-${SSLVER}.tar.gz crossssl fixbat.sed fixmak.sed Makefile
	rm -f OpenSSL
	rm -fr openssl-${SSLVER}
	tar -xvzf openssl-${SSLVER}.tar.gz
	ln -s openssl-${SSLVER} OpenSSL
	cp crossssl fixbat.sed fixmak.sed OpenSSL/
	(cd OpenSSL; ./Configure mingw; ./crossssl)
	cp OpenSSL/libssl32.dll ../server/
	cp OpenSSL/libeay32.dll ../server/
else

ifeq "${PLATFORM}" "ARM"
HAPREADLINE=
HAPSHA256=CONFIG_INTERNAL_SHA256=y
HAPCFLAGS=CFLAGS=" -MMD -O2 -Wall -g -I${PROG_HOME}/3plibs/OpenSSL-Install/include" \
           LDFLAGS=" -L${PROG_HOME}/3plibs/OpenSSL-Install/lib"
CCFGARGS=--build=i586-pc-linux-gnu --host=${GCCPREFIX}
CROSSENV = export PATH=${PATH}:${ARM_TC_BIN}; \
           export CC=${CC}; \
           export CCC=${CCC}; \
           export CXX=${CCC}; \
           export LD=${LD}; \
           export AR=${AR}; \
           export AS=${AS}; \
           export NM=${NM}; \
           export STRIP=${STRIP}; \
           export RANLIB=${RANLIB};

endif


# Build each of these..our dependencies might not notice changes
# to the projects' source code.
.PHONY: pkg_local
pkg_local: libnl/Makefile iw/Makefile iptables/config.h ${NFS_LOCAL_TARG} \
            iproute2/Config hostap/hostapd/.config hostap/wpa_supplicant/.config
	rm -fr ${HLOCAL}
	mkdir -p  ${HLOCAL}/sbin/
	mkdir -p  ${HLOCAL}/bin/dbus
	mkdir -p  ${HLOCAL}/bin/systemd
	${NFS_B1}
	${NFS_B2}
	(cd libnl; ${CROSSENV} make -j4)
	(cd libnl; ${CROSSENV} make install)
	(cd iw; rm -f *.o; rm -f iw)
	(cd iw; V=1 CFLAGS="-O2 -g -I${HOME}/tmp/local/include -I${HLOCAL}/include" PREFIX=${HLOCAL}/ PKG_CONFIG_PATH=${HLOCAL}/lib/pkgconfig ${CROSSENV} make)
	(cd iw; V=1 CFLAGS="-O2 -g -I${HOME}/tmp/local/include -I${HLOCAL}/include" PREFIX=${HLOCAL}/ PKG_CONFIG_PATH=${HLOCAL}/lib/pkgconfig ${CROSSENV} make install)
	(cd iptables; ${CROSSENV} make -j4);
	(cd iptables; ${CROSSENV} make install);
	(cd iproute2; ${CROSSENV} make);
	cp iproute2/ip/ip ${HLOCAL}/sbin/
	cp iproute2/tc/tc ${HLOCAL}/sbin/
	(cd hostap/src; ${CROSSENV} make clean)
	(cd hostap/hostapd; ${CROSSENV} make clean)
	(cd hostap/hostapd; PROG_HOME=${PROG_HOME} V=1 ${HAPSHA256} ${HAPCFLAGS} ${CROSSENV} make; cp hostapd hostapd_cli ${HLOCAL}/bin)
	(cd hostap/src; ${CROSSENV} make clean)
	(cd hostap/wpa_supplicant; ${CROSSENV} make clean)
	(cd hostap/wpa_supplicant; ${HAPREADLINE} PROG_HOME=${PROG_HOME} V=1 ${HAPSHA256} ${HAPCFLAGS} ${CROSSENV} make)
	(cd hostap/wpa_supplicant; DESTDIR=${HLOCAL} LIBDIR=lib BINDIR=bin ${CROSSENV} make install)
	(cd vsftpd-2.3.4 && make && cp vsftpd ct-* ${HLOCAL}/sbin/)

iptables/autogen.sh:
	@echo "You need to clone iptables:"
	@echo "cd 3plibs; git clone dmz2.candelatech.com:/pub/scm/iptables.ct iptables; cd -"
	false

iptables/configure: iptables/autogen.sh Makefile
	(cd iptables; ${CROSSENV} ./autogen.sh)
	touch iptables/configure

iptables/config.h: iptables/configure
	(cd iptables; ${CROSSENV} ./configure ${CCFGARGS} --enable-static --prefix=${HLOCAL})
	touch iptables/config.h

libnl/autogen.sh:
	@echo "You need to clone libnl:"
	@echo "read/write:   cd 3plibs; git clone git at github.com:greearb/libnl-ct.git libnl; cd -"
	@echo "read/only:  cd 3plibs; git clone git://github.com/greearb/libnl-ct.git libnl; cd -"
	false

nfs-utils-ct/autogen.sh:
	@echo "You need to clone nfs-utils-ct:"
	@echo "read/write:  cd 3plibs; git clone git at github.com:greearb/nfs-utils-ct.git; cd -"
	@echo "read/only:   cd 3plibs; git clone git://github.com/greearb/nfs-utils-ct.git; cd -"
	false

nfs-utils-ct/configure: nfs-utils-ct/autogen.sh Makefile
	(cd nfs-utils-ct; ${CROSSENV} ./autogen.sh)
	touch nfs-utils-ct/configure

nfs-utils-ct/support/include/config.h: nfs-utils-ct/configure
	(cd nfs-utils-ct; ${CROSSENV} ./configure ${CCFGARGS} --enable-ipv6)
	touch nfs-utils-ct/support/include/config.h

iw/Makefile:
	@echo "You need to clone iw:"
	@echo "read/write:  cd 3plibs; git clone git at github.com:greearb/iw-ct.git iw; cd -"
	@echo "read/only:   cd 3plibs; git clone git://github.com/greearb/iw-ct.git iw; cd -"
	false

libnl/configure: libnl/autogen.sh libnl/configure.in Makefile
	-(cd libnl; make distclean)
	(cd libnl; ${CROSSENV} ./autogen.sh)
	touch libnl/configure

libnl/Makefile: libnl/configure
	(cd libnl; CPPFLAGS="-O2 -g -I${HOME}/tmp/local/include" ${CROSSENV} \
          ./configure ${CCFGARGS} --disable-python --prefix=${HLOCAL})
	touch libnl/Makefile

hostap:
	@echo "You need to clone hostap:"
	@echo "read/write: cd 3plibs; git clone git at github.com:greearb/hostap-ct.git hostap; cd -"
	@echo "read/only: cd 3plibs; git clone git://github.com/greearb/hostap-ct.git hostap; cd -"
	false

ifeq "${PLATFORM}" "AMD64"
hostap/hostapd/.config: hostap hostapd-64.config
	cp hostapd-64.config hostap/hostapd/.config
	(cd hostap/src; make clean)
	(cd hostap/hostapd; make clean)

hostap/wpa_supplicant/.config: hostap wpa_supplicant-64.config
	cp wpa_supplicant-64.config hostap/wpa_supplicant/.config
	(cd hostap/src; make clean)
	(cd hostap/wpa_supplicant; make clean)
else
#32-bit versions
hostap/hostapd/.config: hostap hostapd.config
	cp hostapd.config hostap/hostapd/.config
	(cd hostap/src; ${CROSSENV} make clean)
	(cd hostap/hostapd; ${CROSSENV} make clean)

hostap/wpa_supplicant/.config: hostap wpa_supplicant.config
	cp wpa_supplicant.config hostap/wpa_supplicant/.config
	(cd hostap/src; ${CROSSENV} make clean)
	(cd hostap/wpa_supplicant; ${CROSSENV} make clean)
endif


iproute2/configure:
	@echo "You need to clone iproute2:"
	@echo "# READ ONLY: "
	@echo "cd 3plibs; git clone git://github.com/greearb/iproute2-ct.git iproute2; cd -"
	@echo "# READ/WRITE (Ben Only):"
	@echo "cd 3plibs; git clone git at github.com:greearb/iproute2-ct.git iproute2; cd -"
	false

iproute2/Config: iproute2/configure Makefile
	(cd iproute2; ${CROSSENV} ./configure ${CCFGARGS})

radvd-${RADVD_VER}/configure:  Makefile
	(cd radvd-${RADVD_VER}; autoheader; autoconf)
	touch radvd-${RADVD_VER}/configure

radvd-${RADVD_VER}/Makefile: radvd-${RADVD_VER}/configure
	(cd radvd-${RADVD_VER}; ./configure ${CCFGARGS} )

radvd: radvd-${RADVD_VER}/Makefile radvd-${RADVD_VER}/*.c radvd-${RADVD_VER}/*.h
	(cd radvd-${RADVD_VER}; make; cp radvd ../../server/lfradvd)

tinyxml: tinyxml_2_4_2.tar.gz Makefile
	rm -fr tinyxml
	tar -xvzf tinyxml_2_4_2.tar.gz
	(cd tinyxml; ${CROSSENV} make)

libsndfile: libsndfile-${SNDFILE_VER}.tar.gz Makefile
	rm -fr libsndfile-${SNDFILE_VER}
	tar -xvzf libsndfile-${SNDFILE_VER}.tar.gz
	rm -f libsndfile
	ln -s libsndfile-${SNDFILE_VER} libsndfile
	cd libsndfile-${SNDFILE_VER}; ${CROSSENV} ./configure ${CCFGARGS} --disable-flac; make


ifeq "${PLATFORM}" "ARM"

all: pcap tinyxml OpenSSL libsndfile pkg_local

OpenSSL: openssl-${SSLVER}.tar.gz Makefile zlib
	@echo "Compiling OpenSSL for ARM"
	rm -f OpenSSL
	rm -fr openssl-${SSLVER}
	tar -xvzf openssl-${SSLVER}.tar.gz
	ln -s openssl-${SSLVER} OpenSSL
	(cd OpenSSL; \
	  ${CROSSENV} \
           ./Configure ${SSLCFGARM} --openssldir=${PROG_HOME}/3plibs/OpenSSL-Install; \
	  cp Makefile Makefile.orig; \
	  sed 's/gcc/arm-unknown-linux-gnu-gcc/g' < Makefile > Makefile.tmp && cp Makefile.tmp Makefile; \
	  sed 's/=ar/=arm-unknown-linux-gnu-ar/g' < Makefile > Makefile.tmp && cp Makefile.tmp Makefile; \
	  sed 's/\/usr\/bin\/ranlib/arm-unknown-linux-gnu-ranlib/g' < Makefile > Makefile.tmp && cp Makefile.tmp Makefile; \
           make -j2; make install; \
         )

zlib: zlib-${ZVER}.tar.bz2 Makefile
	@echo "Compiling zlib for ARM"
	rm -f zlib
	rm -fr zlib-${ZVER}
	tar -xvjf zlib-${ZVER}.tar.bz2
	ln -s zlib-${ZVER} zlib
	(cd zlib; \
	  ${CROSSENV} \
	  export prefix=${PROG_HOME}; \
           ./configure; \
           make -j2; make install; \
         )

pcap: libpcap-${PVER}.tar.gz Makefile
	@echo "Compiling libpcap for ARM"
	rm -f pcap
	rm -fr libpcap-1.2.0
	tar -xvzf libpcap-${PVER}.tar.gz
	ln -s libpcap-1.2.0 pcap
	(cd pcap; \
	  ${CROSSENV} \
	  export CFLAGS="-DETHTOOL_GUFO=0x21 -DETHTOOL_GGSO=0x23"; \
           ./configure --with-pcap=linux --prefix=${PROG_HOME} --build=i586-pc-linux-gnu --host=${GCCPREFIX} ; \
           make -j2; make install; \
         )

else

ifeq "${PLATFORM}" "SOLARIS"
all: tinyxml libsndfile OpenSSL wpcap_oem
else
all: tinyxml libsndfile OpenSSL wpcap_oem radvd pkg_local
endif


#../lib/libxml2nt.a: libxml2-${XML_VER}.tar.gz Makefile
#	rm -fr libxml2-${XML_VER}
#	tar -xvzf libxml2-${XML_VER}.tar.gz
#	rm -f libxml2
#	ln -s libxml2-${XML_VER} libxml2
#	cd libxml2-${XML_VER}; ./configure --without-threads
#	make -j2 -C libxml2-${XML_VER}
#	cp libxml2-${XML_VER}/.libs/libxml2.a $@
ifeq "${PLATFORM}" "SOLARIS"
ifeq "${PFARCH}" "SPARC"
OpenSSL: openssl-${SSLVER}.tar.gz
	rm -f OpenSSL
	rm -fr openssl-${SSLVER}
	tar -xvzf openssl-${SSLVER}.tar.gz
	ln -s openssl-${SSLVER} OpenSSL
	(cd OpenSSL; ./Configure solaris-sparcv7-gcc --openssldir=${PROG_HOME}/3plibs/OpenSSL-Install; make -j2; make install)
else
OpenSSL: openssl-${SSLVER}.tar.gz
	rm -f OpenSSL
	rm -fr openssl-${SSLVER}
	tar -xvzf openssl-${SSLVER}.tar.gz
	ln -s openssl-${SSLVER} OpenSSL
	(cd OpenSSL; ./Configure solaris-x86-gcc --openssldir=${PROG_HOME}/3plibs/OpenSSL-Install; make -j2; make install)
endif
else
OpenSSL: openssl-${SSLVER}.tar.gz
	@echo "Not building open ssl for this platform."
	touch OpenSSL

#OpenSSL: openssl-${SSLVER}.tar.gz
#	rm -f OpenSSL
#	rm -fr openssl-${SSLVER}
#	tar -xvzf openssl-${SSLVER}.tar.gz
#	ln -s openssl-${SSLVER} OpenSSL
#	(cd OpenSSL; ./config --openssldir=${PROG_HOME}/3plibs/OpenSSL-Install; make -j2; make install)
endif
endif
endif

wpcap_oem: Makefile wpcap_oem405
	rm -f wpcap_oem
	ln -s wpcap_oem405 wpcap_oem

cdrom: purge all


clean:
	rm -fr libxml2-${XML_VER}
	rm -fr openssl-${SSLVER} OpenSSL
	rm -f ../lib/libxml2nt.a
	rm -fr libsndfile-${SNDFILE_VER} libsndfile
	-(cd radvd-${RADVD_VER}; ${CROSSENV} make clean)
	rm  -f radvd-${RADVD_VER}/configure
	rm  -f radvd-${RADVD_VER}/Makefile
	-(cd nfs-utils-ct; ${CROSSENV} make distclean)
	-(cd iproute2;${CROSSENV}  make distclean)
	-(cd iptables; ${CROSSENV} make distclean)
	-(cd iw; ${CROSSENV} make clean)
	-(cd libnl; ${CROSSENV} make distclean)
	-(cd hostap/hostapd; ${CROSSENV} make clean)
	-(cd hostap/wpa_supplicant; ${CROSSENV} make clean)
	rm -fr ${HLOCAL}

purge: clean



-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com




More information about the Hostap mailing list