forked from eclipse-paho/paho.mqtt.embedded-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·220 lines (143 loc) · 5.59 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#*******************************************************************************
# Copyright (c) 2009, 2014 IBM Corp.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v1.0 which accompany this distribution.
#
# The Eclipse Public License is available at
# http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# Contributors:
# Xiang Rong - 442039 Add makefile to Embedded C client
#*******************************************************************************/
# Note: on OS X you should install XCode and the associated command-line tools
SHELL = /bin/sh
.PHONY: clean, mkdir, install, uninstall, html
# assume this is normally run in the main Paho directory
ifndef srcdir
srcdir = MQTTPacket/src
endif
ifndef blddir
blddir = build/output
endif
ifndef prefix
prefix = /usr/local
endif
ifndef exec_prefix
exec_prefix = ${prefix}
endif
bindir = $(exec_prefix)/bin
includedir = $(prefix)/include
libdir = $(exec_prefix)/lib
SOURCE_FILES_C = $(srcdir)/*.c
HEADERS = $(srcdir)/*.h
SAMPLE_FILES_C = pub0sub1 qos0pub
SYNC_SAMPLES = ${addprefix ${blddir}/samples/,${SAMPLE_FILES_C}}
TEST_FILES_C = test1
SYNC_TESTS = ${addprefix ${blddir}/test/,${TEST_FILES_C}}
# The names of libraries to be built
MQTT_EMBED_LIB_C = paho-embed-mqtt3c
# determine current platform
ifeq ($(OS),Windows_NT)
OSTYPE = $(OS)
else
OSTYPE = $(shell uname -s)
MACHINETYPE = $(shell uname -m)
endif
ifeq ($(OSTYPE),Linux)
CC ?= gcc
ifndef INSTALL
INSTALL = install
endif
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
MAJOR_VERSION = 1
MINOR_VERSION = 0
VERSION = ${MAJOR_VERSION}.${MINOR_VERSION}
EMBED_MQTTLIB_C_TARGET = ${blddir}/lib${MQTT_EMBED_LIB_C}.so.${VERSION}
CCFLAGS_SO = -g -fPIC -Os -Wall -fvisibility=hidden -DLINUX_SO
FLAGS_EXE = -I ${srcdir} -L ${blddir}
LDFLAGS_C = -shared -Wl,-soname,lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION}
all: build
build: | mkdir ${EMBED_MQTTLIB_C_TARGET} ${SYNC_SAMPLES} ${SYNC_TESTS}
clean:
rm -rf ${blddir}/*
mkdir:
-mkdir -p ${blddir}/samples
-mkdir -p ${blddir}/test
${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c
${CC} -g -o ${blddir}/test/${basename ${+F}} $< -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE}
${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/../samples/%.c ${srcdir}/../samples/transport.o
${CC} -o $@ $^ -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE}
${EMBED_MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C}
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C}
-ln -s lib$(MQTT_EMBED_LIB_C).so.${VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION}
-ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so
strip_options:
$(eval INSTALL_OPTS := -s)
install-strip: build strip_options install
install: build
$(INSTALL_DATA) ${INSTALL_OPTS} ${EMBED_MQTTLIB_C_TARGET} $(DESTDIR)${libdir}
/sbin/ldconfig $(DESTDIR)${libdir}
ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so
uninstall:
rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so.${VERSION}
/sbin/ldconfig $(DESTDIR)${libdir}
rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so
html:
ARDUINO_LIB_FILES = MQTTClient/src/*.h MQTTClient/src/arduino/*.h $(srcdir)/*
ARDUINO_SAMPLES = MQTTClient/samples/arduino/*
LEGAL_FILES = edl-v10 epl-v10 notice.html about.html CONTRIBUTING.md README.md library.properties
arduino: mkdir
-mkdir -p ${blddir}/arduino/MQTTClient/examples
-mkdir -p ${blddir}/arduino/MQTTClient/src
cp $(ARDUINO_LIB_FILES) ${blddir}/arduino/MQTTClient/src
cp $(LEGAL_FILES) ${blddir}/arduino/MQTTClient
cp -R $(ARDUINO_SAMPLES) ${blddir}/arduino/MQTTClient/examples
cd ${blddir}/arduino && zip -r arduino MQTTClient
endif
ifeq ($(OSTYPE),Darwin)
CC ?= gcc
ifndef INSTALL
INSTALL = install
endif
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
MAJOR_VERSION = 1
MINOR_VERSION = 0
VERSION = ${MAJOR_VERSION}.${MINOR_VERSION}
EMBED_MQTTLIB_C_TARGET = ${blddir}/lib${MQTT_EMBED_LIB_C}.so.${VERSION}
CCFLAGS_SO = -g -fPIC -Os -Wall -fvisibility=hidden -Wno-deprecated-declarations -DUSE_NAMED_SEMAPHORES
FLAGS_EXE = -I ${srcdir} -L ${blddir}
LDFLAGS_C = -shared -Wl,-install_name,lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION}
all: build
build: | mkdir ${EMBED_MQTTLIB_C_TARGET} ${SYNC_SAMPLES} ${SYNC_TESTS}
clean:
rm -rf ${blddir}/*
mkdir:
-mkdir -p ${blddir}/samples
-mkdir -p ${blddir}/test
${SYNC_TESTS}: ${blddir}/test/%: ${srcdir}/../test/%.c
${CC} -g -o ${blddir}/test/${basename ${+F}} $< -l${MQTT_EMBED_LIB_C} ${FLAGS_EXE}
${SYNC_SAMPLES}: ${blddir}/samples/%: ${srcdir}/../samples/%.c
${CC} -o ${blddir}/samples/${basename ${+F}} $< ${FLAGS_EXE} -l${MQTT_EMBED_LIB_C}
${EMBED_MQTTLIB_C_TARGET}: ${SOURCE_FILES_C} ${HEADERS_C}
${CC} ${CCFLAGS_SO} -o $@ ${SOURCE_FILES_C} ${LDFLAGS_C}
-ln -s lib$(MQTT_EMBED_LIB_C).so.${VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION}
-ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} ${blddir}/lib$(MQTT_EMBED_LIB_C).so
strip_options:
$(eval INSTALL_OPTS := -s)
install-strip: build strip_options install
install: build
$(INSTALL_DATA) ${INSTALL_OPTS} ${EMBED_MQTTLIB_C_TARGET} $(DESTDIR)${libdir}
/sbin/ldconfig $(DESTDIR)${libdir}
ln -s lib$(MQTT_EMBED_LIB_C).so.${MAJOR_VERSION} $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so
uninstall:
rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so.${VERSION}
/sbin/ldconfig $(DESTDIR)${libdir}
rm $(DESTDIR)${libdir}/lib$(MQTT_EMBED_LIB_C).so
html:
endif