Web host forum - 794 Part VI . Programming in Linux Listing
794 Part VI . Programming in Linux Listing 29-4: A Sample Makefile editor : editor.o screen.o keyboard.o gcc -o editor editor.o screen.o keyboard.o editor.o : editor.c gcc -c editor.c screen.o : screen.c gcc -c screen.c keyboard.o : keyboard.c gcc -c keyboard.c clean : rm -f *.o core *~ realclean : clean rm -f editor To compile editor, you simply type make in the directory that contains the makefile. It s that simple. This example makefile has six rules. The first defines how to create the target named editor. The first target in every makefile is the default target (unless you specifically define one using the .DEFAULT directive, which is not covered in this chapter). The default target is the one that make builds if no target is specified as an argument to make. editor has three dependencies: editor.o, screen.o, and keyboard.o; these three files must exist to build editor. The second line in the first rule is the command that make must execute to create editor: gcc -o editor editor.o screen.o keyboard.o. It builds the executable from the three object files: editor.o, screen.o, and keyboard.o. The next three rules tell make how to build the individual object files. Each rule consists of one object file target (editor.o, screen,o, keyboard.o); one source code file dependency (editor.c, screen.c, keyboard.c); and a rule that defines how to build that target. The fifth rule defines a target named clean with no dependencies. When a target has no dependencies, its commands are executed whenever the target is invoked. In this case, clean deletes the constituent object files (*.o), plus any core files (core) as well as any Emacs backup files (*~) from previous builds.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.