Xiaofan Chen wrote:
> If you come out with a simple instruction to cross compile
> openocd (using libusb-1.0, libusb-win32, libftdi) with the
> help of pkg-config under Linux, that would be helpful.
> Thanks in advance.

I don't know libusb-win32 at all well - does it also provide a .pc
file, or no?

libftdi uses cmake, where cross-compilation is complicated. :\


Unfortunately, as I have ranted about several times before,
including several times during review of the change that made
OpenOCD use libusb-1.0, OpenOCD configure.ac does not use the
PKG_CHECK_MODULES autoconf macros or pkg-config at all. Sad face.

I had managed to forget exactly how bad the libusb-1.0 situation
was in OpenOCD.


Here's an example for urjtag, which uses the pkg-config macros:

( export WD=/tmp/x-urjtag;
  export CROSS=i686-mingw32;
  export PKG_CONFIG_LIBDIR="${WD}"/lib/pkgconfig;
  mkdir -p "${WD}"/source && \
  cd "${WD}"/source && \
  git clone git://git.libusb.org/libusb.git && \
  git clone git://urjtag.git.sourceforge.net/gitroot/urjtag/urjtag && \
  cd libusb && \
  ./autogen.sh --prefix="${WD}" --host=$CROSS --disable-debug-log && \
  make install && \
  cd ../urjtag/urjtag && \
  ./autogen.sh --prefix="${WD}" --host=$CROSS --disable-python \
    --without-readline --with-libusb=1.0 --without-libftdi && \
  make install && \
  ls -l "${WD}"/*
)

..which outputs at the end:

/tmp/x-urjtag/bin:
total 4216
-rwxr-xr-x 1 stuge stuge 2009931 Oct 13 01:44 bsdl2jtag.exe
-rwxr-xr-x 1 stuge stuge 2020824 Oct 13 01:44 jtag.exe
-rwxr-xr-x 1 stuge stuge  282233 Oct 13 01:47 libusb-1.0.dll

/tmp/x-urjtag/include:
total 0
drwxr-xr-x 2 stuge stuge  60 Oct 13 01:47 libusb-1.0
drwxr-xr-x 2 stuge stuge 720 Oct 13 01:48 urjtag

/tmp/x-urjtag/lib:
total 2880
-rw-r--r-- 1 stuge stuge 2518538 Oct 13 01:48 liburjtag.a
-rwxr-xr-x 1 stuge stuge     983 Oct 13 01:48 liburjtag.la
-rw-r--r-- 1 stuge stuge  285212 Oct 13 01:47 libusb-1.0.a
-rwxr-xr-x 1 stuge stuge  132260 Oct 13 01:47 libusb-1.0.dll.a
-rwxr-xr-x 1 stuge stuge     916 Oct 13 01:47 libusb-1.0.la
drwxr-xr-x 2 stuge stuge      80 Oct 13 01:48 pkgconfig

/tmp/x-urjtag/share:
total 0
drwxr-xr-x  3 stuge stuge  60 Oct 13 01:37 man
drwxr-xr-x 26 stuge stuge 540 Oct 13 01:48 urjtag

/tmp/x-urjtag/source:
total 0
drwxr-xr-x 9 stuge stuge 860 Oct 13 01:47 libusb
drwxr-xr-x 5 stuge stuge 100 Oct 13 01:36 urjtag


--disable-python and --without-libftdi were needed for urjtag,
because I have neither Python nor libftdi for Windows, and the
urjtag configure.ac tries very hard to find those optional
dependencies. In the case of libftdi it leads to the discovery of
libftdi-config from the libftdi-0.16 package on my build system.


> As for MinGW/MSys, there is a package manager as part of
> the installer (mingw-get) but it does not have the functionality
> of pkg-config.

Right, and pkg-config is also not related to the package manager, the
point is that using pkg-config allows to build and install packages
in a way that does not create unneccessary conflicts with what the
package manager does. The example above shows a process that is
completely contained in whatever subdirectory one wants, which also
has the nice side-effect that everything can be done by the current
user.


> You can manipulate CFLAGS and LDFLAGS if you do not want to copy
> the header and lib files to the default directories. But I consider
> that as even more problematic than copying the files.

The whole point of pkg-config is to not have to deal with them.

I hope the example works as well on your system as it does on mine.


> Copying files is not feasible for big project with many
> dependencies, but for openocd, it is really not that bad.

It is simply unneccessary, and on top I think it's poor practise,
when tools like pkg-config can handle it. Of course that requires
using them, which OpenOCD doesn't do yet. Again, sad face.


//Peter

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to