Procházet zdrojové kódy

New Windows build instructions using VS.

Ambroz Bizjak před 7 roky
rodič
revize
842241e119
3 změnil soubory, kde provedl 124 přidání a 86 odebrání
  1. 103 0
      BUILD-WINDOWS-VisualStudio.md
  2. 0 79
      BUILD-WINDOWS-old.txt
  3. 21 7
      README.md

+ 103 - 0
BUILD-WINDOWS-VisualStudio.md

@@ -0,0 +1,103 @@
+# Windows build using Visual Studio
+
+This document describes how to build on Windows using Visual Studio. Note that only
+32-bit build has been tested and is described here.
+
+## Prerequisites
+
+### Visual Studio
+
+You need Visual Studio 2017.
+
+### CMake
+
+You need CMake, it is best to get the latest version.
+
+### OpenSSL
+
+You don't need this if you only need tun2socks or udpgw (but only for the VPN software).
+
+Install ActivePerl if not already.
+
+Download and extract the OpenSSL source code.
+
+Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
+Studio 2017) and enter the OpenSSL source code directory. In this terminal, run the
+following commands:
+
+```
+perl Configure VC-WIN32 no-asm --prefix=%cd%\install-dir
+ms\do_ms
+nmake -f ms\ntdll.mak install
+```
+
+### NSS
+
+You don't need this if you only need tun2socks or udpgw (but only for the VPN software).
+
+Install MozillaBuild (https://wiki.mozilla.org/MozillaBuild).
+
+Download and extract the NSS source code that includes NSPR
+(`nss-VERSION-with-nspr-VERSION.tar.gz`).
+
+Copy the file `C:\mozilla-build\start-shell.bat` to
+`C:\mozilla-build\start-shell-fixed.bat`, and in the latter file REMOVE the following
+lines near the beginning:
+
+```
+SET INCLUDE=
+SET LIB=
+IF NOT DEFINED MOZ_NO_RESET_PATH (
+  SET PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
+)
+```
+
+Open a Visual Studio x86 native tools command prompt. In this terminal, first run the
+following command to enter the mozilla-build bash shell:
+
+```
+C:\mozilla-build\start-shell-fixed.bat
+```
+
+Enter the NSS source code directory and run the following commands:
+
+```
+make -C nss nss_build_all OS_TARGET=WINNT BUILD_OPT=1
+cp -r dist/private/. dist/public/. dist/WINNT*.OBJ/include/
+```
+
+## Building BadVPN
+
+Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
+Studio 2017) and enter the BadVPN source code directory.
+
+If you needed to build OpenSSL and NSS, then specify the paths to the builds of these
+libraries by setting the `CMAKE_PREFIX_PATH` environment variable as shown below;
+replace `<openssl-source-dir>` and `<nss-source-dir>` with the correct paths. For NSS,
+check if the `.OBJ` directory name is correct, if not then adjust that as well.
+
+```
+set CMAKE_PREFIX_PATH=<openssl-source-dir>\install-dir;<nss-source-dir>\dist\WINNT6.2_OPT.OBJ
+```
+
+Run the commands shown below. If you only need tun2socks and udpgw then also add
+the following parameters to first `cmake` command:
+`-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1`.
+
+```
+mkdir build
+cd build
+cmake .. -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=%cd%\..\install-dir
+cmake --build . --config Release --target install
+```
+
+If you did need OpenSSL and NSS, then copy the needed DLL so that the programs will
+be able to find them. You can use the following commands to do this (while still in
+the `build` directory):
+
+```
+copy <openssl-source-dir>\install-dir\bin\libeay32.dll ..\install-dir\bin\
+copy <nss-source-dir>\dist\WINNT6.2_OPT.OBJ\lib\*.dll ..\install-dir\bin\
+```
+
+The build is now complete and is located in `<badvpn-source-dir>\install-dir`.

+ 0 - 79
BUILD-WINDOWS-old.txt

