安裝命令:
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