Skip to content

Commit 9e88969

Browse files
committed
fix : update make libmqttclient script
1 parent e4376b9 commit 9e88969

File tree

1 file changed

+59
-45
lines changed

1 file changed

+59
-45
lines changed

make-libmqttclient.sh

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
#!/bin/bash
22

3-
mkdir -p libmqttclient libmqttclient/include libmqttclient/lib
3+
current_pwd=$(
4+
cd "$(dirname "$0")"
5+
pwd
6+
)
47

5-
cd libmqttclient
8+
mkdir -p $current_pwd/libmqttclient $current_pwd/libmqttclient/include $current_pwd/libmqttclient/lib
9+
10+
cd $current_pwd/libmqttclient
611

712
if [ ! -f "Makefile" ]; then
813

9-
cat <<-EOF > Makefile
14+
cat <<-EOF >Makefile
1015
CC=\$(CROSS_COMPILE)gcc
1116
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 \\
2227
)
2328
2429
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
3540
3641
OBJS = \$(patsubst %.c, %.o, \$(SRC))
3742
@@ -40,39 +45,48 @@ TARGET = libmqttclient.so
4045
4146
EOF
4247

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
4550

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
4853

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
5156

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
5459

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
5762

58-
echo -e "\n.PHONY:clean" >> Makefile
63+
echo -e "\n.PHONY:clean" >>Makefile
5964

6065
fi
6166

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/.
7185

7286
if [ " $1" == " " ]; then
87+
cd $current_pwd/libmqttclient
7388
make
74-
make install
75-
mv libmqttclient.so lib/.
89+
mv libmqttclient.so $current_pwd/libmqttclient/lib/.
7690
make clean
7791

7892
elif [ "$1" == "remove" ]; then

0 commit comments

Comments
 (0)