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
1A review of the PerfDog evolution: Discussing mobile software QA with the founding developer of PerfDog A conversation with Awen, the founding developer of PerfDog, to discuss how to ensure the quality of mobile software.
2Enhancing Game Quality with Tencent's automated testing platform UDT, a case study of mobile RPG game project We are thrilled to present a real-world case study that illustrates how our UDT platform and private cloud for remote devices empowered an RPG action game with efficient and high-standard automated testing. This endeavor led to a substantial uplift in both testing quality and productivity.
3How can Mini Program Reinforcement in 5 levels improve the security of a Chinese bank mini program? Let's see how Level-5 expert mini-reinforcement service significantly improves the bank mini program's code security and protect sensitive personal information from attackers.
4How UDT Helps Tencent Achieve Remote Device Management and Automated Testing Efficiency Let's see how UDT helps multiple teams within Tencent achieve agile and efficient collaboration and realize efficient sharing of local devices.
5WeTest showed PC & Console Game QA services and PerfDog at Gamescom 2024 Exhibited at Gamescom 2024 with Industry-leading PC & Console Game QA Solution and PerfDog