Linux configure file generation

Source: Internet
Author: User
Tags automake

1. Install the tool automake and Autoconf. Compile the source program: mycc. C.

#include <stdio.h>#include "config.h"int main(int argc, char** argv){    if(argv == 1)    {        printf("version: %s\n", PACKAGE_STRING);    }    else    {        printf("name     : %s\n", PACKAGE);        printf("version  : %s\n", VERSION);        printf("bugreport: %s\n", PACKAGE_BUGREPORT);    }    return 0;}

It should be noted that the macro used in mycc. C is from config. H, and config. H is generated by the tool (see the following article)

2. Run autoscan to generate Configure. Scan

[root@waf mypkg]# autoscan[root@waf mypkg]# lsautoscan.log  configure.scan  mycc.c[root@waf mypkg]#

Rename Configure. Scan to configure. In and edit Configure. In.

#                                               -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.63])AC_INIT([mycc], [1.0.0], [www.mycc.org])AC_CONFIG_SRCDIR([mycc.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([mycc], [1.0.0])# Checks for programs.AC_PROG_CC# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.AC_OUTPUT(Makefile)

3. Run aclocal and Autoconf

[root@waf mypkg]# aclocal[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure.in  mycc.c[root@waf mypkg]# autoconf[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure  configure.in  mycc.c

4. Create makefile. Am. content:

AUTOMAKE_OPTIONS=foreignbin_PROGRAMS=myccmycc_SOURCES=mycc.c

5. Run autoheader to generate config. H. In (automake is required)

[root@waf mypkg]# lsaclocal.m4  autom4te.cache  autoscan.log  configure  configure.in  mycc.c[root@waf mypkg]# vim Makefile.am[root@waf mypkg]# autoheader[root@waf mypkg]# lsaclocal.m4      autoscan.log  configure     Makefile.amautom4te.cache  config.h.in   configure.in  mycc.c

6. Run automake to generate configure

[root@waf mypkg]# automake --add-missingconfigure.in:8: installing `./install-sh'configure.in:8: installing `./missing'Makefile.am: installing `./depcomp'[root@waf mypkg]#

7. Try configure.

./configuremakemake install

Refer:

Http://www.ibm.com/developerworks/cn/linux/l-makefile/

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.