zoukankan      html  css  js  c++  java
  • Makefile自动编写工具实例

    准备源文件如下:

    /*test.c*/

    #include <stdio.h>
    #include "phello.h"
    #include "pword.h"
    int
    main ()
    {
      phello ();
      pword ();
      return 0;
    }

    /*phello.c*/

    #include<stdio.h>
    #include "phello.h"
    int
    phello ()
    {
      printf ("hello ");
    }

    /*pword.c*/

    #include <stdio.h>
    #include "pword.h"
    int
    pword ()
    {
      printf ("word ");
    }

    /*phello.h*/

    #ifndef __PHELLO_H__
    #define __PHELLO_H__

    int phello ();

    #endif

    /*pword.h*/

    #ifndef __PWORD_H__
    #define __PWORD_H__

    int pword ();

    #endif

    使用autotools(autoscan、aclocal、autoconf、autoheader、automake)自动编写Makefile步骤如下:

    (1)[...@...]#autoscan

    (2)[...@...]#mv configure.scan configure.in

       [...@...]#vim configure.in  (修改如下:红色字体为修改过的地方)

      #                                               -*- Autoconf -*-
      # Process this file with autoconf to produce a configure script.

      AC_PREREQ(2.59)
      #AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
      AC_INIT(test,1.0)
      AM_INIT_AUTOMAKE(test,1.0)
      AC_CONFIG_SRCDIR([phello.c])
      AC_CONFIG_HEADER([config.h])

      # 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])

    (3)[...@...]#aclocal

    (4)[...@...]#autoconf

    (5)[...@...]#autoheader

    (6)自己创建Makefile.am文件,内容如下:

      AUTOMAKE_OPTIONS=foreign
      bin_PROGRAMS=test
      test_SOURCES=test.c phello.c pword.c

      [...@...]#automake --add-missing

    (7)[...@...]#./configure          至此,Makefile已自动生成

    (8)[...@...]#make

      

      

  • 相关阅读:
    线程(java课堂笔记)
    java中的各种流(老师的有道云笔记)
    面向对象(java菜鸟的课堂笔记)
    泛型(java菜鸟的课堂笔记)
    我做的第一个程序(菜鸟的java课堂笔记)
    java中的一些规则(菜鸟的课堂笔记)
    一位菜鸟的java 最基础笔记
    spatial index (空间索引)
    hadoop 的疑问
    numpy 矩阵的运算
  • 原文地址:https://www.cnblogs.com/nufangrensheng/p/3431090.html
Copyright © 2011-2022 走看看