1
1
#! /bin/bash
2
2
3
- mkdir -p libmqttclient libmqttclient/include libmqttclient/lib
3
+ current_pwd=$(
4
+ cd " $( dirname " $0 " ) "
5
+ pwd
6
+ )
4
7
5
- cd libmqttclient
8
+ mkdir -p $current_pwd /libmqttclient $current_pwd /libmqttclient/include $current_pwd /libmqttclient/lib
9
+
10
+ cd $current_pwd /libmqttclient
6
11
7
12
if [ ! -f " Makefile" ]; then
8
13
9
- cat << -EOF > Makefile
14
+ cat << -EOF >Makefile
10
15
CC=\$ (CROSS_COMPILE)gcc
11
16
12
- SRC = \$ (wildcard .. /*.c \\
13
- .. /common/*.c \\
14
- .. /common/log/*.c \\
15
- .. /common/log/arch/linux/*.c \\
16
- .. /network/mbedtls/library/*.c \\
17
- .. /network/mbedtls/wrapper/*.c \\
18
- .. /mqtt/*.c \\
19
- .. /mqttclient/*.c \\
20
- .. /network/*.c \\
21
- .. /platform/linux/*.c \\
17
+ SRC = \$ (wildcard $current_pwd /*.c \\
18
+ $current_pwd /common/*.c \\
19
+ $current_pwd /common/log/*.c \\
20
+ $current_pwd /common/log/arch/linux/*.c \\
21
+ $current_pwd /network/mbedtls/library/*.c \\
22
+ $current_pwd /network/mbedtls/wrapper/*.c \\
23
+ $current_pwd /mqtt/*.c \\
24
+ $current_pwd /mqttclient/*.c \\
25
+ $current_pwd /network/*.c \\
26
+ $current_pwd /platform/linux/*.c \\
22
27
)
23
28
24
29
INC = -lpthread \\
25
- -I.. /common \\
26
- -I.. /common/log \\
27
- -I.. /network/mbedtls/include \\
28
- -I.. /network/mbedtls/include/mbedtls \\
29
- -I.. /network/mbedtls/wrapper \\
30
- -I.. /mqtt \\
31
- -I.. /mqttclient \\
32
- -I.. /network \\
33
- -I.. /platform/linux \\
34
- -I.. /test
30
+ -I$current_pwd /common \\
31
+ -I$current_pwd /common/log \\
32
+ -I$current_pwd /network/mbedtls/include \\
33
+ -I$current_pwd /network/mbedtls/include/mbedtls \\
34
+ -I$current_pwd /network/mbedtls/wrapper \\
35
+ -I$current_pwd /mqtt \\
36
+ -I$current_pwd /mqttclient \\
37
+ -I$current_pwd /network \\
38
+ -I$current_pwd /platform/linux \\
39
+ -I$current_pwd /test
35
40
36
41
OBJS = \$ (patsubst %.c, %.o, \$ (SRC))
37
42
@@ -40,39 +45,48 @@ TARGET = libmqttclient.so
40
45
41
46
EOF
42
47
43
- echo -e " \n\$ (TARGET):\$ (OBJS)" >> Makefile
44
- echo -e " \t\$ (CC) -shared \$ ^ -o \$ @" >> Makefile
48
+ echo -e " \n\$ (TARGET):\$ (OBJS)" >> Makefile
49
+ echo -e " \t\$ (CC) -shared \$ ^ -o \$ @" >> Makefile
45
50
46
- echo -e " \n%.o:%.c" >> Makefile
47
- echo -e " \t\$ (CC) -c \$ (FLAG) \$ ^ -o \$ @" >> Makefile
51
+ echo -e " \n%.o:%.c" >> Makefile
52
+ echo -e " \t\$ (CC) -c \$ (FLAG) \$ ^ -o \$ @" >> Makefile
48
53
49
- echo -e " \nclean:" >> Makefile
50
- echo -e " \trm -rf \$ (TARGET) \$ (OBJS)" >> Makefile
54
+ echo -e " \nclean:" >> Makefile
55
+ echo -e " \trm -rf \$ (TARGET) \$ (OBJS)" >> Makefile
51
56
52
- echo -e " \ninstall:" >> Makefile
53
- echo -e " \tsudo cp -rdf \$ (TARGET) /usr/lib/." >> Makefile
57
+ echo -e " \ninstall:" >> Makefile
58
+ echo -e " \tsudo cp -rdf \$ (TARGET) /usr/lib/." >> Makefile
54
59
55
- echo -e " \nremove:" >> Makefile
56
- echo -e " \tsudo rm -rdf /usr/lib/\$ (TARGET)" >> Makefile
60
+ echo -e " \nremove:" >> Makefile
61
+ echo -e " \tsudo rm -rdf /usr/lib/\$ (TARGET)" >> Makefile
57
62
58
- echo -e " \n.PHONY:clean" >> Makefile
63
+ echo -e " \n.PHONY:clean" >> Makefile
59
64
60
65
fi
61
66
62
- cp -r ../test/* .h include/.
63
- cp -r ../mqtt/* .h include/.
64
- cp -r ../common/* .h include/.
65
- cp -r ../network/* .h include/.
66
- cp -r ../mqttclient/* .h include/.
67
- cp -r ../common/log/* .h include/.
68
- cp -r ../platform/linux/* .h include/.
69
- cp -r ../network/mbedtls/include/mbedtls include/.
70
- cp -r ../network/mbedtls/wrapper/* .h include/.
67
+ mkdir -p $current_pwd /libmqttclient/include/test/.
68
+ mkdir -p $current_pwd /libmqttclient/include/mqtt/.
69
+ mkdir -p $current_pwd /libmqttclient/include/common/.
70
+ mkdir -p $current_pwd /libmqttclient/include/network/.
71
+ mkdir -p $current_pwd /libmqttclient/include/mqttclient/.
72
+ mkdir -p $current_pwd /libmqttclient/include/common/log/.
73
+ mkdir -p $current_pwd /libmqttclient/include/platform/linux/.
74
+ mkdir -p $current_pwd /libmqttclient/include/mbedtls/wrapper/.
75
+
76
+ cp -r $current_pwd /test/* .h $current_pwd /libmqttclient/include/test/.
77
+ cp -r $current_pwd /mqtt/* .h $current_pwd /libmqttclient/include/mqtt/.
78
+ cp -r $current_pwd /common/* .h $current_pwd /libmqttclient/include/common/.
79
+ cp -r $current_pwd /network/* .h $current_pwd /libmqttclient/include/network/.
80
+ cp -r $current_pwd /mqttclient/* .h $current_pwd /libmqttclient/include/mqttclient/.
81
+ cp -r $current_pwd /common/log/* .h $current_pwd /libmqttclient/include/common/log/.
82
+ cp -r $current_pwd /platform/linux/* .h $current_pwd /libmqttclient/include/platform/linux/.
83
+ cp -r $current_pwd /network/mbedtls/$current_pwd /libmqttclient/include/mbedtls $current_pwd /libmqttclient/include/.
84
+ cp -r $current_pwd /network/mbedtls/wrapper/* .h $current_pwd /libmqttclient/include/mbedtls/wrapper/.
71
85
72
86
if [ " $1 " == " " ]; then
87
+ cd $current_pwd /libmqttclient
73
88
make
74
- make install
75
- mv libmqttclient.so lib/.
89
+ mv libmqttclient.so $current_pwd /libmqttclient/lib/.
76
90
make clean
77
91
78
92
elif [ " $1 " == " remove" ]; then
0 commit comments