做 爱 网站小视频下载网络管理系统的每个节点都包含一组与管理有关的软件
一、前言
 文章目的:针对各种开源项目,由于部分项目文档写的不够详细,(或者是我太菜了),没有进行详细的介绍怎么编译该项目,导致花费过多时间在查找如何编译该项目上。因此该篇文章针对目前遇到的编译项目问题进行汇总。 
 
 文章参考:gpt 
 
 注:目前遇到的编译问题更多是嵌入式的交叉编译上,如果有本文章没提及的编译方式,也可以发项目连接到评论,我会抽空补充。 
 
 
目录
一、前言
二、Makefile
2.1 【what】什么是Makefile
2.2 【how】包含Makefile的项目如何编译
三、configure
3.1 【what】什么是configure
3.2【how】包含configure的项目如何编译
3.3 configure支持的配置项
四、autogen.sh
4.1 什么是autogen.sh
4.2 包含autogen.sh的项目如何编译
五、configure.ac、Makefile.am
5.1 什么是configure.ac、Makefile.am
5.2 包含configure.ac、Makefile.am文件的项目如何编译
二、Makefile
2.1 【what】什么是Makefile
Makefile是一种文本文件,用于告诉make(一个Linux/Unix工具)如何编译和链接源代码文件以生成可执行文件。Makefile通常包括编译选项、源文件列表、目标文件、依赖关系和生成可执行文件的命令等信息。它是自动化构建和编译程序的基础,并且通常是大型软件项目的必备组成部分。 
 
 
2.2 【how】包含Makefile的项目如何编译
针对项目中存在Makefile文件,只需要检查Makefile中工具链的配置,平台的配置,需要链接库的库和头文件路径是否正确即可。 
 
 
编译指令:
make / make -jN 三、configure
3.1 【what】什么是configure
configure是一个用于自动生成Makefile的脚本,它通常是由autoconf工具自动生成的。当项目的源代码需要在不同的操作系统或不同的硬件平台上编译时,需要根据目标平台的特点进行适当的调整和优化,因此就需要使用configure来检测目标平台的环境和特性,并生成相应的Makefile。通过执行./configure命令,会根据系统环境自动配置项目的编译选项,并生成Makefile文件,从而方便进行项目的编译和安装。     
  3.2【how】包含configure的项目如何编译
针对项目中只存在configure文件的,可以通过命令行参数配置,最终生成Makefile文件 
 
编译指令
./configure --host=...
make 3.3 configure支持的配置项
不同项目支持的配置项不同可以通过下面的指令进行查看 
 
