Find file
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (65 sloc) 2.79 KB
#
# Build PostgreSQL
#
!IFDEF PG_GIT_REFERENCE
PG_GIT_REFERENCE_CMDSNIP=--reference $(PG_GIT_REFERENCE)
!ELSE
PG_GIT_REFERENCE_CMDSNIP=
!ENDIF
!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 $(PG_GIT_REFERENCE_CMDSNIP) -b "$(PG_BRANCH)" "$(PG_GIT_URL)" "$(PGBUILDDIR)"
cd $(PGBUILDDIR)
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.
#
# The weird hack with tee works around an odd stdio issue that seems to occur
# on some machines with some consoles and some SDK versions with some Perl versions.
# Which ones? Never did work it out.
#
postgresql: zlib $(PGBUILDDIR) $(CONFIG_PL) $(BUILDENV_PL)
cd $(PGBUILDDIR)\src\tools\msvc
!IFDEF TEE
"$(PERL_CMD)" build.pl $(CONFIGURATION) 2>&1 | tee build-log.log
!ELSE
"$(PERL_CMD)" build.pl $(CONFIGURATION)
!ENDIF
!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
postgresql-install: postgresql
cd $(PGBUILDDIR)\src\tools\msvc
install.bat $(PGINSTALLDIR)
postgresql-fullcheck: postgresql-install
cd $(PGBUILDDIR)\src\tools\msvc
$(PGINSTALLDIR)\bin\initdb -D $(PGBUILDDIR)\temp-install
$(PGINSTALLDIR)\bin\pg_ctl start -w -D $(PGBUILDDIR)\temp-install -s -l $(PGBUILDDIR)\temp-install.log
"$(PERL_CMD)" vcregress.pl installcheck
rem "$(PERL_CMD)" vcregress.pl plcheck
"$(PERL_CMD)" vcregress.pl contribcheck
"$(PERL_CMD)" vcregress.pl upgradecheck
$(PGINSTALLDIR)\bin\pg_ctl stop -w -D $(PGBUILDDIR)\temp-install -m immediate