If you dare to build OpenOCD from svn trunk and lucky to have a USB JTAG adapter there is a good chance you will see something like
/bin/sh ../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -I/root/Distr/ftd2/libftd2xx0.4.16 -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -o openocd main.o libopenocd.la -ldl /root/Distr/ftd2/libftd2xx0.4.16/static_lib/libftd2xx.a.0.4.16 -lpthread
libtool: link: gcc -std=gnu99 -g -O2 -I/root/Distr/ftd2/libftd2xx0.4.16 -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -o .libs/openocd main.o /root/Distr/ftd2/libftd2xx0.4.16/static_lib/libftd2xx.a.0.4.16 ./.libs/libopenocd.so -ldl -lpthread
./.libs/libopenocd.so: undefined reference to `FT_GetLatencyTimer'
./.libs/libopenocd.so: undefined reference to `FT_Close'
./.libs/libopenocd.so: undefined reference to `FT_SetBitMode'
./.libs/libopenocd.so: undefined reference to `FT_GetDeviceInfo'
./.libs/libopenocd.so: undefined reference to `FT_OpenEx'
./.libs/libopenocd.so: undefined reference to `FT_Read'
./.libs/libopenocd.so: undefined reference to `FT_SetTimeouts'
./.libs/libopenocd.so: undefined reference to `FT_SetVIDPID'
./.libs/libopenocd.so: undefined reference to `FT_Write'
./.libs/libopenocd.so: undefined reference to `FT_SetLatencyTimer'
./.libs/libopenocd.so: undefined reference to `FT_ListDevices'
./.libs/libopenocd.so: undefined reference to `FT_Purge'
Here is how to fix that:
If you carefully look at the first few lines of the log you will see that the cause of the problem is the libtool output. If you manually swap ./.libs/libopenocd.so and libftd2xx.a.0.4.16 in the command it will work just fine. I spent some time trying to fix the faulty libtool script that comes with openocd, but finelly realized that I’m too lazy to understand the broken logic of almore 9000 of shell script code and implemented possibly the dumbest patch I had ever done. So to fix the problem open libtool script in the OpenOCD source tree (NOT the one in /usr/lib) and go somewhere neare line 8044. You will find lines like these:
*) new_libs="$new_libs $deplib" ;;
esac
done
compile_deplibs="$new_libs"
compile_command="$compile_command $compile_deplibs"
finalize_command="$finalize_command $finalize_deplibs"
Right after these lines add this code:
if test x"$compile_command" = x"gcc -std=gnu99 -g -O2 -I/root/Distr/ftd2/libftd2xx0.4.16 -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -o @OUTPUT@ main.o /root/Distr/ftd2/libftd2xx0.4.16/static_lib/libftd2xx.a.0.4.16 ./.libs/libopenocd.so -ldl -lpthread"; then
compile_command='gcc -std=gnu99 -g -O2 -I/root/Distr/ftd2/libftd2xx0.4.16 -Wall-Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -o @OUTPUT@ main.o ./.libs/libopenocd.so /root/Distr/ftd2/libftd2xx0.4.16/static_lib/libftd2xx.a.0.4.16 -ldl -lpthread'
fi
… or something like the lines above that adequately represent your sources layout and versions. Run make after this mod and everything should compile just fine. That was dumb. But it worked!!
Oh, yeah, one more thing. If you will see also this error:
openocd.texi:12: @include `version.texi': No such file or directory.
then just create file doc/version.texi with this content:
@set UPDATED 20 January 2009
@set UPDATED-MONTH January 2009
@set EDITION 0.1.0
@set VERSION 0.1.0
Ufff… I hope that’s it unless they will implement more bugs in this outstanding piece of software.