Laobaixue programming -- an example analysis of "autotools" - netdata

Keywords: Programming Makefile git RPM

Summary

After learning the knowledge of autotool series for a few days, I found a practical project and compared it with the analysis. Due to the limited knowledge, I don't know how deep I can go. I'm looking forward to it.

Netdata

Netdata is a monitoring software, which is well done. Second level is a feature of netdata. I don't talk about it in detail. The official website documents are well written. I will start with autotool to see the source code.

configure.ac

Set sail

1400 elements

$ wc configure.ac  
 1400  3040 44755 configure.ac  

Edition

Come and have a look.

  5 AC_PREREQ(2.60)
  6
  7 # We do not use m4_esyscmd_s to support older autoconf.
  8 define([VERSION_STRING], m4_esyscmd([git describe 2>/dev/null | tr -d '\n']))
  9 define([VERSION_FROM_FILE], m4_esyscmd([cat packaging/version | tr -d '\n']))
 10 m4_ifval(VERSION_STRING, [], [define([VERSION_STRING], VERSION_FROM_FILE)])
 
 12 AC_INIT([netdata], VERSION_STRING[])

 19 PACKAGE_RPM_VERSION="VERSION_STRING"
 20 AC_SUBST([PACKAGE_RPM_VERSION])

The first line doesn't mention the version of autoconf. You can refer to lines 8, 9 and 10 to get the version. It's not necessary to introduce AC init, but why version string takes the place of a bracket, I don't understand it. A version of package rpm is defined later.

MAINTAINER_MODE

 14 AM_MAINTAINER_MODE([disable])
 15 if test x"$USE_MAINTAINER_MODE" = xyes; then
 16 AC_MSG_NOTICE(***************** MAINTAINER MODE *****************)
 17 fi

Am? Maintainer? Mode turns off the makefile target that is only used by program maintainers by default, mainly for the -- enable maintainer mode option.
not using "AM_MAINTAINER_MODE" means that your makefiles will always be updated in response to changes to Makefile.am.

autoconf

 25 AC_CONFIG_AUX_DIR([.])
 26 AC_CONFIG_HEADERS([config.h])
 27 AC_CONFIG_MACRO_DIR([build/m4])
 28 AC_CONFIG_SRCDIR([daemon/main.c])
 29 define([AUTOMATE_INIT_OPTIONS], [tar-pax subdir-objects])
 30 m4_ifdef([AM_SILENT_RULES], [
 31     define([AUTOMATE_INIT_OPTIONS], [tar-pax silent-rules subdir-objects])
 32     ])
 33 AM_INIT_AUTOMAKE(AUTOMATE_INIT_OPTIONS)
 34 m4_ifdef([AM_SILENT_RULES], [
 35     AM_SILENT_RULES([yes])
 36     ])
 37 AC_CANONICAL_HOST
 38 AC_PROG_CC
 39 AC_PROG_CC_C99
 40 AM_PROG_CC_C_O
 41 AC_PROG_CXX
 42 AC_PROG_INSTALL
 43 PKG_PROG_PKG_CONFIG
 44 AC_USE_SYSTEM_EXTENSIONS

Options manual

AC? Config? Aux? Dir auxiliary file and script storage location definition
The AC config header macro is used to generate the config.h file
The AC config scrdir macro is used to detect the existence of the specified source file to determine the validity of the source directory, so as to avoid running configure elsewhere
AC ﹣ config ﹣ macro ﹣ dir specifies the directory where the local macro files are stored. Files with the. m4 suffix will be saved in this directory, which will be created automatically by the acloacl command
Am? Init? Automake initializes automake. Subdir objects describes the format of. o file in subdirectory. Tar Pax specifies' make dist '. It is based on' POSIX 1003.1-2001 'standard.
When silent rules mode is on, the output will be different, details

[to be continued]

Posted by shivani.shm on Thu, 09 Apr 2020 04:53:44 -0700