Auto generate Makefile
All steps below referce: https://blog.csdn.net/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)