What are Makefile.am and Makefile.in?

后端 未结 4 1868
慢半拍i
慢半拍i 2020-12-02 03:28

These two files are mostly seen in open source projects.

What are they for, and how do they work?

4条回答
  •  独厮守ぢ
    2020-12-02 04:12

    DEVELOPER runs autoconf and automake:

    1. autoconf -- creates shippable configure script
      (which the installer will later run to make the Makefile)
    • ‘autoconf’ is a macro processor.
    • It converts configure.ac, which is a shell script using macro instructions, into configure, a full-fledged shell script.
    1. automake - creates shippable Makefile.in data file
      (which configure will later read to make the Makefile)
    • Automake helps with creating portable and GNU-standard compliant Makefiles.
    • ‘automake’ creates complex Makefile.ins from simple Makefile.ams

    INSTALLER runs configure, make and sudo make install:

    ./configure       # Creates  Makefile        (from     Makefile.in).  
    make              # Creates  the application (from the Makefile just created).  
    
    sudo make install # Installs the application 
                      #   Often, by default its files are installed into /usr/local
    


    INPUT/OUTPUT MAP

    Notation below is roughly: inputs --> programs --> outputs

    DEVELOPER runs these:

    configure.ac -> autoconf -> configure (script) --- (*.ac = autoconf)
    configure.in --> autoconf -> configure (script) --- (configure.in depreciated. Use configure.ac)

    Makefile.am -> automake -> Makefile.in ----------- (*.am = automake)

    INSTALLER runs these:

    Makefile.in -> configure -> Makefile (*.in = input file)

    Makefile -> make ----------> (puts new software in your downloads or temporary directory)
    Makefile -> make install -> (puts new software in system directories)


    "autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention. Autoconf creates a configuration script for a package from a template file that lists the operating system features that the package can use, in the form of M4 macro calls."

    "automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards. Automake requires the use of Autoconf."

    Manuals:

    • GNU AutoTools (The definitive manual on this stuff)

    • m4 (used by autoconf)

    • autoconf

    • automake

    Free online tutorials:

    • Using GNU Autotools

    Example:

    The main configure.ac used to build LibreOffice is over 12k lines of code, (but there are also 57 other configure.ac files in subfolders.)

    From this my generated configure is over 41k lines of code.

    And while the Makefile.in and Makefile are both only 493 lines of code. (But, there are also 768 more Makefile.in's in subfolders.)

提交回复
热议问题