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.

  • 相关阅读:
    Android strings.xml中定义字符串显示空格
    Android各国语言对照表(values-xxx)
    SimInfo获取(MCC, MNC, PLMN)
    Android APN
    Android studio 运行java程序
    [MyBatis]DAO层只写接口,不用写实现类
    idea代码调试debug篇
    比较分析 Spring AOP 和 AspectJ 之间的差别
    maven进阶:一个多模块项目
    Maven最佳实践:划分模块
  • 原文地址:https://www.cnblogs.com/sonnet/p/15187519.html
Copyright © 2011-2022 走看看