This file explains the procedure to cross compile gst-jpeg sources for ARM architecture.

---------------------------------------------------------------------------------
                            Pre-Reqs for ARM libs
---------------------------------------------------------------------------------

1. The following debian packages are required dependencies for the libgstjpeg.so binary.
These can be obtained from any standard distribution or can also be self-built.
NVIDIA has used the Debian package files from Ubuntu 12.04 (Precise) file system repository for armhf.
(Downloaded from http://launchpad.net/ubuntu/)
The packages listed below need to be downloaded onto the host machine where you will be cross-compiling the source code. They are needed for use in the compilation.

Details of the required packages with version info is given below:

  a. libffi6_3.0.11~rc1-5_armhf.deb
     Package: libffi6, Source: ffi6, Version: 3.0.11~rc1-5, Architecture: armhf
  b. libffi-dev_3.0.11~rc1-5_armhf.deb
     Package: libffi-dev, Source: ffi-dev, Version: 3.0.11~rc1-5, Architecture: armhf
  c. libglib2.0-0_2.32.3-0ubuntu1_armhf.deb
     Package: libglib2.0-0, Source: glib2.0, Version: 2.32.3-0ubuntu1, Architecture: armhf
  d. libglib2.0-dev_2.32.1-0ubuntu2_armhf.deb
     Package: libglib2.0-dev, Source: glib2.0, Version: 2.32.1-0ubuntu2, Architecture: armhf
  e. libgstreamer0.10-0_0.10.36-1ubuntu1_armhf.deb
     Package: libgstreamer0.10-0, Source: gstreamer0.10, Version: 0.10.36-1ubuntu1, Architecture: armhf
  f. libgstreamer0.10-dev_0.10.36-1ubuntu1_armhf.deb
     Package: libgstreamer0.10-dev, Source: gstreamer0.10, Version: 0.10.36-1ubuntu1, Architecture: armhf
  g. libgstreamer-plugins-base0.10-0_0.10.36-1_armhf.deb
     Package: libgstreamer-plugins-base0.10-0, Source: gst-plugins-base0.10, Version: 0.10.36-1, Architecture: armhf
  h. libgstreamer-plugins-base0.10-dev_0.10.36-1_armhf.deb
     Package: libgstreamer-plugins-base0.10-dev, Source: gst-plugins-base0.10, Version: 0.10.36-1, Architecture: armhf
  i. libpcre3_8.12-4_armhf.deb
     Package: libpcre3, Source: pcre3, Version: 8.12-4, Architecture: armhf
  j. libpcre3-dev_8.12-4_armhf.deb
     Package: libpcre3-dev, Source: pcre3, Version: 8.12-4, Architecture: armhf
  k. libxml2_2.7.8.dfsg-5.1ubuntu4.1_armhf.deb
     Package: libxml2, Source: xml2, Version: 2.7.8.dfsg-5.1ubuntu4.1, Architecture: armhf
  l. libxml2-dev_2.7.8.dfsg-5.1ubuntu4.1_armhf.deb
     Package: libxml2-dev, Source: xml2, Version: 2.7.8.dfsg-5.1ubuntu4.1, Architecture: armhf
  m. zlib1g_1.2.3.4.dfsg-3ubuntu4_armhf.deb
     Package: zlib1g, Source: zlib, Version: 1.2.3.4.dfsg-3ubuntu4, Architecture: armhf
  n. zlib1g-dev_1.2.3.4.dfsg-3ubuntu4_armhf.deb
     Package:  zlib1g-dev, Source: zlib, Version: 1.2.3.4.dfsg-3ubuntu4, Architecture: armhf

2. Pre-Reqs for host
   Install autotools-dev, autoconf, and autopoint as below:

sudo apt-get install autotools-dev
sudo apt-get install autoconf
sudo apt-get install autopoint

---------------------------------------------------------------------------------
                                    Steps to build:
---------------------------------------------------------------------------------

1. Extract the gst-jpeg source and included headers

        tar -xjvf gstjpeg_src.tbz2
        cd gstjpeg_src

2. Create a common directory to store the above deb files
   and copy all the .deb files into it

        mkdir myDebDir
        cp *.deb myDebDir

3. Extract each deb package listed in 'step 2' above into the myDebdir/.debs directory

        cd myDebsDir
        extract each of the files using the command: dpkg --extract <name-of-pkg> .debs

4. /usr/lib/libglib-2.0.so is a symlink into the absolute /lib directory; fix this manually

        rm .debs/usr/lib/libglib-2.0.so
        ln -s .debs/lib/libglib-2.0.so.0.2600.0 .debs/usr/lib/libglib-2.0.so

5. fix up the .pc and .la files so that they reference into this directory

        find .debs -name "*.pc" | xargs sed -i -e "s@^prefix=\(.*\)@prefix=$PWD/\.debs\1@"
        find .debs -name "*.la" | xargs sed -i -e "s@^libdir='\(.*\)@libdir='$PWD/\.debs\1@"

6. Go to gstjpeg_src directory

        cd ../gstjpeg_src

7. Generate configure from autoconf

        export NOCONFIGURE=true
        ./autogen.sh

8. Export your cross compiler tools with the following enviroment vars:

        export CC="<your ARM toolchain's cc (path + exec name)>"
        export CPP="<your ARM toolchain's ccp (path + exec name)>"
        export NM="<your ARM toolchain's nm (path + exec name)>"
        export CFLAGS="-I<path/to/nv_headers/folder/provided/in/the/package> -I</path-to-myDebsDir/.debs/usr/include/gstreamer-0.10>"


9. Run configure to build the Makefiles

        export CONF_PARAMS="--host=arm-linux --disable-silent-rules --with-pkg-config-path=<path to myDebDir>/.debs/usr/lib/pkgconfig"
        ./configure $CONF_PARAMS

10. Build gstjpeg_src source to create libgstjpeg.so

        make

