Permalink
Browse files

Add an "install" target

  • Loading branch information...
1 parent 9585020 commit 8590469b2d750e59208fc8a595b6c37278fa000f @ringerc ringerc committed Dec 16, 2012
Showing with 95 additions and 19 deletions.
  1. +5 −0 Makefile
  2. +29 −7 README.txt
  3. +8 −0 install.mak
  4. +18 −2 postgresql.mak
  5. +25 −5 settings-template.mak
  6. +10 −5 zlib.mak
View
@@ -42,6 +42,10 @@ PGBUILDDIR=$(PGDIR)\$(PLATFORMTOOLSET)\$(TARGET_PLATFORM)\$(TARGET_CPU)\$(CONFIG
!ENDIF
!ENDIF
+!IFNDEF PGINSTALLDIR
+PGINSTALLDIR=$(PGBUILDDIR)\binaries
+!ENDIF
+
!IF ( "$(TARGET_CPU)" == "x86" )
PERLDIR=$(PERL_X86)
PYTHON2DIR=$(PYTHON2_X86)
@@ -66,6 +70,7 @@ phony:
!INCLUDE zlib.mak
!INCLUDE configpl.mak
!INCLUDE postgresql.mak
+!include install.mak
clean: zlib-clean postgresql-clean
IF EXIST $(LIBBUILDDIR) rd /s /q $(LIBBUILDDIR)
View
@@ -136,20 +136,23 @@ reset using "git clean -fdx" when you "nmake clean" or "nmake postgresql-clean",
do work in the script-managed PostgreSQL trees; either push to a branch and have the tools
build the branch, or manually manage the source tree (see below).
-Builds will go in different locations based on their settings - /x86 vs /x64,
-/release vs /debug, SDK version, target OS, and Pg branch. For example,
+Builds and installs will go in different locations (PGBUILDDIR) based on their settings
+- /x86 vs /x64, /release vs /debug, SDK version, target OS, and Pg branch. For example,
REL9_2_STABLE built for /x86 /release /xp built with Windows SDK 7.1 with PGDIR
set to c:\postgresql-build will go in:
D:\postgresql-build\Windows7.1SDK\xp\x86\Release\REL9_2_STABLE
-As cloning Pg from scratch takes time, I recommend cloning a bare copy of the Pg repo *outside* LIBDIR and PGDIR, eg:
+As cloning Pg from scratch takes time and bandwidth, I recommend cloning a bare copy
+of the Pg repo *outside* LIBDIR and PGDIR, eg:
git clone --bare --mirror git://git.postgresql.org/git/postgresql.git d:\postgresql-git
and specifying the path to it as PG_GIT_URL:
PG_GIT_URL=d:\postgresql-git
+
+To pull new changes into that repository use, "git fetch".
Manually managed PostgreSQL source trees - set PGBUILDDIR
---------------------------------------------------------
@@ -169,11 +172,14 @@ For example:
nmake /f d:\pg_build_win PGBUILDDIR=d:\my-postgresql-dev-tree
-The scripts won't use git and you don't need it installed. In this mode, "nmake
-postgresql-clean" and "nmake clean" will use "src\tools\msvc\clean.bat dist" to
-clean the source tree, rather than using git.
+The pseudo-env-var %CD% is useful if you want to build a PostgreSQL source tree
+rooted in the current directory.
+
+If USE_GIT is not set, the scripts won't use git and you don't need it installed.
+In this mode, "nmake postgresql-clean" and "nmake clean" will use
+"src\tools\msvc\clean.bat dist" to clean the source tree, rather than using git.
-You still need a settings.mak, but if you set LIBDIR on the command line too it
+You still need a settings.mak, but if you set LIBDIR on the command line then it
can be an empty file.
(Optional) Download library source archives
@@ -233,6 +239,22 @@ has "libname" and "libname-clean" targets, eg:
* zlib
* zlib-clean
+INSTALLATION
+------------
+
+To get a tree of installed PostgreSQL binaries, contrib modules,
+etc including the library dependencies, use the "install" target.
+
+By default, "install" will install the binaries to a directory named "binaries"
+under PGBUILDDIR. Change this if desired by setting PGINSTALLDIR.
+
+If you want just the PostgreSQL install but not the libraries, use
+"postgresql-install".
+
+The interpreters for the PLs are not copied over. Neither is the Visual
+C++ redist for your SDK, which will need to be installed before the compiled
+binaries will run on another machine.
+
CLEANING:
---------
View
@@ -0,0 +1,8 @@
+#
+# This script collects up PostgreSQL and its dependencies into a single
+# install tree.
+#
+
+libs-install: zlib-install
+
+install: postgresql-install libs-install
View
@@ -3,30 +3,46 @@
#
!IFDEF USE_GIT
+# The horrific FOR construct is the command-shell equivalent of
+# IF ! test "`$(GIT) ls-remote origin $(GIT_BRANCH) | cut -f 1`" == "`$(GIT) rev-parse HEAD`" THEN
+# What it's doing is testing to see if the remote has changed and updating if it has.
+#
$(PGBUILDDIR): phony
@IF NOT EXIST "$(PGBUILDDIR)" md "$(PGBUILDDIR)
IF NOT EXIST "$(PGBUILDDIR)\.git" "$(GIT)" clone -b "$(PG_BRANCH)" "$(PG_GIT_URL)" "$(PGBUILDDIR)"
cd $(PGBUILDDIR)
- "$(GIT)" pull --force
+ IF "$(GIT_PULL)" == "1" FOR /f "tokens=1" %G IN ('"$(GIT)" ls-remote origin $(PG_BRANCH)') DO FOR /f %H IN ('"$(GIT)" rev-parse HEAD') DO IF NOT "%G" == "%H" "$(GIT)" checkout --force $(PG_BRANCH) && "$(GIT)" pull --force
!ELSE
# This is a dummy target because we expect a valid Pg tree to be
# at $(PGBUILDDIR) already. If there isn't one, protest.
$(PGBUILDDIR): phony
@IF NOT EXIST "$(PGBUILDDIR)"\GNUmakefile.in (echo "No PostgreSQL source tree at $(PGBUILDDIR) and USE_GIT not set" && EXIT 1)
!ENDIF
+#
+# This target will always build, because NMake will always see "$(PGBUILDDIR) as dirty;
+# it doesn't test directory timestamps. That's OK, since there's no reliable way for
+# us to find out if the tree is dirty, so we have to re-run the build and let it decide
+# anyway.
+#
postgresql: $(FLEX) $(BISON) zlib $(PGBUILDDIR) $(CONFIG_PL) $(BUILDENV_PL)
cd $(PGBUILDDIR)\src\tools\msvc
"$(PERL_CMD)" build.pl
!IFDEF USE_GIT
postgresql-clean: phony
IF EXIST $(PGBUILDDIR)\.git\HEAD ( cd $(PGBUILDDIR) && "$(GIT)" clean -fdx )
+ IF EXIST $(PGINSTALLDIR) rd /s /q $(PGINSTALLDIR)
!ELSE
postgresql-clean: phony
IF EXIST $(PGBUILDDIR)\src\tools\msvc ( cd $(PGBUILDDIR)\src\tools\msvc && clean dist)
+ IF EXIST $(PGINSTALLDIR) rd /s /q $(PGINSTALLDIR)
!ENDIF
postgresql-check: postgresql
cd $(PGBUILDDIR)\src\tools\msvc
- "$(PERL_CMD)" vcregress.pl check
+ "$(PERL_CMD)" vcregress.pl check
+
+postgresql-install: postgresql
+ cd $(PGBUILDDIR)\src\tools\msvc
+ install.bat $(PGINSTALLDIR)
View
@@ -3,16 +3,36 @@
#LIBDIR=d:\libs
#TOOLPREFIX=d:
+####################################
+# Manual PostgreSQL source trees #
+####################################
+#
+# If USE_GIT is not set, PGBUILDDIR must be set to point to the path of a PostgreSQL
+# source tree - an unpacked tarball or a git working directory. You can use:
+#
+# nmake /f \path\to\pg_build_win\Makefile PGBUILDDIR=%CD%
+#
+# ... to use the current directory.
+#
+# If you want to install the resulting build, set PGINSTALLDIR to the location
+# you want to install to. If unset, the default will be to install to "binaries\"
+# under the build directory.
+#
+##############################################
+# PostgreSQL automatically managed from git #
+##############################################
+#
+#
# If you define USE_GIT (to anything; it's not a boolean) then these build
# scripts will perform git checkouts of the Pg source tree into a tree based
# at PGDIR.
#
-# If USE_GIT is not set, all commands that work with a PostgreSQL source tree
-# must be run with the root of a PostgreSQL source tree as the current working
-# directory, or PGBUILDDIR must be set to point to the path of such a tree.
-#
#USE_GIT=1
#PGDIR=d:\postgresql
#PG_GIT_URL=D:\postgresql-git
#PG_BRANCH=REL9_2_STABLE
-#GIT=c:\Program Files (x86)\Git\bin\git.exe
+#GIT=c:\Program Files (x86)\Git\bin\git.exe
+#
+# If you set:
+#GIT_PULL=1
+# in USE_GIT mode then the working directory will be updated before each build.
View
@@ -24,7 +24,7 @@ $(ZLIB_SRCDIR)\zlib1.dll: $(ZLIB_SRCDIR)\unpack-stamp
$(MAKE) /f win32\Makefile.msc clean
$(MAKE) /f win32\Makefile.msc
-ZLIB_OBJS=$(ZLIB_BINDIR)\include\zlib.h $(ZLIB_BINDIR)\include\zconf.h $(ZLIB_BINDIR)\bin\zlib1.dll $(ZLIB_BINDIR)\bin\zlib1.pdb $(ZLIB_BINDIR)\lib\zdll.exp $(ZLIB_BINDIR)\lib\zdll.lib
+ZLIB_OBJS=$(ZLIB_BINDIR)\include\zlib.h $(ZLIB_BINDIR)\include\zconf.h $(ZLIB_BINDIR)\bin\zlib1.dll $(ZLIB_BINDIR)\symbols\zlib1.pdb $(ZLIB_BINDIR)\lib\zdll.exp $(ZLIB_BINDIR)\lib\zdll.lib
$(ZLIB_BINDIR)\include\zlib.h: $(ZLIB_SRCDIR)\zlib1.dll
@IF NOT EXIST $(ZLIB_BINDIR)\include md $(ZLIB_BINDIR)\include
@@ -40,9 +40,9 @@ $(ZLIB_BINDIR)\bin\zlib1.dll: $(ZLIB_SRCDIR)\zlib1.dll
@IF NOT EXIST $(ZLIB_BINDIR)\bin md $(ZLIB_BINDIR)\bin
copy /Y /B $(ZLIB_SRCDIR)\zlib1.dll $(ZLIB_BINDIR)\bin\zlib1.dll >NUL
-$(ZLIB_BINDIR)\bin\zlib1.pdb: $(ZLIB_SRCDIR)\zlib1.dll
- @IF NOT EXIST $(ZLIB_BINDIR)\bin md $(ZLIB_BINDIR)\bin
- copy /Y /B $(ZLIB_SRCDIR)\zlib1.pdb $(ZLIB_BINDIR)\bin\zlib1.pdb >NUL
+$(ZLIB_BINDIR)\symbols\zlib1.pdb: $(ZLIB_SRCDIR)\zlib1.dll
+ @IF NOT EXIST $(ZLIB_BINDIR)\symbols md $(ZLIB_BINDIR)\symbols
+ copy /Y /B $(ZLIB_SRCDIR)\zlib1.pdb $(ZLIB_BINDIR)\symbols\zlib1.pdb >NUL
$(ZLIB_BINDIR)\lib\zdll.exp: $(ZLIB_SRCDIR)\zlib1.dll
@IF NOT EXIST $(ZLIB_BINDIR)\lib md $(ZLIB_BINDIR)\lib
@@ -61,4 +61,9 @@ zlib-clean:
IF EXIST $(ZLIB_SRCDIR) rd /s /q $(ZLIB_SRCDIR)
zlib-really-clean: zlib-clean
- IF EXIST $(ZLIB_ARCHIVE) del $(ZLIB_ARCHIVE)
+ IF EXIST $(ZLIB_ARCHIVE) del $(ZLIB_ARCHIVE)
+
+# The zlib bin tree is structured the same as the PostgreSQL install tree
+# so we can just copy it over.
+zlib-install: zlib
+ xcopy $(ZLIB_BINDIR) $(PGINSTALLDIR) /E /I /F /Y

0 comments on commit 8590469

Please sign in to comment.