Add top-level Windows makefile targets for building installers.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 13 Jun 2014 12:34:36 +0000 (15:34 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 13 Jun 2014 12:34:36 +0000 (15:34 +0300)
You can now do "nmake /f win64.mak world" to build both x86 and x64
versions of the installers in one command.

docs/win32-compilation.html
installer/installer.mak [new file with mode: 0644]
installer/productcodes.mak [new file with mode: 0644]
installer/psqlodbc_cpu.wxs
win64.mak

index 028199c5f4b08d318cc19605f7499ee8d65decd5..f6aa30a9950c90a11fcdd149402e1b0c56fdf959 100644 (file)
@@ -33,6 +33,8 @@ The following 3rd party software are required for the build:
 <li> OpenSSL library and header files. Download the latest version from the
      <a href="https://www.openssl.org/related/binaries.html">OpenSSL website</a>.
 </li>
+<li> WiX Toolset. Required for building the installer. Download the latest
+     version from the <a href="http://wixtoolset.org/">WiX Toolset website</a>
 </ul>
 </p>
 
@@ -49,18 +51,29 @@ methods will be disabled.
 
 Use NMAKE.exe to build the driver for the currently active target:<br><br>
 
-    <code>C:\psqlodbc\&gt; nmake /f win64.mak CFG=Release ALL</code><br><br>
-
-Possible configurations are Release and Debug.<br>
-Possible build types are ALL or CLEAN.</li></ol>
+    <code>C:\psqlodbc\&gt; nmake /f win64.mak &lt;options&gt;</code><br><br>
 
 <p>
 Despite the name, win64.mak is used to build both 32-bit and 64-bit binaries.
 With the Microsoft SDK scripts, you can switch between 32-bit and 64-bit
-target architectures with "setenv /x86" and "setenv /x64" commands. To build
-both versions, run the nmake command twice, switching the target inbetween.
+target architectures with "setenv /x86" and "setenv /x64" commands.
+</p>
+
+<p>
+To build the .msi installer file:<br><br>
+
+    <code>C:\psqlodbc\&gt; nmake /f win64.mak installer</code><br><br>
+
+The resulting installer file goes to installer/x64 or installer/x86 directory.
 </p>
 
+<p>
+To build both 32-bit and 64-bit versions in one command:<br><br>
+
+    <code>C:\psqlodbc\&gt; nmake /f win64.mak world</code><br><br>
+</p>
+
+
 <p>
 The following build options may be used, either on the command line, or
 by creating a file called "windows-local.mak".
diff --git a/installer/installer.mak b/installer/installer.mak
new file mode 100644 (file)
index 0000000..d393130
--- /dev/null
@@ -0,0 +1,46 @@
+
+
+# All the driver files that will be included in the installer
+DRIVER_FILES = ../$(TARGET_CPU)_Unicode_$(CFG)/psqlodbc35w.dll \
+   ../$(TARGET_CPU)_Unicode_$(CFG)/pgxalib.dll \
+   ../$(TARGET_CPU)_Unicode_$(CFG)/pgenlist.dll \
+   ../$(TARGET_CPU)_ANSI_$(CFG)/psqlodbc30a.dll \
+   ../$(TARGET_CPU)_ANSI_$(CFG)/pgxalib.dll \
+   ../$(TARGET_CPU)_ANSI_$(CFG)/pgenlista.dll
+
+ALL: $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi
+
+CANDLE="$(WIX)bin\candle.exe"
+LIGHT="$(WIX)bin\light"
+
+!INCLUDE ..\windows-defaults.mak
+!IF EXISTS(..\windows-local.mak)
+!INCLUDE ..\windows-local.mak
+!ENDIF
+
+!MESSAGE determining product code
+
+!INCLUDE productcodes.mak
+
+!MESSAGE Got product code $(PRODUCTCODE)
+
+MSM_OPTS = -dLIBPQBINDIR="$(LIBPQ_BIN)"
+!IF "$(USE_GSS)" == "yes"
+MSM_OPTS = $(MSM_OPTS) -dGSSBINDIR="$(GSSBINDIR)"
+!ENDIF
+
+
+# Merge module
+$(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm: psqlodbcm_cpu.wxs $(DRIVER_FILES)
+   echo Building Installer Merge Module
+   $(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) $(MSM_OPTS) -o $(TARGET_CPU)\psqlodbcm.wixobj psqlodbcm_cpu.wxs
+   $(LIGHT) -nologo -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msm $(TARGET_CPU)\psqlodbcm.wixobj
+
+$(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi: psqlodbc_cpu.wxs $(DRIVER_FILES)
+   echo Building Installer
+   $(CANDLE) -nologo -dPlatform="$(TARGET_CPU)" -dVERSION=$(POSTGRESDRIVERVERSION) -dSUBLOC=$(SUBLOC) -dPRODUCTCODE=$(PRODUCTCODE) -o $(TARGET_CPU)\psqlodbc.wixobj psqlodbc_cpu.wxs
+   $(LIGHT) -nologo -ext WixUIExtension -cultures:en-us -o $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi $(TARGET_CPU)\psqlodbc.wixobj
+   cscript modify_msi.vbs $(TARGET_CPU)\psqlodbc_$(TARGET_CPU).msi
+
+clean:
+   -rd /Q /S x64 x86
diff --git a/installer/productcodes.mak b/installer/productcodes.mak
new file mode 100644 (file)
index 0000000..b343071
--- /dev/null
@@ -0,0 +1,19 @@
+!IF "$(POSTGRESDRIVERVERSION)" == "09.02.0100"
+PRODUCTCODE="3E42F836-9204-4c42-B3C3-8680A0434875"
+SUBLOC=0902
+!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0100"
+PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
+SUBLOC=0903
+!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0200"
+PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
+SUBLOC=0903
+!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0210"
+PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
+SUBLOC=0903
+!ELSE IF "$(POSTGRESDRIVERVERSION)" == "09.03.0300"
+PRODUCTCODE="1F896F2F-5756-4d22-B5A3-040796C9B485"
+SUBLOC=0903
+!ELSE
+!MESSAGE Driver version $(POSTGRESDRIVERVERSION) is not listed in productcodes.mak
+EXIT
+!ENDIF
index 4df4f1751ad7c9dd5eae1b94d29eafb01b9dd909..9c33838e5e5d445f66255f9fca4b703b916aea73 100644 (file)
@@ -12,7 +12,6 @@
 
 <?if $(var.Platform) = x64 ?>
   <?define PKGNAME = "psqlODBC_x64" ?>
-  <?define MERGEM = "$(var.Platform)\psqlodbc_$(var.Platform).msm" ?>
   <?define BIT64 = "yes" ?>
   <?define PGFOLDER = "ProgramFiles64Folder" ?>
   <?define PRODID = "3E42F836-9204-4c42-B3C3-8680A0434875" ?>
@@ -23,7 +22,6 @@
   <?define ALLUSERS = "2" ?>
 <?else?>
   <?define PKGNAME = "psqlODBC" ?>
-  <?define MERGEM = "psqlodbc.msm" ?>
   <?define BIT64 = "no" ?>
   <?define PGFOLDER = "ProgramFilesFolder" ?>
   <?define PRODID = "838E187D-8B7A-473d-B93C-C8E970B15D2B" ?>
@@ -34,6 +32,8 @@
   <?define ALLUSERS = "1" ?>
 <?endif?>
 
+<?define MERGEM = "$(var.Platform)\psqlodbc_$(var.Platform).msm" ?>
+
 <!-- Product details -->
 
   <Product
index 92391e78d6620dcf1f70bdd73bb6de3ee0a6a471..b8f1342f9b64258df51d8ccc2f3e28e2d98cad5c 100755 (executable)
--- a/win64.mak
+++ b/win64.mak
@@ -360,3 +360,40 @@ SOURCE=psqlodbc.rc
 
 "$(INTDIR)\psqlodbc.res" : $(SOURCE)
    $(RSC) $(RSC_PROJ) $(RSC_DEFINES) $(SOURCE)
+
+
+
+####
+# Umbrella targets, for building the driver in multiple configurations
+
+unicode-driver:
+   $(MAKE) -f win64.mak ANSI_VERSION=no
+ansi-driver:
+   $(MAKE) -f win64.mak ANSI_VERSION=yes
+
+installer: unicode-driver ansi-driver
+   cd installer && $(MAKE) -f installer.mak CFG=$(CFG)
+
+# world target builds both 32-bit and 64-bit installers in one command.
+#
+# The "setenv" command, from Microsoft SDK, is used to switch the build
+# target. However, it only changes the environment for the current shell;
+# it is reset for the next command. So we cannot just call "setenv /x64"
+# here one one line and nmake one the next one. I also tried creating a .bat
+# file with the commands, but setenv contains a "EXIT /B" which stops the
+# script from executing. But we can launch a new cmd.exe and pass the
+# commands to it in stdin.
+world:
+   cmd < <<
+setenv /x64
+$(MAKE) -f win64.mak installer CFG=$(CFG)
+setenv /x86
+$(MAKE) -f win64.mak installer CFG=$(CFG)
+<<
+
+clean-world:
+   -rd /Q /S x64_ANSI_Release x64_ANSI_Debug
+   -rd /Q /S x64_Unicode_Release x64_Unicode_Debug
+   -rd /Q /S x86_ANSI_Release x86_ANSI_Debug
+   -rd /Q /S x86_Unicode_Release x86_Unicode_Debug
+   cd installer && $(MAKE) /f installer.mak CFG=$(CFG) clean