beta-0.89.2
[luatex.git] / source / libs / zziplib / zziplib-0.13.62 / m4 / ax_spec_file.m4
blobc80a75a4e040c97c3a64abd389567d9d7070e30f
1 dnl /usr/share/aclocal/guidod-cvs/ax_spec_file.m4
2 dnl @synopsis AX_SPEC_FILE [(rpmspecfile [,subdirpath])]
3 dnl
4 dnl set the specfile - if no argument has been given then check whether
5 dnl the ac_unique_file looks like a .spec file and use it. This macro
6 dnl is ac_REQUIRED by many AX_SPEC_ routines.
7 dnl
8 dnl the AX_SPEC_EXTRACT macro is a helper used by many AX_SPEC_
9 dnl routines and therefore placed here to be automatically included in
10 dnl the macro set of (older) aclocal/acinclude.
11 dnl
12 dnl AX_SPEC_EXTRACT(shellvar [,specvar [,defaultvalue]])
13 dnl
14 dnl @category Misc
15 dnl @author Guido U. Draheim <guidod@gmx.de>
16 dnl @version 2005-01-21
17 dnl @license GPLWithACException
19 AC_DEFUN([AX_SPEC_FILE],
20 [ AC_MSG_CHECKING([rpm spec file])
21   if test ".$1" != "." ; then
22     ax_spec_file_="$1"
23     ax_spec_file=`basename $1`
24   else
25     case ".$ac_unique_file" in
26       *.spec) ax_spec_file="$ac_unique_file"
27               ax_spec_file_="$ac_unique_file" ;;
28       *) ax_spec_file="TODO"
29          if test ".$PACKAGE" != "."
30          then ax_spec_file_="$PACKAGE.spec"
31          else ax_spec_file_="README"
32          fi
33    cat m4_ifset([AS_MESSAGE_LOG_FD],[>&AS_MESSAGE_LOG_FD],[>>config.log]) <<EOF
34          no ax_spec_file argument has been given, using defaults of
35          (1) $ax_spec_file_
36          (2) $ax_spec_file
37 EOF
38          ;;
39     esac
40   fi
41   # find specfile
42   for i in ifelse($2,,,$2) . $srcdir $srcdir/.. .. ; do
43     if test -f "$i/$ax_spec_file_" ; then
44       ax_spec_dir="$i"
45       ax_spec_file="$ax_spec_dir/$ax_spec_file_"
46       break
47     fi
48     if test -f "$i/$ax_spec_file" ; then
49       ax_spec_dir="$i"
50       ax_spec_file="$ax_spec_dir/$ax_spec_file"
51       break
52     fi
53   done
54   case "$ax_spec_file" in
55    ./*) if test "$ax_spec_file" = "./$ax_spec_file_" ; then
56           ax_spec_file="$ax_spec_file_"
57         fi
58         AC_MSG_RESULT([$ax_spec_file]) ;;
59    */*) AC_MSG_RESULT([$ax_spec_file]) ;;
60    *)   AC_MSG_ERROR([no rpm spec file found]) ;;
61   esac
62   m4_define([m4_ax_spec_file],[ax_spec_file])
65 dnl AX_SPEC_EXTRACT(shellvar [,specvar [,defaultvalue]])
67 AC_DEFUN([AX_SPEC_EXTRACT],
69     if test ".$[]$1" = "." ; then
70     $1=`grep -i '^[[    ]]*m4_ifval([$2],[$2],[$1])[[   ]]*:' dnl
71   "$ax_spec_file" | sed -e 's/.*:[[     ]]*//' dnl
72     -e 's/[[    ]][[    ]]*/ /g' -e 's/^ //' -e 's/ $[]//' -e 'q'`
73     if test ".$[]$1" = "." ; then
74   for $1 in $2 $1 m4_tolower([$1]) ; do
75     $1=`echo "$[]$1" | sed -e 's/^%//g'`
76     $1=`sed dnl
77     -e  "/^%[[  ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]/!d"  dnl
78     -e "s/^%[[  ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]*//" dnl
79     -e 's/[[    ]][[    ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file`
80     test ".$1" != "." && break
81   done
82     fi
83   case ".$[]$1" in
84     .%{*)
85     $1=`echo "$[]$1" | sed -e 's/%{//' -e 's/}$[]//'`
86     $1=`sed dnl
87    -e  "/^%[[   ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]/!d"  dnl
88    -e "s/^%[[   ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]*//" dnl
89    -e 's/[[     ]][[    ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
90     .%*)
91     $1=`echo "$[]$1" | sed -e 's/%//'`
92     $1=`sed dnl
93     -e  "/^%[[  ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]/!d"  dnl
94     -e "s/^%[[  ]]*def[]ine[[   ]][[    ]]*$[]$1[[      ]]*//" dnl
95     -e 's/[[    ]][[    ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
96   esac
97   m4_ifval([$3],[test ".$[]$1" = "." && $1="$3"])
98     fi # test ".$[]$1" = "."