Transfer from: http://www.linuxmine.com/3690.html 2006-6-23
Author: linux treasury (http://www.linuxmine.com) from: linux treasury (http://www.linuxmine.com) Existing: http: //www.linuxmine.com/3690.html Contact: linuxmine # gmail .com doesn't understand? Welcome to the Linux Forum (http://bbs.linuxmine.com) to participate in discussion! Makefile file production on Linux Environment (1) Write: Leaf ZHOUEMAIL: Leaf_zhou_8@hotmail.com Free copy but prohibited from deletion 2003-10-12 Whether it is a presence of an initialist or a senior Linux program, writing a Makefile file is a very troublesome thing; more, developers should put the main energy on the program code, and there is too much in the Makefile file. The energy is obviously unmokent; there is also a different processor architecture, the compiler is often different, especially the compilation of various programs in some embedded systems, especially in some embedded systems, and the Makefile file is also It is important to complicate and this problem is also. The masters of Linux for these issues have long been thought of, so they have developed some tools that automatically generate the Makefile file. They are the following tools:> GNU Automake> GNU AutoConf> GNU M4> Perl> GNU Libtool So your operating system must have the above software, otherwise it is not able to automatically generate a Makefile file or a variety of processes during the generation. problem. Use the AutoConf / Automake / AutoHeader tool to handle various transplantability, with these tools to complete the collection of system configuration information, and make your Makefile file. Then just pass "./configure; make" when intending to compile the source code, you can get a clean and neat compilation.
Make the Makefile file requires the following steps: 1> Establish compilation directory and source directory and source file (ie, the source file to be compiled) [root @ localhost leaf] #mkdir testmk [root @ localhost leaf] #CD TestMk [root @ Localhost Testmk] #vi hello.c Editing Hello.c files as follows: / * filename: hello.c * / # include
Localhost Testmk] # lsaclocal.m4 [Autom4Te.cache] configure configure.in DepComphello.c install-sh makefile.am makefile.in missingmkinstallDirs8> Execute the configure script to generate the Makefile file we need. [Root @ localhost testmk] #. / Configurechecking for a BSD-compatible install ... / usr / bin / install -cchecking whether build environment is sane ... yeschecking for gawk ... gawkchecking whether make sets $ (MAKE). .. yeschecking for gcc ... gccchecking for C compiler default output ... a.outchecking whether the C compiler works ... yeschecking whether we are cross 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 ANSI C ... none neededchecking for style of include used by make ... GNUchecking dependency style of gcc ... gcc3configure: creating ./config.statusconfig.status: creating Makefileconfig.status: executing depfiles commands9> to make the final implementation only done: [root @ localhost testmk] # makesource = 'hello.c' object = 'Hello.o' libtool = no /DEpfile='.deps/hello.po 'tmpdepfile ='. DEPS / HELLO.TPO '/ DepMode = GCC3 / bin / sh ./depcomp / gcc -dpackage_name = / "/" - DPAC Kage_tarname = / "/" -dpackage_string = / "/" -dpackage_bugreport = / "/" -dpackage = / "hello /" -dversion = / "1.0 /" -i. -I. - G -O2 -C `Test -f 'hello.c' || echo './'`helo.cccc -g-^ --o Hello Hello.o Note: 1. The above is tested in the Redhat Linux 9.0 environment .