-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
68 lines (54 loc) · 1.28 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
65
66
67
68
#We try to detect the OS we are running on, and adjust commands as needed
ifeq ($(OSTYPE),cygwin)
CLEANUP = rm -f
MKDIR = mkdir -p
TARGET_EXTENSION=.out
else ifeq ($(OS),Windows_NT)
CLEANUP = del /F /Q
MKDIR = mkdir
TARGET_EXTENSION=.exe
else
CLEANUP = rm -f
MKDIR = mkdir -p
TARGET_EXTENSION=.out
endif
#Path Definitions
PATHU = unity/
PATHS = src/
PATHT = test/
PATHB = build/
#determine our source files
SRCU = $(PATHU)unity.c
SRCS = $(wildcard $(PATHS)*.c)
SRCT = $(wildcard $(PATHT)*.c)
SRC = $(SRCU) $(SRCS) $(SRCT)
#Files We Are To Work With
OBJU = $(patsubst $(PATHU)%.c,$(PATHB)%.o,$(SRCU))
OBJS = $(patsubst $(PATHS)%.c,$(PATHB)%.o,$(SRCS))
OBJT = $(patsubst $(PATHT)%.c,$(PATHB)%.o,$(SRCT))
OBJ = $(OBJU) $(OBJS) $(OBJT)
#Other files we care about
DEP = $(PATHU)unity.h $(PATHU)unity_internals.h
TGT = $(PATHB)test$(TARGET_EXTENSION)
#Tool Definitions
CC=gcc
CFLAGS=-I. -I$(PATHU) -I$(PATHS) -DTEST
test: $(PATHB) $(TGT)
./$(TGT)
$(PATHB)%.o:: $(PATHS)%.c $(DEP)
$(CC) -c $(CFLAGS) $< -o $@
$(PATHB)%.o:: $(PATHT)%.c $(DEP)
$(CC) -c $(CFLAGS) $< -o $@
$(PATHB)%.o:: $(PATHU)%.c $(DEP)
$(CC) -c $(CFLAGS) $< -o $@
$(TGT): $(OBJ)
gcc -o $@ $^
clean:
$(CLEANUP) $(PATHB)*.o
$(CLEANUP) $(TGT)
$(PATHB):
$(MKDIR) $(PATHB)
all: clean test
.PHONY: all
.PHONY: clean
.PHONY: test