Use makefile. am and configure. in Linux to generate the installation source code package.

Source: Internet
Author: User

Note: configure. in and configure. ac are different names of the same file, and configure. in is an earlier version.

Previous condition: the current directory contains the source code and prepared makefile. am.

 

1. autoscan

 

The configure. scan and autoscan. log files are generated.

 

2. Change Configure. Scan to configure. In.

 

Modify the content in configure. in. The modified content of one of the many online versions is as follows:

[Litao @ vm1_131 hello] $ mv configure. scan configure. in <br/> [litao @ vm1_131 hello] $ vim configure. in <br/> #-*-Autoconf-*-<br/> # Process this file with autoconf to produce a configure script. <br/> AC_PREREQ (2.59) <br/> AC_INIT (FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) <br/> AC_CONFIG_SRCDIR ([hello. c]) <br/> # AC_CONFIG_HEADER ([config. h]) <br/> AM_INIT_AUTOMAKE (hello, 1.0) <br/> # Checks for programs. <br/> AC_PROG_CC <br/> # Checks for libraries. <br/> # Checks for header files. <br/> # Checks for typedefs, structures, and compiler characteristics. <br/> # Checks for library functions. <br/> AC_OUTPUT (Makefile) </p> <p>

After checking some information, the above AC_INIT and AC_OUTPUT are mandatory and are used to define the start interface and output file when the configure command is executed. AC_PROG_C is required for compiling c Programs. You can also define other macros to check the compilation environment in the future. If it is just a simple project, no more modifications are required.

3. aclocal

Generate aclocal. m4 and autom4te. cache (configure. in is involved when aclocal. m4 is generated)

4. autoconf

Generate configure (according to configure. in, and aclocal. m4)

 

5. Write makefile. am (if makefile. am is already in the source code, skip this step)

 

6. automake-add-missing

In this step, you may be prompted that the news readme authors ChangeLog file cannot be found. Run the following command:

Touch news readme authors ChangeLog

You may be prompted that the config. in. h file cannot be found. Run the following command:

Autoheader

Now that all the source code installation packages have been built, you can use configure & make install to install them.

7 ../configure

Here, if you add the -- prefix =/... // parameter, you can specify the installation path.

 

8. make

Makefile conforming to the GNU makefiel Convention contains some basic pre-defined operations:

Make: Compile the source code, connect to generate the target file, and execute the file according to makefile.

Make clean: Clear the object files generated by the last make command (Files suffixed with ". O") and executable files.

Make install: Install the compiled executable files to the system directory, which is generally the/usr/local/bin directory.

Make Dist: generate the release package ). This command will pack executable files and related files into a tar.gz compressed file for software release. A file named "package-version.tar.gz" will be generated in the current directory. Package and version are the am_init_automake (package, Version) We defined in Configure. In ).

Make distcheck: Generate and test the release package to confirm the correctness of the release package. This operation will automatically unbind the compressed package file, execute the configure command, and execute make to confirm that there is no error in compilation, and finally prompt that your software package is ready and can be released.

Make distclean: similar to make clean, but it also deletes all files generated by configure, including makefile.

9. make install

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.