BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/usr/bin/env bash
2 #
3 # Compiles tun2socks for Linux.
4 # Intended as a convenience if you don't want to deal with CMake.
5  
6 # Input environment vars:
7 # SRCDIR - BadVPN source code
8 # OUTDIR - tun2socks binary output file directory
9 # CC - compiler
10 # CFLAGS - compiler compile flags
11 # LDFLAGS - compiler link flags
12 # ENDIAN - "little" or "big"
13 # KERNEL - "2.6" or "2.4", default "2.6"
14 #
15 # Puts object files and the executable in the working directory.
16 #
17  
18 if [[ -z $SRCDIR ]] || [[ ! -e $SRCDIR/CMakeLists.txt ]]; then
19 echo "SRCDIR is wrong"
20 exit 1
21 fi
22  
23 if [[ ! -z $OUTDIR ]] && [[ ! -d $OUTDIR ]]; then
24 echo "OUTDIR is wrong"
25 exit 1
26 fi
27  
28 if ! "${CC}" --version &>/dev/null; then
29 echo "CC is wrong"
30 exit 1
31 fi
32  
33 if [[ $ENDIAN != "little" ]] && [[ $ENDIAN != "big" ]]; then
34 echo "ENDIAN is wrong"
35 exit 1
36 fi
37  
38 if [[ -z $KERNEL ]]; then
39 KERNEL="2.6"
40 elif [[ $KERNEL != "2.6" ]] && [[ $KERNEL != "2.4" ]]; then
41 echo "KERNEL is wrong"
42 exit 1
43 fi
44  
45 CFLAGS="${CFLAGS} -std=gnu99"
46 INCLUDES=( "-I${SRCDIR}" "-I${SRCDIR}/lwip/src/include/ipv4" "-I${SRCDIR}/lwip/src/include/ipv6" "-I${SRCDIR}/lwip/src/include" "-I${SRCDIR}/lwip/custom" )
47 DEFS=( -DBADVPN_THREAD_SAFE=0 -DBADVPN_LINUX -DBADVPN_BREACTOR_BADVPN -D_GNU_SOURCE )
48  
49 [[ $KERNEL = "2.4" ]] && DEFS=( "${DEFS[@]}" -DBADVPN_USE_SELFPIPE -DBADVPN_USE_POLL ) || DEFS=( "${DEFS[@]}" -DBADVPN_USE_SIGNALFD -DBADVPN_USE_EPOLL )
50  
51 [[ $ENDIAN = "little" ]] && DEFS=( "${DEFS[@]}" -DBADVPN_LITTLE_ENDIAN ) || DEFS=( "${DEFS[@]}" -DBADVPN_BIG_ENDIAN )
52  
53 [[ -z $OUTDIR ]] && OUTDIR="."
54  
55 SOURCES="
56 base/BLog_syslog.c
57 system/BReactor_badvpn.c
58 system/BSignal.c
59 system/BConnection_unix.c
60 system/BConnection_common.c
61 system/BTime.c
62 system/BUnixSignal.c
63 system/BNetwork.c
64 system/BDatagram_common.c
65 system/BDatagram_unix.c
66 flow/StreamRecvInterface.c
67 flow/PacketRecvInterface.c
68 flow/PacketPassInterface.c
69 flow/StreamPassInterface.c
70 flow/SinglePacketBuffer.c
71 flow/BufferWriter.c
72 flow/PacketBuffer.c
73 flow/PacketStreamSender.c
74 flow/PacketPassConnector.c
75 flow/PacketProtoFlow.c
76 flow/PacketPassFairQueue.c
77 flow/PacketProtoEncoder.c
78 flow/PacketProtoDecoder.c
79 socksclient/BSocksClient.c
80 tuntap/BTap.c
81 lwip/src/core/udp.c
82 lwip/src/core/memp.c
83 lwip/src/core/init.c
84 lwip/src/core/pbuf.c
85 lwip/src/core/tcp.c
86 lwip/src/core/tcp_out.c
87 lwip/src/core/sys.c
88 lwip/src/core/netif.c
89 lwip/src/core/def.c
90 lwip/src/core/mem.c
91 lwip/src/core/tcp_in.c
92 lwip/src/core/stats.c
93 lwip/src/core/ip.c
94 lwip/src/core/timeouts.c
95 lwip/src/core/inet_chksum.c
96 lwip/src/core/ipv4/icmp.c
97 lwip/src/core/ipv4/ip4.c
98 lwip/src/core/ipv4/ip4_addr.c
99 lwip/src/core/ipv4/ip4_frag.c
100 lwip/src/core/ipv6/ip6.c
101 lwip/src/core/ipv6/nd6.c
102 lwip/src/core/ipv6/icmp6.c
103 lwip/src/core/ipv6/ip6_addr.c
104 lwip/src/core/ipv6/ip6_frag.c
105 lwip/custom/sys.c
106 tun2socks/tun2socks.c
107 base/DebugObject.c
108 base/BLog.c
109 base/BPending.c
110 flowextra/PacketPassInactivityMonitor.c
111 tun2socks/SocksUdpGwClient.c
112 udpgw_client/UdpGwClient.c
113 socks_udp_client/SocksUdpClient.c
114 "
115  
116 set -e
117 set -x
118  
119 OBJS=()
120 for f in $SOURCES; do
121 obj=${f//\//_}.o
122 "${CC}" -c ${CFLAGS} "${INCLUDES[@]}" "${DEFS[@]}" "${SRCDIR}/${f}" -o "${obj}"
123 OBJS=( "${OBJS[@]}" "${obj}" )
124 done
125  
126 "${CC}" ${LDFLAGS} "${OBJS[@]}" -o $OUTDIR/tun2socks -lrt -lpthread