Use Autotools to Produce Makefile

Environment:

OS:UBUNTU 11.04

Kernel Version:2.6.35

1.      Install the software

sudo apt-get install autoconf

2.      The structure of the files.

TestAutotool

----main.c

----include

--------hello.h

----hello

--------hello.c

<main.c>

#include"../include/hello.h"

int main()

{

  PrintHello();

}

 

<hello.h>

#include<stdio.h>

extern voidPrintHello();

 

<hello.c>

#include"../include/hello.h"

 

voidPrintHello()

{

   printf("Hello World\n");

}

3.      Steps

autoscan

mv configure.scan configure.in

#                                               -*-Autoconf -*-

# Process thisfile with autoconf to produce a configure script.

 

AC_PREREQ([2.67])

AC_INIT(main,1.0,[641959875@qq.com])

AM_INIT_AUTOMAKE(main,1.0)

AC_CONFIG_SRCDIR([main.c])

AC_CONFIG_HEADERS([config.h])

 

# Checks forprograms.

AC_PROG_CC

 

# Checks forlibraries.

AC_PROG_RANLIB

 

# Checks forheader files.

 

# Checks fortypedefs, structures, and compiler characteristics.

 

# Checks forlibrary functions.

 

AC_OUTPUT([Makefile

                       hello/Makefile])

vim Makefile.am

AUTOMAKE_OPTIONS=foreign

INCLUDES= -I./include

bin_PROGRAMS=main

main_SOURCES=main.c

main_LDADD=./hello/libhello.a

 

cd hello

#                                              -*- Autoconf -*-

# Process thisfile with autoconf to produce a configure script.

 

AC_PREREQ([2.67])

AC_INIT(hello,1.0, 641959875@qq.com)

AM_INIT_AUTOMAKE

AC_CONFIG_SRCDIR([hello.c])

AC_CONFIG_HEADERS([config.h])

 

# Checks forprograms.

AC_PROG_CC

 

# Checks forlibraries.

AC_PROG_RANLIB

# Checks for headerfiles.

 

# Checks fortypedefs, structures, and compiler characteristics.

 

# Checks forlibrary functions.

 

AC_CONFIG_FILES([Makefile])

AC_OUTPUT

 

noinst_LIBRARIES=libhello.a

libhello_a_SOURCES=hello.c

INCLUDE =../include/hello.h

AUTOMAKE_OPTIONS=foreign

 

aclocal

autoconf

autoheader

automake --add-missing

cd ..

aclocal

autoconf

autoheader

automake --add-missing

./configure

make

make install

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值