Pricing

How to Generate Makefile for Software Development in Linux using Autoconf and Automake

This article provides a step-by-step guide on how to generate a makefile for a typical project structure, including the use of bin, include, and src directories.

Introduction

In the process of software development under Linux, we often need to write makefile files, using GNU autoconf and automake. Users can install programs into the system by using "./configure", "make", "make install", so as to improve our development efficiency.

Let's assume that the file organization format during our development is such that the bin file is used to store the generated binary files, the include directory is used to store the relevant header files, and the src directory is used to store the relevant implementation files.

To generate a makefile, we only need the following steps.

1. First run the autoscan command to generate the configure.scan file

2. Rename configure.scan to configure.ac, and open the file to

1 # - - Autoconf--

2 # Process this file with autoconf to produce a configure script

3

4 AC_ PREREQ ([2.63])

5 AC_ INIT ([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT ADDRESS])

6 AC_ CONFIG_ SRCDIR ([src/main. cpp])

7 AC_ CONFIG_ HEADERS ([config. h])

8

9 # Checks for programs

10 AC_ PROG_ CXX

11 AC_ PROG_ CC

12

13 # Checks for libraries

fourteen

15 # Checks for header files

16

17 # Checks for typedefs, structures, and compiler characteristics

18

19 # Checks for library functions

20

21 AC_ OUTPUT

 

 

We edited them as

1 # - * - Automatic control-*-

2 # Use autoconf to process this file to generate a configuration script.

three

4 AC_ PREREQ ([2.63])

5 AC_ INIT ([test], [1.0][ michealshen@tencent.com ])

6 AC_ CONFIG_ SRCDIR ([src/main. cpp])

7 AC_ CONFIG_ HEADERS ([configuration h])

8 AM_ INIT_ AUTOMAKE

9 # inspection procedure.

10 Communication_ Procedure_ CXX

11 Communication_ Procedure_ CC

twelve

13 # inspection library.

fourteen

15 # Check header file.

sixteen

17 # Check typedef, structure and compiler characteristics.

eighteen

19 # Check library functions.

twenty

21 AC_ OUTPUT (generating file src/Makefile)

Note that the AM in the eighth line_ INIT_ AUTOMAKE will add it, otherwise, the error will be prompted when the car is manufactured.

3. Then we run the aclocal and autoconf commands to generate acloacl.m4 and configure files.

4. Then we need to edit our Makefile.am file. In addition to the top-level directory, each directory in src is also required.

The Makefile.am of the top-level directory is

1 AUTOMAKE_ OPTIONS=foreign

2 SUBDIRS=src

In the Src directory

1 INCLUDES=- I $(top_srcdir)/include

2 bin_ PROGRAMS=$(top_srcdir)/bin/test

3__ Top_ Srcdir__ Bin_ Test_ SOURCES=test.cpp main.cpp

 

5. The great achievement is almost complete. Next, we execute automake -- add messaging to generate our most important Makefile.in file.

6. To distinguish, we create a new build directory to execute the make command.

Finished!

About WeTest

WeTest Quality Open Platform is the official one-stop testing service platform for game developers. We are a dedicated team of experts with more than ten years of experience in quality management. We are committed to the highest quality standards of game development and product quality and tested over 1,000 games.

WeTest integrates cutting-edge tools such as automated testing, compatibility testing, functionality testing, remote device, performance testing, and security testing, covering all testing stages of games throughout their entire life cycle.

 

Latest Posts
1How To Check Game Compatibility On PC? | Extensive Overview How to check game compatibility on pc? To provide good gameplay, it is important to detect the critical factors of game compatibility between diverse PC setups, hardware, and software
2Xbox Game Beta Testing | Comprehensive Review Carrying a thorough xbox game beta testing before launch is an important step to track down and resolve errors, enhance the gaming experience, and make high-quality games.
3Don't Miss Out! Get Your Free 60-Minute PerfDog Trial with 2024 PerfDog WhitePaper DOWNLOAD THE 2024 PERFDOG WHITEPAPER AND EARN A 60-MINUTE FREE TRIAL OF PERFDOG EVO V10.2!
4PerfDog EVO v10.0 Shatters the Barriers of Game and App Performance Testing In PerfDog EVO v10.0 version, we have made significant optimizations from three perspectives to meet users’ performance testing requirements in different scenarios.
5Overcoming Cloud Real Device Challenges: WeTest’s Exclusive Solution for Lagging and Access Restrictions Public cloud technology has met the testing needs of numerous small and micro-enterprises as well as individuals. However, as customers delve deeper into usage, they encounter a range of new issues. In this article, we will provide answers to several common questions.