Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method and case Analysis of automatic Generation of Makefile by GNU automake

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about the method and case study of automatic generation of Makefile in GNU automake. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

In the world of GNU, there are tools such as Automake to automatically generate Makefile files. Automake is written in Perl language and must be used with GNU autoconf. For the specific generation process, please see the figure in the lower right corner of GNU automake's wikipedia at the following address: http://en.wikipedia.org/wiki/Automake. From this figure, you can see the process of using the tool to generate Makefile automatically. The steps are as follows:

1. Use autoscan to generate configure.scan

$autoscan

$ls

Autoscan.log configure.scan hello.c

$aclocal

Aclocal: `configure.ac' or `configure.in' is required

2. If the above prompt appears when aclocal is executed directly in the previous step, then the generated configure.scan should be modified to configure.ac or configure.in before aclocal execution

$mv configure.scan configure.in or configure.ac

$ls

Autoscan.log configure.in hello.c

3. Execute aclocal

$aclocal

$ls

Autom4te.cache autoscan.log configure.in hello.c

4. Execute autoheader

$ls

Autom4te.cache autoscan.log config.h.in configure.in hello.c

5. Execute autoconf

$autoconf

$ls

Autom4te.cache autoscan.log config.h.in configure configure.in hello.c

6. Create Makefile.am

$vim Makefile.am

$cat Makefile.am

Bin_PROGRAMS=hello

Hello_SOURCES=hello.c

With regard to the details in Makefile.am, it means that the name of the generated executable is hello, and the corresponding source code is hello.c.

7. Execute automake

$automake

Configure.in: no proper invocation of AM_INIT_AUTOMAKE was found.

Configure.in: You should verify that configure.in invokes AM_INIT_AUTOMAKE

Configure.in: that aclocal.m4 is present in the top-level directory

Configure.in: and that aclocal.m4 was recently regenerated (using aclocal).

Automake: no `Makefile.am' found for any configure output

Automake: Did you forget AC_CONFIG_FILES ([Makefile]) in configure.in?

An error occurred at this time, that is, the AM_INIT_AUTOMAKE in the configure.in file was not found. Only modify the configure.in file and then re-execute it from step 3. Add AM_INIT_AUTOMAKE (hello,1.0) under the AC_INIT line in configure.in, or add AM_INIT_AUTOMAKE in the format of AM_INIT_AUTOMAKE (package,version), and then modify the AC_OUTPUT to AC_OUTPUT (Makefile).

After modifying the configure.in file, execute 2x7 again

8. Execute automake

$automake

Configure.in:6: required file `. / install-sh' not found

Configure.in:6: `automake-- add-missing' can install `install-sh'

Configure.in:6: required file `. / missing' not found

Configure.in:6: `automake-- add-missing' can install `missing'

Makefile.am: required file `. / INSTALL' not found

Makefile.am: `automake-- add-missing' can install `INSTALL'

Makefile.am: required file `. / NEWS' not found

Makefile.am: required file `. / README' not found

Makefile.am: required file `. / AUTHORS' not found

Makefile.am: required file `. / ChangeLog' not found

Makefile.am: required file `. / COPYING' not found

Makefile.am: `automake-- add-missing' can install `COPYING'

Makefile.am: required file `. / depcomp' not found

Makefile.am: `automake-- add-missing' can install `depcomp'

Follow the prompts to create the missing file

$touch NEWS README AUTHORS ChangeLog

Then execute: $automake-- add-missing

Execute automake again without error

$ls

Aclocal.m4 ChangeLog configure.in INSTALL missing

AUTHORS config.h.in COPYING install-sh NEWS

Autom4te.cache config.h.in~ depcomp Makefile.am README

Autoscan.log configure hello.c Makefile.in

A cinfigure script to generate the Makefile file has been generated at this point

9. / configure generates Makefile

$ls Makefile

Makefile

10. Make gets the executable program

$make

Make all-am

Make [1]: entering directory `/ home/ufo/hello'

Gcc-DHAVE_CONFIG_H-I. -g-O2-MT hello.o-MD-MP-MF .deps / hello.Tpo-c-o hello.o hello.c

Mv-f .deps / hello.Tpo .deps / hello.Po

Gcc-g-O2-o hello hello.o

Make [1]: leaving directory `/ home/ufo/hello'

$. / hello

Hello World!

After reading the above, do you have any further understanding of the method and case study of GNU automake's automatic generation of Makefile? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report