Quick Start to compile and release automake software in Linux

Source: Internet
Author: User
Tags gz file manual writing automake

In this example, we assume that a software package of simserver1 is to be generated, and the source file is only one, namely, simserver1.cpp. The pthread library is used.

1. Run the autoscan scan source code directory.

Run
$ Autoscan
Execute the command to generate Configure. Scan.

2. Edit the configure. In File

After step 1 is executed, configure. Scan is generated. In this step, copy the file, name it Configure. In, and edit the file. The command is as follows:
$ CP Configure. Scan Configure. In
$ Vim Configure. In
After opening the file in the vim editor, the original content of the file is as follows:
# --------------- Configure. Scan start -------------------------------------
#-*-Autoconf -*-
# Process this file with Autoconf to produce a configure script.

Ac_prereq (2.61)
Ac_init (full-package-name, version, bug-Report-address)
Ac_config_srcdir ([simserver1.cpp])
Ac_config_header ([config. H])

# Checks for programs.
Ac_prog_cxx

# Checks for libraries.
# Fixme: replace 'main' with a function in '-lpthread ':
Ac_check_lib ([pthread], [main])

# Checks for header files.
Ac_check_headers ([ARPA/inet. h netinet/in. h sys/socket. H])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
Ac_header_stdc
Ac_check_funcs ([bzero inet_ntoa socket])

Ac_config_files ([makefile])
Ac_output
# --------------- Configure. Scan end -------------------------------------

Edit to the following content:
# --------------- Configure. In start -------------------------------------
#-*-Autoconf -*-
# Process this file with Autoconf to produce a configure script.
Ac_init (simserver1.cpp) # This macro is used to check the path of the source code and put it at the beginning of the file.
Am_init_automake (simserver1, 1.0) # describe the package name and version number

# Checks for programs.
Ac_prog_cxx # use C ++

# Checks for libraries.

# Checks for header files.
Ac_check_headers ([ARPA/inet. h netinet/in. h sys/socket. H])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
Ac_header_stdc
Ac_check_funcs ([bzero inet_ntoa socket])

Ac_output (makefile) # This macro is the name of the makefile to be output.
# --------------- Configure. In end -------------------------------------

3. Run aclocal to generate the aclocal. M4 File

After editing and saving the configure. In file, run the aclocal command to generate the aclocal. M4 file. Run the following command:
$ Aclocal
Then, use ls to list the generated files. If the aclocal. M4 file is not found, the configure. In file is incorrect. Modify the file and try again.

4. Run Autoconf to generate the configure file

Use the Autoconf command to generate the configure executable file. Run the following command:
$ Autoconf
Then use ls to check whether configure is successfully generated.

5. Create a makefile. Am File

Makefile. Am is used to generate makefile. In, which requires manual writing. Makefile. Am defines some content:
Automake_options
This is the automake option. When running automake, it checks whether there are various files in the standard GNU software package, such as authors, changelog, and news files in the directory. When we set it to foreign, automake will use the standard of the general software package to check.
Bin_programs
This is the name of the executable file to be generated. If you want to generate multiple executable files, separate them by spaces.
Helloworld_sources
This is the source code required to generate "helloworld. If multiple source files are used, separate them with spaces. For example, if you need helloworld. h and helloworld. C, write helloworld_sources = helloworld. h helloworld. C.
If you have defined multiple executable files in bin_programs, the corresponding filename_sources must be defined for each executable file.
Libs
This is used to specify the library of the link. For example, Libs + =-lpthread, specify the link to the pthread library.

Run the following command:
$ Vim makefilemam
On the editing page, enter the following content:
Automake_options = foreign
Bin_programs = simserver1 # package name
Simserver‑sources = simserver1.cpp # source file list. Separate multiple source files with spaces.
Libs + =-lpthread # link to the pthread Library

6. Run automake

Execute automake -- add-missing to generate makefile. In.
$ Automake -- add-Missing
The makefile. In file should be generated after execution.

7. Run configure to generate makefile

Run:
$./Configure

8. Execute make to generate an executable file

$ Make
Compile and output the simserver1 executable file after execution.
Make also has the following commands:
Make install can install simserver1 to the/usr/local/bin directory;
Make clean can clear the last compilation result
Make distcan package the code into the packagename-ver.tar.gz file.
Make distcheck is used to check whether the package is normal.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.