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
1Optimizing Your App's Network Performance with WeTest's Local App Network Testing Solutions LEARN HOW TO OPTIMIZE YOUR APP'S NETWORK PERFORMANCE USING WETEST'S LOCAL APP NETWORK TESTING SOLUTIONS FOR A SEAMLESS USER EXPERIENCE.
2Comprehensive LambdaTest Alternative: WeTest for Game Testing As a lambdatest alternative, WeTest is an advanced and effective solution for game testers & developers with features of cross-browser and cross-device compatibility testing.
3The 5 Must-Do Tests for a Game that Goes for the Global Market Learn about the 5 most important tests during game localization.
4How to Get into QA Game Testing: Comprehensive Guide How to get into qa game testing? In this guide, you will see how to find bugs and determine the peculiarities of game testing, essential approaches, and recommendations.
5How to Test a Game for a Global Audience Try out WeTest's overseas local user testing services to expand your global market.