diff mbox

[APPS/PATCH] cross compilation support

Message ID CAARHBVtTcCE+2xiQBrB43ox9tW=LqNKTMF1LxB933oeYyOFwqg@mail.gmail.com
State New
Headers show

Commit Message

Vincent Hsu May 14, 2014, 7:50 a.m. UTC
On Wed, May 14, 2014 at 12:48 AM, Victor Kamensky <
victor.kamensky@linaro.org> wrote:

> On 13 May 2014 09:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> > On 05/13/2014 08:06 PM, Victor Kamensky wrote:
> >>
> >> Hi Maxim,
> >>
> >> Why do you need to introduce CROSS_COMPILE? If one need to
> >> compile this code in cross compilation mode would not it be
> >> sufficient to be able redefine CC, CFLAGS and such externally.
> >>
> >> Note defining CROSS_COMPILE normally is not sufficient for
> >> user-land app build (unlike kernel). One need to have pointer to
> >> sysroot that contains all libraries, include files, etc.
> >>
> >> IMHO Makefile should be cross compilation friendly, with meaning
> >> that CC, CFLAGS, and other could be defined externally. Don't we
> >> already have OE recipe for ODP, that one does cross compilation
> >> for sure?
> >>
> >> Thanks,
> >> Victor
> >
> > There are number of applications. Each of them uses configure. So that I
> > need to provide --host=arm there somehow.
> > Just setting CC and CFLAGS does not help. So that was the easiest way to
> > call each configure with right options.
>
> And just setting --host is not enough in general cross compilation
> case. Personally unless I see how it could be build under OE,
> any other "cross-compilation" support is useless IMHO.
>
> For this thing to be buildable under OE whole code of odp-apps
> should be restructured, separate recipes for openvpn odp enabled,
> and libpcap odp enabled should be provided, odp patches integrated
> in regular OE in SRC_URI, OE_EXTRA config etc should be
> supplied and so on.
>
> Otherwise, If I want to try to build odp enabled openvpn in cross
> compile mode for my Arndale board with OE image running, what do
> I do? And how proposed below patch will help me? Note both
> openvpn and libpcap can be built under OE without any problem.
>
> Thanks,
> Victor
>
> > Maxim.
> >
> >> On 13 May 2014 08:52, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> >>>
> >>> Hi VIncent,
> >>>
> >>> can you test this patch? Looks like you have openssl and all other req
> >>> installed in cross env.
> >>>
> >>> make CROSS_COMPILE=armeb-linux-gnueabihf
> >>>
> >>> Thanks,
> >>> Maxim.
> >>>
> >>>
> >>> On 05/13/2014 07:51 PM, Maxim Uvarov wrote:
> >>>>
> >>>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> >>>> ---
> >>>>    Makefile         | 4 +++-
> >>>>    libpcap/Makefile | 8 +++++---
> >>>>    openvpn/Makefile | 6 +++---
> >>>>    3 files changed, 11 insertions(+), 7 deletions(-)
> >>>>
> >>>> diff --git a/Makefile b/Makefile
> >>>> index cab82f4..78e9320 100644
> >>>> --- a/Makefile
> >>>> +++ b/Makefile
> >>>> @@ -2,6 +2,8 @@
> >>>>      all: openvpn libpcap
> >>>>    +export $(CROSS_COMPILE)
> >>>> +
> >>>>    libpcap: odp
> >>>>          make -C libpcap ODP_DIR=$(PWD)/odp.git
> >>>>    @@ -12,7 +14,7 @@ odp:
> >>>>          if [ ! -d odp.git ]; \
> >>>>                  then git clone http://git.linaro.org/git/lng/odp.git
> >>>> odp.git; \
> >>>>          fi
> >>>> -       cd odp.git; make libs_install  CFLAGS="-fPIC"
> >>>> +       cd odp.git; make libs_install  CFLAGS="-fPIC"
> >>>> CC=$(CROSS_COMPILE)-gcc
> >>>>      distclean:
> >>>>          rm -rf odp.git
> >>>> diff --git a/libpcap/Makefile b/libpcap/Makefile
> >>>> index 5e47b4a..a00f5b7 100644
> >>>> --- a/libpcap/Makefile
> >>>> +++ b/libpcap/Makefile
> >>>> @@ -15,6 +15,8 @@ WIRESHARK_VERSION=wireshark-1.8.9
> >>>>      ODP_DIR ?= $(PWD)/../odp.git
> >>>>    +HOST ?= `$(CROSS_COMPILE)-gcc -dumpmachine`
> >>>> +
> >>>>    .PHONY: all
> >>>>    all: libpcap tcpdump
> >>>>    @@ -32,7 +34,7 @@ libpcap: get_libpcap
> >>>>          cd $(LIBPCAP_DIR) \
> >>>>          && git checkout $(LIBPCAP_VERSION) \
> >>>>          && git am ../patches/*.patch \
> >>>> -       && ./configure --with-odp=$(ODP_DIR) --libdir=/usr/lib
> >>>> +       && ac_cv_linux_vers=3.2.51 ./configure --with-pcap=linux
> >>>> --with-odp=$(ODP_DIR) --libdir=/usr/lib --host=$(HOST)
> >>>>          $(MAKE) -C $(LIBPCAP_DIR)
> >>>>      .PHONY: get_libpcap
> >>>> @@ -54,7 +56,7 @@ clean_libpcap:
> >>>>    tcpdump: get_tcpdump libpcap
> >>>>          cd $(TCPDUMP_DIR) \
> >>>>          && git checkout $(TCPDUMP_VERSION) \
> >>>> -       && ./configure LIBS="-lrt"
> >>>> +       && ac_cv_linux_vers=3.2.51 ./configure LIBS="-lrt"
> >>>> --host=$(HOST)
> >>>>          $(MAKE) -C $(TCPDUMP_DIR)
> >>>>      .PHONY: get_tcpdump
> >>>> @@ -76,7 +78,7 @@ clean_tcpdump:
> >>>>    wireshark: get_wireshark libpcap
> >>>>          cd $(WIRESHARK_DIR) \
> >>>>          && git checkout $(WIRESHARK_VERSION) \
> >>>> -       && ./autogen.sh && ./configure
> >>>> +       && ./autogen.sh && ./configure --host=$(HOST)
> >>>>          $(MAKE) -C $(WIRESHARK_DIR)
> >>>>      .PHONY: get_wireshark
> >>>> diff --git a/openvpn/Makefile b/openvpn/Makefile
> >>>> index 68e4348..5117490 100644
> >>>> --- a/openvpn/Makefile
> >>>> +++ b/openvpn/Makefile
> >>>> @@ -9,6 +9,8 @@
> OPENVPN_VERSION=cd6555e0159987ef264789f4976053ce2aa5fc20
> >>>>      ODP_DIR ?= $(PWD)/../odp.git
> >>>>    +HOST ?= `$(CROSS_COMPILE)-gcc -dumpmachine`
> >>>> +
> >>>>    .PHONY: all
> >>>>    all: openvpn odp_ipcd
> >>>>    @@ -22,14 +24,12 @@ openvpn:
> >>>>                  git clone $(OPENVPN_REPO) $(OPENVPN_DIR);\
> >>>>          else\
> >>>>                  cd $(OPENVPN_DIR);\
> >>>> -               git fetch --all;\
> >>>>          fi
> >>>> -
> >>>>          cd $(OPENVPN_DIR) \
> >>>>          && git checkout $(OPENVPN_VERSION) \
> >>>>          && git am ../patches/*.patch \
> >>>>          && autoreconf -i -v -f \
> >>>> -       && ./configure
> >>>> +       && ./configure --host=$(HOST) --disable-snappy --disable-lzo
> >>>>          make -C $(OPENVPN_DIR)
> >>>>      .PHONY: clean_openvpn
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> lng-odp mailing list
> >>> lng-odp@lists.linaro.org
> >>> http://lists.linaro.org/mailman/listinfo/lng-odp
> >
> >
>

My environment is not a stand alone cross compilation environment like OE.
It needs to set the ssl headers and libs path when configure the openvpn.
Besides, openvpn seems only accept "host=arm-linux". I must do following
changes, but it's redundant for stand alone build environment.


make CC=armeb-linux-gnueabihf-gcc

or maybe we can set $CC when export $ARCH and $CORSS_COMPILE.
diff mbox

Patch

diff --git a/openvpn/Makefile b/openvpn/Makefile
index 5117490..4169817 100644
--- a/openvpn/Makefile
+++ b/openvpn/Makefile
@@ -29,7 +29,7 @@  openvpn:
        && git checkout $(OPENVPN_VERSION) \
        && git am ../patches/*.patch \
        && autoreconf -i -v -f \
-       && ./configure --host=$(HOST) --disable-snappy --disable-lzo
+       && OPENSSL_SSL_CFLAGS="-I/home/vincent/openssl-1.0.1g/include"
OPENSSL_SSL_LIBS="-L/home/vincent/openssl-1.0.1g -lssl -ldl" ./configure
--host=arm-linux --disable-snappy --disable-lzo
        make -C $(OPENVPN_DIR)

If "--host=" has no argument, It will use x86 by default. And autoconf will
automatically add gcc to the end of
$(host) to be cross-compiler name.  If we do following change, we won't
force to use gcc.

diff --git a/Makefile b/Makefile
index 78e9320..1b720a6 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@  odp:
        if [ ! -d odp.git ]; \
                then git clone http://git.linaro.org/git/lng/odp.gitodp.git; \
        fi
-       cd odp.git; make libs_install  CFLAGS="-fPIC"
CC=$(CROSS_COMPILE)-gcc
+       cd odp.git; make libs_install  CFLAGS="-fPIC"

 distclean:
        rm -rf odp.git
diff --git a/libpcap/Makefile b/libpcap/Makefile
index a00f5b7..4781963 100644
--- a/libpcap/Makefile
+++ b/libpcap/Makefile
@@ -15,7 +15,7 @@  WIRESHARK_VERSION=wireshark-1.8.9

 ODP_DIR ?= $(PWD)/../odp.git

-HOST ?= `$(CROSS_COMPILE)-gcc -dumpmachine`
+HOST ?= `$(CC) -dumpmachine`

 .PHONY: all
 all: libpcap tcpdump
diff --git a/openvpn/Makefile b/openvpn/Makefile
index 5117490..15ac3a1 100644
--- a/openvpn/Makefile
+++ b/openvpn/Makefile
@@ -9,7 +9,7 @@  OPENVPN_VERSION=cd6555e0159987ef264789f4976053ce2aa5fc20

 ODP_DIR ?= $(PWD)/../odp.git

-HOST ?= `$(CROSS_COMPILE)-gcc -dumpmachine`
+HOST ?= `$(CC) -dumpmachine`

 .PHONY: all
 all: openvpn odp_ipcd