author: hjjdebug
date: 2025年 02月 14日 星期五 17:16:12 CST
description: ffmpeg configure 研究1
./configure 命令行参数的分析
文章目录
详细分析了 ffmpeg 下执行
./configure --enable-libx264
libx264 is gpl and --enable-gpl is not specified.
程序退出的过程
如果说在命令行上有 --enable-libx264 而没有 --enable-gpl 就退出,
用c 写也就寥寥几句,
libx264_enable=false,gpl_enable=fale;
for(int i=0;i<argc;i++)
{
if(strcmp(arg[i],“–enable-libx264”)0) libx264_enable=true;
if(strcmp(arg[i],“–enable-gpl”)0) gpl_enable=true;
}
if(libx264_enabletrue && gpl_enablefalse) exit(1)
如果用bash 又应该怎么写呢?
如果只是实现上边的功能,bash 也可以写的很简单, 但在configure 文件中就不是那样写了.
而是有一个复杂的架构,
为什么?因为它要支持一些复杂的功能.
所以该博客就是来了解这个简单的功能是如何在复杂的架构上实现的.
让我们能窥斑见豹. 别被它庞大的架构吓唬注了.
这些是bash编程最基本的东西, 就从此开始吧.
1 configure 对命令行参数的分析,在4019行
for opt do
因为 opt 后面没有 in 参数, 实际上就是 in “ @ " , 代码处于顶层 , @",代码处于顶层, @",代码处于顶层,@就是命令行参数,此时
$opt = --enable-libx264
case 语句会匹配到4087行
–enable-?|–disable-?)
eval ( e c h o " (echo " (echo"opt” | sed ‘s/–/action=/;s/-/ option=/;s/-/_/g’)
if is_in $option $COMPONENT_LIST; then
test $action = dis