-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
139 lines (104 loc) · 3.49 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
# Copyright: 2016-2021 Twinleaf LLC
# Author: [email protected]
# License: MIT
LIBTIO ?= ./libtio
USE_WEBSOCKETS ?= 1
DEBUG ?= 0
CCFLAGS = -O2 -Wall -Wextra -I$(LIBTIO)/include/ -std=gnu11
CXXFLAGS = -O2 -Wall -Wextra -I$(LIBTIO)/include/ -std=gnu++17
LDFLAGS = -L$(LIBTIO)/lib/ -ltio
WEBSOCK_PP=
WEBSOCK_LINK=
ifeq ($(DEBUG), 0)
ifeq ($(shell uname -s),Linux)
LDFLAGS += -Wl,-s
endif
else
CCFLAGS += -g
CXXFLAGS += -g
endif
ifeq ($(USE_WEBSOCKETS), 1)
WEBSOCK_PP+= -DWEBSOCKETS=1
WEBSOCK_LINK+= -lcrypto
ifneq (,$(wildcard /usr/local/opt/openssl))
WEBSOCK_PP+= -I/usr/local/opt/openssl/include
WEBSOCK_LINK+= -L/usr/local/opt/openssl/lib
endif
ifneq (,$(wildcard /opt/homebrew/opt/openssl))
WEBSOCK_PP+= -I/opt/homebrew/opt/openssl/include
WEBSOCK_LINK+= -L/opt/homebrew/opt/openssl/lib
endif
endif
.DEFAULT_GOAL = all
.SECONDARY:
LIB_HEADERS = $(wildcard $(LIBTIO)/include/tio/*.h)
LIB_FILE = $(LIBTIO)/lib/libtio.a
LIB_DEPS = $(wildcard $(LIBTIO)/include/tio/*.h) \
$(wildcard $(LIBTIO)/src/*.c) $(wildcard $(LIBTIO)/src/*.h)
$(LIB_FILE): $(LIB_DEPS)
@$(MAKE) -C $(LIBTIO)
obj bin:
@mkdir -p $@
obj/tio-proxy.o: src/tio-proxy.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) $(WEBSOCK_PP) -c $< -o $@
obj/tio-udp-proxy.o: src/tio-udp-proxy.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
obj/tio-rpc.o: src/tio-rpc.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
obj/tio-firmware-upgrade.o: src/tio-firmware-upgrade.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
obj/tio-sensor-tree.o: src/tio-sensor-tree.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
obj/tio-dataview.o: src/tio-dataview.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
obj/tio-logparse.o: src/tio-logparse.cpp $(LIB_HEADERS) | obj
@$(CXX) $(CXXFLAGS) -c $< -o $@
obj/tio-record.o: src/tio-record.c $(LIB_HEADERS) | obj
@$(CC) $(CCFLAGS) -c $< -o $@
bin/tio-proxy: obj/tio-proxy.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS) $(WEBSOCK_LINK)
bin/tio-udp-proxy: obj/tio-udp-proxy.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-rpc: obj/tio-rpc.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-firmware-upgrade: obj/tio-firmware-upgrade.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-sensor-tree: obj/tio-sensor-tree.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-dataview: obj/tio-dataview.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-logparse: obj/tio-logparse.o $(LIB_FILE) | bin
@$(CXX) -o $@ $< $(LDFLAGS)
bin/tio-record: obj/tio-record.o $(LIB_FILE) | bin
@$(CC) -o $@ $< $(LDFLAGS)
bin/tio-autoproxy: src/tio-autoproxy | bin
@install $< $@
bin/tio-autoproxy-noftdi: src/tio-autoproxy | bin
@install $< $@
all: bin/tio-proxy \
bin/tio-autoproxy \
bin/tio-autoproxy-noftdi \
bin/tio-rpc \
bin/tio-firmware-upgrade \
bin/tio-udp-proxy \
bin/tio-sensor-tree \
bin/tio-dataview \
bin/tio-logparse \
bin/tio-record
clean:
@$(MAKE) -C $(LIBTIO) clean
@rm -rf obj bin
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
install: all
@mkdir -p $(DESTDIR)$(BINDIR)
@cp -p bin/tio-proxy $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-autoproxy $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-autoproxy-noftdi $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-rpc $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-firmware-upgrade $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-record $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-logparse $(DESTDIR)$(BINDIR)/
@cp -p bin/tio-dataview $(DESTDIR)$(BINDIR)/
# @cp -p bin/tio-udp-proxy $(DESTDIR)$(BINDIR)/
# @cp -p bin/tio-sensor-tree $(DESTDIR)$(BINDIR)/