-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (46 loc) · 1.1 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
53
54
55
56
57
58
59
60
61
62
63
64
# Version 4
CC = gcc
TARGET = main
CFLAGS = -c
SRCDIR = source
SRCS = $(wildcard $(SRCDIR)/*.c)
OBJS = $(patsubst $(SRCDIR)/%.c,$(SRCDIR)/%.o,$(SRCS))
$(TARGET): $(OBJS) main.o
$(CC) -o $@ $^
main.o: main.c
gcc -c main.c
$(SRCDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $< -o $@
.PHONY: clean
clean:
rm -rf $(TARGET) $(SRCDIR)/*.o main.o
# Version 1
# main: main.c HashFunction.c HashMap.c HashMapIterator.c
# gcc main.c HashFunction.c HashMap.c HashMapIterator.c -o main
# Version 2
# CXX = gcc
# TARGET = main
# OBJ = main.o HashFunction.o HashMap.o HashMapIterator.o
# CXXFLAGS = -c -Wall
# $(TARGET): $(OBJ)
# $(CXX) -o $(TARGET) $(OBJ)
# main.o: main.c
# $(CXX) -c main.c
# HashFunction.o: HashFunction.c
# $(CXX) -c HashFunction.c
# HashMap.o: HashMap.c
# $(CXX) -c HashMap.c
# HashMapIterator.o: HashMapIterator.c
# $(CXX) -c HashMapIterator.c
# Version 3
# CXX = gcc
# TARGET = main
# OBJ = main.o HashFunction.o HashMap.o HashMapIterator.o
# CXXFLAGS = -c
# $(TARGET): $(OBJ)
# $(CXX) -o $@ $^
# %.o: %.c
# $(CXX) $(CXXFLAGS) $< -o $@
# .PHONY: clean
# clean:
# rm -f *.o $(TARGET)