1This is Info file make.info, produced by Makeinfo-1.54 from the input 2file ./make.texinfo. 3 4 This file documents the GNU Make utility, which determines 5automatically which pieces of a large program need to be recompiled, 6and issues the commands to recompile them. 7 8 This is Edition 0.45, last updated 11 May 1994, of `The GNU Make 9Manual', for `make', Version 3.71 Beta. 10 11 Copyright (C) 1988, '89, '90, '91, '92, '93, '94 Free Software 12Foundation, Inc. 13 14 Permission is granted to make and distribute verbatim copies of this 15manual provided the copyright notice and this permission notice are 16preserved on all copies. 17 18 Permission is granted to copy and distribute modified versions of 19this manual under the conditions for verbatim copying, provided that 20the entire resulting derived work is distributed under the terms of a 21permission notice identical to this one. 22 23 Permission is granted to copy and distribute translations of this 24manual into another language, under the above conditions for modified 25versions, except that this permission notice may be stated in a 26translation approved by the Free Software Foundation. 27 28 29File: make.info, Node: Quick Reference, Next: Complex Makefile, Prev: Makefile Conventions, Up: Top 30 31Quick Reference 32*************** 33 34 This appendix summarizes the directives, text manipulation functions, 35and special variables which GNU `make' understands. *Note Special 36Targets::, *Note Catalogue of Implicit Rules: Catalogue of Rules, and 37*Note Summary of Options: Options Summary, for other summaries. 38 39 Here is a summary of the directives GNU `make' recognizes: 40 41`define VARIABLE' 42`endef' 43 Define a multi-line, recursively-expanded variable. 44 *Note Sequences::. 45 46`ifdef VARIABLE' 47`ifndef VARIABLE' 48`ifeq (A,B)' 49`ifeq "A" "B"' 50`ifeq 'A' 'B'' 51`ifneq (A,B)' 52`ifneq "A" "B"' 53`ifneq 'A' 'B'' 54`else' 55`endif' 56 Conditionally evaluate part of the makefile. 57 *Note Conditionals::. 58 59`include FILE' 60 Include another makefile. 61 *Note Including Other Makefiles: Include. 62 63`override VARIABLE = VALUE' 64`override VARIABLE := VALUE' 65`override VARIABLE += VALUE' 66`override define VARIABLE' 67`endef' 68 Define a variable, overriding any previous definition, even one 69 from the command line. 70 *Note The `override' Directive: Override Directive. 71 72`export' 73 Tell `make' to export all variables to child processes by default. 74 *Note Communicating Variables to a Sub-`make': Variables/Recursion. 75 76`export VARIABLE' 77`export VARIABLE = VALUE' 78`export VARIABLE := VALUE' 79`export VARIABLE += VALUE' 80`unexport VARIABLE' 81 Tell `make' whether or not to export a particular variable to child 82 processes. 83 *Note Communicating Variables to a Sub-`make': Variables/Recursion. 84 85`vpath PATTERN PATH' 86 Specify a search path for files matching a `%' pattern. 87 *Note The `vpath' Directive: Selective Search. 88 89`vpath PATTERN' 90 Remove all search paths previously specified for PATTERN. 91 92`vpath' 93 Remove all search paths previously specified in any `vpath' 94 directive. 95 96 Here is a summary of the text manipulation functions (*note 97Functions::.): 98 99`$(subst FROM,TO,TEXT)' 100 Replace FROM with TO in TEXT. 101 *Note Functions for String Substitution and Analysis: Text 102 Functions. 103 104`$(patsubst PATTERN,REPLACEMENT,TEXT)' 105 Replace words matching PATTERN with REPLACEMENT in TEXT. 106 *Note Functions for String Substitution and Analysis: Text 107 Functions. 108 109`$(strip STRING)' 110 Remove excess whitespace characters from STRING. 111 *Note Functions for String Substitution and Analysis: Text 112 Functions. 113 114`$(findstring FIND,TEXT)' 115 Locate FIND in TEXT. 116 *Note Functions for String Substitution and Analysis: Text 117 Functions. 118 119`$(filter PATTERN...,TEXT)' 120 Select words in TEXT that match one of the PATTERN words. 121 *Note Functions for String Substitution and Analysis: Text 122 Functions. 123 124`$(filter-out PATTERN...,TEXT)' 125 Select words in TEXT that *do not* match any of the PATTERN words. 126 *Note Functions for String Substitution and Analysis: Text 127 Functions. 128 129`$(sort LIST)' 130 Sort the words in LIST lexicographically, removing duplicates. 131 *Note Functions for String Substitution and Analysis: Text 132 Functions. 133 134`$(dir NAMES...)' 135 Extract the directory part of each file name. 136 *Note Functions for File Names: Filename Functions. 137 138`$(notdir NAMES...)' 139 Extract the non-directory part of each file name. 140 *Note Functions for File Names: Filename Functions. 141 142`$(suffix NAMES...)' 143 Extract the suffix (the last `.' and following characters) of each 144 file name. 145 *Note Functions for File Names: Filename Functions. 146 147`$(basename NAMES...)' 148 Extract the base name (name without suffix) of each file name. 149 *Note Functions for File Names: Filename Functions. 150 151`$(addsuffix SUFFIX,NAMES...)' 152 Append SUFFIX to each word in NAMES. 153 *Note Functions for File Names: Filename Functions. 154 155`$(addprefix PREFIX,NAMES...)' 156 Prepend PREFIX to each word in NAMES. 157 *Note Functions for File Names: Filename Functions. 158 159`$(join LIST1,LIST2)' 160 Join two parallel lists of words. 161 *Note Functions for File Names: Filename Functions. 162 163`$(word N,TEXT)' 164 Extract the Nth word (one-origin) of TEXT. 165 *Note Functions for File Names: Filename Functions. 166 167`$(words TEXT)' 168 Count the number of words in TEXT. 169 *Note Functions for File Names: Filename Functions. 170 171`$(firstword NAMES...)' 172 Extract the first word of NAMES. 173 *Note Functions for File Names: Filename Functions. 174 175`$(wildcard PATTERN...)' 176 Find file names matching a shell file name pattern (*not* a `%' 177 pattern). 178 *Note The Function `wildcard': Wildcard Function. 179 180`$(shell COMMAND)' 181 Execute a shell command and return its output. 182 *Note The `shell' Function: Shell Function. 183 184`$(origin VARIABLE)' 185 Return a string describing how the `make' variable VARIABLE was 186 defined. 187 *Note The `origin' Function: Origin Function. 188 189`$(foreach VAR,WORDS,TEXT)' 190 Evaluate TEXT with VAR bound to each word in WORDS, and 191 concatenate the results. 192 *Note The `foreach' Function: Foreach Function. 193 194 Here is a summary of the automatic variables. *Note Automatic 195Variables: Automatic, for full information. 196 197`$@' 198 The file name of the target. 199 200`$%' 201 The target member name, when the target is an archive member. 202 203`$<' 204 The name of the first dependency. 205 206`$?' 207 The names of all the dependencies that are newer than the target, 208 with spaces between them. For dependencies which are archive 209 members, only the member named is used (*note Archives::.). 210 211`$^' 212 The names of all the dependencies, with spaces between them. For 213 dependencies which are archive members, only the member named is 214 used (*note Archives::.). 215 216`$*' 217 The stem with which an implicit rule matches (*note How Patterns 218 Match: Pattern Match.). 219 220`$(@D)' 221`$(@F)' 222 The directory part and the file-within-directory part of `$@'. 223 224`$(*D)' 225`$(*F)' 226 The directory part and the file-within-directory part of `$*'. 227 228`$(%D)' 229`$(%F)' 230 The directory part and the file-within-directory part of `$%'. 231 232`$(<D)' 233`$(<F)' 234 The directory part and the file-within-directory part of `$<'. 235 236`$(^D)' 237`$(^F)' 238 The directory part and the file-within-directory part of `$^'. 239 240`$(?D)' 241`$(?F)' 242 The directory part and the file-within-directory part of `$?'. 243 244 These variables are used specially by GNU `make': 245 246`MAKEFILES' 247 Makefiles to be read on every invocation of `make'. 248 *Note The Variable `MAKEFILES': MAKEFILES Variable. 249 250`VPATH' 251 Directory search path for files not found in the current directory. 252 *Note `VPATH' Search Path for All Dependencies: General Search. 253 254`SHELL' 255 The name of the system default command interpreter, usually 256 `/bin/sh'. You can set `SHELL' in the makefile to change the 257 shell used to run commands. *Note Command Execution: Execution. 258 259`MAKE' 260 The name with which `make' was invoked. Using this variable in 261 commands has special meaning. *Note How the `MAKE' Variable 262 Works: MAKE Variable. 263 264`MAKELEVEL' 265 The number of levels of recursion (sub-`make's). 266 *Note Variables/Recursion::. 267 268`MAKEFLAGS' 269 The flags given to `make'. You can set this in the environment or 270 a makefile to set flags. 271 *Note Communicating Options to a Sub-`make': Options/Recursion. 272 273`SUFFIXES' 274 The default list of suffixes before `make' reads any makefiles. 275 276 277File: make.info, Node: Complex Makefile, Next: Concept Index, Prev: Quick Reference, Up: Top 278 279Complex Makefile Example 280************************ 281 282 Here is the makefile for the GNU `tar' program. This is a 283moderately complex makefile. 284 285 Because it is the first target, the default goal is `all'. An 286interesting feature of this makefile is that `testpad.h' is a source 287file automatically created by the `testpad' program, itself compiled 288from `testpad.c'. 289 290 If you type `make' or `make all', then `make' creates the `tar' 291executable, the `rmt' daemon that provides remote tape access, and the 292`tar.info' Info file. 293 294 If you type `make install', then `make' not only creates `tar', 295`rmt', and `tar.info', but also installs them. 296 297 If you type `make clean', then `make' removes the `.o' files, and 298the `tar', `rmt', `testpad', `testpad.h', and `core' files. 299 300 If you type `make distclean', then `make' not only removes the same 301files as does `make clean' but also the `TAGS', `Makefile', and 302`config.status' files. (Although it is not evident, this makefile (and 303`config.status') is generated by the user with the `configure' program, 304which is provided in the `tar' distribution, but is not shown here.) 305 306 If you type `make realclean', then `make' removes the same files as 307does `make distclean' and also removes the Info files generated from 308`tar.texinfo'. 309 310 In addition, there are targets `shar' and `dist' that create 311distribution kits. 312 313 # Generated automatically from Makefile.in by configure. 314 # Un*x Makefile for GNU tar program. 315 # Copyright (C) 1991 Free Software Foundation, Inc. 316 317 # This program is free software; you can redistribute 318 # it and/or modify it under the terms of the GNU 319 # General Public License ... 320 ... 321 ... 322 323 SHELL = /bin/sh 324 325 #### Start of system configuration section. #### 326 327 srcdir = . 328 329 # If you use gcc, you should either run the 330 # fixincludes script that comes with it or else use 331 # gcc with the -traditional option. Otherwise ioctl 332 # calls will be compiled incorrectly on some systems. 333 CC = gcc -O 334 YACC = bison -y 335 INSTALL = /usr/local/bin/install -c 336 INSTALLDATA = /usr/local/bin/install -c -m 644 337 338 # Things you might add to DEFS: 339 # -DSTDC_HEADERS If you have ANSI C headers and 340 # libraries. 341 # -DPOSIX If you have POSIX.1 headers and 342 # libraries. 343 # -DBSD42 If you have sys/dir.h (unless 344 # you use -DPOSIX), sys/file.h, 345 # and st_blocks in `struct stat'. 346 # -DUSG If you have System V/ANSI C 347 # string and memory functions 348 # and headers, sys/sysmacros.h, 349 # fcntl.h, getcwd, no valloc, 350 # and ndir.h (unless 351 # you use -DDIRENT). 352 # -DNO_MEMORY_H If USG or STDC_HEADERS but do not 353 # include memory.h. 354 # -DDIRENT If USG and you have dirent.h 355 # instead of ndir.h. 356 # -DSIGTYPE=int If your signal handlers 357 # return int, not void. 358 # -DNO_MTIO If you lack sys/mtio.h 359 # (magtape ioctls). 360 # -DNO_REMOTE If you do not have a remote shell 361 # or rexec. 362 # -DUSE_REXEC To use rexec for remote tape 363 # operations instead of 364 # forking rsh or remsh. 365 # -DVPRINTF_MISSING If you lack vprintf function 366 # (but have _doprnt). 367 # -DDOPRNT_MISSING If you lack _doprnt function. 368 # Also need to define 369 # -DVPRINTF_MISSING. 370 # -DFTIME_MISSING If you lack ftime system call. 371 # -DSTRSTR_MISSING If you lack strstr function. 372 # -DVALLOC_MISSING If you lack valloc function. 373 # -DMKDIR_MISSING If you lack mkdir and 374 # rmdir system calls. 375 # -DRENAME_MISSING If you lack rename system call. 376 # -DFTRUNCATE_MISSING If you lack ftruncate 377 # system call. 378 # -DV7 On Version 7 Unix (not 379 # tested in a long time). 380 # -DEMUL_OPEN3 If you lack a 3-argument version 381 # of open, and want to emulate it 382 # with system calls you do have. 383 # -DNO_OPEN3 If you lack the 3-argument open 384 # and want to disable the tar -k 385 # option instead of emulating open. 386 # -DXENIX If you have sys/inode.h 387 # and need it 94 to be included. 388 389 DEFS = -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \ 390 -DVPRINTF_MISSING -DBSD42 391 # Set this to rtapelib.o unless you defined NO_REMOTE, 392 # in which case make it empty. 393 RTAPELIB = rtapelib.o 394 LIBS = 395 DEF_AR_FILE = /dev/rmt8 396 DEFBLOCKING = 20 397 398 CDEBUG = -g 399 CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \ 400 -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \ 401 -DDEFBLOCKING=$(DEFBLOCKING) 402 LDFLAGS = -g 403 404 prefix = /usr/local 405 # Prefix for each installed program, 406 # normally empty or `g'. 407 binprefix = 408 409 # The directory to install tar in. 410 bindir = $(prefix)/bin 411 412 # The directory to install the info files in. 413 infodir = $(prefix)/info 414 415 #### End of system configuration section. #### 416 417 SRC1 = tar.c create.c extract.c buffer.c \ 418 getoldopt.c update.c gnu.c mangle.c 419 SRC2 = version.c list.c names.c diffarch.c \ 420 port.c wildmat.c getopt.c 421 SRC3 = getopt1.c regex.c getdate.y 422 SRCS = $(SRC1) $(SRC2) $(SRC3) 423 OBJ1 = tar.o create.o extract.o buffer.o \ 424 getoldopt.o update.o gnu.o mangle.o 425 OBJ2 = version.o list.o names.o diffarch.o \ 426 port.o wildmat.o getopt.o 427 OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB) 428 OBJS = $(OBJ1) $(OBJ2) $(OBJ3) 429 AUX = README COPYING ChangeLog Makefile.in \ 430 makefile.pc configure configure.in \ 431 tar.texinfo tar.info* texinfo.tex \ 432 tar.h port.h open3.h getopt.h regex.h \ 433 rmt.h rmt.c rtapelib.c alloca.c \ 434 msd_dir.h msd_dir.c tcexparg.c \ 435 level-0 level-1 backup-specs testpad.c 436 437 all: tar rmt tar.info 438 439 tar: $(OBJS) 440 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 441 442 rmt: rmt.c 443 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c 444 445 tar.info: tar.texinfo 446 makeinfo tar.texinfo 447 448 install: all 449 $(INSTALL) tar $(bindir)/$(binprefix)tar 450 -test ! -f rmt || $(INSTALL) rmt /etc/rmt 451 $(INSTALLDATA) $(srcdir)/tar.info* $(infodir) 452 453 $(OBJS): tar.h port.h testpad.h 454 regex.o buffer.o tar.o: regex.h 455 # getdate.y has 8 shift/reduce conflicts. 456 457 testpad.h: testpad 458 ./testpad 459 460 testpad: testpad.o 461 $(CC) -o $@ testpad.o 462 463 TAGS: $(SRCS) 464 etags $(SRCS) 465 466 clean: 467 rm -f *.o tar rmt testpad testpad.h core 468 469 distclean: clean 470 rm -f TAGS Makefile config.status 471 472 realclean: distclean 473 rm -f tar.info* 474 475 shar: $(SRCS) $(AUX) 476 shar $(SRCS) $(AUX) | compress \ 477 > tar-`sed -e '/version_string/!d' \ 478 -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ 479 -e q 480 version.c`.shar.Z 481 482 dist: $(SRCS) $(AUX) 483 echo tar-`sed \ 484 -e '/version_string/!d' \ 485 -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ 486 -e q 487 version.c` > .fname 488 -rm -rf `cat .fname` 489 mkdir `cat .fname` 490 ln $(SRCS) $(AUX) `cat .fname` 491 -rm -rf `cat .fname` .fname 492 tar chZf `cat .fname`.tar.Z `cat .fname` 493 494 tar.zoo: $(SRCS) $(AUX) 495 -rm -rf tmp.dir 496 -mkdir tmp.dir 497 -rm tar.zoo 498 for X in $(SRCS) $(AUX) ; do \ 499 echo $$X ; \ 500 sed 's/$$/^M/' $$X \ 501 > tmp.dir/$$X ; done 502 cd tmp.dir ; zoo aM ../tar.zoo * 503 -rm -rf tmp.dir 504 505