[OSM-dev] [PATCH] osm2pgsql install and prefix

strk strk at keybit.net
Mon Apr 5 22:02:28 BST 2010


On Mon, Apr 05, 2010 at 11:49:12AM -0700, Dane Springmeyer wrote:

> great stuff. I'd also be +1 on an autoconf script!

Find it attached :)

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html
-------------- next part --------------
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 0)
+++ Makefile.in	(revision 0)
@@ -0,0 +1,80 @@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sysconfdir = @sysconfdir@
+datarootdir = @datarootdir@
+datadir = @datadir@
+
+PACKAGE = @PACKAGE_NAME@
+VERSION = @PACKAGE_VERSION@
+SVN:=$(shell svnversion)
+DATADIR = $(datadir)/$(PACKAGE)
+
+
+CC = @CC@ 
+
+CFLAGS += -g -O2 -Wall -Wextra
+CFLAGS += $(shell xml2-config --cflags)
+CFLAGS += $(shell geos-config --cflags)
+CFLAGS += -I$(shell pg_config --includedir)
+CFLAGS += -DVERSION=\"$(VERSION)-$(SVN)\"
+CFLAGS += -DHAVE_PTHREAD
+CFLAGS += -DDATADIR=\"$(DATADIR)\"
+
+LDFLAGS += $(shell xml2-config --libs) 
+LDFLAGS += $(shell geos-config --libs)
+LDFLAGS += -L$(shell pg_config --libdir) -lpq
+LDFLAGS += -lbz2 -lz
+LDFLAGS += -g -lproj
+LDFLAGS += -lstdc++
+LDFLAGS += -lpthread
+
+SRCS:=$(wildcard *.c) $(wildcard *.cpp)
+OBJS:=$(SRCS:.c=.o)
+OBJS:=$(OBJS:.cpp=.o)
+DEPS:=$(SRCS:.c=.d)
+DEPS:=$(DEPS:.cpp=.d)
+
+APPS:=osm2pgsql
+DATA:=default.style
+
+.PHONY: all clean $(PACKAGE).spec
+
+all: $(APPS)
+
+clean: 
+	rm -f $(APPS) $(OBJS) $(DEPS)
+	rm -f $(PACKAGE)-*.tar.bz2
+	rm -f osm2pgsql.spec
+
+install: $(APPS)
+	mkdir -p $(DESTDIR)$(bindir)
+	install -m 0755 $(APPS) $(DESTDIR)$(bindir)
+	mkdir -p $(DESTDIR)$(DATADIR)
+	install -m 0644 $(DATA) $(DESTDIR)$(DATADIR)
+
+%.d: %.c
+	@set -e; rm -f $@; \
+	$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+	rm -f $@.$$$$
+
+-include $(DEPS)
+
+osm2pgsql: $(OBJS)
+	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
+
+$(PACKAGE).spec: $(PACKAGE).spec.in
+	sed -e "s/@PACKAGE@/$(PACKAGE)/g; s/@VERSION@/$(VERSION)/g; s/@SVN@/$(SVN)/g;" $^ > $@
+
+$(PACKAGE)-$(VERSION).tar.bz2: $(PACKAGE).spec
+	rm -fR tmp
+	mkdir -p tmp/osm2pgsql
+	cp -p Makefile *.[ch] *.cpp README.txt osm2pgsql-svn.sh tmp/osm2pgsql
+	cp -p osm2pgsql.spec tmp/
+	tar cjf $@ -C tmp .
+	rm -fR tmp
+
+rpm: $(PACKAGE)-$(VERSION).tar.bz2
+	rpmbuild -ta $^
Index: configure.ac
===================================================================
--- configure.ac	(revision 0)
+++ configure.ac	(revision 0)
@@ -0,0 +1,12 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(osm2pgsql, 0.69)
+
+dnl Generate configuration header file
+AC_CONFIG_HEADER(config.h)
+
+dnl Find C compiler
+AC_PROG_CC
+
+dnl Generate Makefile
+AC_OUTPUT(Makefile)
+
Index: osm2pgsql.c
===================================================================
--- osm2pgsql.c	(revision 20788)
+++ osm2pgsql.c	(working copy)
@@ -523,7 +523,7 @@
     fprintf(stderr, "   -p|--prefix\t\tPrefix for table names (default planet_osm)\n");
     fprintf(stderr, "   -s|--slim\t\tStore temporary data in the database. This greatly\n");
     fprintf(stderr, "            \t\treduces the RAM usage but is much slower.\n");
-    fprintf(stderr, "   -S|--style\t\tLocation of the style file. Defaults to /usr/share/osm2pgsql/default.style\n");
+    fprintf(stderr, "   -S|--style\t\tLocation of the style file. Defaults to "DATADIR"/default.style\n");
     fprintf(stderr, "   -C|--cache\t\tOnly for slim mode: Use upto this many MB for caching nodes\n");
     fprintf(stderr, "             \t\tDefault is 800\n");
     fprintf(stderr, "   -U|--username\tPostgresql user name.\n");
@@ -645,7 +645,7 @@
     const char *port = "5432";
     const char *conninfo = NULL;
     const char *prefix = "planet_osm";
-    const char *style = "/usr/share/osm2pgsql/default.style";
+    const char *style = DATADIR"/default.style";
     const char *temparg;
     const char *output_backend = "pgsql";
     int cache = 800;
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 0)
+++ autogen.sh	(revision 0)
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoconf

Property changes on: autogen.sh
___________________________________________________________________
Added: svn:executable
   + *

Index: config.h.in
===================================================================
--- config.h.in	(revision 0)
+++ config.h.in	(revision 0)
@@ -0,0 +1,12 @@
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
Index: README.txt
===================================================================
--- README.txt	(revision 20788)
+++ README.txt	(working copy)
@@ -64,7 +64,7 @@
 # yum install geos-devel proj-devel postgresql-devel libxml2-devel bzip2-devel gcc-c++
 
 On most Unix-like systems the program can be compiled by
-running 'make'.
+running './configure && make'.
 
 Operation
 =========


More information about the dev mailing list