[GRASS5] Re: auto-locate EPSG

Markus Neteler neteler at itc.it
Fri Apr 28 15:07:54 EDT 2006


Glynn,

I tried to add you suggestions bug autoconf gives me bad
news. Apparently I made something wrong.

Attached a opatch with your suggestions - may I ask you
to try it (at least autoconf-2.13) and then submit?
Hamish is elected beta tester for Debian :-)

thanks
Markus

On Fri, Apr 28, 2006 at 06:26:29PM +0100, Glynn Clements wrote:
> 
> Markus Neteler wrote:
> 
> > > > configure is autogenerated from configure.in by autoconf-2.13
> > > > So, the file configure.in has to be worked on, not configure.
> > > > Unfortunately a macro seems to be
> > > > missing for the .../share/ stuff, that's why this damn hack is needed.
> > > 
> > > So do we need a LOC_ARG_WITH_SHARE macro to go with the
> > > LOC_ARG_WITH_{INC,LIB} macros? I.e.:
> > > 
> > > aclocal.m4:
> > > 
> > > 	AC_DEFUN(LOC_ARG_WITH_SHARE,[
> > > 	AC_ARG_WITH($1-share,
> > > 	LOC_PAD([  --with-$1-share=DIRS])[$2 data files are in DIRS])
> > > 	])
> 
> Actually, this needs to be a single directory, unless the code which
> locates the file can handle a list of directories. So:
> 
> 	AC_DEFUN(LOC_ARG_WITH_SHARE,[
> 	AC_ARG_WITH($1-share,
> 	LOC_PAD([  --with-$1-share=DIR])[$2 data files are in DIR])
> 	])
> 
> Note that, unlike headers/libraries, where the compiler/linker has a
> default search path, the default value (the empty string) isn't much
> use; the option has to be specified explicitly for the file to be
> found.
> 
> > > configure.in:
> > > 
> > > 	LOC_ARG_WITH_SHARE(proj, External PROJ.4)
> > 
> > Thanks for your help! Do we probably also need to define
> > 
> > LOC_CHECK_SHARE_PATH(proj,External PROJ.4,PROJSHARE)
> 
> Definitely; it's needed to actually read the option value.
> 
> > LOC_CHECK_SHARE(epsg,External PROJ.4,$PROJSHARE)
> 
> Probably a good idea, although the file isn't needed until run-time
> (AFAIK), so the test isn't critical.
> 
> Also, if it's possible to use GRASS at all without that file, it
> should use the 4th argument to generate a warning (the default is a
> fatal error), e.g.:
> 
> 	LOC_CHECK_SHARE(epsg,External PROJ.4,$PROJSHARE,[
> 	AC_MSG_WARN([*** Unable to locate PROJ data files.])
> 	])
> 
> > If not, I don't know how to figure out PROJSHARE (which I then need in
> > include/Make/Platform.make[.in]. If yes, would you mind to write those?
> 
> 	AC_DEFUN(LOC_CHECK_SHARE_PATH,[
> 	AC_MSG_CHECKING(for location of $2 data files)
> 	case "$with_$1_share" in
> 	y | ye | yes | n | no)
> 		AC_MSG_ERROR([*** You must supply a directory to --with-$1-share.])
> 		;;
> 	esac
> 	AC_MSG_RESULT($with_$1_share)
> 	
> 	if test -n "$with_$1_share" ; then
> 	    if test -d "$with_$1_share"; then
> 	        $3="$$3 -I$dir"
> 	    else
> 	        AC_MSG_ERROR([*** $2 data directory $dir does not exist.])
> 	    fi
> 	fi
> 	])
> 
> 	AC_DEFUN(LOC_CHECK_SHARE,[
> 	AC_CHECK_FILE($3/$1, [], ifelse($4,[],[
> 	    AC_MSG_ERROR([*** Unable to locate $2 data files.])
> 	], $4))
> 	])
> 
> -- 
> Glynn Clements <glynn at gclements.plus.com>


-- 
Markus Neteler     <neteler itc it>       http://mpa.itc.it
ITC-irst -  Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18        -       38050 Povo (Trento), Italy
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /grassrepository/grass6/configure.in,v
retrieving revision 1.93
diff -u -r1.93 configure.in
--- configure.in	28 Apr 2006 05:40:28 -0000	1.93
+++ configure.in	28 Apr 2006 19:06:02 -0000
@@ -555,6 +555,7 @@
 
 PROJINC=
 PROJLIB=
+PROJSHARE=
 
 # With PROJ includes directory
 
@@ -580,13 +581,11 @@
 
 LOC_CHECK_LIBS(proj,pj_get_def,External PROJ.4,$PROJLIB,PROJLIB,,,)
 
-# Define share/proj/ directory for epsg code file
-PROJSHARE=
-if test -n "$PROJINC"; then
-        PROJSHARE=/usr/share/proj
-else
-        PROJSHARE=/usr/local/share/proj
-fi
+# With PROJ share directory
+
+LOC_CHECK_SHARE_PATH(proj,External PROJ.4,PROJSHARE)
+
+LOC_CHECK_SHARE(epsg,External PROJ.4,$PROJSHARE)
 
 AC_SUBST(PROJINC)
 AC_SUBST(PROJLIB)
Index: aclocal.m4
===================================================================
RCS file: /grassrepository/grass6/aclocal.m4,v
retrieving revision 1.25
diff -u -r1.25 aclocal.m4
--- aclocal.m4	28 Apr 2006 05:40:28 -0000	1.25
+++ aclocal.m4	28 Apr 2006 19:06:04 -0000
@@ -1466,3 +1466,38 @@
 
 dnl XXXXXXXXXXX End Stolen from cdrtools-2.01 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
+dnl macros to find files in ../share/ directories
+AC_DEFUN(LOC_ARG_WITH_SHARE,[
+AC_ARG_WITH($1-share,
+LOC_PAD([  --with-$1-share=DIR])[$2 data files are in DIR])
+])
+
+dnl check for epsg file and friends in proj
+AC_DEFUN(LOC_CHECK_SHARE_PATH,[
+AC_MSG_CHECKING(for location of $2 data files)
+case "$with_$1_share" in
+y | ye | yes | n | no)
+        AC_MSG_ERROR([*** You must supply a directory to --with-$1-share.])
+        ;;
+esac
+AC_MSG_RESULT($with_$1_share)
+
+if test -n "$with_$1_share" ; then
+    if test -d "$with_$1_share"; then
+        $3="$$3 -I$dir"
+    else
+        AC_MSG_ERROR([*** $2 data directory $dir does not exist.])
+    fi
+fi
+])
+
+AC_DEFUN(LOC_CHECK_SHARE,[
+AC_CHECK_FILE($3/$1, [], ifelse($4,[],[
+    AC_MSG_ERROR([*** Unable to locate $2 data files.])
+], $4))
+])
+
+LOC_CHECK_SHARE(epsg,External PROJ.4,$PROJSHARE,[
+AC_MSG_WARN([*** Unable to locate PROJ data files.])
+])
+


More information about the grass-dev mailing list