summaryrefslogtreecommitdiffstats
path: root/install-win32/prebuild
blob: a8a160e3a2373b386be0d867aa714bad533bb381 (plain)
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
# Given a standard OpenVPN tarball tree,
# build a Windows tree which is NSIS-ready.
#
# Requires:
#  MinGW
#  MSYS GNU shell environment
#  See other requirements below

# Top level directory.
H=/c/src

# Output NSIS-ready tree here (will be deleted
# if already exists).
OUT=$H/21

# Source distribution is here.  Can be the top
# level directory of exploded tarball.
IN=/y/openvpn/21/openvpn

# Already built OpenSSL tree.
SSL=$H/openssl-0.9.7i

# Already built LZO tree.
LZO=$H/lzo-2.02

# Already built dmalloc tree.
# Optional, but leave defined even if you are not using
# dmalloc.
DMALLOC=$H/dmalloc-5.4.2

# TAP binaries should be here: tap0801.sys and tapinstall.exe
# These must be built with MS DDK.
TAPBIN=$H/tapbin-21

# u2d.c should exist here.
SCRIPTS=$IN/install-win32

# Put service.[ch] here from MS Platform SDK.
SVC_TEMPLATE=$H/svc-template

# Misc files/directories which should be copied to OUT (optional)
MISC=$H/add

# Temporary directory
TMP=/tmp

# End of user-defined parameters.

U2D=$TMP/u2d

echo BUILD u2d
gcc -O2 $SCRIPTS/u2d.c -o $U2D

echo BUILD output dir from source
rm -rf $OUT
mkdir $OUT
mkdir $OUT/pkcs11-headers

cp $IN/*.[ch] $OUT
rm -f $OUT/config.h
cp $IN/pkcs11-headers/*.h $OUT/pkcs11-headers

if [ $MISC ]; then
  cp $MISC/*.* $OUT
fi

echo BUILD makefile

sed "s#^OPENSSL = .*\$#OPENSSL = $SSL#" <$IN/makefile.w32 | \
sed "s#^LZO = .*\$#LZO = $LZO#" | \
sed "s#^DMALLOC = .*\$#DMALLOC = $DMALLOC#" >$OUT/Makefile

echo BUILD bin

mkdir $OUT/bin
for f in libeay32.dll libssl32.dll openssl.exe ; do
  cp $SSL/$f $OUT/bin
  strip $OUT/bin/$f
done

echo BUILD install-win32

mkdir $OUT/install-win32

cp $IN/install-win32/openvpn.nsi $OUT/install-win32
cp $IN/install-win32/setpath.nsi $OUT/install-win32
cp $IN/images/install-whirl.bmp $OUT/install-win32
cp $IN/images/openvpn.ico $OUT/install-win32
cp $IN/INSTALL-win32.txt $OUT/install-win32
cat $IN/COPYING $IN/COPYRIGHT.GPL | $U2D >$OUT/install-win32/license.txt

$U2D <$IN/sample-config-files/client.conf >$OUT/install-win32/client.ovpn
$U2D <$IN/sample-config-files/server.conf >$OUT/install-win32/server.ovpn
cp $IN/install-win32/sample.ovpn $OUT/install-win32
$U2D <$IN/easy-rsa/1.0/openssl.cnf >$OUT/install-win32/openssl.cnf.sample

echo BUILD tap-win32

mkdir $OUT/tap-win32
cp $IN/tap-win32/*.[ch] $OUT/tap-win32
cp $IN/tap-win32/*.rc $OUT/tap-win32
cp $IN/tap-win32/MAKEFILE $OUT/tap-win32
cp $IN/tap-win32/SOURCES $OUT/tap-win32

mkdir $OUT/tap-win32/i386
cp $IN/tap-win32/i386/OemWin2k.inf $OUT/tap-win32/i386
cp $IN/tap-win32/i386/tap.cat $OUT/tap-win32/i386

cp $TAPBIN/tap0801.sys $OUT/tap-win32/i386

mkdir $OUT/bin/ti3790
cp $TAPBIN/tapinstall.exe $OUT/bin/ti3790

echo BUILD service-win32

mkdir $OUT/service-win32
cp $IN/service-win32/Makefile $OUT/service-win32
cp $IN/service-win32/mkpatch $OUT/service-win32
cp $IN/service-win32/openvpnserv.c $OUT/service-win32
cp $IN/service-win32/service.patch $OUT/service-win32

cp $SVC_TEMPLATE/service.[ch] $OUT/service-win32
cp $OUT/service-win32/service.h $OUT/service-win32/service.h.orig
cp $OUT/service-win32/service.c $OUT/service-win32/service.c.orig

pushd $OUT/service-win32
patch <service.patch
popd

echo BUILD easy-rsa
cp -a $IN/easy-rsa $OUT

echo BUILD sample-keys
cp -a $IN/sample-keys $OUT

echo COMPILE OpenVPN
pushd $OUT
make
strip openvpn.exe
popd

echo COMPILE OpenVPN Service
pushd $OUT/service-win32
make clean
make
strip openvpnserv.exe
popd