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

      

      

  • 相关阅读:
    用OBS studio(Open Broadcaster Software)录屏
    强力粘胶,粘金属
    Win10下不用虚拟机安装ubuntu, 及bash shell打开教程
    latex 的工具集
    python game游戏开发
    usdt 大户列表
    linux, windows, mac 的c/c++程序使用 breakpad 来进行崩溃汇报
    将python代码编译成目标机elf可执行程序的方法
    python的zigzag实现及金融技术指标分析库
    如何在left Join 中使用order排序
  • 原文地址:https://www.cnblogs.com/nufangrensheng/p/3431090.html
Copyright © 2011-2022 走看看