Trouble building OpenOCD (0.5.0) for Mac OS X Leopard (PPC)

I’m having trouble with compiling openocd-0.5.0 on Mac OS X.

I’ve switched to gcc-4.2

libusb and libftdi are already built.

Here’s my build-commands (shortened for better overview):

    ./configure --enable-ft2232_libftdi --enable-usbprog
    make install DESTDIR="$INSTALLDIR/openocd"

First problem:

src/jtag/drivers/usbprog.c wouldn’t compile (unless you add --disable-werror), I’ve submitted a bug report marked ‘trivial’.

Solution: Remove line #320, below line 303, add:

ScanProc f;

Above line 303, add:

typedef void (*ScanProc)(struct usbprog_jtag *usbprog_jtag, char * buffer, int size);

After that, it starts compiling, but stops here…

libtool: link: ranlib .libs/libopenocd.a
libtool: link: rm -fr .libs/libopenocd.lax .libs/libopenocd.lax
libtool: link: ( cd ".libs" && rm -f "libopenocd.la" && ln -s "../libopenocd.la" "libopenocd.la" )
gcc -m32 -std=gnu99 -DHAVE_CONFIG_H -I. -I../../src -I..  -I../../src -I../src -DPKGDATADIR=\"/usr/local/share/openocd\" -DPKGLIBDIR=\"/usr/local/lib/openocd\" -I../../jimtcl -I../jimtcl   -g -O2 -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o ../../src/main.c
mv -f .deps/main.Tpo .deps/main.Po
make[3]: *** No rule to make target `../jimtcl/libjim.a', needed by `openocd'.  Stop.
make[2]: *** [install-recursive] Error 1
make[1]: *** [install] Error 2
make: *** [install-recursive] Error 1

I’ve tried everything I could think of.

–with-jim-tcl= … (found it on the net, but it does not work; looking at configure, I found out that it’s actually not present. Please someone implement this.)

LD_LIBRARY_PATH= … (Never got this to work with anything else anyway)

ln -s …

(also tried changing directory, etc…)

As I am creating a distribution, I’d really like having a build directory, which I can remove using a rm -R (I do this for all my other builds, such as binutils, gcc, libusb, libftdi, etc, etc.

Eg. I usually do it this way…

cd openocd-0.5.0
mkdir build
cd build
../configure ... 
make ...

But as the above wouldn’t work for me, I tried building in the openocd-0.5.0 ‘parent directory’; it didn’t work for me.

I’m really stuck. I could successfully build openocd-0.4.0, and I had it working once, but after a system re-installation, I had trouble building it again, so I decided to move to openocd-0.5.0, however jimtcl is giving me so much trouble; I don’t know how to get it compiling.

I have built it with no trouble on OS X Lion. However, mine is an Intel machine. I used GCC 4.4.6 from MacPorts.

I am building in an external build directory - i.e.

cd $builddir

$pathtosource/configure … etc.

The jimtcl subdirectory configure script is a tcl script rather than the usual configure bash script and seemed problematic. I needed to put “–enable-ft2232_libftdi=yes” on the top level configure line to prevent it barfing - this because the full top level configure options get passed down, and jimtcl does not recognise this one. It does not seem to honour the --disable-option-checking but does ignore unrecognised options with an “=” in them.

philipnye:
I am building in an external build directory - i.e.

cd $builddir

$pathtosource/configure … etc.

Thank you very much for your reply; I really appreciate it. :slight_smile:

I tried placing my build directory outside the source directory…

/Users/toolchain/openocd/

source/

Build/

archives/

I then cd to my build directory and issue the following short configure line:

cd /Users/toolchain/openocd/Build/openocd-0.5.0
/Users/toolchain/openocd/source/openocd-0.5.0/configure

And had the following result:

config.status: executing libtool commands
=== configuring in jimtcl (/Users/toolchain/openocd/openocd-0.5.0/jimtcl)
configure: running /bin/sh /Users/toolchain/openocd/source/openocd-0.5.0/jimtcl/configure.gnu --disable-option-checking '--prefix=/usr/local'  --cache-file=/dev/null --srcdir=/Users/toolchain/openocd/source/openocd-0.5.0/jimtcl
/bin/sh: ..//Users/toolchain/openocd/source/openocd-0.5.0/jimtcl/configure: No such file or directory
configure: error: /Users/toolchain/openocd/source/openocd-0.5.0/jimtcl/configure.gnu failed for jimtcl

This is the configure.gnu script:

#!/bin/sh
$SHELL ..//Users/toolchain/openocd/source/openocd-0.5.0/jimtcl/configure --with-jim-ext=nvp --disable-lineedit --disable-install-jim "$@"

(there’s no newline at EOF)

I wonder why it thinks my path is relative. I started it with a slash.

(My version of make is 3.81)

… Back to basics…

I tried this very simple configure line…

$ cd /Users/toolchain/openocd/source/openocd-0.5.0
$ ./configure

And now my result is different…

config.status: executing libtool commands
=== configuring in jimtcl (/Users/toolchain/openocd/source/openocd-0.5.0/jimtcl)
configure: running /bin/sh ./configure.gnu --disable-option-checking '--prefix=/usr/local'  --cache-file=/dev/null --srcdir=.
No installed jimsh or tclsh, building local bootstrap jimsh0
Host System...powerpc-apple-darwin9.8.0
Build System...powerpc-apple-darwin9.8.0

-It appears that openocd is not supposed to be built outside the source directory. :frowning:

The jimtcl subdirectory configure script is a tcl script rather than the usual configure bash script and seemed problematic. I needed to put “–enable-ft2232_libftdi=yes” on the top level configure line to prevent it barfing - this because the full top level configure options get passed down, and jimtcl does not recognise this one. It does not seem to honour the --disable-option-checking but does ignore unrecognised options with an “=” in them.

By top level configure line; do you mean the configure-line I issue ?

I’m currently trying to build in the source-directory, to see if it goes well.

davshop:
… Back to basics…

I tried this very simple configure line…

$ cd /Users/toolchain/openocd/source/openocd-0.5.0

$ ./configure

This actually works quite well.

The procedure is…

Build libusb 0.1.12

Buid libftdi 0.19

Then cd into the openocd source directory, issue…

./configure --enable-ft2232_libftdi --enable-usbprog && make && make install

Thanks Philip; without your hints, I would still have been stuck. :slight_smile:

This most likely applies to other platforms than Mac OS X Leopard, so if you’re having trouble and are building outside the source directory, try building inside the source directory… :wink:

A shame, that it has to be like that, but I can live with it.