##### http://autoconf-archive.cryp.to/ac_as_dirname.html # # OBSOLETE MACRO # # Autoconf 2.5x makes this unnecessary. # # SYNOPSIS # # AC_AS_DIRNAME (PATH) # # DESCRIPTION # # this is the macro AS_DIRNAME from autoconf 2.4x defined here for # use in autoconf 2.1x, remove the AC_ when you use 2.4x # # LAST MODIFICATION # # 2006-10-13 # # COPYLEFT # # Copyright (c) 2006 Guido U. Draheim # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # As a special exception, the respective Autoconf Macro's copyright # owner gives unlimited permission to copy, distribute and modify the # configure scripts that are the output of Autoconf when processing # the Macro. You need not follow the terms of the GNU General Public # License when using or distributing such scripts, even though # portions of the text of the Macro appear in them. The GNU General # Public License (GPL) does govern all other use of the material that # constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the # Autoconf Macro released by the Autoconf Macro Archive. When you # make and distribute a modified version of the Autoconf Macro, you # may extend this special exception to the GPL to apply to your # modified version as well. AC_DEFUN([AC_ECHO_MKFILE], [dnl case $2 in */*) P=` AC_AS_DIRNAME($2) ` ; AC_AS_MKDIR_P($P) ;; esac echo "$1" >$2 ]) AC_DEFUN([AC_AS_DIRNAME], [AC_AS_DIRNAME_EXPR([$1]) 2>/dev/null || AC_AS_DIRNAME_SED([$1]) ]) # _AC_AS_EXPR_PREPARE # ---------------- # Some expr work properly (i.e. compute and issue the right result), # but exit with failure. When a fall back to expr (as in AS_DIRNAME) # is provided, you get twice the result. Prevent this. AC_DEFUN([_AC_AS_EXPR_PREPARE], [if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi ])# _AC_AS_EXPR_PREPARE # AS_DIRNAME(PATHNAME) # -------------------- # Simulate running `dirname(1)' on PATHNAME, not all systems have it. # This macro must be usable from inside ` `. # # Prefer expr to echo|sed, since expr is usually faster and it handles # backslashes and newlines correctly. However, older expr # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have # a silly length limit that causes expr to fail if the matched # substring is longer than 120 bytes. So fall back on echo|sed if # expr fails. # # FIXME: Please note the following m4_require is quite wrong: if the first # occurrence of AS_DIRNAME_EXPR is in a backquoted expression, the # shell will be lost. We might have to introduce diversions for # setting up an M4sh script: required macros will then be expanded there. AC_DEFUN([AC_AS_DIRNAME_EXPR], [AC_REQUIRE([_AC_AS_EXPR_PREPARE])dnl $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \ X[]$1 : 'X\(//\)[[^/]]' \| \ X[]$1 : 'X\(//\)$' \| \ X[]$1 : 'X\(/\)' \| \ . : '\(.\)']) AC_DEFUN([AC_AS_DIRNAME_SED], [echo X[]$1 | sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q']])