# Updating internal GDAL
1. Remove the `Thirdparty\gdal` directory (but do not `svn delete` it)
2. Download the desired GDAL release and extract its sources into `Thirdparty\gdal`
3. Revert the following files from pending deletion
* `gdal.vcxproj`
* `gdal.vcxproj.filters`
* `gdal_vs15.sln`
* `build.sh`
4. Run the following in `Thirdparty\gdal`
* `generate_vcxproj.bat 14.0 64 gdal_vs2015_x64`
* `generate_vcxproj.bat 14.0 32 gdal_vs2015_x86`
5. Merge the contents of `gdal_vs2015_x64.vcxproj` and `gdal_vs2015_x86.vcxproj` into `gdal.vcxproj`
* Merge strategy
* Convert the absolute path references into relative paths in `gdal_vs2015_x64.vcxproj`
* Paste the contents of `gdal_vs2015_x64.vcxproj` into `gdal.vcxproj`
* Restore the `ProjectGuid` and `ProjectName` elements from the original `gdal.vcxproj`
* Failure to do this means you'd have to update project guid references in `gdal_vs15.sln`
* Copy the `Project/ItemGroup[Label=ProjectConfigurations]` contents from `gdal_vs2015_x86.vcxproj` into `gdal.vcxproj`
* Copy x86-specific `PropertyGroup` and `ImportGroup` elements from `gdal_vs2015_x86.vcxproj` into `gdal.vcxproj`
* Replace the existing NMake build steps with the `NMake section` below
6. Merge the contents of `gdal_vs2015_x64.vcxproj.filters` into `gdal.vcxproj.filters`
* Merge strategy
* Paste the contents of `gdal_vs2015_x64.vcxproj.filters` into `gdal.vcxproj`
* Convert all absolute path references into relative paths
7. Remove the files generated by `generate_vcxproj.bat`
8. Fix up `nmake.opt` using the patch below as a reference
9. Commit the new sources, taking note to:
* `svn add` the new unversioned files
* `svn delete` the (now missing) files
10. Update various `.vcxproj` and build scripts to update the expected gdal dll name
11. If required: Fix up whatever API breakages introduced in this version of GDAL in the GDAL and OGR provider sources. This should be rare as GDAL/OGR has incredible API stability.
12. Update the following files to update the expected GDAL so version (if you don't know, you can do a "dry run" Linux build first to find out)
* `CMakeLists.txt`
* `Thirdparty/Makefile.am` (if/once we axe autotools, we can stop updating this file)
* `Thirdparty/gdal/build.sh`
13. If it exists, mark the following file as executable (and make sure its `svn:executable` attribute is `ON`)
* `Thirdparty/gdal/gcore/generate_gdal_version_h.sh`
14. Commit the above changes
# NMake section
```
$(Configuration)\
$(Configuration)\
mkdir bin\win32\debug
mkdir lib\win32\debug
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1 devinstall
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1 clean
mkdir bin\win32\debug
mkdir lib\win32\debug
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1 clean
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1
nmake -f makefile.vc MSVC_VER=1900 DEBUG=1 WITH_PDB=1 devinstall
Win32;_DEBUG;$(NMakePreprocessorDefinitions)
$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(VC_SourcePath);
$(Configuration)\
$(Configuration)\
mkdir bin\win64\debug
mkdir lib\win64\debug
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1 devinstall
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1 clean
mkdir bin\win64\debug
mkdir lib\win64\debug
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1 clean
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 DEBUG=1 WITH_PDB=1 devinstall
x64;_DEBUG;$(NMakePreprocessorDefinitions)
$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(VC_SourcePath);
$(Configuration)\
$(Configuration)\
mkdir bin\win32\release
mkdir lib\win32\release
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900
nmake -f makefile.vc MSVC_VER=1900 devinstall
nmake -f makefile.vc MSVC_VER=1900 clean
mkdir bin\win32\release
mkdir lib\win32\release
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 clean
nmake -f makefile.vc MSVC_VER=1900
nmake -f makefile.vc MSVC_VER=1900 devinstall
Win32;NDEBUG;$(NMakePreprocessorDefinitions)
$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(VC_SourcePath);
$(Configuration)\
$(Configuration)\
mkdir bin\win64\release
mkdir lib\win64\release
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 devinstall
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 clean
mkdir bin\win64\release
mkdir lib\win64\release
cd $(ProjectDir)
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 clean
nmake -f makefile.vc MSVC_VER=1900
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 devinstall
x64;NDEBUG;$(NMakePreprocessorDefinitions)
$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(VC_SourcePath);
```
# nmake.opt patch
```
Index: nmake.opt
===================================================================
--- nmake.opt (revision 8064)
+++ nmake.opt (working copy)
@@ -47,6 +47,17 @@
# Uncomment this line to use VLD in debug configuration only:
#MSVC_VLD_DIR="C:\Program Files\Visual Leak Detector"
+# Uncomment the following if you are building for 64-bit windows
+# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
+# compiles.
+#WIN64=YES
+PLATFORM_BITS=32
+# Capture WIN64=1 if specified in NMAKE command line
+!IFDEF WIN64
+WIN64=YES
+PLATFORM_BITS=64
+!ENDIF
+
###############################################################################
# Location to install .exe, .dll and python stuff
# Edit as required. GDAL_HOME is used for convenience here,
@@ -53,17 +64,23 @@
# but this particular relative organization is not mandatory.
# But the paths *should* be absolute (relative paths mess up in submakefiles).
+!IFDEF DEBUG
+CONFIGURATION = debug
+!ELSE
+CONFIGURATION = release
+!ENDIF
+
!IFNDEF GDAL_HOME
-GDAL_HOME = "C:\warmerda\bld"
+GDAL_HOME = $(FDOTHIRDPARTY)\gdal
!ENDIF
!IFNDEF BINDIR
-BINDIR = "$(GDAL_HOME)\bin"
+BINDIR = $(GDAL_HOME)\bin\win$(PLATFORM_BITS)\$(CONFIGURATION)
!ENDIF
!IFNDEF PLUGINDIR
PLUGINDIR = "$(BINDIR)\gdalplugins"
!ENDIF
!IFNDEF LIBDIR
-LIBDIR = "$(GDAL_HOME)\lib"
+LIBDIR = $(GDAL_HOME)\lib\win$(PLATFORM_BITS)\$(CONFIGURATION)
!ENDIF
!IFNDEF INCDIR
INCDIR = "$(GDAL_HOME)\include"
```