-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (42 loc) · 1.33 KB
/
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
46
47
48
49
50
51
52
## This is a simple Makefile with lost of comments
## Check Unix Programming Tools handout for more info.
# Define what compiler to use and the flags.
CC=cc
CXX=CC
#CCFLAGS= -g -std=c99 -Wall -Werror
# A rule in Makefile has the form:
#
# target: dependencies
# command
#
# where "target" and "dependencies" are files (most of the time).
# These means that if "target" does not exist or the modification
# date of the dependencies are older than the modification time of
# "target" then "command" is executed.
#
# For example, the rule
#
# mystring.o : mystring.c
# $(CC) -c $(CCFLAGS) mystring.c
#
# means that if mystring.o does not exist, or if mystring.c is older
# than mystring.o, then execute "$(CC) -c $(CCFLAGS) mystring.c".
#
# The goal of make is to execute the minimum set of commands that
# are necessary to build the target files. i.e., it does not rebuild
# files that it expects need not be rebuilt because they have not changed.
#
# Usually, the first target in a Makefile is called "all".
# The dependencies of "all" are the files (or make targets) that we want to build.
#
all: shell test
# Compile all .c files into .o files
# % matches all (like * in a command)
# $< is the source file (.c file)
%.o : %.c
$(CC) -c $(CCFLAGS) $<
# Build shell if necessary
shell: main.o
$(CC) -o shell main.o
clean:
rm -f core *.o shell