This article takes "Hello World" program as an example to explain the production of source code package (. tar.gz) under Linux simply. Of course, it makes no sense to make the Hello world into a source code package. Here, I would like to explain the production process of the source code package.
First, make sure your system contains the following GNU software:
Automake
Autoconf
M4
Perl
Libtool
1. Create a new directory, put your source code in this directory, the following operations are carried out in this directory.
shell> mkdir Hello
2. Execute the AutoScan command to scan the source code.
Shell>autoscan
The Configure.scan and Configure.log files are generated when the command is executed.
3. Modify the Configure.scan file.
Shell>vi Configure.scan
Add, modify the following lines, other comments out.
Ac_init (HELLO.C)//brackets for your source code.
Ac_prog_cc
Am_init_automake (hello,1.0)//In parentheses Hello is the filename, 1.0 is the version number.
Ac_output (Makefile)//Add makefile in parentheses.
Save the file and modify the file name configure.in
SHELL>MV Configure.scan configure.in
4. Run the aclocal command, and then generate the Aclocal.m4 file.
Shell>aclocal
5. Run the autoconf command, and then generate the Autom4te.cache directory and configure executable file.
Shell>autoconf
6. Write your own makefile.am files. This file format is:
Shell>vi makefile.am
Automake_options=foreign
Bin_programs=hello
Hello_sources=hello.c
Of course, you may also be interested in extending the makefile.am file.
7. Use Automake--add-missing to add some files necessary to build a standard package.
Shell>automake--add-missing
8. Execute the Configure document. Generates the makefile and other files required for make.
Shell>./configure
Array. Compile with make, the executable file is generated Hello, but only in the current directory./execution. To be able to execute in any directory, make install.
Shell>make
10.make install to write the executable file under/usr/local/bin.
Shell>make Install
11. Final step, packing. Generates a. tar.gz package, note that this package was not generated with the tar command.
Shell>make Dist
At this point, a simple source code package is finished. LS Look, there will be a hello-1.tar.gz source code package generated.
Rocky
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.