-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (85 loc) · 2.73 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ------------------------------------------------
# Generic Makefile
#
# Author: [email protected]
# Date : 2011-08-10
#
# Changelog :
# 2010-11-05 - first version
# 2011-08-10 - added structure : sources, objects, binaries
# thanks to http://stackoverflow.com/users/128940/beta
# ------------------------------------------------
ifeq (${mode},debug)
MODEFLAGS = -g
endif
ifeq (${mode},release)
MODEFLAGS = -O2
endif
# project name (generate executable with this name)
TARGET = robot
CC = g++
# compiling flags here
CFLAGS = $(MODEFLAGS) -Wall -I. -I/usr/local/lib
LINKER = g++ -o
# linking flags here
OPENCV_LIBS = $(MODEFLAGS) -lrt -lopencv_core -lopencv_imgproc -lopencv_video -lopencv_highgui -lopencv_photo -lopencv_flann -lopencv_stitching -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_core -lopencv_legacy
LFLAGS = -Wall -I. -lm -lwiringPi -lpthread -lstdc++ $(OPENCV_LIBS)
MYSRCSDIR = .
ROBOTAPIDIR = ./robotAPI
OBJDIR = ./obj
MYSOURCES := $(wildcard $(MYSRCSDIR)/*.cpp)
MYINCLUDES := $(wildcard $(MYSRCSDIR)/*.h)
MYOBJS := $(patsubst $(MYSRCSDIR)/%, $(OBJDIR)/%, $(MYSOURCES:.cpp=.o))
RAPISOURCES := $(wildcard $(ROBOTAPIDIR)/*.cpp)
RAPIINCLUDES := $(wildcard $(ROBOTAPIDIR)/*.h)
RAPIOBJS := $(patsubst $(ROBOTAPIDIR)/%, $(OBJDIR)/%, $(RAPISOURCES:.cpp=.o))
rm = rm -f
$(TARGET): $(MYOBJS) $(RAPIOBJS)
@echo "Linking" $@
@echo $(LINKER) $@ $(LFLAGS) $(MYOBJS) $(RAPIOBJS)
@$(LINKER) $@ $(LFLAGS) $(MYOBJS) $(RAPIOBJS)
@echo "Linking complete!"
$(RAPIOBJS): $(OBJDIR)/%.o : $(ROBOTAPIDIR)/%.cpp $(ROBOTAPIDIR)/%.h
@echo "Building" $<
@echo $(CC) $(CFLAGS) -c $< -o $@
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"
$(MYOBJS): $(OBJDIR)/%.o : $(MYSOURCES) $(MYINCLUDES)
@echo "Building" $<
@echo $(CC) $(CFLAGS) -c $< -o $@
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully!"
.PHONEY: clean
clean:
@$(rm) $(MYOBJS) $(RAPIOBJS)
@echo "Cleanup complete!"
.PHONEY: remove
remove: clean
@$(rm) $(TARGET)
@echo "Executable removed!"
.PHONEY: display
display:
@echo mode: $(mode)
@echo CFLAGS: $(CFLAGS)
@echo LFLAGS: $(LFLAGS)
@echo $(ROBOTAPIDIR)/%.cpp
@echo "robotAPI="
@echo $(ROBOTAPIDIR)
@echo "RAPISOURCES="
@echo $(RAPISOURCES)
@echo "RAPIINCLUDES="
@echo $(RAPIINCLUDES)
@echo "RAPIOBJECTS="
@echo $(RAPIOBJS)
@echo "MYSOURCES="
@echo $(MYSOURCES)
@echo "MYINCLUDES="
@echo $(MYINCLUDES)
@echo "OBJECTS="
@echo $(MYOBJS)
@echo "ROBOT API RULE:"
@echo $(RAPIOBJS): $(OBJDIR)/%.o : $(ROBOTAPIDIR)/%.cpp $(ROBOTAPIDIR)/%.h
@echo "MYOBJECTS RULE:"
@echo $(MYOBJ): $(OBJDIR)/%.o : $(MYSRCSDIR)/%.cpp $(MYSRCSDIR)/%.h
@echo "TARGET RULE:"
@echo $(TARGET): $(MYOBJ) $(RAPIOBJS)