forked from dabrowne/ADS
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
57 lines (43 loc) · 1.31 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
OS_NAME ?= $(shell uname)
VPATH = AdsLib
LIBS = -lpthread
LIB_NAME = AdsLib-$(OS_NAME).a
SHARED_LIB_NAME = adslib.so
INSTALL_DIR=/usr/lib/
CXX :=$(CROSS_COMPILE)$(CXX)
CFLAGS += -std=c++11
CFLAGS += -pedantic
CFLAGS += -Wall
CFLAGS += -fPIC
SRC_DIR := AdsLib/
OBJ_DIR := obj/
# Automatically collect all .cpp files
CPP_FILES := $(wildcard $(SRC_DIR)*.cpp)
# Create list of corresponding .obj outputs
OBJ_FILES := $(addprefix $(OBJ_DIR),$(notdir $(CPP_FILES:.cpp=.o)))
LDFLAGS += -lpthread
LDFLAGS_Darwin += -lc++
LDFLAGS_win32 += -lws2_32
LDFLAGS += $(LDFLAGS_$(OS_NAME))
all: $(SHARED_LIB_NAME)
$(OBJ_FILES): $(OBJ_DIR)%.o: %.cpp
mkdir -p $(OBJ_DIR)
$(CXX) -c $(CFLAGS) $< -o $@ -I AdsLib/
$(SHARED_LIB_NAME): $(OBJ_FILES)
$(CXX) -shared -fPIC -o $(SHARED_LIB_NAME) $?
AdsLibTest.bin: AdsLibTest/main.o $(LIB_NAME)
$(CXX) $^ $(LIBS) -o $@
test: AdsLibTest.bin
./$<
install: $(SHARED_LIB_NAME)
cp $? $(INSTALL_DIR)$(SHARED_LIB_NAME)
sudo chmod 755 $(INSTALL_DIR)$(SHARED_LIB_NAME)
clean:
rm -f *.a *.o *.bin AdsLibTest/*.o $(OBJ_DIR)*.o *.so
uncrustify:
uncrustify --no-backup -c tools/uncrustify.cfg AdsLib*/*.h AdsLib*/*.cpp example/*.cpp
prepare-hooks:
rm -f .git/hooks/pre-commit
ln -Fv tools/pre-commit.uncrustify .git/hooks/pre-commit
chmod a+x .git/hooks/pre-commit
.PHONY: clean uncrustify prepare-hooks