• Makefile自动生成(Automake)


    Makefile file makes compiling work more efficient, especially when it turns to solve some jobs with a complex structure. But
    it depends on the building environment so hard that we can't use it portably. So that a tools called automake assist us to generate makefile
    automatically.

    Brief

    1. autoscan
    2. vim configure.scan and mv configure.scan configure.ac
    3. aclocal
    4. autoconf
    5. vim Makefile.am
    6. automake --add-missing
    7. ./configure
    8. make

    Example

    Project Layout

    1. First of all, create a source code in C:
    /* hello.c */
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    	fprintf(stdout, "Hello Auto Makefile
    ");
    	return 0;
    }
    

    then autoscan it, you will find a file named configure.scan

    $ autoscan
    $ ls
    hello.c configure.scan
    
    1. edit configure.scan and rename it as configure.ac
    $ vim configure.scan
    $ cat configure.scan
    
    #    -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.
    
    AC_INIT( hello.c)
    AM_INIT_AUTOMAKE(hello, 1.0)
    
    # Checks for programs.
    AC_PROG_CC
    
    # Checks for libraries.
    
    # Checks for header files.
    
    # Checks for typedefs, structures, and compiler characteristics.
    
    # Checks for library functions.
    
    AC_OUTPUT(Makefile)
    
    $ mv configure.scan configure.ac
    
    1. use aclocal to create aclocal.m4. m4 is a kind of marco processor.
    $ aclocal
    $ ls
    aclocal.m4 configure.ac hello.c
    
    1. use autoconf to generate configure
    $ autoconfig
    $ ls
    aclocal.m4 autom4te.cache configure configure.ac hello.c
    
    1. edit makefile.am
    $ vim makefile.am
    $ cat makefile.am
    AUTOMAKE_OPTIONS=foreign
    bin_PROGRAMS=hello
    helloworld_SOURCE=hello.c
    
    1. ./configure
    2. ./make

    Copyright © 2021 Gsharp. All Rights Reserved.

  • 相关阅读:
    linux 内存映射-ioremap和mmap函数
    vue 模板语法-插值的操作(12-22)
    chrome浏览器json插件
    vue初识(1-11)2020-10-27
    后盾人:JS课程第一章(11-18)2020-10-25
    博客园美化
    chrome 设置自动刷新网页
    二叉树的层次遍历
    poj 2905 双向队列(待补充)
    poj 2159 D
  • 原文地址:https://www.cnblogs.com/sonnet/p/15187519.html
Copyright © 2020-2023  润新知