Auto generate Makefile

本文详细介绍使用Autotools(包括autoconf、automake等工具)进行软件构建的过程。从安装必要的软件开始,到生成configure脚本,再到创建Makefile并进行编译,提供了完整的步骤指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值