From b7687223c15593f12ee3f34a4fa8763586410e45 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 28 Jul 2021 20:29:28 +0000 Subject: [PATCH] Updates to build with VS 2019 --- mswin32/Build.bat | 15 +++++++++++++++ mswin32/Makefile | 44 ++++++++++++++++---------------------------- mswin32/make-vars.h | 9 +++++++++ mswin32/nmap.vcxproj | 5 ++--- 4 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 mswin32/Build.bat create mode 100644 mswin32/make-vars.h diff --git a/mswin32/Build.bat b/mswin32/Build.bat new file mode 100644 index 0000000000..37e7c49407 --- /dev/null +++ b/mswin32/Build.bat @@ -0,0 +1,15 @@ +@echo off +set TARGET=%1 +set VCCONFIG=%2 + +for /f "usebackq delims=#" %%a in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere" -version 16 -property installationPath`) do call "%%a\VC\Auxiliary\Build\vcvarsall.bat" x86 + +@echo on +if "%TARGET%" == "Vars" ( goto :vars ) + +msbuild -nologo nmap.sln -m -t:%TARGET% -p:Configuration="%VCCONFIG%" -p:Platform="Win32" -fl +exit /b %errorlevel% + +:vars +cl.exe /nologo /EP make-vars.h > make-vars.make +exit /b %errorlevel% diff --git a/mswin32/Makefile b/mswin32/Makefile index e5c8f5f5db..249098f18a 100644 --- a/mswin32/Makefile +++ b/mswin32/Makefile @@ -1,15 +1,12 @@ MAKENSIS=/cygdrive/c/Program Files (x86)/NSIS-strlen/makensis.exe MAKENSIS_WIN=$(shell echo '$(MAKENSIS)' | sed 's|/cygdrive/\(.\)|\1:|;s|/|\\|g') -# VCExpress.exe is devenv.com with the commercial Visual Studio suite instead of VC++ Express -VCEXPRESS := $(shell reg query "HKEY_CLASSES_ROOT\\Applications\\devenv.exe\\shell\\edit\\command" | egrep -i '[A-Z]:\\' | cut -d\" -f2 | sed 's%\\%/%g' | tr -d '\r\n') -SIGNTOOL := $(shell reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.1" /v "InstallationFolder" | egrep InstallationFolder | cut -d ' ' -f13- | sed 's%\\%/%g' | tr -d '\r\n' | sed 's%$$%bin/x86/signtool.exe%') +SIGNTOOL := $(shell reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" /v "InstallationFolder" | egrep InstallationFolder | cut -d ' ' -f13- | sed 's%\\%/%g' | tr -d '\r\n' | sed 's%$$%bin/x86/signtool.exe%') NMAPDIR=.. NMAPDIR_WIN=$(shell echo '$(NMAPDIR)' | sed 's|/cygdrive/\(.\)|\1:|;s|/|\\|g') -export NMAP_VERSION := $(shell echo NMAP_VERSION | $(CPP) -imacros $(NMAPDIR)/nmap.h - | sed -n '$$s/[" ]//g;$$p') -export NMAP_VERSION := $(shell echo NMAP_NUM_VERSION | $(CPP) -imacros $(NMAPDIR)/nmap.h - | sed -n '$$s/[" ]//g;$$p') + +include make-vars.make export NPCAP_VERSION := $(shell ls npcap-*.exe | sed -e 's/npcap-\([0-9.]*\)[-oem]*\.exe/\1/' -e 'q') -COMMA_VERSION=$(shell echo $(NMAP_NUM_VERSION) | tr '.' ',') -LOGLOC=c:nmapbuild.log + NSE_FILES = $(NMAPDIR)/scripts/script.db $(NMAPDIR)/scripts/*.nse NMAP_MSWIN32_AUX = $(NMAPDIR)/../nmap-mswin32-aux SIGNTOOL_ARGS = sign /a /n "Insecure.Com LLC" /tr http://timestamp.digicert.com /td sha256 /fd sha256 @@ -22,12 +19,17 @@ PLATFORM=Win32 VCCONFIG=Release NSIS_DEFINES= +all: build-nmap + +make-vars.make: make-vars.h + cmd /c Build.bat Vars + bundle-nmap: bundle-zip bundle-nsis -build-nmap${OEM_SUFFIX}: nmap.sln nmap${OEM_SUFFIX}.rc - "$(VCEXPRESS)" nmap.sln /build "$(VCCONFIG)${OEM_SUFFIX}|$(PLATFORM)" /out $(LOGLOC) +build-nmap${OEM_SUFFIX}: nmap.sln + cmd /c Build.bat Build "$(VCCONFIG)${OEM_SUFFIX}" -stage-common: $(NMAPDIR)/CHANGELOG $(NMAPDIR)/LICENSE $(NMAPDIR)/nmap-mac-prefixes $(NMAPDIR)/nmap-os-db $(NMAPDIR)/nmap-payloads $(NMAPDIR)/nmap-protocols $(NMAPDIR)/nmap-rpc $(NMAPDIR)/nmap-service-probes $(NMAPDIR)/nmap-services $(NMAPDIR)/docs/nmap.xsl $(NMAPDIR)/nse_main.lua $(NMAPDIR)/mswin32/nmap_performance.reg $(NMAPDIR)/README-WIN32 $(NMAPDIR)/docs/3rd-party-licenses.txt icon1.ico LICENSE.formatted +stage-common: $(NMAPDIR)/CHANGELOG $(NMAPDIR)/LICENSE $(NMAPDIR)/nmap-mac-prefixes $(NMAPDIR)/nmap-os-db $(NMAPDIR)/nmap-payloads $(NMAPDIR)/nmap-protocols $(NMAPDIR)/nmap-rpc $(NMAPDIR)/nmap-service-probes $(NMAPDIR)/nmap-services $(NMAPDIR)/docs/nmap.xsl $(NMAPDIR)/nse_main.lua $(NMAPDIR)/mswin32/nmap_performance.reg $(NMAPDIR)/README-WIN32 $(NMAPDIR)/docs/3rd-party-licenses.txt icon1.ico LICENSE.formatted VC_redist.x86.exe mkdir -p nmap-$(NMAP_VERSION) cp $^ nmap-$(NMAP_VERSION)/ # Use "cmd /c copy" rather than "cp" to preserve Windows ACLs. Using @@ -46,8 +48,8 @@ stage-common: $(NMAPDIR)/CHANGELOG $(NMAPDIR)/LICENSE $(NMAPDIR)/nmap-mac-prefix done cp -r $(NMAPDIR)/docs/licenses nmap-$(NMAP_VERSION)/ rm -rf nmap-$(NMAP_VERSION)/licenses/.svn - cp $(NMAP_MSWIN32_AUX)/vcredist_x86.exe nmap-$(NMAP_VERSION) - cp $(NMAP_MSWIN32_AUX)/vcredist2008_x86.exe nmap-$(NMAP_VERSION) + cp VC_redist.x86.exe nmap-$(NMAP_VERSION) + #cp $(NMAP_MSWIN32_AUX)/vcredist2008_x86.exe nmap-$(NMAP_VERSION) cp $(NMAPDIR)/ncat/$(VCCONFIG)/ncat.exe nmap-$(NMAP_VERSION) cp $(NMAPDIR)/ncat/$(VCCONFIG)/ca-bundle.crt nmap-$(NMAP_VERSION) cp $(NMAPDIR)/nping/$(VCCONFIG)/nping.exe nmap-$(NMAP_VERSION) @@ -118,20 +120,6 @@ bundle-zip-main: sign-files -r nmap-$(NMAP_VERSION)${OEM_SUFFIX}-win32.zip nmap-$(NMAP_VERSION)${OEM_SUFFIX} rm nmap-$(NMAP_VERSION)${OEM_SUFFIX}/npcap-$(NPCAP_VERSION)${OEM_SUFFIX}.exe -nmap.rc: nmap.rc.in $(NMAPDIR)/nmap.h - sed -e '1i// Automatically generated from $<.' \ - -e 's/@@FILEVERSION@@/"$(NMAP_VERSION)\\0"/' \ - -e 's/@@COMMAVERSION@@/$(COMMA_VERSION)/' \ - -e 's/@@PRODUCT_NAME@@/$(PRODUCT_NAME)/' \ - "$<" > "$@" - -nmap-oem.rc: nmap.rc.in $(NMAPDIR)/nmap.h - sed -e '1i// Automatically generated from $<.' \ - -e 's/@@FILEVERSION@@/"$(NMAP_VERSION)\\0"/' \ - -e 's/@@COMMAVERSION@@/$(COMMA_VERSION)/' \ - -e 's/@@PRODUCT_NAME@@/$(PRODUCT_NAME) OEM/' \ - "$<" > "$@" - nmap-$(NMAP_VERSION)/Nmap.nsi: nsis/Nmap.nsi.in $(NMAPDIR)/nmap.h test -n "$(NPCAP_VERSION)" # Make sure NPcap is present mkdir -p nmap-$(NMAP_VERSION) @@ -147,5 +135,5 @@ LICENSE.formatted: $(NMAPDIR)/LICENSE ./license-format/licformat.sh "$<" > "$@" clean: - "$(VCEXPRESS)" nmap.sln /clean - rm -rf nmap-$(NMAP_VERSION) nmap-$(NMAP_VERSION)-oem Debug Release Release-oem nmapbuild.log nmap.rc nmap-oem.rc LICENSE.formatted + ./Build.bat Clean "$(VCCONFIG)${OEM_SUFFIX}" + rm -rf nmap-$(NMAP_VERSION) nmap-$(NMAP_VERSION)-oem Debug Release Release-oem msbuild.log LICENSE.formatted diff --git a/mswin32/make-vars.h b/mswin32/make-vars.h new file mode 100644 index 0000000000..4a7b05160e --- /dev/null +++ b/mswin32/make-vars.h @@ -0,0 +1,9 @@ +define IGNORE +#include "../nmap.h" +endef + +#define EXPORT(_var) export $(name)##_var:= $(patsubst "%",%,$(subst " ",,NMAP##_var)) + +name = NMAP +EXPORT(_VERSION) +EXPORT(_NUM_VERSION) diff --git a/mswin32/nmap.vcxproj b/mswin32/nmap.vcxproj index 107b47d0af..2a9c3630a8 100644 --- a/mswin32/nmap.vcxproj +++ b/mswin32/nmap.vcxproj @@ -244,8 +244,7 @@ - - + @@ -446,4 +445,4 @@ - \ No newline at end of file +