Make Makefile build all supported platforms

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-04-18 14:00:02 +02:00
parent cd34b73893
commit e4f4d71477
3 changed files with 81 additions and 68 deletions

View File

@ -11,73 +11,51 @@ WINTUN_VERSION_REV=2019
WINTUN_VERSION_BUILD=0128 WINTUN_VERSION_BUILD=0128
WINTUN_VERSION=$(WINTUN_VERSION_MAJ).$(WINTUN_VERSION_MIN).$(WINTUN_VERSION_REV).$(WINTUN_VERSION_BUILD) 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 DIST_DIR=dist
OUTPUT_DIR=$(PLAT)\$(CFG) MSBUILD_FLAGS=/m /v:minimal /nologo
MSM_NAME=wintun_$(WINTUN_VERSION)_$(PLAT) WIX_CANDLE_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -dWINTUN_VERSION="$(WINTUN_VERSION)"
MSBUILD_FLAGS=/p:Configuration="$(CFG)" /p:Platform="$(PLAT_MSBUILD)" /m /v:minimal /nologo WIX_LIGHT_FLAGS=-nologo -ext WixDifxAppExtension -ext WixIIsExtension -sw1103
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
build :: build :: \
msbuild.exe "wintun.vcxproj" /t:Build $(MSBUILD_FLAGS) build_x86_Release \
build_amd64_Release \
clean :: build_arm64_Release
-rd /s /q "$(DIST_DIR)" > NUL 2>&1
-rd /s /q "$(OUTPUT_DIR)" > NUL 2>&1
!IF "$(CFG)" == "Release" && "$(PLAT)" != "arm64"
dvl :: "wintun.DVL.XML" dvl :: "wintun.DVL.XML"
msm :: \
"$(DIST_DIR)" \
"$(DIST_DIR)\wintun_$(WINTUN_VERSION)_x86.msm" \
"$(DIST_DIR)\wintun_$(WINTUN_VERSION)_amd64.msm"
"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 :: clean ::
-rd /s /q "sdv" > NUL 2>&1 -rd /s /q "sdv" > NUL 2>&1
-del /f /q "wintun.DVL.XML" > NUL 2>&1 -del /f /q "wintun.DVL.XML" > NUL 2>&1
-del /f /q "smvbuild.log" > NUL 2>&1 -del /f /q "smvbuild.log" > NUL 2>&1
-del /f /q "smvstats.txt" > 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" : CFG=Release
msbuild.exe "wintun.vcxproj" /t:sdv /p:Inputs="/check:*" $(MSBUILD_FLAGS) PLAT=x86
!INCLUDE "Makefile.PlatCfg.mak"
PLAT=amd64
!INCLUDE "Makefile.PlatCfg.mak"
PLAT=arm64
!INCLUDE "Makefile.PlatCfg.mak"
"wintun.DVL.XML" : "sdv\SDV.DVL.xml" "$(OUTPUT_DIR)\vc.nativecodeanalysis.all.xml" CFG=Debug
msbuild.exe "wintun.vcxproj" /t:dvl $(MSBUILD_FLAGS) PLAT=x86
!INCLUDE "Makefile.PlatCfg.mak"
msm :: "$(DIST_DIR)\$(MSM_NAME).msm" PLAT=amd64
!INCLUDE "Makefile.PlatCfg.mak"
"$(OUTPUT_DIR)\wintun.wixobj" : "wintun.wxs" PLAT=arm64
"$(WIX)bin\candle.exe" $(WIX_CANDLE_FLAGS) -out $@ $** !INCLUDE "Makefile.PlatCfg.mak"
"$(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
"$(DIST_DIR)" :
md $@ > NUL 2>&1

43
Makefile.PlatCfg.mak Normal file
View File

@ -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

View File

@ -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: Open _Developer Command Prompt for VS 2017_ and use the `nmake` command:
``` ```
nmake [<target>] [CFG=<configuration>] [PLAT=<platform>] nmake [<target>]
``` ```
### Targets ### Targets
@ -46,7 +46,7 @@ nmake [<target>] [CFG=<configuration>] [PLAT=<platform>]
- `clean`: Deletes all intermediate and output files. - `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`). - `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 Debug | `arm64\Debug\wintun`
ARM64 Release | `arm64\Release\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 ## Usage