All steps below referce: https://blog.youkuaiyun.com/qq_19004627/article/details/79061457
1. Install software.
Note: autoconf belong a part of "autotools" software.
sudo apt install autoconf
2.Generate
input "autoscan", as following:

Would generate 2 file: autoscan.log configure.scan
3. Rename "configure.scan" to "configure.in".
4.Modify the "configure.in" file.
Origin file is:
# -*- 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
Modified is:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(main, 1.0, xxxxxxx@qq.com) #修改
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(main,1.0) #新增
# 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
5.Input "aclocal", would generate 2 file: aclocal.m4 autom4te.cache

6.Input "autoconf", would generate 1 file: configure

7.Input "autoheader", would generate 1 file: configure.in

8.Create a file named "Makefile.am", contain is:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
7.Input "automake --add-missing", would generate server file.

8. Input "./configure" to generate a Makefile, then you can use "make" command.
\(end)
本文详细介绍使用Autotools(包括autoconf、automake等工具)进行软件构建的过程。从安装必要的软件开始,到生成configure脚本,再到创建Makefile并进行编译,提供了完整的步骤指导。
461

被折叠的 条评论
为什么被折叠?



