1 dnl /usr/share/aclocal/guidod-cvs/ax_spec_file.m4
2 dnl @synopsis AX_SPEC_FILE [(rpmspecfile [,subdirpath])]
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.
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.
12 dnl AX_SPEC_EXTRACT(shellvar [,specvar [,defaultvalue]])
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
23 ax_spec_file=`basename $1`
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"
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
42 for i in ifelse($2,,,$2) . $srcdir $srcdir/.. .. ; do
43 if test -f "$i/$ax_spec_file_" ; then
45 ax_spec_file="$ax_spec_dir/$ax_spec_file_"
48 if test -f "$i/$ax_spec_file" ; then
50 ax_spec_file="$ax_spec_dir/$ax_spec_file"
54 case "$ax_spec_file" in
55 ./*) if test "$ax_spec_file" = "./$ax_spec_file_" ; then
56 ax_spec_file="$ax_spec_file_"
58 AC_MSG_RESULT([$ax_spec_file]) ;;
59 */*) AC_MSG_RESULT([$ax_spec_file]) ;;
60 *) AC_MSG_ERROR([no rpm spec file found]) ;;
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'`
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
85 $1=`echo "$[]$1" | sed -e 's/%{//' -e 's/}$[]//'`
87 -e "/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]/!d" dnl
88 -e "s/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]*//" dnl
89 -e 's/[[ ]][[ ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
91 $1=`echo "$[]$1" | sed -e 's/%//'`
93 -e "/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]/!d" dnl
94 -e "s/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]*//" dnl
95 -e 's/[[ ]][[ ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
97 m4_ifval([$3],[test ".$[]$1" = "." && $1="$3"])
98 fi # test ".$[]$1" = "."