aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile92
-rw-r--r--Makefile.PlatCfg.mak43
-rw-r--r--README.md12
3 files changed, 80 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index 4bdd5ec..ca2d752 100644
--- a/Makefile
+++ b/Makefile
@@ -11,73 +11,51 @@ WINTUN_VERSION_REV=2019
WINTUN_VERSION_BUILD=0128
WINTUN_VERSION=$(WINTUN_VERSION_MAJ).$(WINTUN_VERSION_MIN).$(WINTUN_VERSION_REV).$(WINTUN_VERSION_BUILD)
-!IFNDEF CFG
-CFG=Release
-!ENDIF
-!IFNDEF PLAT
-PLAT=amd64
-!ENDIF
-!IF "$(PLAT)" == "x86" || "$(PLAT)" == "X86"
-PLAT=x86
-PLAT_MSBUILD=Win32
-PLAT_WIX=x86
-!ELSEIF "$(PLAT)" == "amd64" || "$(PLAT)" == "AMD64"
-PLAT=amd64
-PLAT_MSBUILD=x64
-PLAT_WIX=x64
-!ELSEIF "$(PLAT)" == "arm64" || "$(PLAT)" == "ARM64"
-PLAT=arm64
-PLAT_MSBUILD=ARM64
-PLAT_WIX=arm64 # TODO: Follow WiX ARM64 support.
-!ELSE
-!ERROR Invalid platform "$(PLAT)". PLAT must be "x86", "amd64", or "arm64".
-!ENDIF
DIST_DIR=dist
-OUTPUT_DIR=$(PLAT)\$(CFG)
-MSM_NAME=wintun_$(WINTUN_VERSION)_$(PLAT)
-MSBUILD_FLAGS=/p:Configuration="$(CFG)" /p:Platform="$(PLAT_MSBUILD)" /m /v:minimal /nologo
-WIX_CANDLE_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -arch "$(PLAT_WIX)" -dWINTUN_VERSION="$(WINTUN_VERSION)"
-WIX_LIGHT_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -b output_dir="$(OUTPUT_DIR)" -sw1103
+MSBUILD_FLAGS=/m /v:minimal /nologo
+WIX_CANDLE_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -dWINTUN_VERSION="$(WINTUN_VERSION)"
+WIX_LIGHT_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -sw1103
-build ::
- msbuild.exe "wintun.vcxproj" /t:Build $(MSBUILD_FLAGS)
+build :: \
+ build_x86_Release \
+ build_amd64_Release \
+ build_arm64_Release
-clean ::
- -rd /s /q "$(DIST_DIR)" > NUL 2>&1
- -rd /s /q "$(OUTPUT_DIR)" > NUL 2>&1
+dvl :: "wintun.DVL.XML"
-!IF "$(CFG)" == "Release" && "$(PLAT)" != "arm64"
+msm :: \
+ "$(DIST_DIR)" \
+ "$(DIST_DIR)\wintun_$(WINTUN_VERSION)_x86.msm" \
+ "$(DIST_DIR)\wintun_$(WINTUN_VERSION)_amd64.msm"
-dvl :: "wintun.DVL.XML"
+"sdv\SDV.DVL.xml" "amd64\Release\vc.nativecodeanalysis.all.xml" :
+ msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/check:*" /p:Configuration="Release" /p:Platform="x64" $(MSBUILD_FLAGS)
+
+"wintun.DVL.XML" : "sdv\SDV.DVL.xml" "amd64\Release\vc.nativecodeanalysis.all.xml"
+ msbuild.exe "wintun.vcxproj" /t:dvl /p:Configuration="Release" /p:Platform="x64" $(MSBUILD_FLAGS)
+
+"$(DIST_DIR)" :
+ md $@ > NUL 2>&1
clean ::
-rd /s /q "sdv" > NUL 2>&1
-del /f /q "wintun.DVL.XML" > NUL 2>&1
-del /f /q "smvbuild.log" > NUL 2>&1
-del /f /q "smvstats.txt" > NUL 2>&1
+ -rd /s /q "$(DIST_DIR)" > NUL 2>&1
-"sdv\SDV.DVL.xml" "$(OUTPUT_DIR)\vc.nativecodeanalysis.all.xml" :
- msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/check:*" $(MSBUILD_FLAGS)
-
-"wintun.DVL.XML" : "sdv\SDV.DVL.xml" "$(OUTPUT_DIR)\vc.nativecodeanalysis.all.xml"
- msbuild.exe "wintun.vcxproj" /t:dvl $(MSBUILD_FLAGS)
-
-msm :: "$(DIST_DIR)\$(MSM_NAME).msm"
-
-"$(OUTPUT_DIR)\wintun.wixobj" : "wintun.wxs"
- "$(WIX)bin\candle.exe" $(WIX_CANDLE_FLAGS) -out $@ $**
-
-"$(DIST_DIR)\$(MSM_NAME).msm" : \
- "$(DIST_DIR)" \
- "$(OUTPUT_DIR)\wintun.cer" \
- "$(OUTPUT_DIR)\wintun\wintun.cat" \
- "$(OUTPUT_DIR)\wintun\wintun.inf" \
- "$(OUTPUT_DIR)\wintun\wintun.sys" \
- "$(OUTPUT_DIR)\wintun.wixobj" \
- "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib"
- "$(WIX)bin\light.exe" $(WIX_LIGHT_FLAGS) -out "$(DIST_DIR)\$(MSM_NAME).msm" -spdb "$(OUTPUT_DIR)\wintun.wixobj" "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib"
-
-!ENDIF
+CFG=Release
+PLAT=x86
+!INCLUDE "Makefile.PlatCfg.mak"
+PLAT=amd64
+!INCLUDE "Makefile.PlatCfg.mak"
+PLAT=arm64
+!INCLUDE "Makefile.PlatCfg.mak"
-"$(DIST_DIR)" :
- md $@ > NUL 2>&1
+CFG=Debug
+PLAT=x86
+!INCLUDE "Makefile.PlatCfg.mak"
+PLAT=amd64
+!INCLUDE "Makefile.PlatCfg.mak"
+PLAT=arm64
+!INCLUDE "Makefile.PlatCfg.mak"
diff --git a/Makefile.PlatCfg.mak b/Makefile.PlatCfg.mak
new file mode 100644
index 0000000..1dfd925
--- /dev/null
+++ b/Makefile.PlatCfg.mak
@@ -0,0 +1,43 @@
+#
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved.
+#
+
+!IF "$(PLAT)" == "x86"
+PLAT_MSBUILD=Win32
+PLAT_WIX=x86
+!ELSEIF "$(PLAT)" == "amd64"
+PLAT_MSBUILD=x64
+PLAT_WIX=x64
+!ELSEIF "$(PLAT)" == "arm64"
+PLAT_MSBUILD=ARM64
+PLAT_WIX=arm64 # TODO: Follow WiX ARM64 support.
+!ELSE
+!ERROR Invalid platform "$(PLAT)". PLAT must be "x86", "amd64", or "arm64".
+!ENDIF
+
+OUTPUT_DIR=$(PLAT)\$(CFG)
+
+build_$(PLAT)_$(CFG) ::
+ msbuild.exe "wintun.vcxproj" /t:Build /p:Configuration="$(CFG)" /p:Platform="$(PLAT_MSBUILD)" $(MSBUILD_FLAGS)
+
+clean ::
+ -rd /s /q "$(OUTPUT_DIR)" > NUL 2>&1
+
+!IF "$(CFG)" == "Release"
+
+"$(OUTPUT_DIR)\wintun.wixobj" : "wintun.wxs"
+ "$(WIX)bin\candle.exe" $(WIX_CANDLE_FLAGS) -arch "$(PLAT_WIX)" -out $@ $**
+
+"$(DIST_DIR)\wintun_$(WINTUN_VERSION)_$(PLAT).msm" : \
+ "$(DIST_DIR)" \
+ "$(OUTPUT_DIR)\wintun.cer" \
+ "$(OUTPUT_DIR)\wintun\wintun.cat" \
+ "$(OUTPUT_DIR)\wintun\wintun.inf" \
+ "$(OUTPUT_DIR)\wintun\wintun.sys" \
+ "$(OUTPUT_DIR)\wintun.wixobj" \
+ "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib"
+ "$(WIX)bin\light.exe" $(WIX_LIGHT_FLAGS) -b output_dir="$(OUTPUT_DIR)" -out $@ -spdb "$(OUTPUT_DIR)\wintun.wixobj" "$(WIX)bin\difxapp_$(PLAT_WIX).wixlib"
+
+!ENDIF
diff --git a/README.md b/README.md
index 0185b43..2db1beb 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ If you already have `wintun.vcxproj.user` file, just add the `<PropertyGroup>` s
Open _Developer Command Prompt for VS 2017_ and use the `nmake` command:
```
-nmake [<target>] [CFG=<configuration>] [PLAT=<platform>]
+nmake [<target>]
```
### Targets
@@ -46,7 +46,7 @@ nmake [<target>] [CFG=<configuration>] [PLAT=<platform>]
- `clean`: Deletes all intermediate and output files.
- - `dvl`: Runs Static Driver Verifier, which includes a clean driver build, and creates a Driver Verification Log in `wintun.DVL.XML` file. Release configurations only. When you are ready to test your driver using the Windows Hardware Certification Kit (HCK), you need to copy the `wintun.DVL.XML` file to the `%SystemDrive%\DVL` directory on the test computer.
+ - `dvl`: Runs Static Driver Verifier, which includes a clean driver build, and creates a Driver Verification Log in `wintun.DVL.XML` file. When you are ready to test your driver using the Windows Hardware Certification Kit (HCK), you need to copy the `wintun.DVL.XML` file to the `%SystemDrive%\DVL` directory on the test computer.
- `msm`: Builds Microsoft Installer Merge Module in `<output folder>\wintun.msm`. This target requires the driver to be built first (e.g. `nmake build msm` or `nmake dvl msm`).
@@ -61,14 +61,6 @@ AMD64 Release | `amd64\Release\wintun`
ARM64 Debug | `arm64\Debug\wintun`
ARM64 Release | `arm64\Release\wintun`
-### Properties
-
-Properties may be defined as environment variables, or specified on the `nmake` command line.
-
- - `CFG`: Specifies configuration to build or clean. May be `Debug` or `Release` (default).
-
- - `PLAT`: Specifies driver platform to build. May be `x86` or `amd64` (default), or `arm64`.
-
## Usage