Linux automake使用教程執行個體__Linux

來源:互聯網
上載者:User

安裝命令:

apt-get  install automake

automake執行個體:

helloworld.c 

#include <stdio.h>#include <string.h>extern int output(char* data);int main(){int n=15;printf("hellow world %d \n",n);output("from helloword.c");return 0;}

output.c

#include <stdio.h>#include <string.h>int output(char* data){printf("output data=%s\n",data);return 0;}

1、執行命令:

autoscan

2、修改configure.scan並改名為configure.ac

# -*- Autoconf -*-

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

AC_PREREQ([2.68])

AC_INIT([helloworld], [2.0], [542335496@qq.com])

AM_INIT_AUTOMAKE(helloworld,2.0) 

AC_CONFIG_SRCDIR([output.c])

AC_CONFIG_HEADERS([config.h])

# Checks for programs.

AC_PROG_CC

# Checks for libraries.

# Checks for header files.

AC_CHECK_HEADERS([string.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)

命令:mv configure.scan configure.ac

   gedit  configure.ac

3、執行命令:

  aclocal  產生aclocal.m4檔案、即為配置成功

  autoconf 產生configure檔案、即為配置成功

4、執行命令:

  autoheader   產生config.h.in 

5、建立和編輯Makefile.am檔案:

 gedit Makefile.am

內容為:

AUTOMAKE_OPTIONS= foreign 

bin_PROGRAMS= helloworld 

helloworld_SOURCES= helloworld.c output.c

6、automake --add-missing 產生Makefile.in檔案,無輸出資訊即可成功

7、./configure

8、Make

9、Make install 編譯完成

10、運行:

./helloworld

11、打包發布,產生helloworld-2.0.tar.gz:

 make dist




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.