You are on page 1of 94

GNU Make

Linux Linux Linux


Linux Makefile
Linux Makefile
GNU Make 3.79 Linux
GCC GNU Make
E-mail
yfc70@public2.lyptt.ha.cn

GNU make Version 3.79

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

Make GNU Make


GNU Make GNU Make make
Make GNU 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

Make Makefile Makefile


Make
Makefile 8 C 3
Makefile Make

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

2.3 make makefile


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

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

OBJ
makefile

makefile objects, OBJECTS, objs, OBJS, obj, OBJ


OBJ makefile objects
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o

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 :

-rm edit $(objects)


make clean rm

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

makefile -f--file makefile


-f name--file=name make name makefile
-f--file makefile makefile
-f --file
GNUmakefilemakefileMakefile makefile

3.3 makefile
include make makefile include makefile
makefile
include filenames...
filenames shell
include make
Tab Tab make
include
make
#
make

.mka.mkb.mkc.mk$(bar) bish bash

include foo *.mk $(bar)


include foo a.mk b.mk c.mk bish bash
make include make makefile
makefile make makefile include
include makefile

include
makefile make makefile

makefile /
-|--include-dir

prefix/include' ( /usr/local/include') /usr/gnu/include', /usr/local/include',


/usr/include'
makefile make
include makefile
makefile makefile make
makefile makefile make
makefile make makefile

makefile
-include include
-include filenames...

makefile

make sinclude -include

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 makefile makefile


make makefile

makefile makefile make


makefile
make
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

foo makefile Makefile


GNUmakefile makefile
foo:
frobnicate > foo
%: force
@$(MAKE) -f Makefile $@
force: ;

make foomake GNUmakefilefrobnicate > foo


make barmake GNUmakefilebar
make f Makefile barMakefilebarmake
GNUmakefile make
%
forceforce
make make
force

3.7 make makefile


GNU make make makefile
makefile
make

make
makefile makefile
make
make makefile
make

immediate = deferred
immediate ?= deferred
immediate := immediate
immediate += deferred or immediate
define immediate
deferred
endef
+=:=

ifdefifeqifndef inneq

immediate : immediate ; deferred


deferred

makefile

make
makefile
.
/

makefile
makefile all

4.1

targets : prerequisites
command
...

targets : prerequisites ; command


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)

objects *.ofoo OBJ


foo
OBJ
foo*.omake
*.o

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,%.o,$(wildcard *.c))

patsubst
C makefile

objects := $(patsubst %.c,%.o,$(wildcard *.c))


foo : $(objects)
cc -o foo $(objects)

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

vpath pattern directories

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

GNU make GPATH

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 $@

foofoo.ccc foo.c /usr/lib/libcurses.a -o foo'


libname.so' libname.a'
.LIBPATTERNS
-|namemake name

.LIBPATTERNS "lib%.so lib%.a'"

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

SUBDIRS = foo bar baz


.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $
foo: baz

bazfoo

make

makefile makefile
makefile

all : prog1 prog2 prog3


.PHONY : all
prog1 : prog1.o utils.o
cc -o prog1 prog1.o utils.o
prog2 : prog2.o
cc -o prog2 prog2.o
prog3 : prog3.o sort.o utils.o
cc -o prog3 prog3.o sort.o utils.o

make prog1
prog3'

make cleanall' OBJ diff

.PHONY: cleanall cleanobj cleandiff


cleanall : cleanobj cleandiff
rm program
cleanobj :
rm *.o
cleandiff :
rm *.diff

4.5

make

clean: FORCE
rm $(objects)
FORCE:

FORCRclean
FORCRFORCR
FORCR.PHONY: clean
make
FORCR makefile

4.6

touch

print: foo.c bar.c


lpr -p $?
touch print

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

$@

kbd.o command.o files.o: command.h

$@

bigoutput littleoutput : text.g


generate text.g -$(subst output,,$@) > $@

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

objects = foo.o bar.o


foo.o : defs.h
bar.o : defs.h test.h
$(objects) : config.h

make

extradeps=
$(objects) : $(extradeps)

