Commit 10fc02f7 authored by Sandro Santilli's avatar Sandro Santilli
Browse files

Use an SQLPP command for pre-processing SQL files (#1694)

The SQLPP command is figured at ./configure time.
It will use cpp(1) or gpp(1) if any is found in that order or
fallback to whatever CPP expands to (usually the compiler with -E)

git-svn-id: http://svn.osgeo.org/postgis/trunk@9639 b70326c6-7e19-0410-871a-916f4a2858ee
parent 6fcbf77e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -28,6 +28,22 @@ AC_PROG_CXX
AC_PATH_PROG([ANT], [ant], [])
AC_SUBST([ANT])

dnl
dnl SQL Preprocessor
dnl
AC_PATH_PROG([CPPBIN], [cpp], [])
if test "x$CPPBIN" != "x"; then
  SQLPP="${CPPBIN} -traditional-cpp -P"
else
  AC_PATH_PROG([GPP], [gpp_], [])
  if test "x$GPP" != "x"; then
    SQLPP="${GPP} -C -s \'" dnl Use better string support
  else
    SQLPP="${CPP} -traditional-cpp"
  fi
fi
AC_SUBST([SQLPP])

dnl
dnl Define PIC flags in PICFLAGS (note: this variable is set as part of libtool initialisation above)
dnl
@@ -1104,6 +1120,7 @@ AC_MSG_RESULT()
AC_MSG_RESULT([ -------------- Compiler Info ------------- ])
AC_MSG_RESULT([  C compiler:           ${CC} ${CFLAGS}])
AC_MSG_RESULT([  C++ compiler:         ${CXX} ${CXXFLAGS}])
AC_MSG_RESULT([  SQL preprocessor:     ${SQLPP}])
AC_MSG_RESULT()
AC_MSG_RESULT([ -------------- Dependencies -------------- ])
AC_MSG_RESULT([  GEOS config:          ${GEOSCONFIG}])
+6 −3
Original line number Diff line number Diff line
@@ -18,7 +18,10 @@ MODULEDIR=contrib/$(MODULE_big)
DATA_built=postgis.sql uninstall_postgis.sql postgis_upgrade_20_minor.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql
DATA=../spatial_ref_sys.sql

# SQL objects (files requiring C pre-processing)
# SQL preprocessor
SQLPP = @SQLPP@

# SQL objects (files requiring pre-processing)
SQL_OBJS=postgis.sql.in legacy.sql.in legacy_minimal.sql.in 

# PostgreSQL objects
@@ -128,9 +131,9 @@ postgis_upgrade_20_minor.sql.in: postgis_drop_before.sql postgis.sql postgis_dro
postgis_upgrade_20_minor.sql: postgis_upgrade_20_minor.sql.in ../utils/postgis_proc_upgrade.pl 
	$(PERL) ../utils/postgis_proc_upgrade.pl $< 2.0 > $@

# Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
# Generate any .sql.in files from .sql.in.c files by running them through the SQL pre-processor 
$(SQL_OBJS): %.in: %.in.c
	$(CPP) -traditional-cpp -I../libpgcommon $< | grep -v '^#' > $@
	$(SQLPP) -I../libpgcommon $< | grep -v '^#' > $@

# SQL objects are also dependent on postgis_config.h for PostgreSQL version
$(SQL_OBJS): ../postgis_config.h ../postgis_svn_revision.h
+6 −3
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@ MODULEDIR=contrib/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
DATA_built=rtpostgis.sql rtpostgis_upgrade_20_minor.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql
DATA=

# SQL objects (files requiring C pre-processing)
# SQL preprocessor
SQLPP = @SQLPP@

# SQL objects (files requiring pre-processing)
SQL_OBJS=rtpostgis.sql.in rtpostgis_drop.sql.in rtpostgis_upgrade_cleanup.sql.in rtpostgis_legacy.sql.in

# Objects to build using PGXS
@@ -87,9 +90,9 @@ endif
# Objects dependencies
$(OBJS): ../../liblwgeom/.libs/liblwgeom.a ../../libpgcommon/libpgcommon.a ../../postgis_config.h ../../postgis_svn_revision.h

# Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
# Generate any .sql.in files from .sql.in.c files by running them through the SQL pre-processor 
$(SQL_OBJS): %.in: %.in.c
	$(CPP) -I../../postgis/ -I../../ -traditional-cpp $< | grep -v '^#' > $@
	$(SQLPP) -I../../postgis/ -I../../ $< | grep -v '^#' > $@

# SQL objects deps here
$(SQL_OBJS): ../../postgis/sqldefines.h ../../postgis_svn_revision.h
+6 −3
Original line number Diff line number Diff line
@@ -26,7 +26,10 @@ MODULEDIR=contrib/$(PGIS_MODULE_big)
# Files to be copied to the contrib/ directory
DATA_built=topology.sql topology_upgrade_20_minor.sql uninstall_topology.sql

# SQL objects (files requiring C pre-processing)
# SQL preprocessor
SQLPP = @SQLPP@

# SQL objects (files requiring pre-processing)
SQL_OBJS = \
  topology.sql \
  topology_upgrade.sql \
@@ -73,9 +76,9 @@ endif
%.sql: %.sql.in
	sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@

# Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
# Generate any .sql.in files from .sql.in.c files by running them through the SQL pre-processor 
%.in: %.in.c
	$(CPP) -traditional-cpp $< | grep -v '^#' > $@
	$(SQLPP) $< | grep -v '^#' > $@
	
#Generate upgrade script by stripping things that can't be reinstalled
#e.g. don't bother with tables, types, triggers, and domains