Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

XENIX Programming make: Program Maintainer Invoking make Once you have a makefile and wish to update and modify one or more target files in the directory, you can invoke make by typing its name and optional arguments. The invocation has the form make [ option ] ... [ macdef] ... [ target] ... where option is a program option used to modify program operation, macdef is a macro definition used to give a macro a value or meaning, and target is the file name of a file to be updated. target must correspond to one of the target names in the makefile. All arguments are optional. If you give more than one argument, you must separate them with spaces. You can direct make to update the first target file in the makefile by typing just the program name "make". In this case, make searches for one of the files makefile, Makefile, s.makefile, or s. Makefile in the current directory and uses the first one it finds as the makefile. For example, assume that the current makefile contains the dependency lines given in the last section. Then the com mand make compares the modification dates of the prog program and each of the object files x.o, y.o, and z.o and recreates prog if any changes have been made to any object file since prog was last created. It also compares the modified dates of the object files with those of the four source files, x.c, y.c, z.c, and defs, and recreates the object files if the source files have changed. It does this before recreating prog so that the recreated object files can be used to recreate prog. If none of the source or object files has been altered since the last time prog was made, make announces this fact and stops. No files are changed. You can direct make to update a given target file by giving the file name of the target. For example, make x.o causes make to recompile the x.o file if the x.c or defs files have changed since the object file was last created. Sim ilarly, the command make x.o z.o causes make to recompile x.o and z.o if the corresponding dependents have been modified. make processes target names from the command line in a left-to-right order. You can specify the name of the makefile you wish make to use by giving the -f option in the invocation. The option has the form -f filename where filename is the name of the makefile. You must supply a full path name if the file is not in the current directory. For example, the command make -f makeprog 4-3

make: Program Maintainer XENIX Programming reads the dependency lines of the makefile named makeprog found in the current directory. You can direct make to read dependency lines from the standard input by giving "- " as the file name. make will read the standard input until end-of-file is encountered. You may use program options to modify the operation of the make program. The following list describes some of the options: -p Prints the complete set of macro definitions and dependency lines in a makefile. -i Ignores errors returned by XENIX commands. -k Abandons work on the current entry but continues on other branches that do not depend on that entry. -s Executes commands without displaying them. -r Ignores the built-in rules. -n Displays commands but does not execute them. make -n even displays lines beginning with the at sign (@). -e Ignores any macro definitions that attempt to assign new values to the shell's environment variables. -t Changes the modification date of each target file without recreating the files. Note that make executes each command in the makefile by passing it to a separate invocation of a shell. Because each command line is passed to a separate invocation of the shell, care must be taken with certain commands (e.g., cd and shell control commands) that have meaning only within a single shell process; the results are forgotten before the next line is executed. If an error occurs, make norm ally stops the command. Using Pseudo-Target Names It is often useful to include dependency lines that have pseudo-target names, i.e., names for which no files actually exist or are produced. Pseudo-target names allow make to perform tasks not directly connected with the creation of a program, such as deleting old files or printing copies of source files. For example, the following dependency line removes old copies of the given object files when the pseudo-target name "cleanup" is given in the invocation of make. cleanup : rm x.o y.o z.o Since no file exists for a given pseudo-target name, the target is always assumed to be out of date. Thus the associated command is always executed. 4-4

make: Program Maintainer <strong>XENIX</strong> Programming<br />

reads the dependency lines of the makefile named makeprog found in the current<br />

directory. You can direct make to read dependency lines from the standard input by<br />

giving "- " as the file name. make will read the standard input until end-of-file is<br />

encountered.<br />

You may use program options to modify the operation of the make program. The<br />

following list describes some of the options:<br />

-p Prints the complete set of macro definitions and dependency lines in a makefile.<br />

-i Ignores errors returned by <strong>XENIX</strong> commands.<br />

-k Abandons work on the current entry but continues on other branches that do not<br />

depend on that entry.<br />

-s Executes commands without displaying them.<br />

-r Ignores the built-in rules.<br />

-n Displays commands but does not execute them. make -n even displays lines<br />

beginning with the at sign (@).<br />

-e Ignores any macro definitions that attempt to assign new values to the shell's<br />

environment variables.<br />

-t Changes the modification date of each target file without recreating the files.<br />

Note that make executes each command in the makefile by passing it to a separate<br />

invocation of a shell. Because each command line is passed to a separate invocation of<br />

the shell, care must be taken with certain commands (e.g., cd and shell control<br />

commands) that have meaning only within a single shell process; the results are<br />

forgotten before the next line is executed. If an error occurs, make norm ally stops the<br />

command.<br />

Using Pseudo-Target Names<br />

It is often useful to include dependency lines that have pseudo-target names, i.e., names<br />

for which no files actually exist or are produced. Pseudo-target names allow make to<br />

perform tasks not directly connected with the creation of a program, such as deleting<br />

old files or printing copies of source files. For example, the following dependency line<br />

removes old copies of the given object files when the pseudo-target name "cleanup" is<br />

given in the invocation of make.<br />

cleanup :<br />

rm x.o y.o z.o<br />

Since no file exists for a given pseudo-target name, the target is always assumed to be<br />

out of date. Thus the associated command is always executed.<br />

4-4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!