-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (36 loc) · 1.2 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
# Define variable CC to be the compiler we want to use
CC = gcc
# Define CFLAGS for the flags we will want to use with compiler
CFLAGS = -g -Wall
# Output executable
TARGET1 = evzip
TARGET2 = evunzip
# Output object files dependencies for linking
TARGET1_DEPENDENCIES = evzip.o huffmantree.o heap.o
TARGET2_DEPENDENCIES = evunzip.o huffmantree.o heap.o
# ensure these targets are executed even if there is a file named like that
.PHONY: clean all
# If no arguments are passed to make, it will attempt the 'all' target
default: all
all: $(TARGET1) $(TARGET2)
# TARGET_DEPENDENCIES
# $< first dependency, $^ all dependencies, $@ the file LHS of ':'
evzip.o: evzip.c huffmantree.h
$(CC) -c $(CFLAGS) $< -o $@
evunzip.o: evunzip.c huffmantree.h
$(CC) -c $(CFLAGS) $< -o $@
huffmantree.o: huffmantree.c huffmantree.h
$(CC) -c $(CFLAGS) $< -o $@
heap.o: heap/heap.c heap/heap.h
$(CC) -c $(CFLAGS) $< -o $@
# TARGET linking
$(TARGET1): $(TARGET1_DEPENDENCIES)
$(CC) $(CFLAGS) $^ -o $@
$(TARGET2): $(TARGET2_DEPENDENCIES)
$(CC) $(CFLAGS) $^ -o $@
# $(RM) is the platform agnostic way to delete a file
clean:
$(RM) $(TARGET1)
$(RM) $(TARGET1_DEPENDENCIES)
$(RM) $(TARGET2)
$(RM) $(TARGET2_DEPENDENCIES)