1. 源程序
[root@node001 str]# cat include/str.h
#include <stdio.h>
int str(char *string);
[root@node001 str]# cat src/str.c
#include "str.h"
//print string
int str(char *string){
printf("\n----PRINT STRING----\n\"%s\"\n",string);
return 0;
}
//interface of this program
int main(int argc , char **argv){
char str_read[1024];
printf("Please INPUT something end by [ENTER]\n");
scanf("%s",str_read);
return str(str_read );
}
2. autoscan ,
[root@node001 str]# autoscan //生成 configure.scan[root@node001 str]# mv configure.scan configure.ac //改名
然后修改configure.ac
[root@node001 str]# cat configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(str, 0.0.1, [www@gmail.com])
AM_INIT_AUTOMAKE(str, 0.0.1)
AC_CONFIG_SRCDIR([src/str.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_CONFIG_FILES([Makefile])
AC_OUTPUT
3. aclocal 生成aclocal.m4
[root@node001 str]# aclocal
4. 创建Makefile.am
[root@node001 str]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=str
str_SOURCES=include/str.h src/str.c
str_CPPFLAGS=-I include
5. autoheader
[root@node001 str]# autoheader //生成 config.h.in
6. 添加automake必须文件
[root@node001 str]# touch NEWS README AUTHORS ChangeLog INSTALL COPYING
7. automake
[root@node001 str]# automake -a //生成Makefile.in
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./compile'
Makefile.am: installing `./depcomp'
8. autoconf
[root@node001 str]# autoconf //生成 configure文件
===============================
测试:
[root@node001 str]# mkdir -p ~/program/str
[root@node001 str]# ./configure --prefix=/root/program/str/
[root@node001 str]# make
[root@node001 str]# make install