Simple source code package (.tar.gz) production under Linux

xiaoxiao2021-03-06  59

Simple source code package (.tar.gz) production under Linux

This article uses the "Hello World" program as an example to briefly describe the production of Linux's next source code package (.tar.gz). Of course, it is impossible to make a source of Hello World into a source code package. Here, we will like to explain the production process of the source code package.

First, make sure your system is equipped with the following GNU software:

AUTOMAKE

AutoConf

M4

Perl

Libtool

1. Create a directory, place your source code in this directory, and the following operations are 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 will be generated after executing this command.

3. Modify the Configure.scan file.

Shell> vi configure.scan

Add, modify the following lines, other comments.

AC_INIT (Hello.c) // Brand for your source code.

AC_PROG_CC

AM_INIT_AUTOMAKE (Hello, 1.0) // Brackets Hello is the file name, 1.0 is the version number.

Ac_output (makefile) / / Add Makefile in parentheses.

Save the file and modify this file called configure.in

Shell> MV Configure.scan configure.in

4. Run the aclocal command, then generate the ACLOCAL.M4 file.

Shell> ACLOCAL

5. Run the AutoConf command, then generate the Autom4Te.cache directory and configure executable.

Shell> AutoConf

6. Write your Makefile.am file yourself. This file format is:

Shell> vi makefile.am

Automake_Options = Foreign

BIN_PROGRAMS = Hello

Hello_sources = Hello.c

Of course, interest You can also expand your Makefile.AM file.

7. Add some of the files necessary to generate standard software packages with Automake --Add-missing.

Shell> Automake --Add-Missing

8. Execute the Configure file. Makefile and other files required for Make will generate.

Shell> ./ Configure

9. Use Make to compile, and then generate the executable Hello, but can only be used in the current directory. To do it in any directory, make install.

Shell> Make

10. Make Install, write the executable file to / usr / local / bin.

Shell> make install

11. The last step, packaged. Will build .Tar.gz package, note that this package is not generated with tar commands.

Shell> make dist

At this point, a simple source code package is completed. LS Look, there will be a Hello-1.Tar.gz source code package generation.

Rocky

转载请注明原文地址:https://www.9cbs.com/read-84054.html

New Post(0)