Annotation of researchv9/cmd/make/make.1, revision 1.1.1.1

1.1       root        1: .TH MAKE 1
                      2: .CT 1 prog_c writing_troff prog_other
                      3: .SH NAME
                      4: make \(mi maintain collections of programs
                      5: .SH SYNOPSIS
                      6: .B make
                      7: [
                      8: .B -f
                      9: .I makefile
                     10: ]
                     11: [
                     12: .I option ...
                     13: ]
                     14: [
                     15: .I name ...
                     16: ]
                     17: .SH DESCRIPTION
                     18: .I Make
                     19: executes recipes in
                     20: .I makefile
                     21: to update the target
                     22: .IR names
                     23: (usually programs).
                     24: If no target is specified, the targets of the first rule in
                     25: .I makefile
                     26: are updated.
                     27: If no
                     28: .B -f
                     29: option is present,
                     30: .L makefile
                     31: and
                     32: .L Makefile
                     33: are tried in order.
                     34: If
                     35: .I makefile
                     36: is 
                     37: .LR - ,
                     38: the standard input is taken.
                     39: More than one
                     40: .B -f
                     41: option may appear.
                     42: .PP
                     43: .I Make
                     44: updates a target if it depends on prerequisite files
                     45: that have been modified since the target was last modified,
                     46: or if the target does not exist.
                     47: The prerequisites are updated before the target.
                     48: .PP
                     49: The makefile
                     50: comprises a sequence of rules and macro definitions.
                     51: The first line of a rule is a
                     52: blank-separated list of targets, then a single or double colon,
                     53: then a list of prerequisite files terminated by semicolon or newline.
                     54: Text following a semicolon, and all following lines
                     55: that begin with a tab, are shell commands:
                     56: the recipe for updating the target.
                     57: .PP
                     58: If a name appears as target in more than one single-colon rule, it depends
                     59: on all of the prerequisites of those rules, but only
                     60: one recipe may be specified among the rules.
                     61: A target in a double-colon rule is updated by the following
                     62: recipe only if it is out of date with respect to the
                     63: prerequisites of that rule.
                     64: .PP
                     65: Two special forms of name are recognized.
                     66: A name like
                     67: .IR a ( b )
                     68: means the file named
                     69: .I b
                     70: stored in the archive named
                     71: .I a.
                     72: A name like
                     73: .IR a (( b ))
                     74: means the file stored in archive
                     75: .I a
                     76: and containing the entry point
                     77: .I b.
                     78: .PP
                     79: Sharp and newline surround comments.
                     80: .PP
                     81: In this makefile
                     82: .L pgm
                     83: depends on two
                     84: files
                     85: .L a.o
                     86: and
                     87: .LR b.o ,
                     88: and they in turn depend on
                     89: .L .c
                     90: files and a common file
                     91: .L ab.h :
                     92: .EX
                     93: pgm: a.o b.o
                     94: cc a.o b.o -lplot -o pgm
                     95: .sp
                     96: a.o: ab.h a.c
                     97: cc -c a.c
                     98: .sp
                     99: b.o: ab.h b.c
                    100: cc -c b.c
                    101: .EE
                    102: .PP
                    103: Makefile lines of the form
                    104: .IP
                    105: .IB "string1 " = " string2"
                    106: .LP
                    107: are macro definitions.
                    108: Subsequent appearances of
                    109: .BI $( string1 )
                    110: are replaced by
                    111: .IR string2 .
                    112: If
                    113: .I string1
                    114: is a single character, the parentheses are optional;
                    115: .B $$
                    116: is replaced by
                    117: .BR $ .
                    118: Each entry in the environment (see
                    119: .IR sh (1))
                    120: of the
                    121: .I make
                    122: command is taken as a macro definition,
                    123: as are command arguments with embedded equal signs.
                    124: .PP
                    125: Lines of the form
                    126: .IB "string1 " := " string2"
                    127: occurring in a recipe are assignments: macro definitions
                    128: that are made in the course of executing the recipe.
                    129: .PP
                    130: A target containing a single 
                    131: .B %
                    132: introduces a pattern rule,
                    133: which controls the making of names that do not occur
                    134: explicitly as targets.
                    135: The 
                    136: .B %
                    137: matches an arbitrary string called the stem:
                    138: .IB A % B
                    139: matches any string that begins with
                    140: .I A
                    141: and ends with
                    142: .I B.
                    143: A 
                    144: .B %
                    145: in a prerequisite name stands for the stem;
                    146: and the special macro
                    147: .B $%
                    148: stands for the stem in the recipe.
                    149: A name that has no explicit rule is
                    150: matched against the target of each pattern rule.
                    151: The first pattern rule for which the prerequisites exist
                    152: specifies
                    153: further dependencies.
                    154: .PP
                    155: The following pattern rule maintains an object library where all the C source files
                    156: share a common include file
                    157: .LR defs.h .
                    158: The macro
                    159: .B CFLAGS
                    160: sets compiler options.
                    161: .EX
                    162: arch.a(%.o) : %.c defs.h
                    163:        cc $(CFLAGS) -c $%.c
                    164:        ar r arch.a $%.o
                    165:        rm $%.o
                    166: .EE
                    167: .PP
                    168: A set of default pattern rules is built in, and effectively
                    169: follows the user's list of rules.
                    170: Assuming these rules,
                    171: which tell, among other things, how to make
                    172: .B .o
                    173: files from
                    174: .B .c
                    175: files, the first example becomes:
                    176: .EX
                    177: pgm: a.o b.o
                    178: cc a.o b.o -lplot -o pgm
                    179: .sp
                    180: a.o b.o: ab.h
                    181: .EE
                    182: .PP
                    183: Here, greatly simplified, is a sample of the built-in rules:
                    184: .EX
                    185:  CC = cc
                    186:  %.o: %.c
                    187:        $(CC) $(CFLAGS) -c $%.c
                    188:  %.o: %.f
                    189:        f77 $(FFLAGS) -c $%.f
                    190:  % : %.c
                    191:        $(CC) $(CFLAGS) -o $% $%.c
                    192: .EE
                    193: .PP
                    194: The first rule
                    195: says that a name ending in
                    196: .B .o
                    197: could be made
                    198: if a matching name ending in
                    199: .B .c
                    200: were present.
                    201: The second states a similar rule for files ending in
                    202: .BR .f .
                    203: The third says that an arbitrary name can be made
                    204: by compiling a file with that name suffixed by
                    205: .BR .c .
                    206: .PP
                    207: Macros make the builtin pattern rules flexible:
                    208: .B CC
                    209: names the particular C compiler,
                    210: .B CFLAGS
                    211: gives
                    212: .IR cc (1)
                    213: options,
                    214: .B FFLAGS
                    215: for
                    216: .IR f77 (1),
                    217: .B LFLAGS
                    218: for
                    219: .IR lex (1),
                    220: .B YFLAGS
                    221: for
                    222: .IR yacc (1),
                    223: and
                    224: .B PFLAGS
                    225: for
                    226: .IR pascal (1).
                    227: .PP
                    228: An older, now disparaged, means of specifying default rules
                    229: is based only on suffixes.
                    230: Prerequisites are inferred according to selected suffixes
                    231: listed as the `prerequisites' for the special name
                    232: .BR .SUFFIXES ;
                    233: multiple lists accumulate;
                    234: an empty list clears what came before.
                    235: .PP
                    236: The rule to create a file with suffix
                    237: .I s2
                    238: that depends on a similarly named file with suffix
                    239: .I s1
                    240: is specified as an entry
                    241: for the `target'
                    242: .IR s1s2 .
                    243: Order is significant; the first possible name for which both
                    244: a file and a rule exist
                    245: is inferred.
                    246: An old style rule for making
                    247: optimized
                    248: .B .o
                    249: files from
                    250: .B .c
                    251: files is
                    252: .IP
                    253: .L 
                    254: \&.c.o: ; cc -c -O -o $@ $*.c
                    255: .PP
                    256: The following two macros are defined for use in any rule:
                    257: .TP
                    258: .B $($@)
                    259: full name of target
                    260: .PD0
                    261: .TP
                    262: .B $($/)
                    263: target name beginning at the last slash, if any
                    264: .PD
                    265: .LP
                    266: A number of other special macros are defined
                    267: automatically in rules invoked by one of the implicit mechanisms:
                    268: .TP
                    269: .B $*
                    270: target name with suffix deleted
                    271: .PD0
                    272: .TP
                    273: .B $@
                    274: full target name
                    275: .TP
                    276: .B $<
                    277: list of prerequisites in an implicit rule
                    278: .TP
                    279: .B $?
                    280: list of prerequisites that are out of date
                    281: .TP
                    282: .B $^
                    283: list of all prerequisites
                    284: .PD
                    285: .BP
                    286: The following are included for consistency with System V:
                    287: .TP
                    288: .B $(@D)
                    289: directory part of 
                    290: .B $@
                    291: (up to last slash)
                    292: .PD0
                    293: .TP
                    294: .B $(@F)
                    295: file name part of 
                    296: .B $@
                    297: (after last slash)
                    298: .TP
                    299: .B $(*D)
                    300: directory part of 
                    301: .B $*
                    302: (up to last slash)
                    303: .TP
                    304: .B $(*F)
                    305: file name part of 
                    306: .B $*
                    307: (after last slash)
                    308: .TP
                    309: .B $(<D)
                    310: directory part of 
                    311: .B $<
                    312: (up to last slash)
                    313: .TP
                    314: .B $(<F)
                    315: file name part of 
                    316: .B $<
                    317: (after last slash)
                    318: .PD
                    319: .PP
                    320: Recipe lines are executed one at a time, each by its
                    321: own shell.
                    322: A line is printed when it is executed unless
                    323: the special target
                    324: .B .SILENT
                    325: is in the makefile,
                    326: or the first character of the command is 
                    327: .BR @ .
                    328: .PP
                    329: Commands returning nonzero status (see
                    330: .IR intro (1))
                    331: cause
                    332: .I make
                    333: to terminate unless
                    334: the special target
                    335: .B .IGNORE
                    336: is in the makefile
                    337: or the command begins with
                    338: <tab><hyphen>.
                    339: .PP
                    340: Interrupt and quit cause the target to be deleted
                    341: unless the target depends on the special name
                    342: .BR .PRECIOUS .
                    343: .PP
                    344: .I Make
                    345: includes a rudimentary parallel processing ability.
                    346: If the separation string is
                    347: .B :&
                    348: or
                    349: .B ::& ,
                    350: .I make
                    351: can run the command sequences to create the prerequisites
                    352: simultaneously.
                    353: If two names are separated by an ampersand on the right side
                    354: of a colon, those two may be created in parallel.
                    355: .PP
                    356: Other options:
                    357: .TP
                    358: .B -i
                    359: Equivalent to the special entry
                    360: .L .IGNORE: .
                    361: .TP
                    362: .B -k
                    363: When a command returns nonzero status,
                    364: abandon work on the current entry, but
                    365: continue on branches that do not depend on the current entry.
                    366: .TP
                    367: .B -n
                    368: Trace and print, but do not execute the commands
                    369: needed to update the targets.
                    370: .TP
                    371: .B -t
                    372: Touch, i.e. update the modified date of targets, without
                    373: executing any commands.
                    374: .TP
                    375: .B -r
                    376: Equivalent to an initial special entry
                    377: .B .SUFFIXES:
                    378: with no list.
                    379: .TP
                    380: .B -s
                    381: Equivalent to the special entry
                    382: .BR .SILENT: .
                    383: .TP
                    384: .B -e
                    385: Environment definitions override conflicting definitions in arguments
                    386: or in makefiles.
                    387: Ordinary precedence is argument over makefile
                    388: over environment.
                    389: .TP
                    390: .B -o
                    391: Assume old style default suffix list:
                    392: .L
                    393: \&.SUFFIXES: .out .o .c .e .r .f .y .l .s .p
                    394: .TP
                    395: .BI -P n
                    396: Permit
                    397: .I n
                    398: command sequences to be done in parallel with 
                    399: .BR & .
                    400: .TP
                    401: .B -z
                    402: Run commands by passing them to the shell;
                    403: normally simple commands are run directly by
                    404: .IR exec (2).
                    405: .SH FILES
                    406: .F makefile
                    407: .br
                    408: .F Makefile
                    409: .SH "SEE ALSO"
                    410: .IR sh (1), 
                    411: .IR touch (1), 
                    412: .IR ar (1),
                    413: .IR mk (1)
                    414: .br
                    415: S. I. Feldman,
                    416: `Make \- A Program for Maintaining Computer Programs', in
                    417: Bell Laboratories,
                    418: .I Unix Programmer's Manual,
                    419: Holt, Rinehart and Winston, 1983, Vol. 2
                    420: .RI ( "Seventh Edition" )

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.