Days Without makefile

Source: Internet
Author: User
Tags automake

1. Days Without makefile

2. Download references and code

<1>. Days Without makefile  

[Previous] introduced the makefile writing rules. The first title is "Days Without makefile". If you receive a reply from zhuangzhuang1988, a netizen from [blog], you can use automake to automatically generate makefile. If you have installed a program from the source code in linux, the general process is as follows:

./Configure; make install

Next we will try to generate this release version, which mainly uses tools such as aclocal and automake.

 

1. Now let's assume that the source code of the program has been compiled. Here is main. c.

Xuqiang @ ubuntu :~ /Automake/helloworld $ ls

Main. cxuqiang @ ubuntu :~ /Automake/helloworld $ cat main. c # include <stdio. h> int main () {printf ("hello linux world! "); Return 0 ;}

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

Xuqiang @ ubuntu :~ /Automake/helloworld $ autoscan

Xuqiang @ ubuntu :~ /Automake/helloworld $ lsautoscan. log configure. scan main. c

3. We use configure. scan as the template of the configure. in file for use by aclocal. First, change configure. scan to configure. in.

Xuqiang @ ubuntu :~ /Automake/helloworld $ mv configure. scan configure. in

Modify configure. in:

Xuqiang @ ubuntu :~ /Automake/helloworld $ vim configure. in

Xuqiang @ ubuntu :~ /Automake/helloworld $ cat configure. in #-*-Autoconf-*-# Process this file with autoconf to produce a configure script. AC_PREREQ ([2.63]) AC_INIT ([helloauto], [1.0], [xuqiang@gmail.com]) AC_CONFIG_SRCDIR ([main. c]) # comment this line, no use # AC_CONFIG_HEADERS ([config. h]) # Checks for programs. AC_PROG_CC # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler c Haracteristics. # Checks for library functions. # init automakeAM_INIT_AUTOMAKE (helloauto, 1.0) # write out the makefileAC_OUTPUT (Makefile) 4. execute the aclocal command to generate aclocal. m4 autom4te. cache two files: xuqiang @ ubuntu :~ /Automake/helloworld $ aclocalxuqiang @ ubuntu :~ /Automake/helloworld $ lsaclocal. m4 autom4te. cache autoscan. log configure. in main. c

5. Run the autoconf command to generate the configure file.

Xuqiang @ ubuntu :~ /Automake/helloworld $ autoconf

Xuqiang @ ubuntu :~ /Automake/helloworld $ lsaclocal. m4 autom4te. cache autoscan. log configure. in main. c6. create the Makefile. am file, which is the dependent file of automake.

Xuqiang @ ubuntu :~ /Automake/helloworld $ vim Makefile. am

Xuqiang @ ubuntu :~ /Automake/helloworld $ cat Makefile. amAUTOMAKE_OPTIONS = foreignbin_PROGRAMS = helloautohelloauto_SOURCES = main. c7. run the automake command to add the required scripts, such as the INSTALL file, to the source file directory. Xuqiang @ ubuntu :~ /Automake/helloworld $ automake -- add-missingMakefile.am: installing '. /INSTALL 'makefile. am: required file '. /NEWS 'not foundMakefile. am: required file '. /README 'not foundMakefile. am: required file '. /AUTHORS 'not foundMakefile. am: required file '. /ChangeLog 'not foundMakefile. am: installing '. /COPYING 'using GNU General Public License v3 fileMakefile. am: Consider adding the COPYING file to the ver Sion control systemMakefile. am: for your code, to avoid questions about which license your project uses. xuqiang @ ubuntu :~ /Automake/helloworld $ lsaclocal. m4 autoscan. log config. status configure. in INSTALL Makefile. amautom4te. cache config. log configure COPYING main. c Makefile. in

8. Test the file generated above.

Xuqiang @ ubuntu :~ /Automake/helloworld $./configure

Checking for a BSD-compatible install... /usr/bin/install-cchecking whether build environment is sane... yeschecking for a thread-safe mkdir-p... /bin/mkdir-pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $ (MAKE )... yeschecking for gcc... gccchecking for C compiler default output file name... a. outchecking whether the C compiler works... yeschecking whether we are cro Ss compiling... nochecking for suffix of executables... checking for suffix of object files... ochecking whether we are using the gnu c compiler... yeschecking whether gcc accepts-g... yeschecking for gcc option to accept ISO c89... none neededchecking for style of include used by make... GNUchecking dependency style of gcc... gcc3configure: creating. /config. statusconfig. status: creating Makefile Config. status: executing depfiles commandsxuqiang @ ubuntu :~ /Automake/helloworld $ makegcc-DPACKAGE_NAME = \ "helloauto \"-DPACKAGE_TARNAME = \ "helloauto \"-DPACKAGE_VERSION = \ "1.0 \"-DPACKAGE_STRING = \ "helloauto \ 1.0 \" -DPACKAGE_BUGREPORT = \ "xuqiang@gmail.com \"-DPACKAGE = \ "helloauto \"-DVERSION = \ "1.0 \"-I. -g-O2-MT main. o-MD-MP-MF. deps/main. tpo-c-o main. o main.. deps/main. tpo. deps/main. pogcc-g-O2-o helloauto main. oxuqiang @ ubuntu :~ /Automake/helloworld $ lsaclocal. m4 config. log configure. in INSTALL Makefileautom4te. cache config. status COPYING main. c Makefile. amautoscan. log configure helloauto main. o Makefile. inxuqiang @ ubuntu :~ /Automake/helloworld $./helloautohello linux world! Xuqiang @ ubuntu :~ /Automake/helloworld $

By using these tools, only a few simple files can be written to generate Makefile and compile the source code.

<2>. Download reference materials and code  

Use the autoconf and automake commands to generate Makefile files.

How to generate automake for Makefile in Linux

A tutorial for porting to autoconf & automake

/Files/xuqiang/helloautomake.rar

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.