xcode-select --install
brew install autoconf automake pkg-config libtool texinfo
下载代码:
git clone --recursive https://github.com/riscv/riscv-openocd.git
进入到riscv-openocd目录下,执行:
./bootstrap
./configure
make
make install
在执行./bootstrap的时候可能会报warning
+ aclocal --warnings=all
+ glibtoolize --automake --copy
+ autoconf --warnings=all
+ autoheader --warnings=all
+ automake --warnings=all --gnu --add-missing --copy
Setting up submodules
Generating build system...
configure.ac:38: warning: The macro `AC_PROG_CC_C99' is obsolete.
configure.ac:38: You should run autoupdate.
./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
configure.ac:38: the top level
Bootstrap complete. Quick build instructions:
./configure ....
这里提示configure.ac第38行有告警。开始以为是当前目录下的configure.ac文件有不兼容的问题。其实注释掉openocd-code/src/jtag/drivers/libjaylink/configure.ac.文件的第38行就可以了。
修改后重新执行,log显示不再有告警:
+ aclocal --warnings=all
+ glibtoolize --automake --copy
+ autoconf --warnings=all
+ autoheader --warnings=all
+ automake --warnings=all --gnu --add-missing --copy
Setting up submodules
Generating build system...
Bootstrap complete. Quick build instructions:
./configure ....
brew install texinfo 后执行
export PATH=“/opt/homebrew/opt/texinfo/bin:$PATH”
系统目录下/usr/bin/libtool版本较旧,我的是2.4.6
用brew install libtool后会安装新的libtool,版本2.4.7,需要用环境变量执行新安装的目录。
执行下面命令可以看到安装后的信息。
> brew info libtool
...
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
注意添加path后立即执行make是不生效的。原因是在config阶段会copy libtool到当前目录下,后面make阶段调用的都是当前目录下的libtool。这时需要手动删除当前目录下的libtool,然后重新执行./configure
编译产生如下错误:
src/flash/nor/dsp5680xx_flash.c:48:11: error: variable 'offset' set but not used [-Werror,-Wunused-but-set-variable]
uint32_t offset = HFM_FLASH_BASE_ADDR;
^
1 error generated.
看起来是可以waive掉的问题。打开configure.ac文件,找到Werror的地方,注释的这个选项。如下:
AS_IF([test "x${gcc_werror}" = "xyes"], [
#GCC_WARNINGS="${GCC_WARNINGS} -Werror"
GCC_WARNINGS="${GCC_WARNINGS}"
])
> openocd --version
Open On-Chip Debugger 0.11.0+dev-02377-g911d68ef2-dirty (2022-09-15-09:24)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
显示已经安装成功了。