Linux uses autoconf and automake to generate configure
Introduction
Make is a very important compilation command, both in Linux and in the UNIX environment. Whether you are developing your own projects or installing applications, we often use make or makes install. With make tools, we can break down large-scale development projects into more manageable modules, and for an application that includes hundreds of source files, using make and makefile tools makes it easy to straighten out the intricacies of each source file.
But it is a challenge for any programmer to write makefile manually by looking at make's help documentation. Fortunately, the GNU-provided autoconf and Automake are two sets of tools that make writing makefile no longer a challenge.
This article will show you how to use the GNU Autoconf and Automake tools to help us automate the generation of makefile files, and let the software be developed like most source packages, just "./configure", "make", "made Install the program to the system.
First, the environment
Ubuntu14.04 LTS, installing Automake, sudo apt-get install Automake
Second, the process
Take a picture from the web and look at the general flow
Third, practice
1. Create a new directory: Xpcdetector, create a new subdirectory in the Xpcdetector directory: Xpcdatabase, Xpcnetwork, and Xpcdetector, the first two of which are dynamic libraries, and Xpcdetector are executable programs.
2. CD Xpcdetector
3, execute the command: AutoScan
4. Rename the Configure.scan in the generated file to Configure.ac and modify the contents of the file:
#-*-Autoconf-*-
# Process This file with autoconf to produce a configure script.
Ac_prereq ([2.69])
Ac_init (Etector, 1.0.0, [email protected])
Ac_config_srcdir ([macchinadaemon/main.cpp])
Ac_config_headers ([config.h])
# Checks for programs.
Ac_prog_cxx
Ac_prog_cc
# Checks for libraries.
Lt_init
# Checks for header files.
Ac_check_headers ([inttypes.h limits.h stdint.h stdlib.h string.h sys/param.h sys/time.h syslog.h unistd.h opencv/cv.h SDL.h sdl_thread.h libavformat/avformat.h Poco/logger.h])
# Checks for typedefs, structures, and compiler characteristics.
Ac_check_header_stdbool
Ac_c_inline
ac_type_int16_t
ac_type_int64_t
ac_type_pid_t
ac_type_size_t
ac_type_uint32_t
ac_type_uint64_t
ac_type_uint8_t
Am_init_automake ([foreign])
# Checks for library functions.
Ac_func_error_at_line
Ac_func_fork
Ac_check_funcs ([memset rint sqrt strchr strerror strstr strtol])
Ac_config_files ([Makefile
Xpcdatabase/makefile xpcnetwork/makefile xpcdetector/makefile xpcdaemon/makefile XPCWatchdog/Makefile Xpcwatchdogdaemon/makefile Macchinadaemon/makefile])
Ac_output
5. Create a new makefile.am file in the Xpcdetector directory and write the following content:
Automake_options = Foreign
Subdirs = xpcdatabase xpcnetwork xpcdetector xpcdaemon xpcwatchdog Xpcwatchdogdaemon MacchinaDaemon
It's just a list of definitions.
6. Create a new makefile.am file in Xpcdatabase, Xpcnetwork, and xpcdetector directories, such as xpcdatabase in makefile.am directory as follows:
Automake_options = Foreign
Lib_ltlibraries = libxpcdatabase.la
libxpcdatabase_la_sources = DetectorSt.cpp DetectorSt.h DetectorTable.cpp DetectorTable.h
#include_HEADERS = DetectorSt.h DetectorTable.h
DEFS + =-d_gnu_source
Libxpcdatabase_la_ldflags =-d_gnu_source-shared–fpic
Libxpcdatabase_la_libadd =-l/usr/local/macchina/lib/-lpocofoundation-lpocodata-lpocodatasqlite
Libxpcdatabase_la_cxxflags =-i/usr/local/macchina/include/
7, back to the Xpcdetector directory to create a new autogen.sh file, the contents are as follows:
#!/bin/sh
Aclocal
Autoheader
Automake--add-missing
Autoconf
8. Execute command in Xpcdetector directory: Bash./autogen.sh
9./configure--prefix=[Installation path name]
10, Make-j4
11. Sudo make install
Iv. issues that may be encountered
There was an error compiling the C + + program under Linux:
$ automake--add-missing
....
configure.in:18:required file ' build/ltmain.sh ' not found
....
Solution (Libtoolize configuration):
$libtoolize--version
-libtoolize (GNU libtool) 1.4.2
.....
$libtoolize--automake--copy--debug--force
If the Libtool is not installed, install it first: sudo apt-get install Libtool
Linux uses autoconf and automake to generate configure