Roland Ver. 4.5 Technické informace Strana 14

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 212
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 13
4 GNU make
2.2 A Simple Makefile
Here is a straightforward makefile that describes the way an executable file called edit
depends on eight object files which, in turn, depend on eight C source and three header
files.
In this example, all the C files include defs.h, but only those defining editing commands
include command.h, and only low level files that change the editor buffer include buffer.h.
edit : main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
cc -o edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
main.o : main.c defs.h
cc -c main.c
kbd.o : kbd.c defs.h command.h
cc -c kbd.c
command.o : command.c defs.h command.h
cc -c command.c
display.o : display.c defs.h buffer.h
cc -c display.c
insert.o : insert.c defs.h buffer.h
cc -c insert.c
search.o : search.c defs.h buffer.h
cc -c search.c
files.o : files.c defs.h buffer.h command.h
cc -c files.c
utils.o : utils.c defs.h
cc -c utils.c
clean :
rm edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
We split each long line into two lines using backslash/newline; this is like using one long
line, but is easier to read. See Section 3.1.1 [Splitting Long Lines], page 12.
To use this makefile to create the executable file called edit, type:
make
To use this makefile to delete the executable file and all the object files from the directory,
type:
make clean
In the example makefile, the targets include the executable file edit’, and the object
files main.o and kbd.o’. The prerequisites are files such as main.c and defs.h’. In
fact, each .o file is both a target and a prerequisite. Recipes include cc -c main.c and
cc -c kbd.c’.
When a target is a file, it needs to be recompiled or relinked if any of its prerequisites
change. In addition, any prerequisites that are themselves automatically generated should
be updated first. In this example, edit depends on each of the eight object files; the object
file main.o depends on the source file main.c and on the header file defs.h.
Zobrazit stránku 13
1 2 ... 9 10 11 12 13 14 15 16 17 18 19 ... 211 212

Komentáře k této Příručce

Žádné komentáře