[postgis-devel] building 1.4.1 on NetBSD

Greg Troxel gdt at ir.bbn.com
Wed Jan 27 16:32:19 PST 2010


Thanks to some of the people who work on pkgsrc-wip.sourceforge.net,
there is now a postgis package in pkgsrc.  To get this to work a few
patches were needed, and for some of these changes, I don't understand
how it builds on other systems.

I am testing with 8.4, with pgxs files from 8.4.  With the below
patches, postgis passes make check.

The big issue was that liblwgeom is built into a .a and then included to
form the postgis.so module.  libtool complains that this is improper and
doesn't include liblwgeom, and thus nothing works.

A minor issue is that where postgis.sql looks for the module is
different than where the build puts it.

So, the changes are

1) Use libtool to compile files, rather than making a static library
that is later expected to be linked into a shlib.

2) Change the path to look for the postgis module as

/usr/pkg/lib/libpostgis-1.4.so:

rather than as postgis-1.4.so.

I didn't make these changes, so I am not 100% clear on them.  But I did
run into both problems.


$NetBSD: patch-aa,v 1.1.1.1 2010/01/21 12:53:19 adam Exp $

--- postgis/Makefile.in.orig	2009-11-13 22:26:00.000000000 +0000
+++ postgis/Makefile.in
@@ -60,7 +60,7 @@ OBJS=$(PG_OBJS)
 # older version of PostGIS, rather than with the static liblwgeom.a 
 # supplied with newer versions of PostGIS
 PG_CPPFLAGS+=@CPPFLAGS@ -I../liblwgeom
-SHLIB_LINK+=@SHLIB_LINK@ ../liblwgeom/liblwgeom.a
+SHLIB_LINK+=@SHLIB_LINK@ ../liblwgeom/liblwgeom.la
 
 # Extra files to remove during 'make clean'
 EXTRA_CLEAN=$(SQL_OBJS)
@@ -73,7 +73,7 @@ include $(PGXS)
 
 # Borrow the $libdir substitution from PGXS but customise by adding the version number
 %.sql: %.sql.in
-	sed 's,MODULE_PATHNAME,$$libdir/$*- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@,g' $< >$@
+	sed 's,MODULE_PATHNAME,$$libdir/../lib$*- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@,g' $< >$@
 
 postgis_upgrade_14_minor.sql: postgis.sql
 	$(PERL) ../utils/postgis_proc_upgrade.pl $< 1.4 > $@


$NetBSD: patch-ab,v 1.1.1.1 2010/01/21 12:53:19 adam Exp $

--- liblwgeom/Makefile.in.orig	2009-01-13 12:27:39.000000000 +0000
+++ liblwgeom/Makefile.in
@@ -48,10 +48,12 @@ SA_HEADERS = \
 	liblwgeom.h \
 	lwalgorithm.h
 
-all: liblwgeom.a
+all: liblwgeom.la
 
-liblwgeom.a: $(SA_OBJS) $(SA_HEADERS) 
-	ar rs liblwgeom.a $(SA_OBJS) 	
+liblwgeom.la: $(SA_OBJS) $(SA_HEADERS) 
+	${LIBTOOL} --mode=link ${CC} -o liblwgeom.la \
+		${SA_OBJS:.o=.lo} -rpath ${PREFIX}/lib \
+		-version-info @POSTGIS_MAJOR_VERSION@:@POSTGIS_MINOR_VERSION@
 
 clean:
 	rm -f $(SA_OBJS) 
@@ -62,7 +64,7 @@ check: liblwgeom.a
 
 # Command to build each of the .o files
 $(SA_OBJS): %.o: %.c 
-	$(CC) $(CFLAGS) -c -o $@ $<
+	${LIBTOOL} --mode=compile $(CC) $(CFLAGS) -c -o $@ $<
 
 # Commands to generate the lexer and parser from input files
 wktparse.tab.c: wktparse.y


