-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
Makefile
149 lines (122 loc) · 3.88 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
include config.mk
CFLAGS += -Wall -DNS_ENABLE_IPV6
LIBS = $(MORELIBS) -lm
LIBS += -lcurl -lconfig
TARGETS=
OTR_OBJS = json.o \
gcache.o \
geo.o \
geohash.o \
mkpath.o \
base64.o \
misc.o \
util.o \
storage.o \
fences.o \
listsort.o
OTR_EXTRA_OBJS =
CFLAGS += -DGHASHPREC=$(GHASHPREC)
LIBS += -llmdb
LIBS += -lpthread
define CPP_CONDITION
printf '#if $(1) \n
true \n
#else \n
#error false \n
#endif' | $(CPP) -P - >/dev/null 2>&1 && echo yes
endef
ifeq ($(WITH_MQTT),yes)
CFLAGS += -DWITH_MQTT=1
CFLAGS += $(MOSQUITTO_CFLAGS)
LIBS += $(MOSQUITTO_LIBS) -lm
endif
ifeq ($(WITH_PING),yes)
CFLAGS += -DWITH_PING=1
endif
ifeq ($(WITH_LUA),yes)
CFLAGS += -DWITH_LUA=1 $(LUA_CFLAGS)
LIBS += $(LUA_LIBS)
OTR_OBJS += hooks.o
endif
ifeq ($(WITH_ENCRYPT),yes)
CFLAGS += -DWITH_ENCRYPT=1 $(SODIUM_CFLAGS)
LIBS += $(SODIUM_LIBS)
endif
ifeq ($(WITH_KILL),yes)
CFLAGS += -DWITH_KILL=1
endif
ifeq ($(WITH_HTTP),yes)
CFLAGS += -DWITH_HTTP=1
OTR_EXTRA_OBJS += mongoose.o http.o
endif
ifeq ($(WITH_TOURS),yes)
CFLAGS += -DWITH_TOURS
OTR_EXTRA_OBJS +=
# Debian requires uuid-dev
# RHEL/CentOS needs libuuid-devel
ifeq ($(shell $(call CPP_CONDITION,__linux__)),yes)
LIBS += -luuid
endif
endif
ifeq ($(WITH_TZ),yes)
CFLAGS += -DWITH_TZ
CFLAGS += -DTZDATADB=\"$(TZDATADB)\"
OTR_EXTRA_OBJS += zonedetect.o
OCAT_EXTRA_OBJS += zonedetect.o
endif
ifeq ($(JSON_INDENT),yes)
CFLAGS += -DJSON_INDENT="\" \""
else
CFLAGS += -DJSON_INDENT=NULL
endif
CFLAGS += -DSTORAGEDEFAULT=\"$(STORAGEDEFAULT)\" -DDOCROOT=\"$(DOCROOT)\"
CFLAGS += -DCONFIGFILE=\"$(CONFIGFILE)\"
CFLAGS += -DGEOCODE_TIMEOUT=$(GEOCODE_TIMEOUT)
TARGETS += ot-recorder ocat
GIT_VERSION := $(shell git describe --long --abbrev=10 --dirty --tags 2>/dev/null || echo "tarball")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
PKG_CONFIG ?= pkg-config
all: $(TARGETS)
ot-recorder: recorder.o $(OTR_OBJS) $(OTR_EXTRA_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o ot-recorder recorder.o $(OTR_OBJS) $(OTR_EXTRA_OBJS) $(LIBS)
if test -r codesign.sh; then /bin/sh codesign.sh; fi
ocat: ocat.o $(OTR_OBJS) $(OCAT_EXTRA_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o ocat ocat.o $(OTR_OBJS) $(OCAT_EXTRA_OBJS) $(LIBS)
$(OTR_OBJS): config.mk Makefile
recorder.o: recorder.c storage.h util.h Makefile geo.h udata.h json.h http.h gcache.h config.mk hooks.h base64.h recorder.h version.h fences.h
geo.o: geo.h geo.c udata.h
geohash.o: geohash.h geohash.c udata.h
base64.o: base64.h base64.c
$(CC) $(CFLAGS) -Wno-unused-result -Wno-uninitialized -c base64.c
gcache.o: gcache.c gcache.h json.h
misc.o: misc.c misc.h udata.h
http.o: http.c mongoose.h util.h http.h storage.h version.h hooks.h
util.o: util.c util.h
mongoose.o: mongoose.c mongoose.h
ocat.o: ocat.c storage.h util.h version.h config.mk Makefile
storage.o: storage.c storage.h util.h gcache.h listsort.h zonedetect.c
hooks.o: hooks.c udata.h hooks.h util.h version.h gcache.h
listsort.o: listsort.c listsort.h
zonedetect.o: zonedetect.c zonedetect.h
fences.o: fences.c fences.h util.h json.h udata.h gcache.h hooks.h
clean:
rm -f *.o
clobber: clean
rm -f ot-recorder ocat
install: ot-recorder ocat
mkdir -p $(DESTDIR)$(INSTALLDIR)/bin
mkdir -p $(DESTDIR)$(INSTALLDIR)/sbin
mkdir -p $(DESTDIR)$(DOCROOT)
mkdir -p $$(dirname $(DESTDIR)$(TZDATADB))
install contrib/tzdatadb/timezone16.bin $(DESTDIR)$(TZDATADB)
mkdir -p $(DESTDIR)$(STORAGEDEFAULT)
cd docroot && find ! -type d ! -name .gitignore -exec install -m0644 -D {} $(DESTDIR)$(DOCROOT)/{} \;
install -m 0755 ot-recorder $(DESTDIR)$(INSTALLDIR)/sbin
install -m 0755 ocat $(DESTDIR)$(INSTALLDIR)/bin
mkdir -p `dirname $(DESTDIR)/$(CONFIGFILE)`
test -r $(DESTDIR)/$(CONFIGFILE) || install -m 640 etc/ot-recorder.default $(DESTDIR)/$(CONFIGFILE)
ifndef DESTDIR
$(INSTALLDIR)/sbin/ot-recorder --initialize
endif
# mkdir -p $(DESTDIR)/etc/systemd/system/
# install --mode 0644 etc/ot-recorder.service $(DESTDIR)/etc/systemd/system/ot-recorder.service