对于不同的项目来说,传递首选编译器进行配置似乎有很大不同。例如,如果我想用 clang 构建 tcc,我必须这样做,./configure --cc=clang
但在大多数其他情况下,项目会理解./configure CC=clang
. 是否有一个事实上的标准,或者这并不重要,我应该检查每个单独的项目是如何完成的?
$ wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/tcc/0.9.27\+git20200814.62c30a4a-1/tcc_0.9.27\+git20200814.62c30a4a.orig.tar.bz2
$ tar -xvjf tcc_0.9.27+git20200814.62c30a4a.orig.tar.bz2
$ ./configure --cc=clang
$ make
$ make install
Run Code Online (Sandbox Code Playgroud)
大多数情况下,configure
脚本是由 Autoconf 生成的,建议在 Arguments 中设置变量:
./configure CC=clang\n
Run Code Online (Sandbox Code Playgroud)\n然而,有些项目(例如tcc
)提供手写configure
脚本,并且做法各不相同。
根据经验,如果存在\xe2\x80\x99s 文件configure.ac
,则可以假设 Autoconf 行为;如果没有\xe2\x80\x99t,则需要检查项目\xe2\x80\x99s的期望。
(严格来说,Autoconf 生成的脚本 don\xe2\x80\x99t必须支持CC
,您应该检查 的使用AC_PROG_CC
;但绝大多数使用 C 编译器的 Autoconf 脚本都支持。)