|
|
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: .LR ab.h : ! 92: .PP ! 93: .EX ! 94: pgm: a.o b.o ! 95: cc a.o b.o -lplot -o pgm ! 96: .EE ! 97: .PP ! 98: .EX ! 99: a.o: ab.h a.c ! 100: cc -c a.c ! 101: .EE ! 102: .PP ! 103: .EX ! 104: b.o: ab.h b.c ! 105: cc -c b.c ! 106: .EE ! 107: .PP ! 108: Makefile lines of the form ! 109: .IP ! 110: .IB "string1 " = " string2" ! 111: .LP ! 112: are macro definitions. ! 113: Subsequent appearances of ! 114: .BI $( string1 ) ! 115: are replaced by ! 116: .IR string2 . ! 117: If ! 118: .I string1 ! 119: is a single character, the parentheses are optional; ! 120: .B $$ ! 121: is replaced by ! 122: .BR $ . ! 123: Each entry in the environment (see ! 124: .IR sh (1)) ! 125: of the ! 126: .I make ! 127: command is taken as a macro definition, ! 128: as are command arguments with embedded equal signs. ! 129: .PP ! 130: Lines of the form ! 131: .IB "string1 " := " string2" ! 132: occurring in a recipe are assignments: macro definitions ! 133: that are made in the course of executing the recipe. ! 134: .PP ! 135: A target containing a single ! 136: .B % ! 137: introduces a pattern rule, ! 138: which controls the making of names that do not occur ! 139: explicitly as targets. ! 140: The ! 141: .B % ! 142: matches an arbitrary string called the stem: ! 143: .IB A % B ! 144: matches any string that begins with ! 145: .I A ! 146: and ends with ! 147: .I B. ! 148: A ! 149: .B % ! 150: in a prerequisite name stands for the stem; ! 151: and the special macro ! 152: .B $% ! 153: stands for the stem in the recipe. ! 154: A name that has no explicit recipe is ! 155: matched against the target of each pattern rule. ! 156: The first pattern rule for which the prerequisites exist ! 157: specifies ! 158: further dependencies. ! 159: .PP ! 160: The following pattern rule maintains an object library where all the C source files ! 161: share a common include file ! 162: .LR defs.h . ! 163: .PP ! 164: .EX ! 165: arch.a(%.o) : %.c defs.h ! 166: cc -c $%.c ! 167: ar r arch.a $%.o ! 168: rm $%.o ! 169: .EE ! 170: .PP ! 171: A set of default pattern rules is built in, and effectively ! 172: follows the user's list of rules. ! 173: Assuming these rules, ! 174: which tell, among other things, how to make ! 175: .B .o ! 176: files from ! 177: .B .c ! 178: files, the first example becomes: ! 179: .PP ! 180: .EX ! 181: pgm: a.o b.o ! 182: cc a.o b.o -lplot -o pgm ! 183: .EE ! 184: .PP ! 185: .EX ! 186: a.o b.o: ab.h ! 187: .EE ! 188: .PP ! 189: Here, greatly simplified, is a sample of the built-in rules: ! 190: .PP ! 191: .EX ! 192: CC = cc ! 193: %.o: %.c ! 194: $(CC) $(CFLAGS) -c $%.c ! 195: %.o: %.f ! 196: f77 $(FFLAGS) -c $%.f ! 197: % : %.c ! 198: $(CC) $(CFLAGS) -o $% $%.c ! 199: .EE ! 200: .PP ! 201: The first rule ! 202: says that a name ending in ! 203: .B .o ! 204: could be made ! 205: if a matching name ending in ! 206: .B .c ! 207: were present. ! 208: The second states a similar rule for files ending in ! 209: .BR .f . ! 210: The third says that an arbitrary name can be made ! 211: by compiling a file with that name suffixed by ! 212: .BR .c . ! 213: .PP ! 214: Macros make the builtin pattern rules flexible: ! 215: .B CC ! 216: names the particular C compiler, ! 217: .B CFLAGS ! 218: gives ! 219: .IR cc (1) ! 220: options, ! 221: .B FFLAGS ! 222: for ! 223: .IR f77 (1), ! 224: .B LFLAGS ! 225: for ! 226: .IR lex (1), ! 227: .B YFLAGS ! 228: for ! 229: .IR yacc (1), ! 230: and ! 231: .B PFLAGS ! 232: for ! 233: .IR pascal (A). ! 234: .PP ! 235: An older, now disparaged, means of specifying default rules ! 236: is based only on suffixes. ! 237: Prerequisites are inferred according to selected suffixes ! 238: listed as the `prerequisites' for the special name ! 239: .BR .SUFFIXES ; ! 240: multiple lists accumulate; ! 241: an empty list clears what came before. ! 242: .PP ! 243: The rule to create a file with suffix ! 244: .I s2 ! 245: that depends on a similarly named file with suffix ! 246: .I s1 ! 247: is specified as an entry ! 248: for the `target' ! 249: .IR s1s2 . ! 250: Order is significant; the first possible name for which both ! 251: a file and a rule exist ! 252: is inferred. ! 253: An old style rule for making ! 254: optimized ! 255: .B .o ! 256: files from ! 257: .B .c ! 258: files is ! 259: .PP ! 260: .EX ! 261: \&.SUFFIXES: .c .o ! 262: \&.c.o: ; cc -c -O -o $@ $*.c ! 263: .EE ! 264: .PP ! 265: The following two macros are defined for use in any rule: ! 266: .TP ! 267: .B $($@) ! 268: full name of target ! 269: .PD0 ! 270: .TP ! 271: .B $($/) ! 272: target name beginning at the last slash, if any ! 273: .PD ! 274: .LP ! 275: A number of other special macros are defined ! 276: automatically in rules invoked by one of the implicit mechanisms: ! 277: .TP ! 278: .B $* ! 279: target name with suffix deleted ! 280: .PD0 ! 281: .TP ! 282: .B $@ ! 283: full target name ! 284: .TP ! 285: .B $< ! 286: list of prerequisites in an implicit rule ! 287: .TP ! 288: .B $? ! 289: list of prerequisites that are out of date ! 290: .TP ! 291: .B $^ ! 292: list of all prerequisites ! 293: .PD ! 294: .PP ! 295: The following are included for consistency with System V: ! 296: .TP ! 297: .B $(@D) ! 298: directory part of ! 299: .B $@ ! 300: (up to last slash) ! 301: .PD0 ! 302: .TP ! 303: .B $(@F) ! 304: file name part of ! 305: .B $@ ! 306: (after last slash) ! 307: .TP ! 308: .B $(*D) ! 309: directory part of ! 310: .B $* ! 311: (up to last slash) ! 312: .TP ! 313: .B $(*F) ! 314: file name part of ! 315: .B $* ! 316: (after last slash) ! 317: .TP ! 318: .B $(<D) ! 319: directory part of ! 320: .B $< ! 321: (up to last slash) ! 322: .TP ! 323: .B $(<F) ! 324: file name part of ! 325: .B $< ! 326: (after last slash) ! 327: .PD ! 328: .PP ! 329: Recipe lines are executed one at a time, each by its ! 330: own shell. ! 331: A line is printed when it is executed unless ! 332: the special target ! 333: .B .SILENT ! 334: is in the makefile, ! 335: or the first character of the command is ! 336: .BR @ . ! 337: .PP ! 338: Commands that return nonzero status ! 339: cause ! 340: .I make ! 341: to terminate unless ! 342: the special target ! 343: .B .IGNORE ! 344: is in the makefile ! 345: or the command begins with ! 346: <tab><hyphen>. ! 347: .PP ! 348: Interrupt and quit cause the target to be deleted ! 349: unless the target depends on the special name ! 350: .BR .PRECIOUS . ! 351: .PP ! 352: .I Make ! 353: includes a rudimentary parallel processing ability. ! 354: If the separation string is ! 355: .B :& ! 356: or ! 357: .B ::& , ! 358: .I make ! 359: can run the command sequences to create the prerequisites ! 360: simultaneously. ! 361: If two names are separated by an ampersand on the right side ! 362: of a colon, those two may be created in parallel. ! 363: .PP ! 364: Other options: ! 365: .TP ! 366: .B -i ! 367: Equivalent to the special entry ! 368: .L .IGNORE: . ! 369: .TP ! 370: .B -k ! 371: When a command returns nonzero status, ! 372: abandon work on the current entry, but ! 373: continue on branches that do not depend on the current entry. ! 374: .TP ! 375: .B -n ! 376: Trace and print, but do not execute the commands ! 377: needed to update the targets. ! 378: .TP ! 379: .B -t ! 380: Touch, i.e. update the modified date of targets, without ! 381: executing any commands. ! 382: .TP ! 383: .B -r ! 384: Turn off built-in rules. ! 385: .TP ! 386: .B -s ! 387: Equivalent to the special entry ! 388: .BR .SILENT: . ! 389: .TP ! 390: .B -e ! 391: Environment definitions override conflicting definitions in arguments ! 392: or in makefiles. ! 393: Ordinary precedence is argument over makefile ! 394: over environment. ! 395: .TP ! 396: .B -o ! 397: Assume old style default suffix list: ! 398: .L ! 399: \&.SUFFIXES: .out .o .c .e .r .f .y .l .s .p ! 400: .TP ! 401: .BI -P n ! 402: Permit ! 403: .I n ! 404: command sequences to be done in parallel with ! 405: .BR & . ! 406: .TP ! 407: .B -z ! 408: Run commands by passing them to the shell; ! 409: normally simple commands are run directly by ! 410: .IR exec (2). ! 411: .SH FILES ! 412: .F makefile ! 413: .br ! 414: .F Makefile ! 415: .SH "SEE ALSO" ! 416: .IR sh (1), ! 417: .I touch ! 418: in ! 419: .IR chdate (1), ! 420: .IR ar (1), ! 421: .IR mk (1) ! 422: .SH BUGS ! 423: Comments can't appear on recipe lines. ! 424: .br ! 425: Archive entries are not handled reliably.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.