Professional Documents
Culture Documents
April 2000
Richard M. Stallman and Roland McGrath
1 make
1.1
1.2 BUG
2 Makefile
2.1
2.2 Makefile
2.3make Makefile
2.4 Makefile
2.5 make
2.6 Makefile
2.7
3 3
Makefile
3.1Makefile
3.2Makefile
3.3 Makefile
3.4 MAKEFILES
3.5Makefile
3.6 Makefile
3.7make Makefile
4
4.1
4.2
4.2.1
4.2.2
4.2.3 wildcard
4.3
4.3.1VPATH:
4.3.2vpath
4.3.3
4.3.4 shell
4.3.5
4.3.6
4.4
4.5
4.6
4.7
4.8
4.9
4.10
4.10.1
4.10.2
4.11
4.12
5
5.1
5.2
5.3
5.4
5.5 make
5.6 make
5.6.1 MAKE
5.6.2 make
5.6.3 make
5.6.4`--print-directory'
5.7
5.8
6 6
6.1
6.2
6.3
6.3.1
6.3.2
6.4
6.5
6.6
6.7override
6.8
6.9
6.10
6.11
7 Makefile
7.1
7.2
7.3
8
8.1
8.2
8.3
8.4 foreach
8.5 if
8.6 call
8.7 origin
8.8 shell
8.9 Make
9 9
make
9.1 Makefile
9.2
9.3
9.4
9.5
9.6
9.7
10
10.1
10.2
10.3
10.4
10.5
10.5.1
10.5.2
10.5.3
10.5.4
10.5.5
10.5.6
10.6
10.7
10.8
11 make
11.1
11.2
11.2.1
11.3
11.4
12 GNU make
13
14 Makefile
14.1makefile
14.2makefile
14.3
14.4
14.5
14.6
15
16make
17 Makefile
1 Make
Make
GNU Make Richard M. Stallman and Roland McGrath Paul D. Smith
V3.76
GNU Make IEEE Standard 1003.2-1992 (POSIX.2) 6.2
C C Make
C Shell
GNU Make
Make Makefile
OBJ
OBJ
Makefile shell
make
Make Makefile
Make Makefile
Make
1.1
Make make
1.2 BUG
GNU Make BUG
BUG
BUG
BUG
BUG
Makefile Makefile Make
E-mail E-mail
bug-make@gnu.org
GNU Make make--version
config.h
2 Makefile
Makefile
Makefile
Make C
C
C OBJ
OBJ
2.1
Makefile
(target): (prerequiries)
<tab>(command)
(target) OBJ
clean
Make
Tab Tab
clern
Make
Makefile Makefile
2.2 Makefile
Makefile edit
8 OBJ .o
8 C 3
C defs.h
command.hbuffer.h
edit : main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
cc -o edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
main.o : main.c defs.h
cc -c main.c
kbd.o : kbd.c defs.h command.h
cc -c kbd.c
command.o : command.c defs.h command.h
cc -c command.c
display.o : display.c defs.h buffer.h
cc -c display.c
insert.o : insert.c defs.h buffer.h
cc -c insert.c
search.o : search.c defs.h buffer.h
cc -c search.c
files.o : files.c defs.h buffer.h command.h
cc -c files.c
utils.o : utils.c defs.h
cc -c utils.c
clean :
rm edit main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
Makefile editmake
Makefile make clean
Makefile edit OBJ main.okdb.o
C C main.cdef.h OBJ
cc -c main.ccc -c kbd.c
Tab Makefile
Make
Make
cleanclean
clean make clean
clean
rm make
make
edit
make
make makefile
edit make edit OBJ
OBJ OBJ
OBJ OBJ
Make
make clean
OBJ Make C C
C C make
Make C
Bison Yacc C
OBJ make edit
edit OBJ edit make
edit
insert.c makemake insert.c
insert.o edit command.h
makemake kbd.ocommand.o edit
2.4 makefile
edit OBJ
OBJ
makefile
OBJ `$(objects)'
makefile
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
main.o : main.c defs.h
cc -c main.c
kbd.o : kbd.c defs.h command.h
cc -c kbd.c
command.o : command.c defs.h command.h
cc -c command.c
display.o : display.c defs.h buffer.h
cc -c display.c
insert.o : insert.c defs.h buffer.h
cc -c insert.c
search.o : search.c defs.h buffer.h
cc -c search.c
files.o : files.c defs.h buffer.h command.h
cc -c files.c
utils.o : utils.c defs.h
cc -c utils.c
clean :
rm edit $(objects)
2.5 make
C make make
CC c C OBJ
make cc -c main.c -o main.omain.c main.o
OBJ
C
C objects
makefile
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
main.o : defs.h
kbd.o : defs.h command.h
command.o : defs.h command.h
display.o : defs.h buffer.h
insert.o : defs.h buffer.h
search.o : defs.h buffer.h
files.o : defs.h buffer.h command.h
utils.o : defs.h
.PHONY : clean
clean :
-rm edit $(objects)
makefile
clean
makefile
2.6 makefile
makefile OBJ makefile
makefile
makefile
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
$(objects) : defs.h
kbd.o command.o files.o : command.h
display.o insert.o search.o files.o : buffer.h
defs.h OBJ command.h bufffer.h OBJ
makefile makefile
2.7
make Makefile make
OBJ
make
clean:
rm edit $(objects)
.PHONY : clean
clean :
makefile
makefile edit edit
3 makefile
make makefile
3.1 makefile
makefile 5
makefile makefile
OBJ objects
makefile
!
make makefile :
"
makefile makefile
"
makefile
makefile
"
!
# make
\ define
makefile shell
3.2 makfile
make makefile
GNUmakefilemakefileMakefile
makefile makefileMakefile(
MakefileREADME
)GNUmakefile makefile
GNU make make GNUmakefile
makefile
make makefile
make
3.3 makefile
include make makefile include makefile
makefile
include filenames...
filenames shell
include make
Tab Tab make
include
make
#
make
include
makefile make makefile
makefile /
-|--include-dir
makefile
-include include
-include filenames...
makefile
3.4 MAKEFILES
MAKEFILESmake makefile
makefile Make
include
makefile makefile
MAKEFILES make
make make
makefile make makefile
MAKEFILES makefile
MAKEFILES makefile
makefile
makefile include ()
3.5 makefile
makefile RCS SCCS
makefile make makefile makefile
makefile make
makefile makefile makefile
makefile
make
makefile
makefile make
makefile makefile makefile
makefile make
makefile
-f--file makefile make makefile
3.2
-f--file makefile make
makefile makefile make
makefile
makefile make
makefile make make makefile
makefile make
-t-t--touch makefile
makefile -t--touch makefile
touch
-q' ( --question')
-n' ( --just-print') makefile makefile
make -f mfile -n foomfile
foofoofoo
mfile
makefile
makefile makefile
makefile makefile -t
make -f mfile -n foomfilefoo
foofoomfile
3.6 makefile
makefile makefile include
makefile makefile
make
makefile makefile
makefile make makefile
make
makefile makefile
make
make makefile
make
immediate = deferred
immediate ?= deferred
immediate := immediate
immediate += deferred or immediate
define immediate
deferred
endef
+=:=
ifdefifeqifndef inneq
makefile
make
makefile
.
/
makefile
makefile all
4.1
targets : prerequisites
command
...
target
am m a
Tab
Tab
$$\
\make
makefile make
shell
4.2
Make Bourne shell
*[]*.C.C
~~/
home ~/bin/home/bin~ home
~John/binhome/John/bin
ms-dosms-windows home home
\
foo\*barfoo*bar
4.2.1
shell
OBJ
clean
rm f *.o
makefile make print
.c
print: *.c
lpr -p $?
touch print
ptint
$?
objects = *.o
objects *.o objects
objects=$(wildcard *.o)
wildcard
4.2.2
foo OBJ
objects = *.o
foo : $(objects)
cc -o foo $(CFLAGS) $(objects)
wildcard
MS-DOSMS-WINDOWS
C:\foo\bar\bar.c
Unix c:/foo/bar/bar.cc:
make
Unix
Unix
4.2.3 wildcard
wildcard
$(wildcard pattern...)
makefile
wildcard
wildcard C
$(wildcard *.c)
C .c.o OBJ
patsubst
C makefile
C :=
=:=
4.3
Make
4.3.1 VPATH
make VPATH make
VPATH make
make VPATH
shell
VPATH make
MS-DOSMS-WINDOWS VPATH
VPATH = src:../headers
src/headersmake VPATH
foo.o : foo.c
foo.o : src/foo.c
src foo.c
4.3.2 vpath
vpath VPATH vpath
vpath
MS-DOSMS-WINDOWS VPATH
vpath pattern
vpath
vapth
vpath pattern %
%
%.h .h %
vpath %%
%
%
vpath
vpath VPATH
vpath %.h ../headers
make .h../headers.h
vpath make
Make makefile vpath
vpath %.c foo
vpath %
blish
vpath %.c bar
`.c'`foo'`blish'`bar'
vpath %.c foo:bar
vpath %
blish
`.c'foo'bar'blish'
4.3.3
Make
11 makefile
22
33
44
11
make
22 makefile
make makefile
make
GPATH VPATH
GPATH
4.3.4 shell
make
$^ shell
$^
$@
foo.o : foo.c
cc -c $(CFLAGS) $^ -o $@
CFLAGS C
C
$<
VPATH = src:../headers
foo.o : foo.c defs.h hack.h
cc -c $(CFLAGS) $< -o $@
4.3.5
VPATH vpath
foo.omake foo.c
make foo.c
foo.cmake
4.3.6
-|name
libname.a -|name
-|namemake vpath
VPATH /lib, /usr/lib', prefix/lib'`/usr/local/lib'
MS-DOSMS-Windows make prefix DJGPP
libname.so'libname.so'
libname.a'
/usr/lib/libcurses.a'
foo : foo.c -lcurses
cc $^ -o $@
4.4
clean:
rm *.o temp
rm cleanclean
`make clean'rm
clean
clean clean clean
.PHONY
.PHONY : clean
make cleanclean
make
.PHONY: clean
clean:
rm *.o temp
make makefile
shell
subdirs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done
shell make -k
make
bazfoo
make
makefile makefile
makefile
make prog1
prog3'
4.5
make
clean: FORCE
rm $(objects)
FORCE:
FORCRclean
FORCRFORCR
FORCR.PHONY: clean
make
FORCR makefile
4.6
touch
make print'make
print' lpr $?
4.7
!
.PHONY
.PHONY make
!
.SUFFIXES
.SUFFIXES
!
.DEFAULT
.DEFAULT
-.DEFAULT
!
.PRECIOUS
.PRECIOUS
make
make
.SECONDARY
%.O.PRECIOUS
!
.INTERMEDIATE
.INTERMEDIATE
.INTERMEDIATE
!
.SECONDARY
.SECONDARY
.SECONDARY makefile
!
.DELETE_ON_ERROR
makefile .DELETE_ON_ERROR
make
!
.IGNORE
.IGNORE MAKE
.IGNORE MAKE
.IGNORE .IGNORE
.IGNORE
!
.SILENT
.SILENT MAKE
.SILENT
.SILENT
-s-silent()
!
.EXPORT_ALL_VARIABLES
MAKE
MAKE
!
.NOTPARALLEL
.NOTPARALLEL -jmake
make makefile .NOTPARALLEL
.NOTPARALLEL
.c.o
.
.
4.8
$@
$@
bigoutput : text.g
generate text.g -big > bigoutput
littleoutput : text.g
generate text.g -little > littleoutput
-big-little
subst
$@
4.9
make
.
make
makefile make
objectscongfig.h
make
extradeps=
$(objects) : $(extradeps)
make
4.10
4.10.1
%%
foo.o%.o
foofoo.cfoo.out
%
%.cfoo%foo.c%
%\%
%\
%`the\%weird\\%pattern\\'`the%weird\' %'
pattern\\'%
.cfoo.obar.o
objects = foo.o bar.o
all: $(objects)
$(objects): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$<$@
filter
generate $*biglittle
4.10.2
make
!
make
4.11
makefile
4.12
makefile OBJ
main.c#include defs.h
main.o: defs.h
make defs.hmain.o
makefile
#include makefile
C #include
-M
cc -M main.c
makefile main.omain.o
make
make make depend
depend
makefile include makefile
C name.cname.d
%.d: %.c
set -e; $(CC) -M $(CPPFLAGS) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@
-e shell $(CC)
shell
sed, make
GNU C -MM-M
GNU CC
Sed
.d.oMake
.d include
makefile
foo.c bar.c'foo.d
bar.d'.d makefile makefile
make Makefile
shell
- TAB
TAB
5.1
make
@@ shell makefile
echo makefile
@echo About to make distribution files
make -n--just-print
@
make
-s--silent make @
makefile .SILENT
@.SILENT
5.2
shell
make
shell cd
cd
make shell
foo : bar/lose
cd bar; gobble lose > ../foo
shell
foo : bar/lose
cd bar; \
gobble lose > ../foo
DOS sh.exe PATH
makefile `SHELL = /bin/sh' Unix makefile
MS_DOS
Unix
SHELL SHELL
shell SHELL
makefile MS-DOS MS-WINDOWS
SHELL
make MS-DOS
SHELL make MAKESHELL make
shell SHELL
5.3
GNU make make
-j--jobs make
MS-DOS -j
-j job slots
-j job slots job slots
make
Broken pipe
make
make
make make
-k
--keep-going
make make
-|
make -|--max-load
-| 2.5
make 2.5 -|
-|
make
-|make
5.4
shell make
shell
make
mkdir
mkdir make
- TAB
- shell
clean:
-rm -f *.o
rm
make -i--ignore-errors
makefile .IGNORE
-
--i make
make
make -k
--keep-goningmake make
OBJ make
OBJ make -k' OBJ
make make
-k make
Emacs -k
make
make
.DELETE_ON_ERROR makefile make
make
5.5 make
make make
make
Ctrl-c OBJ foo.oCtrl-c
OBJ foo.ofoo.c make
Ctrl-c OBJ foo.o make OBJ foo.omake
linker OBJ
.PRECIOUS make
make .PRECIOUS
5.6 make
makefile make
makefile
subdir makefile make makefile
subsystem:
cd subdir && $(MAKE)
, ():
subsystem:
$(MAKE) -C subdir
make
make make
GNU make CURDIR -C
makefile
CURDIR
make
5.6.1 MAKE
make MAKEmake
subsystem:
cd subdir && $(MAKE)
make /bin/make`cd
subdir && /bin/make' makefile make
make -t
-t
make t
subsystemcd subdir && make t
-t
Make MAKE`-t', `-n' `-q'
MAKE make
MAKEFLAGS make make
5.6.2 make
make make make
-e make makefile
make
make
make
shell
SHELL MAKEFLAGS
MAKEFILE
Make MAKEFLAGS
Make make
make export
export variable ...
make unexport
unexport variable ...
variable := value
export variable
,
export variable += value
:
variable += value
export variable
makefile
MAKEFILES make makefile
MAKEFILES makefile makefile
make makefile
make makefile MAKEFILES
5.6.3 make
-s-k MAKEFLAGS make make
make make ks MAKEFLAGS
ks
make MAKEFLAGS
make
MAKEFLAGS make
MAKEFLAGS =make
-j 1 MAKEFLAGS
-j make
-j
1
MAKEFLAGS
subsystem:
cd subdir && $(MAKE) MAKEFLAGS=
MAKEOVERRIDES
MAKEFLAGS
MAKEOVERRIDES
MAKEOVERRIDES =
POSIX.2 makefile
.POSIX MAKEOVERRIDES MAKEFLAGS
MFLAGS
MAKEFLAGS
MAKEFLAGS
--warn-undefined-variables
MFLAGS make
subsystem:
cd subdir && $(MAKE) $(MFLAGS)
MAKEFLAGS makefile
make make
make -k
MAKEFLAGS MAKEFLAGS
MFLAGS MFLAGS
make
make MAKEFLAGS
makefile
make
-C',
-f',-h',-o',-W'
MAKEFLAGS make makefile
make -t', -n', -q'
MAKEFLAGS
5.6.4 --print-directory
make -w--print-directory make
make w
/u/gnu/make make make
make: Entering directory `/u/gnu/make'.
make -C-w
make -s-w
-s`--no-print-directory'-w
5.7
define
define run-yacc
yacc $(firstword $^)
mv y.tab.c $@
endef
define
foo.c : foo.y
$(run-yacc)
run-yaccfoo.y$^foo.c$@
make
Tabmake shell
make
frob.out: frob.in
@$(frobnicate)
5.8
target: ;
target Tab
makefile
makefile
make macros
makefile shell ==
define makefile
:',#',='
6.1
$(foo)'
${foo}'foo$$$
$
OBJ
objects = program.o foo.o utils.o
program : $(objects)
cc -o program $(objects)
$(objects) : defs.h
foo = c
prog.o : prog.$(foo)
$(foo)$(foo) -$(foo) prog.$(foo)
C prog.c
foo C
makefile
$x x
6.2
GNU make
two flavors
= define
foo = $(bar)
bar = $(ugh)
ugh = Huh?
all:;echo $(foo)
Huh?'$(foo)$(bar)$(ugh)Huh?
make
CFLAGS = $(include_dirs) -O
include_dirs = -Ifoo -Ibar
CFLAGS-Ifoo -Ibar
CFLAGS = $(CFLAGS) -O
make
make shell
:=
x := foo
y := $(x) bar
x := later
y := foo bar
x := later
:= shell shell
MAKELEVEL
make
MAKELEVEL
ifeq (0,${MAKELEVEL})
cur-dir
:= $(shell pwd)
whoami
:= $(shell whoami)
host-type := $(shell arch)
MAKE := ${MAKE} host-type=${host-type} whoami=${whoami}
endif
:=
${subdirs}:
${MAKE} cur-dir=${cur-dir}/$@ -C $@ all
makefile
nullstring :=
space := $(nullstring) # end of the line
dir := /foo/bar
dir /foo/bar
/foo/bar
?=
FOO ?= bar
origin
ifeq ($(origin FOO), undefined)
FOO = bar
endif
?=
6.3
6.3.1
$(var:a=b)
${var:a=b}
var a b
a a
a a
foo := a.o b.o c.o
bar := $(foo:.o=.c)
bara.c b.c c.c
patsubst
patsubst make
patsubst$(var:a=b)
%$(patsubst a,b,$(var))
patsubst
foo := a.o b.o c.o
bar := $(foo:%.o=%.c)
bar'a.c b.c c.c'
6.3.2
makefile
x=y
y=z
a := $($(x))
a z$(x)$($(x))y$($(x))$(y)z
$(x)$(x)
x=y
y=z
z=u
a := $($($(x)))
$(x) y$($(x))$(y)$(y) zu
x = $(y)
y=z
z = Hello
a := $($(x))
a Hello$($(x))$($(y))$($(y))$(z), $(z)Hello
subst
x = variable1
variable2 := Hello
y = $(subst 1,2,$(x))
z=y
a := $($($(z)))
a Hello
$($($(z))) $($(y))$($(y))$(subst 1,2,$(x))xvariable1,
variable2$( variable2)
Hello
ifdef do_sort
func := sort
else
func := strip
endif
bar := a d b g q c
foo := $($(func) $(bar))
foosort a d b g q c' strip a d b g q c'a d b g q c
sort strip
define
dir = foo
$(dir)_sources := $(wildcard $(dir)/*.c)
define $(dir)_print
lpr $($(dir)_sources)
endef
dir',foo_sources', foo_print'
makefile
6.4
!
make
!
makefile
!
make
!
6.5
makefile =:==
:=
objects = main.o foo.o bar.o utils.o
objects =
=:=
make
makefile
?==
origin
FOO ?= bar
6.6
+=
objects += another.o
objects another.o
objects = main.o foo.o bar.o utils.o
objects += another.o
`+=' :
objects = main.o foo.o bar.o utils.o
objects := $(objects) another.o
+=
=+=
+=make
:=+=
variable := value
variable += more
variable := value
variable := $(variable) more
+==make
make
+=
variable = value
variable += more
temp = value
variable = $(temp) more
temp
CFLAGS = $(includes) -O
...
CFLAGS += -pg # enable profiling
6.7 override
makefile
override
override variable = value
override variable := value
override makefile
C -g
override :
override CFLAGS += -g
define override
override define foo
bar
endef
define
6.8
define
define
endef define
=
define two-lines
echo foo
echo $(bar)
endef
define define
endef endef
shell
make shell shell
define define
override
override define two-lines
foo
$(bar)
endef
override
6.9
make make make make
make makefile
-e
makefile
CFLAGS makefile C
makefile
makefile
CFLAGS CFLAGS make
make make make
make export
make
makefile
makefile makefile
makefile
SHELL shell SHELL
make make
SHELL MS-DOS MS-Windows
SHELL
6.10
make
make
vs.
makefile
-e override
target ...
prog : CFLAGS = -g
prog : prog.o foo.o bar.o
6.11
GNU make
pattern%-pattern ...
variable-assignment
override
%.o : CFLAGS = -O
%.o CFLAGS -0
7 makefile
makefile
7.1
make CC gcc
CC=gcc
make
libs_for_gcc = -lgnu
normal_libs =
foo: $(objects)
ifeq ($(CC),gcc)
$(CC) -o foo $(objects) $(libs_for_gcc)
else
$(CC) -o foo $(objects) $(normal_libs)
endif
ifeqelse endif
Ifeq
makefile ifeq
else
else
makefile
makefile
CC gcc
foo: $(objects)
CC gcc
foo: $(objects)
$(CC) -o foo $(objects) $(normal_libs)
libs_for_gcc = -lgnu
normal_libs =
ifeq ($(CC),gcc)
libs=$(libs_for_gcc)
else
libs=$(normal_libs)
endif
foo: $(objects)
$(CC) -o foo $(objects) $(libs)
7.2
else
conditional-directive
text-if-true
endif
text-if-true makefile
conditional-directive
text-if-true
else
text-if-false
endif
text-if-truetext-if-falsetext-if-false
conditional-directive
arg1arg2
text-if-truetext-if-false
strip
$(foo)text-if-empty
ifneq (arg1, arg2)
ifneq 'arg1' 'arg2'
ifneq "arg1" "arg2"
ifneq "arg1" 'arg2'
ifneq 'arg1' "arg2"
arg1arg2 text-if-true
text-if-false
ifdef variable-name
variable-nametext-if-truetext-if-false
ifdef
ifdef foo=
ifeq($(foo),)
bar =
foo = $(bar)
ifdef foo
frobozz = yes
else
frobozz = no
endif
frobozz'yes', :
foo =
ifdef foo
frobozz = yes
else
frobozz = no
endif
frobozz' no'
ifndef variable-name
variable-nametext-if-truetext-if-false
Tab
Tab Tab
#
else endif
Tab #
makefile Make
makefile
makefile makefile
include
7.3
MAKEFLAGS findstring -t
make touch
findstring -t
-t MAKEFLAGS
ranlib t
archive.a: ...
ifneq (,$(findstring t,$(MAKEFLAGS)))
+touch archive.a
+ranlib -t archive.a
else
ranlib archive.a
endif
+-t
make
makefile
makefile
8.1
$(function arguments)
${function arguments}
function make
call arguments Tab
comma space
comma:= ,
empty:=
space:= $(empty) $(empty)
foo:= a b c
bar:= $(subst $(space),$(comma),$(foo))
# bar is now `a,b,c'.
subst foo
8.2
$(subst from,to,text)
texttofrom
$(subst ee,EE,feet on the street)
fEEt on the street
$(patsubst pattern,replacement,text)
textpatternreplacementpattern
%replacement%%
pattern% patsubst %(\)
%%
stem%
$(patsubst pattern,replacement,$(var))
patsubst
$(var:suffix=replacement)
$(patsubst %suffix,%replacement,$(var))
OBJ
objects = foo.o bar.o baz.o
$(objects:.o=.c)
$(patsubst %.o,%.c,$(objects))
$(strip string)
$(strip a b c )'a
b c strip ifeq ifneq
makefile
.PHONY: all
ifneq
"$(needs_made)" ""
all: $(needs_made)
else
all:;@echo 'Nothing to make!'
endif
$(findstring find,in)
infindfind
$(findstring a,a b c)
$(findstring a,b c)
a findstring
$(filter pattern...,text)
textpattern...pattern...
% patsubst filter
$(filter-out pattern...,text)
baz.s'
textpattern...pattern...
filter
objects=main1.o foo.o main2.o bar.o
mains=main1.o main2.o
mains OBJ
$(filter-out $(mains),$(objects))
$(sort list)
list
$(subst :, ,$(VPATH))
8.3
$(dir names...)
names
./
$(dir src/foo.c hacks)
src/ ./
$(notdir names...)
names
foo.c hacks
$(suffix names...)
names
names
.c .c
$(basename names...)
names
namessuffix Suffix
foo.c bar.c
$(addprefix prefix,names...)
namesprefix preffix
src/foo src/bar
$(join list1,list2)
$(word n,text)
text n N 1 n text
bar
$(wordlist s,e,text)
text s e Se 1 s
text e text s
text s e
$(wordlist 2, 3, foo bar baz)
`bar baz'
$(words text)
names
$(wildcard pattern)
pattern shel
wildcard
8.4 foreach
foreach
shell sh for C-shell csh foreach
foreach
$(foreach var,list,text)
varlisttext
listvartext
text listlisttext
foreach
files dirs
dirs := a b c d
files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
8.5 if
if GNU make makefile
ifeq
if
$(if condition,then-part[,else-part])
condition
conditioncondition
condition,then-part
if
condition,else-part
if if
then-partelse-part
shell
8.6 call
call
call
call
$(call variable,param,param,...)
make param$(1)$(2)$(0)
variableparam
call
variable make
variable$(1) call param
variable$
make
call variable
foreach if
foo b a
PATH
LS /bin/ls
call $(1)
call
map = $(foreach a,$(2),$(call $(1),$(a)))
map origin
o = $(call map,origin,o map MAKE)
8.7 origin
origin
origin
$(origin variable)
variable$
origin
undefined'
variable
default'
variable CC
origin
environment'
variable-e
environment override'
variable-e
file'
variable makefile
command line'
variable
override'
variable makefile override override
automatic'
variable
foo makefile bar makefile
bletchmake f bar makefile bar
bletch makefile foo makefile barbletch
override makefile foo override
override makefile
bar makefile bar
ifdef bletch
ifeq "$(origin bletch)" "environment"
bletch = barf, gag, etc.
endif
endif
bletch
-ebletch
8.8 shell
wildcard shell make
shell shell
shell Make
make /
make shell
makefile shell
shell
shell
contents := $(shell cat foo)
foo contents
files := $(shell echo *.c)
8.9 make
make makefile
make
$(error text...)
text
text
ifdef ERROR1
$(error error is $(ERROR1))
endif
ERROR01 makefile
ERR = $(error found an error!)
.PHONY: err
err: ; $(ERR)
err make
$(warning text...)
9 make
makefile
makefile make
make
make
0
make
2
2 make
1
1 make -q make
9.1 makefile
makefile -f--file--makefile-f
altmakealtmake makefile
-f-f
makefile
-f--fileGNUmakefile', makefile',
Makefile' makefile
9.2
gaol make
makefile
makefile
make
make
makefile -=
makefile
Make MAKECMGOALS
.d
make
makefile
.PHONY: all
all: size nm ld ar as
makefile
makefile clean
make cleanmake
GNU make
all'
makefile
`clean'
make
`mostlyclean'
clean
GCC mostlycleanlibgcc.a
`distclean'
`realclean'
`clobber'
clean
makefile
install
tar
tar
shar
shell
dist
tar shar
TAGS
tags
`check'
`test'
makefile
9.3
makefile make
make
`-n'
`--just-print'
`--dry-run'
`--recon'
No-opmake
`-t'
`--touch'
touchmake
`-q'
`--question'
question
`-W file'
`--what-if=file'
`--assume-new=file'
`--new-file=file'
What if-W make
-W-n
-nmake
-tmake touch
-s.SILENTtouchmake
touch touch
-qmake make
0 1 make 2
make -n-t-s
+$(MAKE)' ${MAKE}'
+$(MAKE)' ${MAKE}'
MAKE
-W
!
-n-q make
!
-n-q make -W make
9.4
make
-t make
1 make
2
3make t make
-o file
1make -o file
-o
2make t
9.5
=v=x v x
makefile make
makefile
CFLAGS C make
foo.c
cc -c $(CFLAGS) foo.c
makefile CFALAGS
make make CFLAGS='-g -O' C
cc -c -g -O shell
CFALAGS
makefile
make
:==
makfile makfile
override override variable = value override
9.6
shell make
make make
make
-k--keep-going make
make , make k
shell make
make k-k
make
-k
Emacs M-x compile -k
9.7
make
`-b'
`-m'
make
`-C dir'
`--directory=dir'
makefile dir-C
-C/-C etc-C/etc make
make
-d
---- make
-d--debug=a
`--debug[=options]'
a (all)
-d
b (basic)
v (verbose)
makefile
i (implicit)
j (jobs)
m (makefile)
makefile all
`-e'
`--environment-overrides'
makefile
`-f file'
`--file=file'
`--makefile=file'
file makefile makefile
`-h'
`--help'
make
`-i'
`--ignore-errors'
`-I dir'
`--include-dir=dir'
makefile dir makefile -I
`-j [jobs]'
`--jobs[=jobs]'
make -j
MS-DOS
`-k'
`--keep-going'
`-l [load]'
`--load-average[=load]'
`--max-load[=load]'
load
`-n'
`--just-print'
`--dry-run'
`--recon'
`-o file'
`--old-file=file'
`--assume-old=file'
file file
`-p'
`--print-data-base'
makefile
-v
`-q'
`--question'
make
0 1 make 2
`-r'
`--no-builtin-rules'
-r
.SUFFIXES -r
-R
`-R'
`--no-builtin-variables'
-R-r
`-s'
`--silent'
`--quiet'
`-S'
`--no-keep-going'
`--stop'
-k make MAKEFLAGS make
-k-k
`-t'
`--touch'
make
`-v'
`--version'
make
`-w'
`--print-directory'
makefile make
make make
--print-directory
`--no-print-directory'
-w-w
--print-directory
`-W file'
`--what-if=file'
`--new-file=file'
`--assume-new=file'
n
n make touch make
`--warn-undefined-variables'
make
makefile
10
OBJ
C cc C
make
C
C .c.o make
C
make .y.c.o
CFLAGS C C
10.1
make
make
makefile
foo : foo.o bar.o
cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS)
foo.omake
make foo.omake
foo.o
.o C .C Pascal .p
.C
make C .pmake Pascal
makefile make
make
makefile
make
make
foo.o: foo.p
10.2
makefile
-r--no-builtin-rules
make
.SUFFIXES
.out, .a, .ln, .o, .c, .cc, .C, .p, .f, .F, .r, .y, .l, .s, .S, .mod, .sym, .def, .
h, .info, .dvi, .tex, .texinfo, .texi, .txinfo, .w, .ch .web, .sh, .elc, .el
Compiling C programs C
n.o' n.c' $(CC) -c $(CPPFLAGS) $(CFLAGS)'
Compiling C++ programs C++
n.o'n.cc' n.C'$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
C++.cc' .C
Compiling Pascal programs Pascal
n.o'n.p'$(PC) -c $(PFLAGS)'
Compiling Fortran and Ratfor programs Fortran Ratfor
n.o'n.r', n.F'n.f' Fortran
`.f'
`$(FC) -c $(FFLAGS)'.
`.F'
`$(FC) -c $(FFLAGS) $(CPPFLAGS)'.
`.r'
`$(FC) -c $(FFLAGS) $(RFLAGS)'.
Preprocessing Fortran and Ratfor programs Fortran Ratfor
n.f' n.r'n.F' Ratfor
Fortran Fortran
`.F'
`$(FC) -F $(CPPFLAGS) $(FFLAGS)'.
`.r'
`$(FC) -F $(FFLAGS) $(RFLAGS)'.
Compiling Modula-2 programs Modula-2
n.sym' n.def'$(M2C) $(M2FLAGS) $(DEFFLAGS)' n.o'
n.mod':$(M2C) $(M2FLAGS) $(MODFLAGS)'
Assembling and preprocessing assembler programs
n.o'n.S' C cpp:$(CPP) $(CPPFLAGS)'
Linking a single object file OBJ
n' n.o' C linker ( ld): $(CC)
$(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)'
OBJ
OBJ OBJ
x: y.o z.o
x.c', y.c' z.c'
cc -c x.c -o x.o
cc -c y.c -o y.o
cc -c z.c -o z.o
cc x.o y.o z.o -o x
rm -f x.o
rm -f y.o
rm -f z.o
OBJ
.o-c
($(CC)',$(FC)'$(PC)' C $(CC)')
OBJ
Yacc for C programs Yacc C
n.c'n.y'$(YACC) $(YFLAGS)' Yacc
Lex for C programs Lex C
n.c'n.l' Lex $(LEX) $(LFLAGS)'
Lex for Ratfor programs Lex Rator
n.r'n.l' Lex $(LEX) $(LFLAGS)' Lex
C Ratfor .l
make make .l
OBJ C , C
Ratfor , makefile n.r' make
Ratfor C ,
.c
.SUFFIXES:
.SUFFIXES: .o .r .f .l ...
Making Lint Libraries from C, Yacc, or Lex programs C, Yacc, Lex Lint
n.ln' n.c' lint $(LINT) $(LINTFLAGS)
$(CPPFLAGS) i C n.y'n.l'
TeX and WebTeX Web
n.dvi'n.tex' $(TEX)'n.tex'n.web'$(WEAVE)'
n.w' (n.ch'n.ch') $(CWEAVE)'n.p'
n.web'$(TANGLE)'n.c' n.w' (n.ch'n.ch'
) $(CTANGLE)'
Texinfo and InfoTexinfo Info
n.dvi' n.texinfo',n.texi', n.txinfo', $(TEXI2DVI)
$(TEXI2DVI_FLAGS)' n.info' n.texinfo',n.texi', n.txinfo',
$(MAKEINFO) $(MAKEINFO_FLAGS)'
RCS
n' n,v' RCS/n,v' RCS $(CO)
$(COFLAGS)'n' RCS RCS
RCS RCS
SCCS
n's.n'SCCS/s.n' SCCS $(GET)
$(GFLAGS)' SCCS SCCS
SCCS n' n.sh'
() shell SCCS
RCS RCS
SCCSRCS
OBJ -o VPATH
OUTPUT_OPTION ; mv $*.o
$@
10.3
makefile
make
-R--no-builtin-variables
CFLAGS
(
)
AR
ar'.
AS
as'.
CC
C cc'.
CXX
C++g++'.
CO
RCS co'.
CPP
C $(CC) -E'.
FC
SCCS get'.
LEX
Pascal pc'.
YACC
Yacc C yacc'.
YACCR
Texinfo makeinfo'.
TEX
Web C ctangle'.
RM
rm -f'.
ARFLAGS
rv'.
ASFLAGS
(.s'.S')
CFLAGS
C
CXXFLAGS
C++
COFLAGS
RCS co
CPPFLAGS
C (C Fortran )
FFLAGS
Fortran
GFLAGS
SCCS get
LDFLAGS
linkerld
LFLAGS
Lex
PFLAGS
Pascal
RFLAGS
Ratfor Fortran
YFLAGS
Yacc Yacc
10.4
n.yn.o
Yacc cc
n.c makefile make
C n.c OBJ n.c Yacc
n.cn.o
n.c makefile make n.y
n.on.c make
makefile
make b
make b b b b
make b
b
make b b make
make make Make
rm f
makefile
.INTERMEDIATE
secondary
.SECONDARY secondary make
secondary
%.o .PRECIOUS
make
RCS/foo.y,vfoo
RCSYacc cc foo.y foo.c
make
foo.o.o foo linker make
foo.c foo
foo.o
cc
10.5
%
%
%
%.o : %.cstem.cstem.o
% makefile
10.5.1
%
%
%.c.cs.%.cs..c
5 %
% stem()
% stem
n.on.cn.c
%
make
make
makefile
10.5.2
make .c.o
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
x.cx.o$@$<
% :: RCS/%,v
$(CO) $(COFLAGS) $<
RCSx.vx%
10.5.3
.c.oCC
make
$@$<
$@
$@
$@
$%
make
foo.a(bar.o)'$%'bar.o'$@'foo.a'
$%'
$<
$?
make
$^
make
$^
$+
$^' makefile
$*
stem()dir/a.foo.b'
a.%.b' stem dir/foo' stem
stem % stem
$*'
$*'
foo.c'$*' foo', .c' GNU make
make
$*'$*
$?'
lib OBJ OBJ
`$(@D)'
`$@'`dir/foo.o'
`$(@D)'`dir' `$@'`.'
`$(@F)'
`$@'`dir/foo.o'
` foo.o '`$(@F)' `$(notdir $@)'
`$(@F)'
`$(*D)'
`$(*F)'
stem`dir' `foo'
`$(%D)'
`$(%F)'
archive(member)
`$(<D)'
`$(<F)'
`$(^D)'
`$(^F)'
`$(?D)'
`$(?F)'
10.5.4
%
stem%.otest.o
stemteststem%
%.ctest.c
e%tsrc/eatstem()src/a
10.5.5
%
make make
makefile foo.cmake
OBJ foo.c.o C foo.c.c
Pascal foo.c.p
make foo.c C
make foo.c.o foo.c.p
make
make
%.p :
Pascal foo.p'
foo.p.o' foo.p.c'
%.p'
10.5.6
%.o : %.s
10.6
makefile
%::
touch $@
.DEFAULT
.DEFAULT
.DEFAULT :
.DEFAULT:
.DEFAULT make
.DEFAULT
.DEFAULT
makefile
makefile
10.7
.o.c`%.o : %.c'
.c
% : %.c
make
make
.o.c
.c.o make .c.o
C
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
.c.o: foo.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
foo.h .c.o
%.o: %.c foo.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
.c' .o' .c'.o'
foo.h'
.SUFFIXES.SUFFIXES
.SUFFIXES.SUFFIXES
.SUFFIXES:
.SUFFIXES: .c .o .h
#
#
-r'--no-builtin-rules'
SUFFIXES make makefile
.SUFFIXES SUFFIXES
10.8
make t
makefile
archive(member)
t(member)t
1
1
tdnt
src/foo.odsrc/nfoo.o
2
2
tn
tn
3
1 1 stems%tn
2 2 stemsd
3 3
makefile
6
6
1 1
2 2
3 3
4 4
5 5
7
7
.DEFAULT
.DEFAULTt
tn stems
%t
t
t
4
5
11 make
ar
11.1
make
archivemember
archive(member)
ar
ar
hack.ofoolibhack.o:
foolib(hack.o) : hack.o
ar cr foolib hack.o
ar c
foolib(hack.o kludge.o)
foolib(hack.o) foolib(kludge.o)
shell
foolib(*.o)' foolib.o
foolib(hack.o) foolib(kludge.o)'
11.2
a(m)ma
Make make (m)
a(m)
(%)m
a(m)bar.ofoo.afoo.a(bar.o)
make "foo.a(bar.o)"'
shell makefile bar.c
cc -c bar.c -o bar.o
ar r foo.a bar.o
rm -f bar.o
make bar.o
$%
makefile
foo.a(dir/file.o)make
ar r foo.a dir/file.o
dir/file.ofile.a
%D %F
11.2.1
__.SYMDEF __.SYMDEF
__.SYMDEF__.SYMDEF__.SYMDEF
ranlib
ranlib archivefile
GNU ar __.SYMDEF
11.3
-j
make
makefile -j
11.4
GNU make
make
.a
C
.c.a:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
$(AR) r $@ $*.o
$(RM) $*.o
(%.o): %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
$(AR) r $@ $*.o
$(RM) $*.o
make .a
.x.a' (%.o)' %.x'.
.a' make
.x.a' (%.o):
%.x' %.a: %.x'.
12 GNU make
System V make
VPATH System V
make4.3 BSD make System V
VPATFH
makefile makefile
GNU
MAKEFLAGS make make
$%
$@, $*, $<, $%, $? $(@F)$(@D)
$^
-b'-m' System V make
-n',-q'-t' MAKE make
make
.a' GNU make
-
makefile
make
% make
$+ $^
"what if" (GNU make -W') Andrew Hume mk
GNU make
-v'`--version'
-h' --help' make
-o'--old-file'
make C
makefile
makefile makefile
makefile MAKEFILES
`./' ./file' file'
-lname
make
./
make MAKWFILES make
MAKECMDGOALS
vpath
`MAKE_VERSION' make
13
file((entry))' file
enty OBJ GNU make
make
~ System V make
Unix make $*
Unix make
$*
Unix make
foo.o:
cc -c foo.c
Unix make foo.o' foo.c'Make
GNU make
.c.a:
.c.a'
GNU make
.c.a: ;
make shell -e'-k' ()
-e' shell
14 makefile
14.1 makefile
makefile
SHELL = /bin/sh
SHELL
GNU make
make
makefile
.SUFFIXES:
.SUFFIXES: .c .o
makefile
.'
./
$(srcdir)
build directory ./(source directory) $(srcdir)
configure--srcdir
foo.1 : foo.man sedscript
sed -e sedscript foo.man > foo.1
foo.mansedscript
GNU make VPATH
make $< make
$< makefile
foo.o : bar.c
$(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
foo.o : bar.c
$(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
VPATH$(srcdir)
foo.l
foo.1 : foo.man sedscript
sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
GNU Info Autoconf,
Automake, Bison Flex
makefile
makefile
make
14.2 makefile
shell sh csh makefile ( shell
configure) ksh bash
configure Makefile
makefile
Makefile make
ranlib ldconfig
AutoconfAC_PROG_RANLIB'
make
chgrp chmod chown mknod
makefile
14.3
Makefile
Bison, BISON
BISON = bison Bison $(BISON)
ln, rm, mv
CFLAGS
CFLAGS
C CFLAGS
Makefile INSTALL INSTALL
DESTDIR
makefile DESTDIR
DERSTDIR
$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
14.4
`prefix'
prefix /usr/local'
GNU prefix /usr' /'( Autoconf
@prefix@') prefix make install'
`exec_prefix'
exec_prefix $(prefix). (
Autoconf`@exec_prefix@') $(exec_prefix)
$(prefix)
exec_prefix make install'
`bindir'
/usr/local/bin'
$(exec_prefix)/bin' ( Autoconf,
@bindir@')
`sbindir'
shell
/usr/local/sbin'$(exec_prefix)/sbin' (
Autoconf, @sbindir@')
`libexecdir'
/usr/local/libexec'
$(exec_prefix)/libexec'( Autoconf,
@libexecdir@')
OBJ
Makefile
`datadir'
/usr/local/share'
$(prefix)/share'( Autoconf, @datadir@')
$(infodir)'$(includedir)'
`sysconfdir'
/etc/passwd'
ASCII /usr/local/etc',
$(prefix)/etc'. ( Autoconf, @sysconfdir@'.)
$(libexecdir)'$(sbindir)'
$(localstatedir)'
`sharedstatedir'
/usr/local/com'$(prefix)/com' ( Autoconf,
@sharedstatedir@')
`localstatedir'
`includedir'
C#include'
/usr/local/include'$(prefix)/include' ( Autoconf,
@includedir@') GCC /usr/local/include'
GCC
GCC
includedir oldincludedir
`oldincludedir'
#include' GCC C
/usr/include' ( Autoconf,
@oldincludedir@') Makefile oldincludedir
Foo
foo.h' oldincludedir (1)
foo.h' (2) Foo foo.h'
foo.h' Foo magic --
--grep
Unix
`mandir'
/usr/local/man'
$(prefix)/man' ( Autoconf, @mandir@')
`man1dir'
$(mandir)/man1'
`man2dir'
$(mandir)/man2'
`...'
GNU
Unix GNU
`manext'
1
`man1ext'
`man2ext'
`...'
`manext'
`srcdir'
shell configure
( Autoconf, srcdir = @srcdir@'.)
#
#
prefix = /usr/local
exec_prefix = $(prefix)
# `gcc'
bindir = $(exec_prefix)/bin
#
libexecdir = $(exec_prefix)/libexec
# Info
infodir = $(prefix)/info
GNU
14.5
GNU makefile
`all'
Info
DVI make
-g'
`install'
install-strip
install
make all'
prefix
exec_prefix
installdirs-' make
Unix
Info $(INSTALL_DATA) Info
$(infodir)'
install-info install-info
Infodir' Info Texinfo
Info
$(DESTDIR)$(infodir)/foo.info: foo.info
$(POST_INSTALL)
# . srcdir
-if test -f foo.info; then d=.; \
else d=$(srcdir); fi; \
$(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \
# install-info
# if'-'
# install-info
# $(SHELL) -c' shell
#
if $(SHELL) -c 'install-info --version' \
>/dev/null 2>&1; then \
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(DESTDIR)$(infodir)/foo.info; \
else true; fi
install
`uninstall'
--install
`install-strip'
install
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
install
BUG
`clean'
.dvi'
clean.dvi'
`distclean'
make distclean'
`mostlyclean'
clean' GCC
mostlyclean libgcc.a'
`maintainer-clean'
makefile
distclean, Bison C
Info make maintainer-clean'
configure'configure' Makefile
make maintainer-clean'configure'
make maintainer-clean'
maintainer-clean'
make maintainer-clean'
make
maintainer-clean
@echo
@echo
`TAGS'
`info'
Info
info: foo.info
foo.info: foo.texi chap1.texi chap2.texi
$(MAKEINFO) $(srcdir)/foo.texi
makefile MAKEINFO makeinfo
`dist'
tar tar
installcheck
$(bindir)'
installdirs
installdirs'
mkinstalldirs' Texinfo
# ( $(bindir))
#
installdirs: mkinstalldirs
$(srcdir)/mkinstalldirs $(bindir) $(datadir) \
$(libdir) $(infodir) \
$(mandir)
14.6
install-info
Info
Info
category lines
Tab make
make makefile
$(PRE_INSTALL)
#
$(POST_INSTALL)
#
$(NORMAL_INSTALL) #
$(PRE_UNINSTALL)
#
$(POST_UNINSTALL)
#
$(NORMAL_UNINSTALL) #
Info
install uninstall
15
GNU make
GNU make
define variable
endef
ifdef variable
ifndef variable
ifeq (a,b)
ifeq "a" "b"
ifeq 'a' 'b'
ifneq (a,b)
ifneq "a" "b"
ifneq 'a' 'b'
else
endif
makefile makefile
include file
-include file
sinclude file
makefile makefile
override variable = value
override variable := value
override variable += value
override variable ?= value
override define variable
endef
override
export
make make
export variable
export variable = value
export variable := value
export variable += value
export variable ?= value
unexport variable
make make
vpath pattern path
% vpath
vpath pattern
pattern
vpath
vpath
$(subst from,to,text)
texttofrom
$(patsubst pattern,replacement,text)
textreplacementpattern
$(strip string)
$(findstring find,text)
findtext
$(filter pattern...,text)
textpattern
$(filter-out pattern...,text)
textpattern
$(sort list)
list
$(dir names...)
$(notdir names...)
$(suffix names...)
$(basename names...)
$(addsuffix suffix,names...)
names
$(addprefix prefix,names...)
names
$(join list1,list2)
$(word n,text)
text n
$(words text)
text
$(wordlist s,e,text)
text s e
$(firstword names...)
names
$(wildcard pattern...)
shell wildcard
$(error text...)
shell shell
$(origin variable)
call
$@
$%
$<
$?
make
$^
$+
make $^ $+
$*
stem()
$(@D)
$(@F)
$@.
$(*D)
$(*F)
$*
$(%D)
$(%F)
$%
$(<D)
$(<F)
$<
$(^D)
$(^F)
$^
$(+D)
$(+F)
$+
$(?D)
$(?F)
$?
GNU make
MAKEFILES
make Makefiles MAKEFILES
VPATH
VPATH:
SHELL
`/bin/sh' makefile SHELL
shell
MAKESHELL
MS-DOSmake SHELL
MAKE
make MAKE
MAKELEVEL
( makes) make
MAKEFLAGS
make makefile
make shell
make make
MAKECMDGOALS
make make
CURDIR
make
SUFFIXES
makefile
.LIBPATTERNS
make
16 make
make
make
-k***
makefile
*** makefile
make
`missing separator. Stop.'
`missing separator (did you mean TAB instead of 8 spaces?). Stop.'
make GNU make
(:, =, TAB)
make
ms-windows
Tabmake
Tab
`commands commence before first target. Stop.'
`missing rule before commands. Stop.'
makefile Tab
make
"target: prerequisite"
`No rule to make target `xxx'.'
`No rule to make target `xxx', needed by `yyy'.'
make makefile
makefile
`Circular xxx <- yyy dependency dropped.'
make xxx yyy
yyy xxx
`Recursive variable `xxx' references itself (eventually). Stop.'
make xxx
(:=)+=
`warning: jobserver unavailable: using -j1. Add `+' to parent make rule.'
make make make
make make
MAKE
makefile
make
17 makfile
GNU tar makefile makefile
all makefile testpad.h'
testpad testpad.c'
make'`make all' make tar',
rmt'tar.info' Info
make install' make tar',rmt',tar.info'
make clean', make .o'tar',rmt',testpad', testpad.h',
core
make distclean', make make clean'
TAGS', Makefile', config.status' ( makefile (config.status')
configure tar )
make realclean', make make distclean '
tar.texinfo' Info
shar dist
# makefile.in
# GNU tar Unix Makefile
# -DPOSIX
POSIX.1
#
# -DBSD42
sys/dir.h (
#
-DPOSIX), sys/file.h,
#
st_blocks `struct stat'
# -DUSG
System V/ANSI C
#
#
sys/sysmacros.h,
#
fcntl.h, getcwd, no valloc,
#
ndir.h (
#
-DDIRENT)
# -DNO_MEMORY_H
USG STDC_HEADERS
#
memory.h.
# -DDIRENT
USG dirent.h
#
ndir.h
# -DSIGTYPE=int
#
int, void.
# -DNO_MTIO
sys/mtio.h
#
(magtape ioctls).
# -DNO_REMOTE
shell
#
rexec.
# -DUSE_REXEC
rexec
#
rsh remsh.
#
# -DVPRINTF_MISSING
vprintf
#
(_doprnt).
# -DDOPRNT_MISSING
_doprnt.
#
#
-DVPRINTF_MISSING.
# -DFTIME_MISSING
ftime
# -DSTRSTR_MISSING
strstr
# -DVALLOC_MISSING
valloc
# -DMKDIR_MISSING
mkdir
#
rmdir
# -DRENAME_MISSING
rename
# -DFTRUNCATE_MISSING
ftruncate
#
# -DV7
Unix 7 (
#
).
# -DEMUL_OPEN3
3-
#
open,
#
# -DNO_OPEN3
3- open
#
tar k
#
open.
# -DXENIX
sys/inode.h
#
94
DEFS =
tar:
$(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
rmt:
rmt.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c
tar.info: tar.texinfo
makeinfo tar.texinfo
install: all
$(INSTALL) tar $(bindir)/$(binprefix)tar
-test ! -f rmt || $(INSTALL) rmt /etc/rmt
$(INSTALLDATA) $(srcdir)/tar.info* $(infodir)
$(OBJS): tar.h port.h testpad.h
regex.o buffer.o tar.o: regex.h
# getdate.y 8 /
testpad.h: testpad
./testpad
testpad: testpad.o
$(CC) -o $@ testpad.o
TAGS:
$(SRCS)
etags $(SRCS)
clean:
rm -f *.o tar rmt testpad testpad.h core
distclean: clean
rm -f TAGS Makefile config.status
realclean: distclean
rm -f tar.info*
shar: $(SRCS) $(AUX)
shar $(SRCS) $(AUX) | compress \
> tar-`sed -e '/version_string/!d' \
-e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
-e q
version.c`.shar.Z
dist: $(SRCS) $(AUX)
echo tar-`sed \
-e '/version_string/!d' \
-e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
-e q
(1)
MS-DOS MS-Windows GNU Make DJGPP
(2)
MS-DOS , global,
(3)
texi2dvi
archive
archive member targets
arguments of functions
automatic variables
backslash (\)
basename
binary packages
compatibility
data base
default directries
default goal
defining variables verbatim
directive
dummy pattern rule
echoing of commands
editor
empty commands
empty targets
environment
explicit rule
file name functions
file name suffix
flags
flavors of variables
functions
goal
implicit rule
incompatibilities
intermediate files
match-anything rule
options
parallel execution
pattern rule
phony targets
prefix
prerequisite
recompilation
rule
shell command
static pattern rule
stem
sub-make
subdirectories
suffix
suffix rule
switches
target
value
variable
wildcard
word
shell
make