-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
78 lines (55 loc) · 2.03 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
DESTDIR ?= /
HEADERS=utils.h mqtt_wrapper.h http_helper.h mqttrpc.h version.h
OBJS=mqtt_wrapper.o utils.o http_helper.o mqttrpc.o
CXX=g++
CXX_PATH := $(shell which g++-4.7)
CC=gcc
CC_PATH := $(shell which gcc-4.7)
ifneq ($(CXX_PATH),)
CXX=g++-4.7
endif
ifneq ($(CC_PATH),)
CC=gcc-4.7
endif
#CFLAGS=-Wall -ggdb -std=c++0x -O0 -I.
CFLAGS=-Wall -std=c++0x -Os -I. -fPIC -g
LDFLAGS= -lmosquittopp -lcurl -ljsoncpp -lmosquitto
COMMON_DIR=common
COMMON_H=$(patsubst %.h,$(COMMON_DIR)/%.h,$(HEADERS))
COMMON_O=$(patsubst %.o,$(COMMON_DIR)/%.o,$(OBJS))
NAME=libwbmqtt
INCLUDE_DIR=wbmqtt
MAJOR=0
MINOR=1
VERSION=$(MAJOR).$(MINOR)
LIBRARY_NAME=$(NAME).so.$(VERSION)
LIBRARY_DEV_NAME=$(NAME).so
lib : $(COMMON_DIR)/$(NAME).so.$(VERSION)
$(COMMON_DIR)/$(LIBRARY_NAME) : $(COMMON_O)
${CXX} -shared -Wl,-soname,$(NAME).so.$(MAJOR) -o $(COMMON_DIR)/$(LIBRARY_NAME) $(COMMON_O) $(LDFLAGS)
$(COMMON_DIR)/utils.o : $(COMMON_DIR)/utils.cpp $(COMMON_H)
${CXX} -c $< -o $@ ${CFLAGS}
$(COMMON_DIR)/mqttrpc.o : $(COMMON_DIR)/mqttrpc.cpp $(COMMON_H)
${CXX} -c $< -o $@ ${CFLAGS}
$(COMMON_DIR)/mqtt_wrapper.o : $(COMMON_DIR)/mqtt_wrapper.cpp $(COMMON_H)
${CXX} -c $< -o $@ ${CFLAGS}
$(COMMON_DIR)/http_helper.o : $(COMMON_DIR)/http_helper.cpp $(COMMON_H)
${CXX} -c $< -o $@ ${CFLAGS}
clean :
-rm -f $(COMMON_DIR)/*.o
-rm -f $(COMMON_DIR)/*.so
INSTALL_HEADERS=$(patsubst %.h,%.install-header,$(HEADERS))
install-headers: $(INSTALL_HEADERS)
install-headers-dir:
install -d $(DESTDIR)
install -d $(DESTDIR)/usr/include
install -d $(DESTDIR)/usr/include/$(INCLUDE_DIR)
%.install-header: $(COMMON_DIR)/%.h install-headers-dir
install -m 0755 $< $(DESTDIR)/usr/include/$(INCLUDE_DIR)/$(patsubst $(COMMON_DIR)/%.h,%.h,$<)
install: lib install-headers
install -d $(DESTDIR)
install -d $(DESTDIR)/usr/lib
install -m 0755 $(COMMON_DIR)/$(LIBRARY_NAME) $(DESTDIR)/usr/lib/$(LIBRARY_NAME)
ln -s -f $(LIBRARY_NAME) $(DESTDIR)/usr/lib/$(LIBRARY_DEV_NAME)
ln -s -f $(LIBRARY_NAME) $(DESTDIR)/usr/lib/$(LIBRARY_DEV_NAME).$(MAJOR)
.PHONY: all lib clean install install-headers