-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·56 lines (44 loc) · 1.46 KB
/
compile.sh
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
#!/bin/bash
set -xe
[ -z "$CXX" ] && CXX=g++
[ -z "$AR" ] && AR=ar
HOST=$(uname -s)
[ -z "$TARGET" ] && TARGET=$(uname -s)
if [[ "$TARGET" == *NT* ]]; then
if [ "$HOST" != "$TARGET" ]; then
HOSTPREFIX=i686-w64-mingw32
fi
INCPATHS="-Iwin32/include -Lwin32/lib"
CXXFLAGS="-DCURL_STATICLIB -fno-pic"
LDFLAGS="-lws2_32 -lwldap32 -static-libgcc -static-libstdc++"
EXESUFFIX=".exe"
DLLSUFFIX=".dll"
elif [ "$TARGET" == "Darwin" ]; then
INCPATHS=""
CXXFLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.7 -stdlib=libc++"
LDFLAGS=" -arch i386 -arch x86_64 -mmacosx-version-min=10.7 -stdlib=libc++"
EXESUFFIX=""
DLLSUFFIX=".dylib"
else
EXESUFFIX=""
DLLSUFFIX=".so"
fi
CXXFLAGS+=" -Wall -Wextra -Wno-unused-function -Wformat -Wformat-security"
if [ -n "$DEBUG" ]; then
CXXFLAGS+=" -g"
else
CXXFLAGS+=" -O2"
if [ "$TARGET" != "Darwin" ]; then
LDFLAGS+=" -Wl,-s"
fi
fi
if [ -n "$HOSTPREFIX" ]; then
CXX="$HOSTPREFIX-$CXX"
AR="$HOSTPREFIX-$AR"
fi
rm -f *.o *.a *.so 3wg3-watch{,.exe} libzte_mf283plus_watch$SUFFIX{.a,.dll,.dylib,.dll}
$CXX zte_mf283plus_watch.cpp -fpic $CXXFLAGS $INCPATHS -std=c++11 -c
$CXX main.cpp $CXXFLAGS $INCPATHS -std=c++11 -c
$AR rcs libzte_mf283plus_watch$SUFFIX.a zte_mf283plus_watch.o
$CXX zte_mf283plus_watch.o -shared -pthread $CXXFLAGS $INCPATHS -lcurl $LDFLAGS -o libzte_mf283plus_watch$SUFFIX$DLLSUFFIX
$CXX main.o libzte_mf283plus_watch$SUFFIX.a -pthread $INCPATHS -lcurl $LDFLAGS -o 3wg3-watch$SUFFIX$EXESUFFIX