`make extradeps=foo.h'foo.h OBJ make

make

4.10

4.10.1

targets ...: target-pattern: dep-patterns ...


commands
...

%%
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

files = foo.elc bar.o lose.o


$(filter %.o,$(files)): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(filter %.elc,$(files)): %.elc: %.el
emacs -f batch-byte-compile $<

$(filter %.o,$(files))'bar.o lose.o'


C OBJ $(filter %.elc,$(files))' foo.elc'
foo.el
$*
bigoutput littleoutput : %output : text.g
generate text.g -$* > $@

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

main.o : main.c defs.h

makefile main.omain.o
make
make make depend
depend
makefile include makefile

GNU make makefile

make GNU make makefile


Makefile
makefile
name.cname.d makefile makefile
name.o OBJ

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

main.o : main.c defs.h

main.o main.d : main.c defs.h

.d.oMake

.d include

makefile

sources = foo.c bar.c


include $(sources:.c=.d)

foo.c bar.c'foo.d
bar.d'.d makefile makefile
make Makefile

shell
- TAB

TAB

shell makefile shell


/bin/sh makefile
shell
/bin/sh shell###

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

shell SHELL /bin/sh shell


MS_DOS SHELL COMSPEC
shell
MS_DOS makefile SHELL
MS_DOS shellcommand.com make
shell MS_DOS make SHELL
Unix DOS shell SHELL
command.com make SHELL
SHELL Unix shell MS_DOS make
shell shell MS_DOS GNU make
shell:
1 SHELL makefile `SHELL = /bin/sh'make
/bin
2
3 PATH
make sh

make .exe', .com', .bat', .btm', .sh'

shell SHELL shell


SHELL shell
make Unix shellmake
Unix shell
shell makefile SHELL
shell Unix


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' (--touch'), -n' (--just-print'), -q'


