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!
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.