LINUX Environment Makeup (1) Writing: Leaf Zhou Email: Leaf_zhou_8@hotmail.com Free copy but prohibitedly deleted 2003-10-12 No matter what a senior Linux programmer is written, write makefile files It is a very troublesome thing; more, developers should put the main energy on the programming code, and it costs too much in the makefile file obviously unblocked; and for different processor architectures Different compilers, the environment is different, especially the compilation of various procedures in the embedded system, so that the implication of the Makefile file is complicated, and this problem is important. 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
Makefile.am: installing `./depcomp '[root @ localhost testmk] #ls aclocal.m4 [autom4te.cache] configure configure.in depcomp hello.c install-sh Makefile.am Makefile.in missing mkinstalldirs 8> configure script Generate the Makefile file we need. [root @ localhost testmk] #. / configure checking for a bsd-compatible install ... / usr / bin / install ... product is checking for gawk ... gawk checking for gawk ... gawk checking WHETHER MAKE SETS $ (Make) ... YES Checking for GCC ... GCC Checking for C Compiler Default Output ... a.out checking WHETER THE C Compiler Works ... Yes Checking WETHER WEARE CROSS Compiling ... No Checking for Suffix Of Executables ... Checking for Suffix Of Object Files ... o Checking WHETHER WEE Are Using The GNU C Compiler ... Yes Checking WHETER GCC Accepts -g ... YES Checking for GCC Option To Accept ANSI C ... NONE NEEDED checking for style of include used by make ... GNU checking dependency style of gcc ... gcc3 configure: creating ./config.status config.status: creating Makefile config.status: executing depfiles commands 9> last executed only make you're done [Root @ localhost testmk] #make source = 'hello.c' {= 'hello.o' libtool = no / depfile = '. DEPS / HELLO.PO' TMPDEPFILE = '. DEPS / HELLO.TPO' / Deps = GCC3 / BIN / SH./DEPComp / GCC - DPACKAGE_NAME = / "/" / "-dpackage_version = /" / "-dpackage_bugreport = /" / "-dpackage = /" hello / "-dversion = /" 1.0 / " -I. -I. -G -O2 -C `Test -f 'hello.c' || echo './'`Hello.c gcc -g-^ -o hello hello.o Note: 1. All above Tested in the Redhat Linux 9.0 environment.