aboutsummaryrefslogtreecommitdiff
path: root/install-win32/makeopenvpn
blob: ced2a5464ee920728a70383754a0a7932a88cc60 (plain) (blame)
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
#!/bin/sh

H=`pwd`

case "`uname -o 2>/dev/null`" in
  *inux)

    # cross-compiling, make dude's life easier
    XAUTOCONF="--host=i586-mingw32msvc --build=i386-linux $XAUTOCONF"
    export CC=i586-mingw32msvc-gcc
    export CXXCPP=i586-mingw32msvc-cpp
    export CXX=i586-mingw32msvc-g++
    # this requires the human to setup these environ vars:
    # OPENSSL_DIR LZO_DIR PKCS11_HELPER_DIR
    OPENSSL_INC_DIR=$OPENSSL_DIR/include
    OPENSSL_LIB_DIR=$OPENSSL_DIR/out
    LZO_INC_DIR=$LZO_DIR/include
    LZO_LIB_DIR=$LZO_DIR/src/.libs
    PKCS11_INC_DIR=$PKCS11_HELPER_DIR/include/pkcs11-helper-1.0/
    PKCS11_LIB_DIR=$PKCS11_HELPER_DIR/lib/.libs/
    ;;
  *)
    # get version.nsi definitions
    . autodefs/defs.sh
    XAUTOCONF=""
    # default configuration creates relative-path environ vars:
    OPENSSL_INC_DIR=$H/$OPENSSL_DIR/include
    OPENSSL_LIB_DIR=$H/$OPENSSL_DIR/out
    LZO_INC_DIR=$H/$LZO_DIR/include
    LZO_LIB_DIR=$H/$LZO_DIR
    PKCS11_INC_DIR=$H/$PKCS11_HELPER_DIR/usr/local/include
    PKCS11_LIB_DIR=$H/$PKCS11_HELPER_DIR/usr/local/lib
    ;;
esac
if $CC --version &>/dev/null && [ -d "$OPENSSL_DIR" ] && [ -d "$LZO_DIR" ] && [ -d "$PKCS11_HELPER_DIR" ]; then
    # build OpenVPN binary

    if ! [ -f Makefile ]; then
	autoreconf -i -v \
	&& ./configure $XAUTOCONF \
	    --enable-strict \
	    --prefix=$H/windest \
	    MAN2HTML=true \
	    --with-ssl-headers=$OPENSSL_INC_DIR \
	    --with-ssl-lib=$OPENSSL_LIB_DIR \
	    --with-lzo-headers=$LZO_INC_DIR \
	    --with-lzo-lib=$LZO_LIB_DIR \
	    --with-pkcs11-helper-headers=$PKCS11_INC_DIR \
	    --with-pkcs11-helper-lib=$PKCS11_LIB_DIR \
	    || exit 1
    fi

    make -j $MAKE_JOBS && make install

    if [ -n "$GENOOUT" ];then
    # copy OpenVPN and service executables to GENOUT/bin
      mkdir -p $GENOUT/bin &>/dev/null
      cp windest/sbin/openvpn.exe $GENOUT/bin
      cp windest/sbin/openvpnserv.exe $GENOUT/bin
      if [ -z "$NO_STRIP" ]; then
  	strip $GENOUT/bin/openvpn.exe
  	strip $GENOUT/bin/openvpnserv.exe
      fi
    fi
else
    echo DID NOT BUILD openvpn.exe and openvpnserv.exe because one or more of gcc, OPENSSL_DIR, LZO_DIR, or PKCS11_HELPER_DIR directories were missing
fi