-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
182 lines (143 loc) · 3.79 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Shared library makefile
# Created on : Sep 12, 2017
# Author : may
TARGET := libimusensor
# Paths
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
MINGW_INSTALL_DIR := /usr/i686-w64-mingw32
DEVEL_DIR := /local/work.may/Development_Linux
CM_ROOT_DIR := /home/matt/ipg/hil/linux-6.0.4
OBJ_DIR := out
RM := rm -rf
# Global flags
LD_FLAGS :=
LIBS :=
LIB_DIRS := $(OBJ_DIR)
INCLUDE_DIRS :=
OUT_DIR :=
EXT :=
# Sub-projects ----------------------------------------------------------------
SUB_DIRS := \
DTrackSDK
LIBS += \
dtrack
#------------------------------------------------------------------------------
# OS independent cpp's
CPP_SRCS := \
ImuAPIWrapper.cpp \
device_interface.cpp \
utils.cpp \
DeviceBase.cpp \
smarttrack.cpp \
IPGTrack.cpp
# Windows Buids ---------------------------------------------------------------
ifeq ($(OS), win)
# Specific Windows cpp's
CPP_SRCS += \
hid_windows.cpp
# Shared libraries
LIBS += \
boost_system \
boost_chrono \
boost_thread_win32 \
hid \
setupapi \
tcl86 \
ws2_32
INCLUDE_DIRS += \
$(DEVEL_DIR)/boost_1_65_1 \
$(DEVEL_DIR)/tcl8.6.7/generic \
$(SUB_DIRS)
LIB_DIRS += \
$(DEVEL_DIR)/boost_1_65_1/stage/lib \
$(DEVEL_DIR)/tcl8.6.7/build/tcl
# Prepend include/lib dir prefix
INCLUDE_DIRS := $(addprefix -I,$(INCLUDE_DIRS))
LIB_DIRS := $(addprefix -L,$(LIB_DIRS))
CC := i686-w64-mingw32-gcc
CXX := i686-w64-mingw32-g++
OUT_DIR := $(OBJ_DIR)
EXT := so
CXXFLAGS := \
-DOS_WINDOWS -D_WIN32 -DBUILD_DLL \
-O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP \
$(INCLUDE_DIRS)
LDFLAGS := \
-Wl,--out-implib,$(OBJ_DIR)/$(TARGET).a \
$(LIB_DIRS)
else
# Linux builds ----------------------------------------------------------------
# Specific Linux cpp's
CPP_SRCS += \
hid_linux.cpp
# Shared libraries
LIBS += \
boost_system \
boost_thread \
usb
INCLUDE_DIRS += \
$(SUB_DIRS)
LIB_DIRS += \
$(CM_ROOT_DIR)/GUI/libtcl8.6.so
CC := gcc
CXX := g++
OUT_DIR := $(CM_ROOT_DIR)/GUI/lib
EXT := so
# Prepend include/lib dir prefix
INCLUDE_DIRS := $(addprefix -I,$(INCLUDE_DIRS))
LIB_DIRS := $(addprefix -L,$(LIB_DIRS))
CXXFLAGS := \
-DOS_LINUX \
-O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP \
$(INCLUDE_DIRS)
LDFLAGS := \
$(LIB_DIRS)
endif
# Export variables for sub-makefiles ------------------------------------------
export ROOT_DIR
export OBJ_DIR
export OS
#------------------------------------------------------------------------------
#DO NOT EDIT BELOW THIS LINE
#------------------------------------------------------------------------------
# Prepend -l to library list
LIBS := $(addprefix -l,$(LIBS))
# Grab obj names from cpp and prepend obj dir
# obj1.cpp obj2.cpp ... --> $(OBJS) := out/obj1.o out/obj2.o ...
OBJS := $(patsubst %.cpp,$(OBJ_DIR)/%.o, $(CPP_SRCS))
# All Target
all: \
directories \
submodules \
$(TARGET).$(EXT)
module: \
directories \
$(TARGET).$(EXT)
directories:
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OUT_DIR)
# Link
# Passes each object in $(OBJS) to the compiler and links to $(TARGET).$(EXT) afterwards
$(TARGET).$(EXT): $(OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
$(CXX) -m32 -shared $(LDFLAGS) -o $(OUT_DIR)/$(TARGET).$(EXT) $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Compile
# Called recursively for each object in $(OBJS) by the linking process
$(OBJ_DIR)/%.o: ./%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
$(CXX) -m32 $(CXXFLAGS) -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
# Recursive call subdirs
submodules:
$(MAKE) -C $(SUB_DIRS)
# Clean build
clean:
$(RM) $(OBJ_DIR) $(OUT_DIR)/$(TARGET).*
@echo ' '
.PHONY: all submodules module clean