1#
2# m4 configure macros specific to Img.
3#
4
5AC_DEFUN(IMG_SRCPATH, [
6#--------------------------------------------------------------------
7# Compute an absolute path to the src directory of module '$1' so
8# that we are able to find its headers even if they are not installed.
9#--------------------------------------------------------------------
10
11case [$]$1_SRC_DIR in
12/*)	$1_SRC_PATH=[$]$1_SRC_DIR
13	;;
14*)	# SRC_DIR relative, splice with BUILD_PATH
15	$1_SRC_PATH="`dirname [$]$1_BUILD_STUB_LIB_PATH`/[$]$1_SRC_DIR"
16esac
17
18$1_BUILD_PATH="`dirname [$]$1_BUILD_STUB_LIB_PATH`"
19
20if test "[$]{TEA_PLATFORM}" = "windows" ; then
21    $1_SRC_PATH="`[$]CYGPATH [$]$1_SRC_PATH`"
22    $1_BUILD_PATH="`[$]CYGPATH [$]$1_BUILD_PATH`"
23fi
24
25AC_SUBST($1_SRC_PATH)
26AC_SUBST($1_BUILD_PATH)
27])
28
29#
30# Add here whatever m4 macros you want to define for your package
31#
32
33AC_DEFUN(TEA_CONFIG_SUBDIR, [
34    tea_config_dir="$1"
35    tea_config_arguments="$2"
36    subdirs="$subdirs $tea_config_dir"
37    AC_SUBST(subdirs)
38
39    # Do not complain, so a configure script can configure whichever
40    # parts of a large source tree are present.
41    if test ! -d $srcdir/$tea_config_dir; then
42      continue
43    fi
44
45    echo configuring in $tea_config_dir
46
47    case "$srcdir" in
48    .) ;;
49    *)
50      if test -d ./$tea_config_dir || mkdir -p ./$tea_config_dir; then :;
51      else
52        { echo "configure: error: can not create `pwd`/$tea_config_dir" 1>&2; exit 1; }
53      fi
54      ;;
55    esac
56
57    tea_popdir=`pwd`
58    cd $tea_config_dir
59
60      # A "../" for each directory in /$tea_config_dir.
61      tea_dots=`echo $tea_config_dir|sed -e 's%^\./%%' -e ['s%[^/]$%&/%'] -e ['s%[^/]*/%../%g']`
62
63    case "$srcdir" in
64    .) # No --srcdir option.  We are building in place.
65      tea_sub_srcdir=$srcdir ;;
66    /*) # Absolute path.
67      tea_sub_srcdir=$srcdir/$tea_config_dir ;;
68    *) # Relative path.
69      tea_sub_srcdir=$tea_dots$srcdir/$tea_config_dir ;;
70    esac
71
72    # Check for guested configure; otherwise get Cygnus style configure.
73    if test -f $tea_sub_srcdir/configure; then
74      tea_sub_configure=$tea_sub_srcdir/configure
75    elif test -f $tea_sub_srcdir/configure.in; then
76      tea_sub_configure=$tea_configure
77    else
78      echo "configure: warning: no configuration information is in $tea_config_dir" 1>&2
79      tea_sub_configure=
80    fi
81
82    # The recursion is here.
83    if test -n "$tea_sub_configure"; then
84
85      # Force usage of a cache file.
86      if test "X$cache_file" = "X/dev/null" ; then
87	cache_file=config.cache
88      fi
89
90      # Make the cache file name correct relative to the subdirectory.
91      case "$cache_file" in
92      /*) tea_sub_cache_file=$cache_file ;;
93      *) # Relative path.
94        tea_sub_cache_file="$tea_dots$cache_file" ;;
95      esac
96
97      echo "running ${CONFIG_SHELL-/bin/sh} $tea_sub_configure $tea_sub_configure_args --cache-file=$tea_sub_cache_file --srcdir=$tea_sub_srcdir $tea_config_arguments"
98      # The eval makes quoting arguments work.
99      if eval ${CONFIG_SHELL-/bin/sh} $tea_sub_configure $tea_sub_configure_args --cache-file=$tea_sub_cache_file --srcdir=$tea_sub_srcdir $tea_config_arguments
100      then :
101      else
102        { echo "configure: error: $tea_sub_configure failed for $tea_config_dir" 1>&2; exit 1; }
103      fi
104    fi
105
106    cd $tea_popdir
107])
108
109
110AC_DEFUN(TEA_CONFIG_COLLECT, [
111  tea_sub_configure_args=
112  tea_prev=
113  for tea_arg in $ac_configure_args; do
114    if test -n "$tea_prev"; then
115      tea_prev=
116      continue
117    fi
118    case "$tea_arg" in
119    -cache-file | --cache-file | --cache-fil | --cache-fi \
120    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
121      tea_prev=cache_file ;;
122    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
123    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
124      ;;
125    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
126      tea_prev=srcdir ;;
127    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
128      ;;
129    *) tea_sub_configure_args="$tea_sub_configure_args $tea_arg" ;;
130    esac
131  done
132])
133
134