@@ -1,79 +0,0 @@
-NOTE: These instructions are out of date!
-The supported method for building Windows binaries is described in BUILD-WINDOWS.txt.
-
-1 Requirements
-
-1.1 Operating system
-
-Linux:
-- Linux kernel 2.6. Kernel 2.4 will work, but performance will suffer.
-- tested on x86, x86_64 and ARM architectures. Not tested on any big-endian architecture.
-
-Windows:
-- Windows XP or newer; tested on Windows XP and Windows 7
-
-FreeBSD:
-- Not regularly tested.
-
-Other systems are not supported.
-
-1.2 Compilers
-
-Linux:
-  - gcc
-  - clang, except >=3.0 (clang bug http://llvm.org/bugs/show_bug.cgi?id=11535)
-
-Windows:
-  - gcc from the mingw-w64 project for 32-bit targets
-
-C language features used:
-  - Standard (all part of C99):
-    - designated initializers
-    - stdint.h, inttypes.h, stddef.h
-    - intermingled declarations and code
-    - for loop initial declaration
-    - one-line "//" comments
-  - Extensions:
-    - packed structure attribute (to pack a structure and allow unaligned access)
-
-1.3 CMake
-
-The build system uses CMake.
-
-1.4 OpenSSL
-
-Libcrypto (part of OpenSSL) is used for block ciphers, hash functions and random data generation.
-
-1.5 Network Security Services (NSS)
-
-The NSS library from Mozilla is used for TLS support. NSS command-line tools are also needed
-for setting up certificates.
-
-1.6 TAP-Win32 (Windows only) (runtime only)
-
-The TAP-Win32 driver, part of OpenVPN.
-
-2 Compilation
-
-2.1 Compiling on Linux
-
-$ tar xf badvpn-<version>.tar.bz2
-$ mkdir build
-$ cd build
-$ cmake ../badvpn-<version> -DCMAKE_INSTALL_PREFIX=/usr/local
-$ make
-If you want to install it, run as root:
-# make install
-
-If you only want NCD or tun2socks and not the VPN system, you can avoid the NSS dependency by passing
-the following to the cmake command:
--DBUILD_NCD=1 -DBUILD_TUN2SOCKS=1 -DBUILD_NOTHING_BY_DEFAULT=1
-
-2.2 Compiling for Windows
-
-See the file INSTALL-WINDOWS for detailed instructions.
-
-3 Usage
-
-The primary documentation is on the BadVPN homepage, http://code.google.com/p/badvpn/ .
-Additionally, some man pages are installed (badvpn(7), badvpn-server(8), badvpn-client(8)).

+ 21 - 7
README.md

@@ -36,17 +36,31 @@ These connections are used for transferring network data (Ethernet frames), and
   - Local peers inside a NAT can communicate directly
   - Local peers inside a NAT can communicate directly
   - Relaying as a fallback (needs configuration)
   - Relaying as a fallback (needs configuration)
 
 
-## Documentation
-
-- [NCD] - Introduction to the NCD language.
-- [badvpn] - General description of BadVPN and its features.
-- [Examples] - Quick guide to setting up a working VPN.
-- [badvpn_server], [badvpn_client] - Documentation of individual programs.
-
 ## Requirements
 ## Requirements
 
 
 NCD only works on Linux. Tun2socks works on Linux and Windows. The P2P VPN works on Linux, Windows and FreeBSD (not tested often).
 NCD only works on Linux. Tun2socks works on Linux and Windows. The P2P VPN works on Linux, Windows and FreeBSD (not tested often).
 
 
+## Installation
+
+The build system is based on CMake. On Linux, the following commands can be used to
+build:
+
+```
+cd <badvpn-source-dir>
+mkdir build
+cd build
+cmake .. -DCMAKE_INSTALL_PREFIX=<install-dir>
+make install
+```
+
+If you only need tun2socks or udpgw, then add the following arguments to the `cmake`
+command: `-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1`.
+Otherwise (if you want the VPN software), you will first need to install the OpenSSL
+and NSS libraries and make sure that CMake can find them.
+
+Windows builds are not provided. You can build from source code using Visual Studio by
+following the instructions in the file `BUILD-WINDOWS-VisualStudio.md`.
+
 ## License
 ## License
 
 
 The BSD 3-clause license as shown below applies to most of the code.
 The BSD 3-clause license as shown below applies to most of the code.