You are on page 1of 6

GNU Make Make is a tool which controls the generation of executables and other non-source files of a program from

the program's source files. Make gets its knowledge of how to build your program from a file called the makefile, which lists each of the non-source files and how to compute it from other files. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program. Capabilities of Make

Make enables the end user to build and install your package without knowing the details of how that is done -- because these details are recorded in the makefile that you supply.

Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source file. As a result, if you change a few source files and then run Make, it does not need to recompile all of your program. It updates only those non-source files that depend directly or indirectly on the source files that you changed.

Make is not limited to any particular language. For each non-source file in the program, the makefile specifies the shell commands to compute it. These shell commands can run a compiler to produce an object file, the linker to produce an executable, ar to update a library, or TeX or Makeinfo to format documentation.

Make is not limited to building a package. You can also use Make to control installing or deinstalling a package, generate tags tables for it, or anything else you want to do often enough to make it worth while writing down how to do it.

Make Rules and Targets A rule in the makefile tells Make how to execute a series of commands in order to build a target file from source files. It also specifies a list of dependencies of the target file. This list should

include all files (whether source files or other targets) which are used as inputs to the commands in the rule. Here is what a simple rule looks like: target: dependencies ... commands ... When you run Make, you can specify particular targets to update; otherwise, Make updates the first target listed in the makefile. Of course, any other target files needed as input for generating these targets must be updated first. Make uses the makefile to figure out which target files ought to be brought up to date, and then determines which of them actually need to be updated. If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated. The other target files do need to be updated, but in the right order: each target file must be regenerated before it is used in regenerating other targets. Advantages of GNU Make GNU Make has many powerful features for use in makefiles, beyond what other Make versions have. It can also regenerate, use, and then delete intermediate files which need not be saved. GNU Make also has a few simple features that are very convenient. For example, the -o file option which says ``pretend that source file file has not changed, even though it has changed.'' This is extremely useful when you add a new macro to a header file. Most versions of Make will assume they must therefore recompile all the source files that use the header file; but GNU Make gives you a way to avoid the recompilation, in the case where you know your change to the header file does not require it.

gcc gcc is the C and C++ compiler developed by GNU project. It is widely adopted as the default compiler of UNIX-like systems. If you are using a Mac, you may also get gcc by installing Xcode (Developer) Tools in the Mac OS X installation Disc #1. The basic way of compiling garbage.c into an executable file called "garbage" is:

gcc -o garbage garbage.c

If the program is compiled without errors, you can execute the program by typing "./garbage" followed by two numbers as its arguments. If you are interested about how the assembly code of garbage.c look like, you can also generate the assembly code by replacing the "-o garbage" option with "-S" as:

gcc -S garbage.c

The gcc will stop compiling the program after the "garbage.s" file is generated. You may use any text editor to browser the content of the assembly code. To figure out what the assembly code does, you may reference the following documents.

In addition to the basic usage, gcc also provides options that help you optimize or debug your code. For example, you may:
o

Compile your code with debugging information:

gcc -g -o garbage garbage.c

Compile your code with optimizations:

gcc -On -o garbage garbage.c

gdb gcc is a debugger by GNU project. Gdb can step through your source code line-by-line or even instruction by instruction. You may also watch the value of any variable at run-time. In additon, it also helps to identify the place and the reason making the program crash.

Basic Usage All program to be debugged in gdb must be compiled by gcc with the option "-g" turning on. Continue with the "garbage" example, if we want to debug the program "garbage", we can simply start gdb by:
o

gdb ./garbage

(gdb) To start running and debugging the program, we can simply type the "run" command after the (gdb) prompt as below:

(gdb) run If the program takes arguments such as "garbage arg_1 arg_2", we may start running the program with these arguments as: (gdb) run arg_1 arg_2

Using Valgrind to Find Memory Leaks and Invalid Memory Use Valgrind is a multipurpose code profiling and memory debugging tool for Linux when on the x86 and, as of version 3, AMD64, architectures. It allows you to run your program in Valgrind's own environment that monitors memory usage such as calls to malloc and free (or new and delete in C++). If you use uninitialized memory, write off the end of an array, or forget to free a pointer, Valgrind can detect it. Since these are particularly common problems, this tutorial will focus mainly on using Valgrind to find these types of simple memory problems, though Valgrind is a tool that can do a lot more. Valgrind can also find the use of invalid heap memory using the memcheck tool. For instance, if you allocate an array with malloc or new and then try to access a location past the end of the array: Another type of operation that Valgrind will detect is the use of an uninitialized value in a conditional statement. Although you should be in the

habit of initializing all variables that you create, Valgrind will help find those cases where you don't. The Valgrind distribution currently includes five production-quality tools:

a memory error detector a thread error detector a cache and branch-prediction profiler a call-graph generating cache profiler a heap profiler

It also includes two experimental tools:


a data race detector an instant memory leak detector.

It runs on the following platforms:


X86/Linux AMD64/Linux PPC32/Linux PPC64/Linux

Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with GNU CC (GCC) suite.[1]

The gcov utility gives information on how often a program executes segments of code.[2] It produces a copy of the source file, annotated with execution frequencies. The gcov utility does not produce any time-based data and works only on code compiled with GNU CC. It is not compatible with any other profiling or test coverage mechanism.[3]

CVS is a version control system, an important component of Source Configuration Management (SCM). Using it, you can record the history of sources files, and documents. It fills a similar role to the free software RCS, PRCS, and Aegis packages.

CVS is a production quality system in wide use around the world, including many free software projects.

Bugzilla is the most popular bug tracking system available today. Bugzillas popularity is due to its highly customizable interface, easy configuration, and a large community of very active users. With Bugzilla, you can begin configuring your products, users, and bugs within minutes of starting up the system. Bugzilla provides you with many features, including: LDAP integration SMTP and Sendmail support Internationalized User authentication, group security, and SSL support Voting system Shortcut flags Custom fields Keyword tagging Saved searches Voting module Multiple report types

You might also like