zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    如何优雅的使用mybatis
    Spring Data JPA、MyBatis还有Hibernate有什么区别
    微服务RPC框架选美
    微服务 Rpc和Rest协议
    开源PaaS工具CloudFoundry落地阿里云
    JS中的位置和宽度:clientWidth、offsetWidth、scrollWidth等区别
    vue cli3.X项目打包
    前端实现文件下载功能
    vue elementui 页面监控form表单数据变化
    vue 刮刮乐功能实现
  • 原文地址:https://www.cnblogs.com/sonnet/p/15187519.html
Copyright © 2011-2022 走看看