forked from xArm-Developer/xArm-CPLUS-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (58 loc) · 2.14 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
CXX = g++
C_DEFS = -DSOFT_VERSION=$(SOFT_VERSION)
C_FLAGS = -std=c++0x -Wall -g -s $(C_DEFS) -I$(INC_DIR) $(LIBDIRS)
LIBS += -lm -lpthread -fPIC -shared
BUILDDIR = ./build/
INC_DIR = ./include/
SRC_DIR = ./src/
EXAMPLE_DIR = ./example/
BUILD_EXAMPLE_DIR = $(BUILDDIR)example/
BUILD_LIB_DIR = $(BUILDDIR)lib/
SRC_SERIAL_DIR = $(SRC_DIR)serial/
SRC_SERIAL_IMPL_DIR = $(SRC_SERIAL_DIR)impl/
SRC_SERIAL_IMPL_LISTPORT_DIR = $(SRC_SERIAL_IMPL_DIR)list_ports/
SRC_XARM_DIR = $(SRC_DIR)xarm/
SRC_XARM_CORE_DIR = $(SRC_XARM_DIR)core/
SRC_XARM_WRAPPER_DIR = $(SRC_XARM_DIR)wrapper/
SRC_XARM_CORE_COMMON_DIR = $(SRC_XARM_CORE_DIR)common/
SRC_XARM_CORE_DEBUG_DIR = $(SRC_XARM_CORE_DIR)debug/
SRC_XARM_CORE_INSTRUCTION_DIR = $(SRC_XARM_CORE_DIR)instruction/
SRC_XARM_CORE_LINUX_DIR = $(SRC_XARM_CORE_DIR)linux/
SRC_XARM_CORE_PORT_DIR = $(SRC_XARM_CORE_DIR)port/
SRC_XARM := $(wildcard $(SRC_SERIAL_DIR)*.cc \
$(SRC_SERIAL_IMPL_DIR)*.cc \
$(SRC_SERIAL_IMPL_LISTPORT_DIR)*.cc \
$(SRC_XARM_WRAPPER_DIR)*.cc \
$(SRC_XARM_CORE_COMMON_DIR)*.cc \
$(SRC_XARM_CORE_DEBUG_DIR)*.cc \
$(SRC_XARM_CORE_INSTRUCTION_DIR)*.cc \
$(SRC_XARM_CORE_LINUX_DIR)*.cc \
$(SRC_XARM_CORE_PORT_DIR)*.cc)
# OBJ_XARM := $(patsubst %.cc, %.o, $(SRC_XARM))
LIB_NAME = libxarm.so
SRC_EXAMPLE := $(wildcard $(EXAMPLE_DIR)*.cc)
# OBJ_EXAMPLE := $(patsubst %.cc, %.o, $(SRC_EXAMPLE))
all: xarm test
xarm:
mkdir -p $(BUILD_LIB_DIR)
$(CXX) $(SRC_XARM) $(C_FLAGS) $(LIBS) -o $(BUILD_LIB_DIR)/$(LIB_NAME)
test:
for file in $(SRC_EXAMPLE); do \
make test-`echo $$file | awk -F'/' '{print $$NF}' | awk -F'.cc' '{print $$1}'`; \
# $(CXX) $$file $(C_FLAGS) -L$(BUILD_LIB_DIR) -lxarm -o $(BUILD_EXAMPLE_DIR)/`echo $$file | awk -F'/' '{print $$NF}' | awk -F'.cc' '{print $$1}'`; \
done
test-%:
mkdir -p $(BUILD_EXAMPLE_DIR)
$(CXX) $(addprefix ./$(EXAMPLE_DIR)/, $(subst test-, , $@)).cc $(C_FLAGS) -L$(BUILD_LIB_DIR) -lxarm -o $(addprefix $(BUILD_EXAMPLE_DIR), $(subst test-, , $@))
install:
cp -rf include/xarm /usr/include
cp -f build/lib/$(LIB_NAME) /usr/lib/
uninstall:
rm -rf /usr/include/xarm
rm -f /usr/lib/$(LIB_NAME)
clean:
rm -rf ./build
clean-xarm:
rm -rf ./build/lib
clean-test:
rm -rf ./build/example