./configure --help 下面是motion项目,生成的configure,支持的配置项列表
~/git_code/motion$ ./configure --help
`configure' configures motion 4.5.1+git20230416-c28d41b to adapt to many kinds of sy                                                                                                                           stems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help              display this help and exit--help=short        display options specific to this package--help=recursive    display the short help of all the included packages-V, --version           display version information and exit-q, --quiet, --silent   do not print `checking ...' messages--cache-file=FILE   cache test results in FILE [disabled]-C, --config-cache      alias for `--cache-file=config.cache'-n, --no-create         do not create output files--srcdir=DIR        find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX         install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR            user executables [EPREFIX/bin]--sbindir=DIR           system admin executables [EPREFIX/sbin]--libexecdir=DIR        program executables [EPREFIX/libexec]--sysconfdir=DIR        read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR     modifiable single-machine data [PREFIX/var]--runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]--libdir=DIR            object code libraries [EPREFIX/lib]--includedir=DIR        C header files [PREFIX/include]--oldincludedir=DIR     C header files for non-gcc [/usr/include]--datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]--datadir=DIR           read-only architecture-independent data [DATAROOTDIR]--infodir=DIR           info documentation [DATAROOTDIR/info]--localedir=DIR         locale-dependent data [DATAROOTDIR/locale]--mandir=DIR            man documentation [DATAROOTDIR/man]--docdir=DIR            documentation root [DATAROOTDIR/doc/motion]--htmldir=DIR           html documentation [DOCDIR]--dvidir=DIR            dvi documentation [DOCDIR]--pdfdir=DIR            pdf documentation [DOCDIR]--psdir=DIR             ps documentation [DOCDIR]Program names:--program-prefix=PREFIX            prepend PREFIX to installed program names--program-suffix=SUFFIX            append SUFFIX to installed program names--program-transform-name=PROGRAM   run sed PROGRAM on installed program namesSystem types:--build=BUILD     configure for building on BUILD [guessed]--host=HOST       cross-compile to build programs to run on HOST [BUILD]Optional Features:--disable-option-checking  ignore unrecognized --enable/--with options--disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG]  include FEATURE [ARG=yes]--enable-silent-rules   less verbose build output (undo: "make V=1")--disable-silent-rules  verbose build output (undo: "make V=0")--disable-maintainer-modedisable make rules and dependencies not useful (andsometimes confusing) to the casual installer--enable-dependency-trackingdo not reject slow dependency extractors--disable-dependency-trackingspeeds up one-time build--disable-nls           do not use Native Language Support--disable-rpath         do not hardcode runtime library pathsOptional Packages:--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]--without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)--with-gnu-ld           assume the C compiler uses GNU ld [default=no]--with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib--without-libiconv-prefix     don't search for libiconv in includedir and libdir--with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib--without-libintl-prefix     don't search for libintl in includedir and libdir--without-bktr          Disable bktr devices--without-v4l2          Disable V4L2 devices--with-webp             Compile with Webp image support--with-mmal=DIR         Compile with RasperryPi mmal camera support--with-ffmpeg=DIR       Build with FFMPEG support--with-mariadb=DIR      Build with MariaDB support--with-mysql=DIR        Build with MySQL support--with-pgsql=DIR        Build with PostgreSQL support--without-sqlite3       Disable sqlite3 support.--without-optimizecpu   Exclude autodetecting platform and cpu type. Thiswill disable the compilation of gcc optimizing codeby platform and cpu.--with-developer-flags  Causes practically all of the possible gcc warningflags to be set. This may produce a large amount ofwarnings.--with-prototype-flags  Causes practically all of the possible gcc warningflags to be set except missing prototypes.Some influential environment variables:CC          C compiler commandCFLAGS      C compiler flagsLDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS        libraries to pass to the linker, e.g. -l<library>CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CXX         C++ compiler commandCXXFLAGS    C++ compiler flagsCPP         C preprocessorKILL        the 'kill' program to use to send signals to motionUse these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
 四、autogen.sh
4.1 什么是autogen.sh
autogen.sh是一个脚本文件,通常用于生成configure脚本和Makefile。在许多开源项目中,开发者使用autogen.sh来简化项目的构建过程,特别是当项目使用了autoconf、automake和libtool等自动化工具时。 
 该脚本的作用是使用autoconf、automake和libtoolize等工具生成configure脚本、Makefile.in文件和其他必要的文件。autogen.sh脚本还负责检查必要的依赖项,例如特定版本的autoconf和automake等。 
 使用autogen.sh脚本的好处是可以使整个构建过程更加自动化和简单,开发人员只需运行一个脚本即可生成必要的构建文件。 
  4.2 包含autogen.sh的项目如何编译
针对项目中只存在autogen.sh脚本文件的,该脚本会自动检查系统环境和依赖库是否满足项目要求,并生成 configue 文件. 
 
编译指令:
./autogen.sh
./configure --host=....  #指定
make 五、configure.ac、Makefile.am
5.1 什么是configure.ac、Makefile.am
configure.ac和Makefile.am是Autoconf和Automake工具的输入文件。它们通常与configure和Makefile.in文件一起使用,这些文件是Autoconf和Automake工具生成的。在GNU构建系统中,这些工具可以自动化地生成与目标平台和操作系统兼容的Makefile文件和可执行文件。 
 configure.ac文件是Autoconf的输入文件,其中包含检查系统的程序。 
 Makefile.am文件是Automake的输入文件,其中包含Makefile的规则。它使用AUTOMAKE_OPTIONS、AM_INIT_AUTOMAKE等宏来定义Makefile的规则。此文件通常包含文件的列表、目标和依赖项以及要执行的命令。 
 configure和Makefile.in文件由Autoconf和Automake工具生成,并根据目标平台和操作系统生成符合标准的Makefile文件和可执行文件。configure文件通常包含源代码的配置选项,而Makefile.in文件包含Makefile的规则。configure和Makefile.in文件的生成过程是通过运行./configure脚本完成的,该脚本将根据系统环境和用户定义的选项生成符合目标平台和操作系统的Makefile文件和可执行文件。 
  5.2 包含configure.ac、Makefile.am文件的项目如何编译
针对项目中只存在configure.ac、Makefile.am文件,可以根据下面的指令一步步生成对应的Makefile 
 
编译指令:
autoreconf -i
./configure
make  
