本文主要介紹如何用autotool工具構建一個自己的工程,每個工具具體是做什麼用的,正常開發中應該在哪裏增加相關配置文件等。
編寫一個示例
main.c
#include "plib.h"
void main()
{
myprint();
}
plib/plib.h
void myprint();
plib/plib.c
#include <stdio.h>
void myprint()
{
printf("aaaaaaaa\n");
}
autoscan
autoscan會根據當前目錄下的代碼生成autoscan.log
和configure.scan
autoscan.log
記錄了宏被調用的詳細信息
configure.scan
根據目錄下的源碼生成的配置文件
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([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
aclocal
需要configure.ac
文件,生成aclocal.m4
文件
m4
autoconf
根據configure.in
文件生成configure
腳本
automake
根據Makefile.am
生成Makefile.in