(--question') 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 ...

export variable = value


:
variable = value
export variable

export variable := value

variable := value
export variable
,
export variable += value
:
variable += value
export variable

export unexport make shell sh


export
export
make export unexport unexport
export
export

export GNU make makefile


GNU make
.EXPORT_ALL_VARIABLES export GNU make
export
unexport make
export makefile
export unexport
export unexport make
MAKELEVEL
0 make1 make2
--makeMake 1
makefile

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

`-C', `-f', `-o', -W MAKEFLAGS


-jN
Unix
make make
N
N make

-j 1 MAKEFLAGS
-j make
-j
1
MAKEFLAGS

subsystem:
cd subdir && $(MAKE) MAKEFLAGS=

MAKEOVERRIDES
MAKEFLAGS
MAKEOVERRIDES
MAKEOVERRIDES =

MAKEFLAGS Arg list too long'

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

makefile MAKEFLAGS makefile

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: Leaving 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

run-yacc endef define


$
define
Yacc
Yacc y.tab.c

define

foo.c : foo.y
$(run-yacc)

run-yaccfoo.y$^foo.c$@
make

Tabmake shell

(`@', `-', `+')

@echo "frobnicating target $@"


frob-step-1 $< -o $@-step-1
frob-step-2 $@-step-1 -o $@
endef

make

frob.out: frob.in
@$(frobnicate)

5.8

target: ;

target Tab

makefile
makefile

make macros

makefile shell ==
define makefile

:',#',='

shell make make

foo', FOO', Foo'


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

space # end of the line

dir := /foo/bar

# directory to put the frobs in

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

a_dirs := dira dirb


1_dirs := dir1 dir2
a_files := filea fileb
1_files := file1 file2
ifeq "$(use_a)" "yes"
a1 := a
else
a1 := 1
endif
ifeq "$(use_dirs)" "yes"
df := dirs
else
df := files
endif
dirs := $($(a1)_$(df))
use_a use_dirs dirs a_dirs, 1_dirs, a_files
1_files

a_objects := a.o b.o c.o


1_objects := 1.o 2.o 3.o
sources := $($(a1)_objects:.o=.c)
a1 sources `a.c b.c c.c' `1.c 2.c 3.c'

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

ifeq ($(origin FOO), undefined)


FOO = bar
endif

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 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

CFLAGS CFLAGS includes CFLAGS


C = CFLAGS
$(includes) -O make CFLAGS
includes CFLAGS
+= CFLAGS
CFLAGS := $(CFLAGS) -pg # enable profiling
:= CFLAGS
make CFLAGS $(CFLAGS) -pg includes
-0 -pg includes
+= CFLAGS $(CFLAGS) 0 -pg
includes includes $(CFLAGS)

6.7 override
makefile
override
override variable = value


override variable := value

override variable += more text

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

two-lines = echo foo; echo $(bar)

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

target ... : variable-assignment

target ... : override variable-assignment


target ...
variable-assignment=
:=+=?=variable-assignment
target ... target ...

vs.
makefile
-e override

target ...

prog : CFLAGS = -g
prog : prog.o foo.o bar.o

prog CFLAGS -g`prog.o', `foo.o',


`bar.o' CFLAGS -g prog.o',foo.o', bar.o'
CFLAGS -g

6.11
GNU make

pattern ... : variable-assignment

pattern ... : override variable-assignment

pattern%-pattern ...

variable-assignment
override
%.o : CFLAGS = -O

%.o CFLAGS -0

7 makefile

makefile

make makefile shell

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

Endif endif makefile

makefile
makefile

CC gcc
foo: $(objects)

$(CC) -o foo $(objects) $(libs_for_gcc)

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

ifeq (arg1, arg2)


ifeq 'arg1' 'arg2'
ifeq "arg1" "arg2"
ifeq "arg1" 'arg2'
ifeq 'arg1' "arg2"

arg1arg2
text-if-truetext-if-false

strip

ifeq ($(strip $(foo)),)


text-if-empty
endif

$(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 #

make makefile make text-if-true


make text-if-falsemakefile

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

$(subst a,b,$(x))', `$(subst a,b,${x})'

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%

the\%weird\\%pattern\\' the%weird\' %'pattern\\'


%

$(patsubst %.c,%.o,x.c.c bar.c)

x.c.o bar.o' patsubst


$(var:pattern=replacement)


$(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

ifneq $(strip $(needs_made))'$(needs_made)'

$(findstring find,in)

infindfind

$(findstring a,a b c)
$(findstring a,b c)

a findstring
$(filter pattern...,text)

textpattern...pattern...
% patsubst filter

sources := foo.c bar.c baz.s ugh.h


foo: $(sources)
cc $(filter %.c %.s,$(sources)) -o foo
foo' foo.c',bar.c',baz.s' ugh.h'foo.c',bar.c'

$(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

$(sort foo bar lose)

bar foo lose sort

subst patsubst makefile VPATH


make VPATH:
C
VPATH src:../headers' subst

$(subst :, ,$(VPATH))

src ../headers' patsubst -|


CFLAGS C
override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
CFLAGS -Isrc -I../headersOverride
CFLAGS override

8.3

$(dir names...)

names
./
$(dir src/foo.c hacks)

src/ ./
$(notdir names...)

names

$(notdir src/foo.c hacks)

foo.c hacks
$(suffix names...)

names

names

$(suffix src/foo.c src-1.0/bar.c hacks)

.c .c
$(basename names...)

names

$(basename src/foo.c src-1.0/bar hacks)

src/foo src-1.0/bar hacks


$(addsuffix suffix,names...)

namessuffix Suffix

$(addsuffix .c,foo bar)

foo.c bar.c
$(addprefix prefix,names...)

namesprefix preffix

$(addprefix src/,foo bar)

src/foo src/bar
$(join list1,list2)

$(join a b,.c .o)'a.c b.o'


dirnotdir

$(word n,text)

text n N 1 n text

$(word 2, foo bar baz)

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)

texttext$(word $(words text),text)


$(firstword names...)

names

$(firstword foo bar)

foo $(firstword text) $(word 1,text)

$(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)/*))

text$(wildcard $(dir)/*) dir a foreach


$(wildcard a/*)b foreach
$(wildcard b/*)c foreach
$(wildcard c/*)
files := $(wildcard a/* b/* c/* d/*)
text
find_files = $(wildcard $(dir)/*)
dirs := a b c d
files := $(foreach dir,$(dirs),$(find_files))
find_file find_file =
find_file foreach
find_file wildcard
foreach var foreach
list foreach
var foreach foreach var
foreach

files := $(foreach Esta escrito en espanol!,b c ch,$(find_files))


find_file Esta escrito en espanol!

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

reverse = $(2) $(1)


foo = $(call reverse,a,b)

foo b a
PATH

pathsearch = $(firstword $(wildcard $(addsufix /$(1),$(subst :, ,$(PATH)))))


LS := $(call pathsearch,ls)

LS /bin/ls
call $(1)
call
map = $(foreach a,$(2),$(call $(1),$(a)))

map origin
o = $(call map,origin,o map MAKE)

o file file default


call
call

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

ifneq "$(findstring environment,$(origin bletch))" ""


bletch = barf, gag, etc.
endif
$(origin bletch)environmentenvironment overridebletch

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)

*.c files make shell


wildcard *.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...)

error make text


make

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

sources = foo.c bar.c


ifneq ($(MAKECMDGOALS),clean)
include $(sources:.c=.d)
endif

makefile

.PHONY: all
all: size nm ld ar as

size make size

makefile

makefile clean
make cleanmake
GNU make

all'

makefile

`clean'

make
`mostlyclean'

clean
GCC mostlycleanlibgcc.a

`distclean'
`realclean'
`clobber'

clean
makefile
install

print

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

-p-v make makefile

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

make qpmake p f/dev/null

`-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

foo.p make Pascal .p


OBJ .o.p foo.p
foo.c foo.c foo.o C
Pascal

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

COMPILE.c, LINK.p, PREPROCESS.S


Make .x
COMPILE.x.xLINK.x.x
PREPROCESS.x
OBJ OUTPUT_OPTIONmake
-o $@-O
VPATH

OBJ -o VPATH
OUTPUT_OPTION ; mv $*.o
$@

10.3
makefile
make
-R--no-builtin-variables

C $(CC) -c $(CFLAGS) $(CPPFLAGS)


cccc cCCncc
ncc C CFLAGS-g
-g C $CC
$(CFLAGS)
cc

CFLAGS
(
)

AR

ar'.
AS

as'.
CC

C cc'.
CXX

C++g++'.
CO

RCS co'.
CPP

C $(CC) -E'.
FC

Fortran Ratfor f77'.


GET

SCCS get'.
LEX

Lex C Ratfor lex'.


PC

Pascal pc'.
YACC

Yacc C yacc'.
YACCR

Yacc Ratfor yacc -r'.


MAKEINFO

Texinfo makeinfo'.
TEX

TeX TeX DVI tex'.


TEXI2DVI

Texinfo TeX DVI texi2dvi'.


WEAVE

Web TeX weave'.


CWEAVE

CWeb TeX cweave'.


TANGLE

Web Pascal tangle'.


CTANGLE

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

%.o : %.c ; command...

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%

%.tab.c %.tab.h: %.y


bison -d $<

make bison -d x.yx.tab.cx.tab.h foo parse.tab.o


scan.oscan.oparse.tab.hparse.ybison -d parse.y
parse.tab.oscan.o
parse.tab.oparse.tab.c
scan.oscan.cparse.tab.oscan.o foo

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

lib: foo.o bar.o lose.o win.o


ar r lib $?

DF GNU make T dir notdir


F' dir

`$(@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)'

"the value of$<'",


"the variable <" objects CFLAGS
$<' <
$(CFLAGS)' CFLAGS $(<)'$<'

10.5.4
%

stem%.otest.o
stemteststem%
%.ctest.c

e%tsrc/eatstem()src/a

stem stem()% stem src/a


c%rsrc/car

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

RCS SCCS foo.c,v'


make foo.c,v.oRCS/SCCS/s.foo.c,v RCS
SCCS make

foo.c' `%.c : %.y' ( Yacc)


(foo.y)
foo.c make foo.c.o',foo.c.c', foo.c.p'
foo.c'

%.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

GNU make makefile

.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: .hack .win


.hack' .win'

.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

libfoo.a: libfoo.a(x.o) libfoo.a(y.o) ...


ranlib libfoo.a
x.o',y.o', , ranlib
__.SYMDEF

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

GNU make make 4.2 BSD


make makefile 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

Stu Feldman make


AT&T Unix AT&T Andrew Hume
mk


$+ $^
"what if" (GNU make -W') Andrew Hume mk

make System V BSD

SunOS 4 GNU make


SunOS 4 patsubst
GNU make patsubst SunOS 4
+ IEEE
Standard 1003.2-1992 (POSIX.2)
+= SunOS 4 make

archive(mem1 mem2...)' SunOS 4 make.

-include makefile with


SunOS 4 make( SunOS 4 make makefile )
SGI make sinclude

GNU make

-v'`--version'
-h' --help' make

make MAKE make


-C' --directory'

.PHONY AT&T Andrew Hume


mk

-o'--old-file'
make C
makefile

makefile makefile
makefile MAKEFILES
`./' ./file' file'
-lname

make
./
make MAKWFILES make
MAKECMDGOALS

vpath

makefile makefile System V make


make SCCS

`MAKE_VERSION' make

13

make GNU make POSIX.2 (IEEE


Standard 1003.2-1992)

file((entry))' file
enty OBJ GNU make
make
~ System V make

~ SCCS .c~.o's.n.c' SCCS


n.o'
GNU make SCCS

System V make , $$@'


GNU make $$'
$'System V
make
$(targets): $$@.o lib.a
GNU make
$(targets): %: %.o lib.a
System V 4.3 BSD make VPATH

Unix make $*
Unix make
$*
Unix make

foo.o:
cc -c foo.c
Unix make foo.o' foo.c'Make
GNU make

GNU make EFL


EFL
SVR4 make

.c.a:
.c.a'
GNU make
.c.a: ;
make shell -e'-k' ()
-e' shell

14 makefile

GNU make makefile Automake


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

cat cmp cp diff echo egrep expr false grep install-info


ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
gzip dist
mkdir -p'

makefile
Makefile make

ar bison cc flex install ld ldconfig lex


make makeinfo ranlib texi2dvi yacc
make :
$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)

ranlib ldconfig

AutoconfAC_PROG_RANLIB'

make
chgrp chmod chown mknod
makefile

14.3
Makefile
Bison, BISON
BISON = bison Bison $(BISON)

ln, rm, mv

FLAGS'--, BISONFLAGS( CFLAGS


C , YFLAGS yacc LFLAGS lex
)
CPPFLAGS LDFLAGS
ld
C CFLAGS
CFLAGS CFLAGS C
,
CFLAGS = -g
ALL_CFLAGS = -I. $(CFLAGS)
.c.o:
$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
CFLAGS -g
GCC CFLAGS -o,

CFLAGS
CFLAGS
C CFLAGS
Makefile INSTALL INSTALL

Makefile INSTALL_PROGRAM INSTALL_DATA(


$(INSTALL))

$(INSTALL_PROGRAM) foo $(bindir)/foo


$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a

DESTDIR
makefile DESTDIR
DERSTDIR
$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a

14.4

SVR4, 4.4BSD, Linux, Ultrix v4,

`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'

$(datadir)' $(sysconfdir)' $(localstatedir)'


/usr/local/var'$(prefix)/var' ( Autoconf,
@localstatedir@')
`libdir'
OBJ OBJ
$(libexecdir)' libdir /usr/local/lib'
$(exec_prefix)/lib'( Autoconf, @libdir@')
`infodir'
Info /usr/local/info'
$(prefix)/info'. ( Autoconf, @infodir@'.)
`lispdir'
Emacs Lisp
/usr/local/share/emacs/site-lisp'$(prefix)/share/emacs/site-lisp'
Autoconf, @lispdir@'@lispdir@'
configure.in'
lispdir='${datadir}/emacs/site-lisp'
AC_SUBST(lispdir)

`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

Texinfo GNU Info


Info
make Info
`dvi'
DVI Texinfo
dvi: foo.dvi
foo.dvi: foo.texi chap1.texi chap2.texi
$(TEXI2DVI) $(srcdir)/foo.texi
makefile TEXI2DVI texi2dvi

Texinfo GNU make

`dist'
tar tar

GCC 1.40 tar gcc-1.40'


in cp tar
gzip tar GCC 1.40
gcc-1.40.tar.gz' dist
GNU
`check'


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

basename bash cat chgrp chmod chown cmp cp dd diff echo


egrep expand expr false fgrep find getopt grep gunzip gzip
hostname install install-info kill ldconfig ln ls md5sum
mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
test touch true uname xargs yes

make -n install -o all \


PRE_INSTALL=pre-install \
POST_INSTALL=post-install \
NORMAL_INSTALL=normal-install \
| gawk -f pre-install.awk
pre-install.awk'
$0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
on {print $0}
$0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
shell

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...)

make text make


$(warning text...)

make text make


$(shell command)

shell shell
$(origin variable)

make variable origin


$(foreach var,words,text)

words var text


foreach
$(call var,param,...)
$(1), $(2)... var $(1), $(2)... param

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

`[foo] Error NN'


`[foo] signal description'
make make
Error NN
make

*** 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

`No targets specified and no makefile found. Stop.'


`No targets. Stop.'
make makefile
makefile GNU make
makefile
`Makefile `xxx' was not found.'
`Included makefile `xxx' was not found.'
makefile makefile
`warning: overriding commands for target `xxx''
`warning: ignoring old commands for target `xxx''
GNU make ()


`Circular xxx <- yyy dependency dropped.'
make xxx yyy
yyy xxx
`Recursive variable `xxx' references itself (eventually). Stop.'
make xxx
(:=)+=

`Unterminated variable reference. Stop.'

`insufficient arguments to function `xxx'. Stop.'

`missing target pattern. Stop.'


`multiple target patterns. Stop.'
`target pattern contains no `%'. Stop.'

`warning: -jN forced in submake: disabling jobserver mode.'


make make
make
make
-jn n 1

MAKE make j2 make make

`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

# Copyright (C) 1991 Free Software Foundation, Inc.


# GNU
#
# ...
...
...
SHELL = /bin/sh
#### ####
srcdir = .
# gcc,
#
# -traditional gcc
# ioctl
CC = gcc -O
YACC = bison -y
INSTALL = /usr/local/bin/install -c
INSTALLDATA = /usr/local/bin/install -c -m 644
# DEFS
# -DSTDC_HEADERS
C
#

# -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 =

-DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \


-DVPRINTF_MISSING -DBSD42
# rtapelib.o
# NO_REMOTE,
RTAPELIB = rtapelib.o
LIBS =
DEF_AR_FILE = /dev/rmt8
DEFBLOCKING = 20
CDEBUG = -g
CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
-DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
-DDEFBLOCKING=$(DEFBLOCKING)
LDFLAGS = -g
prefix = /usr/local
#
#`g'
binprefix =
# tar
bindir = $(prefix)/bin
# info .
infodir = $(prefix)/info
#### ####
SRC1 =
SRC2 =
SRC3 =
SRCS =
OBJ1 =
OBJ2 =

tar.c create.c extract.c buffer.c \


getoldopt.c update.c gnu.c mangle.c
version.c list.c names.c diffarch.c \
port.c wildmat.c getopt.c
getopt1.c regex.c getdate.y
$(SRC1) $(SRC2) $(SRC3)
tar.o create.o extract.o buffer.o \
getoldopt.o update.o gnu.o mangle.o
version.o list.o names.o diffarch.o \
port.o wildmat.o getopt.o

OBJ3 = getopt1.o regex.o getdate.o $(RTAPELIB)


OBJS = $(OBJ1) $(OBJ2) $(OBJ3)
AUX =
README COPYING ChangeLog Makefile.in
makefile.pc configure configure.in \
tar.texinfo tar.info* texinfo.tex \
tar.h port.h open3.h getopt.h regex.h \
rmt.h rmt.c rtapelib.c alloca.c \
msd_dir.h msd_dir.c tcexparg.c \
level-0 level-1 backup-specs testpad.c
all:

tar rmt tar.info

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

version.c` > .fname


-rm -rf `cat .fname`
mkdir `cat .fname`
ln $(SRCS) $(AUX) `cat .fname`
tar chZf `cat .fname`.tar.Z `cat .fname`
-rm -rf `cat .fname` .fname
tar.zoo: $(SRCS) $(AUX)
-rm -rf tmp.dir
-mkdir tmp.dir
-rm tar.zoo
for X in $(SRCS) $(AUX) ; do \
echo $$X ; \
sed 's/$$/^M/' $$X \
> tmp.dir/$$X ; done
cd tmp.dir ; zoo aM ../tar.zoo *
-rm -rf tmp.dir

(1)
MS-DOS MS-Windows GNU Make DJGPP

(2)
MS-DOS , global,

(3)
texi2dvi

TeX . TeX Texinfo

1.54 texi2html 2000 7 19

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

You might also like