$NetBSD: patch-ac,v 1.1.1.1 2010/01/21 12:53:19 adam Exp $

--- loader/Makefile.in.orig	2009-10-06 08:51:49.000000000 +0000
+++ loader/Makefile.in
@@ -39,7 +39,7 @@ PGSQL_FE_LDFLAGS=@PGSQL_FE_LDFLAGS@
 ICONV_LDFLAGS=@ICONV_LDFLAGS@
 
 # liblwgeom
-LIBLWGEOM=../liblwgeom/liblwgeom.a
+LIBLWGEOM=../liblwgeom/liblwgeom.la
 
 # GTK includes and libraries
 GTK_CFLAGS = @GTK_CFLAGS@
@@ -60,10 +60,10 @@ pgsql2shp.o: pgsql2shp.c
 	$(CC) $(CFLAGS) $(PGSQL_FE_CPPFLAGS) -c $<
 
 $(PGSQL2SHP): shpopen.o dbfopen.o getopt.o pgsql2shp.o $(LIBLWGEOM) 
-	$(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm -o $@ 
+	${LIBTOOL} --mode=link $(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm -o $@ 
 
 $(SHP2PGSQL): shpopen.o dbfopen.o getopt.o  shp2pgsql.o $(LIBLWGEOM) 
-	$(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) -lm -o $@ 
+	${LIBTOOL} --mode=link $(CC) $(CFLAGS) $^ $(ICONV_LDFLAGS) -lm -o $@ 
 
 shp2pgsql-core-gui.o: shp2pgsql-core.c
 	$(CC) $(CFLAGS) -DPGUI -c -o $@ $^
@@ -79,8 +79,8 @@ $(SHP2PGSQL-CLI): stringbuffer.o shpopen
 
 install: all
 	@mkdir -p $(DESTDIR)$(bindir)
-	$(INSTALL) $(PGSQL2SHP) $(DESTDIR)$(bindir)
-	$(INSTALL) $(SHP2PGSQL) $(DESTDIR)$(bindir)
+	${LIBTOOL} --mode=install ${BSD_INSTALL_PROGRAM} $(PGSQL2SHP) $(DESTDIR)$(bindir)
+	${LIBTOOL} --mode=install ${BSD_INSTALL_PROGRAM} $(SHP2PGSQL) $(DESTDIR)$(bindir)
 
 uninstall:
 	@rm -f $(DESTDIR)$(bindir)/$(PGSQL2SHP)


The set of files installed is:

Information for postgresql84-postgis-1.4.1:

Files:
/usr/pkg/bin/pgsql2shp
/usr/pkg/bin/shp2pgsql
/usr/pkg/lib/liblwgeom.la
/usr/pkg/lib/liblwgeom.a
/usr/pkg/lib/liblwgeom.so
/usr/pkg/lib/liblwgeom.so.1
/usr/pkg/lib/liblwgeom.so.1.0.4
/usr/pkg/lib/libpostgis-1.4.la
/usr/pkg/lib/libpostgis-1.4.a
/usr/pkg/lib/libpostgis-1.4.so
/usr/pkg/lib/libpostgis-1.4.so.0
/usr/pkg/lib/libpostgis-1.4.so.0.0.0
/usr/pkg/man/man1/pgsql2shp.1
/usr/pkg/man/man1/shp2pgsql.1
/usr/pkg/share/doc/postgis/README.postgis
/usr/pkg/share/doc/postgis/images/caution.png
/usr/pkg/share/doc/postgis/images/check.png
/usr/pkg/share/doc/postgis/images/important.png
/usr/pkg/share/doc/postgis/images/note.png
/usr/pkg/share/doc/postgis/images/st_buffer01.png
/usr/pkg/share/doc/postgis/images/st_buffer02.png
/usr/pkg/share/doc/postgis/images/st_buildarea01.png
/usr/pkg/share/doc/postgis/images/st_buildarea02.png
/usr/pkg/share/doc/postgis/images/st_centroid01.png
/usr/pkg/share/doc/postgis/images/st_centroid02.png
/usr/pkg/share/doc/postgis/images/st_centroid03.png
/usr/pkg/share/doc/postgis/images/st_centroid04.png
/usr/pkg/share/doc/postgis/images/st_contains01.png
/usr/pkg/share/doc/postgis/images/st_contains02.png
/usr/pkg/share/doc/postgis/images/st_contains03.png
/usr/pkg/share/doc/postgis/images/st_contains04.png
/usr/pkg/share/doc/postgis/images/st_contains05.png
/usr/pkg/share/doc/postgis/images/st_contains06.png
/usr/pkg/share/doc/postgis/images/st_convexhull01.png
/usr/pkg/share/doc/postgis/images/st_crosses-math.gif
/usr/pkg/share/doc/postgis/images/st_crosses01.gif
/usr/pkg/share/doc/postgis/images/st_crosses01.png
/usr/pkg/share/doc/postgis/images/st_crosses02.gif
/usr/pkg/share/doc/postgis/images/st_crosses02.png
/usr/pkg/share/doc/postgis/images/st_crosses03.gif
/usr/pkg/share/doc/postgis/images/st_crosses03.png
/usr/pkg/share/doc/postgis/images/st_crosses04.gif
/usr/pkg/share/doc/postgis/images/st_crosses04.png
/usr/pkg/share/doc/postgis/images/st_difference01.png
/usr/pkg/share/doc/postgis/images/st_issimple01.png
/usr/pkg/share/doc/postgis/images/st_issimple02.png
/usr/pkg/share/doc/postgis/images/st_issimple03.png
/usr/pkg/share/doc/postgis/images/st_issimple04.png
/usr/pkg/share/doc/postgis/images/st_issimple05.png
/usr/pkg/share/doc/postgis/images/st_issimple06.png
/usr/pkg/share/doc/postgis/images/st_issimple07.png
/usr/pkg/share/doc/postgis/images/st_isvalid01.png
/usr/pkg/share/doc/postgis/images/st_isvalid02.png
/usr/pkg/share/doc/postgis/images/st_isvalid03.png
/usr/pkg/share/doc/postgis/images/st_isvalid04.png
/usr/pkg/share/doc/postgis/images/st_isvalid05.png
/usr/pkg/share/doc/postgis/images/st_isvalid06.png
/usr/pkg/share/doc/postgis/images/st_isvalid07.png
/usr/pkg/share/doc/postgis/images/st_isvalid08.png
/usr/pkg/share/doc/postgis/images/st_line_interpolate_point01.png
/usr/pkg/share/doc/postgis/images/st_line_substring01.png
/usr/pkg/share/doc/postgis/images/st_linecrossingdirection01.png
/usr/pkg/share/doc/postgis/images/st_linecrossingdirection02.png
/usr/pkg/share/doc/postgis/images/st_linecrossingdirection03.png
/usr/pkg/share/doc/postgis/images/st_linecrossingdirection04.png
/usr/pkg/share/doc/postgis/images/st_minimumboundingcircle01.png
/usr/pkg/share/doc/postgis/images/st_symdifference01.png
/usr/pkg/share/doc/postgis/images/st_symdifference02.png
/usr/pkg/share/doc/postgis/images/st_touches-math.gif
/usr/pkg/share/doc/postgis/images/st_touches01.png
/usr/pkg/share/doc/postgis/images/st_touches02.png
/usr/pkg/share/doc/postgis/images/st_touches03.png
/usr/pkg/share/doc/postgis/images/st_touches04.png
/usr/pkg/share/doc/postgis/images/st_touches05.png
/usr/pkg/share/doc/postgis/images/st_touches06.png
/usr/pkg/share/doc/postgis/images/st_within01.png
/usr/pkg/share/doc/postgis/images/tip.png
/usr/pkg/share/doc/postgis/images/warning.png
/usr/pkg/share/doc/postgis/postgis.html
/usr/pkg/share/doc/postgis/style.css
/usr/pkg/share/postgresql/contrib/postgis.sql
/usr/pkg/share/postgresql/contrib/postgis_comments.sql
/usr/pkg/share/postgresql/contrib/postgis_upgrade_12_to_14.sql
/usr/pkg/share/postgresql/contrib/postgis_upgrade_13_to_14.sql
/usr/pkg/share/postgresql/contrib/postgis_upgrade_14_minor.sql
/usr/pkg/share/postgresql/contrib/spatial_ref_sys.sql
/usr/pkg/share/postgresql/contrib/uninstall_postgis.sql

And the library links like this:

/usr/pkg/lib/libpostgis-1.4.so:
	-lc.12 => /usr/lib/libc.so.12
	-lstdc++.6 => /usr/lib/libstdc++.so.6
	-lm.0 => /usr/lib/libm.so.0
	-lgcc_s.1 => /usr/lib/libgcc_s.so.1
	-lgeos-3.2.0 => /usr/pkg/lib/libgeos-3.2.0.so
	-lgeos_c.1 => /usr/pkg/lib/libgeos_c.so.1
	-lproj.0 => /usr/pkg/lib/libproj.so.0
	-llwgeom.1 => /usr/pkg/lib/liblwgeom.so.1

/usr/pkg/lib/liblwgeom.so.1:
	-lc.12 => /usr/lib/libc.so.12


$ pg_config
BINDIR = /usr/pkg/bin
DOCDIR = /usr/pkg/share/doc/postgresql
HTMLDIR = /usr/pkg/share/doc/postgresql
INCLUDEDIR = /usr/pkg/include
PKGINCLUDEDIR = /usr/pkg/include/postgresql
INCLUDEDIR-SERVER = /usr/pkg/include/postgresql/server
LIBDIR = /usr/pkg/lib
PKGLIBDIR = /usr/pkg/lib/postgresql
LOCALEDIR = /usr/pkg/share/locale
MANDIR = /usr/pkg/man
SHAREDIR = /usr/pkg/share/postgresql
SYSCONFDIR = /usr/pkg/etc/postgresql
PGXS = /usr/pkg/lib/postgresql/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--sysconfdir=/usr/pkg/etc/postgresql' '--datadir=/usr/pkg/share/postgresql' '--localedir=/usr/pkg/share/locale' '--with-docdir=/usr/pkg/share/doc/postgresql' '--with-template=netbsd' '--without-readline' '--without-zlib' '--enable-nls' '--without-perl' '--without-python' '--without-tcl' '--with-openssl' '--with-readline' '--with-zlib' '--enable-thread-safety' '--without-libintl-prefix' '--without-libiconv-prefix' '--prefix=/usr/pkg' '--build=i386--netbsdelf' '--host=i386--netbsdelf' '--mandir=/usr/pkg/man' 'build_alias=i386--netbsdelf' 'host_alias=i386--netbsdelf' 'CC=cc' 'CFLAGS=-O2 -I/usr/include -I/usr/pkg/include' 'LDFLAGS=-L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib' 'LIBS=' 'CPPFLAGS=-I/usr/include -I/usr/pkg/include'
CC = cc
CPPFLAGS = -I/usr/include -I/usr/pkg/include
CFLAGS = -O2 -I/usr/include -I/usr/pkg/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv
CFLAGS_SL = -fpic -DPIC
LDFLAGS = -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -Wl,--as-needed -Wl,-R'/usr/pkg/lib'
LDFLAGS_SL = 
LIBS = -lpgport -lintl -lssl -lcrypto -lz -lreadline -lcurses -lcrypt -lm 
VERSION = PostgreSQL 8.4.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20100127/54008650/attachment.sig>


More information about the postgis-devel mailing list