Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
CHAPTER 4 make: PROGRAM MAINTAINER The make program provides an easy way to automate the creation of large programs. make reads commands from a user-defined "makefile" that lists the files to be created, the commands that create them, and the files from which they are created. When you direct make to create a program, it makes sure that each file on which the program depends is up to date, then creates the program by executing the given commands. If a file is not up to date, make updates it before creating the program by executing explicitly given commands or one of the many built-in commands. This chapter explains how to use make to automate medium-sized programming projects. It explains how to create makefiles for each project and how to invoke make for creat ing programs and updating files. For more details about the program, see make in "Commands" in the XENIX 286 Reference Manual. Creating a Makefile A makefile contains one or more lines of text called dependency lines. A dependency line shows how a given file depends on other files and what commands are required to bring a file up to date. A dependency line has the form target ... : [ dependent .. . ] [ ; command ... ] where target is the name of a file to be updated, dependent is the name of a file on which the target depends, and command is the XENIX command needed to create the target file. Each dependency line must have at least one command associated with it, even if it is only the null command (;). You may give more than one target name or dependent name if desired. Each name must be separated from the next by at least one space. The target names must be separated from the dependent names by a colon (:). File names must be spelled as defined by the XENIX system. Shell metacharacters, such as star (*) and question mark (?), in file names are expanded when make uses the name. You may give a sequence of commands on the same line as the target and dependent names if you precede each command with a semicolon (;). You can give additional commands on following lines by beginning each line with a tab character. Commands must be given exactly as they would appear on a shell command line. The at sign (@) may be placed in front of a command to prevent make from displaying the command before executing it. Shell commands, such as cd, must appear on single lines; they must not contain the backslash (\} and newline character combination that normally can be used to continue commands between lines. You may add a comment to a makefile by starting the com ment with a nu mber sign (#) and ending it with a newline character. All characters after the nu mber sign are ignored. Comments may be placed at the end of a dependency line if desired. If a command contains a number sign, it must be enclosed in double quotat ion marks ("#"). 4- 1
make: Program Maintainer XENIX Programming If a dependency line is too long, you can continue it by typing a backslash (\) immediately followed by a newline character. The makefile should be kept in the same directory as the given source files. For convenience, the file names makefile, Makefile, s.makefile, and s.Makefile are provided as default file names used by make if no explicit name is given at invocation. You may use one of these names for your makefile or choose one of your own. If the file name begins with the s. prefix, make assumes that it is an sees file and invokes the appropriate sees command to retrieve the latest version of the file. To illustrate dependency lines, consider the following example. A program named prog is made by linking three object files, x.o, y.o, and z.o. These object files are created by compiling the e language source files x.c, y.c, and z.c. Furthermore, the files x.c and y.c contain the line #include "defs" This means that prog depends on the three object files, the object files depend on the e source files, and two of the source files depend on the include file defs. You can represent these relationships in a makefile with the following lines prog : x.o y.o z.o cc x.o y.o z.o -o prog x.o: x.c defs cc -c x.c y.o: y.c defs cc -c y.c z.o: z.c cc -c z.c In the first dependency line, prog is the target file and x.o, y.o, and z.o are its dependents. The command sequence cc x.o y.o z.o -o prog on the next line tells how to create prog if it is out of date. The program is out of date if any one of its dependents has been modified since prog was last created. The second, third, and fourth dependency lines have the same form, with the x.o, y.o, and z.o files as targets and x.c, y.c, z.c, and defs files as dependents. Each dependency line has one command sequence that defines how to update the given target file. 4-2
- Page 1 and 2: 0 • • •
- Page 3 and 4: The information in this document is
- Page 5 and 6: Table of Contents CONTENTS Compiler
- Page 7 and 8: Table of Contents CONTENTS Using Ot
- Page 9 and 10: Table of Contents CONTENTS Assemble
- Page 11 and 12: Table of Contents CONTENTS CHAPTER
- Page 13 and 14: Table of Contents TABLES TABLE TITL
- Page 15 and 16: Introduction XENIX Programming 10.
- Page 17 and 18: cc: C Compiler XENIX Programming Cr
- Page 19 and 20: cc: C Compiler XENIX Programming Th
- Page 21 and 22: cc: C Compiler XENIX Programming Th
- Page 23 and 24: cc: C Compiler XENIX Programming Cr
- Page 25 and 26: cc: C Compiler XENIX Programming Th
- Page 27 and 28: cc: C Compiler XENIX Programming Co
- Page 29 and 30: cc: C Compiler XENIX Programming Sa
- Page 31 and 32: cc: C Compiler XENIX Programming Us
- Page 33 and 34: cc: C Compiler XENIX Programming Wh
- Page 35 and 36: cc: C Compiler XENIX Programming Co
- Page 37 and 38: cc: C Compiler XENIX Programming d
- Page 39 and 40: cc: C Compiler XENIX Programming Se
- Page 41 and 42: lint: C Program Checker XENIX Progr
- Page 43 and 44: lint: C Program Checker XENIX Progr
- Page 45 and 46: lint: C Program Checker XENIX Progr
- Page 47 and 48: lint: C Program Checker XENIX Progr
- Page 49 and 50: lint: C Program Checker XENIX Progr
- Page 51: lint: C Program Checker XENIX Progr
- Page 55 and 56: make: Program Maintainer XENIX Prog
- Page 57 and 58: make: Program Maintainer XENIX Prog
- Page 59 and 60: make: Program Maintainer XENIX Prog
- Page 61 and 62: make: Program Maintainer XENIX Prog
- Page 63 and 64: make: Program Maintainer XENIX Prog
- Page 65 and 66: make: Program Maintainer print: $(F
- Page 67 and 68: SCCS: Source Code Control System XE
- Page 69 and 70: SCCS: Source Code Control System XE
- Page 71 and 72: SCCS: Source Code Control System XE
- Page 73 and 74: SCCS: Source Code Control System XE
- Page 75 and 76: SCCS: Source Code Control System XE
- Page 77 and 78: SCCS: Source Code Control System XE
- Page 79 and 80: SCCS: Source Code Control System XE
- Page 81 and 82: SCCS: Source Code Control System XE
- Page 83 and 84: SCCS: Source Code Control System XE
- Page 85 and 86: SCCS: Source Code Control System XE
- Page 87 and 88: SCCS: Source Code Control System XE
- Page 89 and 90: SCCS: Source Code Control System XE
- Page 91 and 92: SCCS: Source Code Control System XE
- Page 93 and 94: SCCS: Source Code Control System XE
- Page 95 and 96: SCCS: Source Code Control System XE
- Page 98 and 99: CHAPTER 6 adb: PROGRAM DEBUGGER adb
- Page 100 and 101: XENIX Programming adb: Program Debu
CHAPTER 4<br />
make: PROGRAM MAINTAINER<br />
The make program provides an easy way to automate the creation of large programs.<br />
make reads commands from a user-defined "makefile" that lists the files to be created,<br />
the commands that create them, and the files from which they are created. When you<br />
direct make to create a program, it makes sure that each file on which the program<br />
depends is up to date, then creates the program by executing the given commands. If a<br />
file is not up to date, make updates it before creating the program by executing<br />
explicitly given commands or one of the many built-in commands.<br />
This chapter explains how to use make to automate medium-sized programming<br />
projects. It explains how to create makefiles for each project and how to invoke make<br />
for creat ing programs and updating files. For more details about the program, see make<br />
in "Commands" in the <strong>XENIX</strong> <strong>2<strong>86</strong></strong> Reference Manual.<br />
Creating a Makefile<br />
A makefile contains one or more lines of text called dependency lines. A dependency<br />
line shows how a given file depends on other files and what commands are required to<br />
bring a file up to date. A dependency line has the form<br />
target ... : [ dependent .. . ] [ ; command ... ]<br />
where target is the name of a file to be updated, dependent is the name of a file on<br />
which the target depends, and command is the <strong>XENIX</strong> command needed to create the<br />
target file. Each dependency line must have at least one command associated with it,<br />
even if it is only the null command (;).<br />
You may give more than one target name or dependent name if desired. Each name<br />
must be separated from the next by at least one space. The target names must be<br />
separated from the dependent names by a colon (:). File names must be spelled as<br />
defined by the <strong>XENIX</strong> system. Shell metacharacters, such as star (*) and question mark<br />
(?), in file names are expanded when make uses the name.<br />
You may give a sequence of commands on the same line as the target and dependent<br />
names if you precede each command with a semicolon (;). You can give additional<br />
commands on following lines by beginning each line with a tab character. Commands<br />
must be given exactly as they would appear on a shell command line. The at sign (@)<br />
may be placed in front of a command to prevent make from displaying the command<br />
before executing it. Shell commands, such as cd, must appear on single lines; they must<br />
not contain the backslash (\} and newline character combination that normally can be<br />
used to continue commands between lines.<br />
You may add a comment to a makefile by starting the com ment with a nu mber sign (#)<br />
and ending it with a newline character. All characters after the nu mber sign are<br />
ignored. Comments may be placed at the end of a dependency line if desired. If a<br />
command contains a number sign, it must be enclosed in double quotat ion marks ("#").<br />
4- 1