-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
148 lines (110 loc) · 5.11 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
#
# Makefile for Thrift4OZW
# Elias Karakoulakis <[email protected]>
# based on Makefile for OpenWave Control Panel application by Greg Satz
# GNU make only
.SUFFIXES: .cpp .o .a .s .thrift
# Sorry gcc, clang is way better.
# Use it if found in path...
CLANG := $(shell which clang)
ifeq ($(CLANG),)
CC := gcc
CXX := g++
else
CC := clang
CXX := clang++
endif
LD := ld
AR := ar rc
RANLIB := ranlib
# Change for DEBUG or RELEASE
TARGET := DEBUG
# TODO: Restore the -Werror flag after removing calls to the deprecated
# Manager::BeginControllerCommand method.
DEBUG_CFLAGS := -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -Wall -Wno-format -g -DDEBUG -O0 -DDEBUG_BOOSTSTOMP
RELEASE_CFLAGS := -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -Wall -Wno-unknown-pragmas -Wno-format -O3 -DNDEBUG
DEBUG_LDFLAGS := -g
# ============================
# change directories if needed
# ============================
OPENZWAVE := $(HOME)/ozw/openzwave
OPENZWAVE_LIB := /usr/lib
OPENZWAVE_INC := $(OPENZWAVE)/cpp/src
THRIFT := $(HOME)/ozw/thrift
THRIFT_INC := /usr/local/include/thrift
BOOSTSTOMP_LIB := /usr/local/lib
BOOSTSTOMP_INC := /usr/local/include/booststomp
CFLAGS := -c $($(TARGET)_CFLAGS)
LDFLAGS := $($(TARGET)_LDFLAGS) \
-Wl,-rpath=$(OPENZWAVE)/cpp/lib/linux/
INCLUDES := -I $(OPENZWAVE_INC) -I $(OPENZWAVE_INC)/command_classes/ -I $(OPENZWAVE_INC)/value_classes/ \
-I $(OPENZWAVE_INC)/platform/ -I $(OPENZWAVE_INC)/platform/unix -I $(THRIFT_INC) -I $(BOOSTSTOMP_INC) \
-I . -I gen-cpp
# Remove comment below for gnutls support
#GNUTLS := -lgnutls
LIBZWAVE_STATIC := $(OPENZWAVE_LIB)/libopenzwave.a
LIBZWAVE_DYNAMIC := $(OPENZWAVE_LIB)/libopenzwave.so.1.3
LIBZWAVE := -lopenzwave
LIBUSB := -ludev
# for Mac OS X comment out above 2 lines and uncomment next 2 lines
#LIBZWAVE := $(wildcard $(OPENZWAVE)/cpp/lib/mac/*.a)
#LIBUSB := -framework IOKit -framework CoreFoundation
LIBBOOST := -lboost_thread -lboost_program_options -lboost_system -lboost_filesystem -lpthread
LIBBOOST_STATIC := -lboost_thread -lboost_program_options -lboost_system -lboost_filesystem
LIBTHRIFT := -lthrift
LIBBOOSTSTOMP := -lbooststomp
LIBBOOSTSTOMP_STATIC := libbooststomp.a
LIBS := $(GNUTLS) $(LIBZWAVE) $(LIBUSB) $(LIBBOOST) $(LIBTHRIFT) $(LIBBOOSTSTOMP)
%.o : %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -o $@ $<
%.o : %.c
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $<
#all: openzwave booststomp ozwd ozwd.static
all: openzwave booststomp ozwd
@echo "---------------------------------"
@echo "Your OpenZWave daemon is compiled!"
@echo "---------------------------------"
gen-cpp/RemoteManager_server.cpp: create_server.rb gen-cpp/RemoteManager.cpp
- patch -u -N -p0 gen-cpp/ozw_types.h < ozw_types.h.patch
ruby create_server.rb --ozwroot=${OPENZWAVE} --thriftroot=$(THRIFT_INC)
cp gen-cpp/RemoteManager_server.cpp gen-cpp/RemoteManager_server.cpp.orig
cp gen-cpp/ozw_types.h gen-cpp/ozw_types.h.orig
- patch -u -N -p0 gen-cpp/RemoteManager_server.cpp < RemoteManager_server.cpp.patch
gen-cpp/RemoteManager.cpp: ozw.thrift
thrift --gen cpp --gen java --gen js --gen py --gen rb ozw.thrift
gen-cpp/RemoteManager.o: gen-cpp/RemoteManager.cpp
$(CXX) $(CFLAGS) -c gen-cpp/RemoteManager.cpp -o gen-cpp/RemoteManager.o $(INCLUDES)
gen-cpp/ozw_constants.o: gen-cpp/ozw_constants.cpp
$(CXX) $(CFLAGS) -c gen-cpp/ozw_constants.cpp -o gen-cpp/ozw_constants.o $(INCLUDES)
gen-cpp/ozw_types.o: gen-cpp/ozw_types.cpp gen-cpp/ozw_types.h
$(CXX) $(CFLAGS) -c gen-cpp/ozw_types.cpp -o gen-cpp/ozw_types.o $(INCLUDES)
Main.o: Main.cpp gen-cpp/RemoteManager_server.cpp
$(CXX) $(CFLAGS) -c Main.cpp $(INCLUDES)
openzwave:
cd $(OPENZWAVE); make
openzwave-install: openzwave
cd $(OPENZWAVE); sudo make install
booststomp:
#cd $(BOOSTSTOMP); make
ozwd.static: Main.o booststomp gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o openzwave
$(CXX) -static -static-libgcc -o $@ $(LDFLAGS) Main.o gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o $(LIBZWAVE_STATIC) $(LIBBOOSTSTOMP_STATIC) $(LIBBOOST_STATIC) -lpthread -ludev -lthrift -lrt
ozwd: Main.o booststomp gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o openzwave
$(CXX) -o $@ $(LDFLAGS) Main.o gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o $(LIBS)
dist: main
rm -f Thrift4OZW.tar.gz
tar -c --exclude=".git" --exclude ".svn" --exclude "*.o" -hvzf Thrift4OZW.tar.gz *.cpp *.h *.thrift *.sm *.rb Makefile gen-*/ license/ README*
bindist: main
rm -f Thrift4OZW_bin_`uname -i`.tar.gz
upx ozwd*
tar -c --exclude=".git" --exclude ".svn" -hvzf Thrift4OZW_bin_`uname -i`.tar.gz ozwd license/ README*
clean:
rm -f ozwd*.o gen-cpp/RemoteManager.cpp gen-cpp/RemoteManager_server.cpp gen-cpp/ozw_types.h
binclean:
rm -f ozwd *.o gen-cpp/*.o
thrift: gen-cpp/RemoteManager.cpp
patchdiffs:
- diff -u gen-cpp/ozw_types.h.orig gen-cpp/ozw_types.h > ozw_types.h.patch
- diff -u gen-cpp/RemoteManager_server.cpp.orig gen-cpp/RemoteManager_server.cpp > RemoteManager_server.cpp.patch
java:
cd gen-java/OpenZWave; javac -cp .:`find $(THRIFT)/lib/java/build -name "*.jar" | tr "\n" ":"` *.java
cd gen-java; jar -cf OpenZWave.jar OpenZWave/*.class