-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
45 lines (33 loc) · 810 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Rule
target: prerequisites (sub targets)
<tab>recipe # uses prerequisites to make the target
# substitute variables for the above
$@: $<
@echo compiling...
${CC} ...
.DEFAULT_GOAL := the 1st target, often called 'all'
.PHONY: all clean # not actual files, run regardless of mtime
-include Makefile # '-' for no errors
# this is a 1 line recipe thus we need the ;s
# $$ is used as $variables are valid in Makefiles
setup:
@for d in *.db; \
do \
[[ -f $$d ]] && ln -sf "$${d%.db}" "$${d%.db}.in"; \
done
Example
CC := gcc
hack: privileges.o intrusion.o
linker ...
privileges.o: privileges.c
${CC} ...
intrusion.o: intrusion.c
${CC} ...
hack
depends on
*.o
which in turn depend on
*.c
privileges.c mtime has changed => rebuild
privileges.o => relink
hack