Debian Codegraph @

libs/zziplib/zziplib-src/m4/ax_spec_package_version.m4

raw
1 dnl /usr/share/aclocal/guidod-cvs/ax_spec_package_version.m4
2 dnl @synopsis AX_SPEC_PACKAGE_AND_VERSION ([specfile])
3 dnl @synopsis AX_SPEC_PACKAGE_NAME ([shellvar],[defaultvalue])
4 dnl @synopsis AX_SPEC_PACKAGE_VERSION ([shellvar],[defaultvalue])
5 dnl @synopsis AX_SPEC_PACKAGE_SUMMARY ([shellvar],[defaultvalue])
6 dnl @synopsis AX_SPEC_PACKAGE_LICENSE ([shellvar],[defaultvalue])
7 dnl @synopsis AX_SPEC_PACKAGE_CATEGORY ([shellvar],[defaultvalue])
8 dnl @synopsis AX_SPEC_PACKAGE_ICON ([shellvar],[defaultvalue])
9 dnl @synopsis AX_SPEC_DEFAULTS([specfile])
10 dnl
11 dnl set PACKAGE from the given specfile - default to basename of the
12 dnl rpmspecfile if no "name:" could be found in the spec file.
13 dnl
14 dnl set VERSION from the given specfile - default to a date-derived
15 dnl value if no "version:" could be found in the spec file.
16 dnl
17 dnl this macro builds on top of AX_SPEC_FILE / AX_SPEC_EXTRACT
18 dnl
19 dnl more specific: if not "name:" or "%define name" was found in the
20 dnl myproject.spec file then the PACKAGE var is set to the basename
21 dnl "myproject". When no spec file was present then it will usually
22 dnl default to "TODO".
23 dnl
24 dnl The version spec looks for "version:" or "%define version" in the
25 dnl spec file. When no such value was seen or no spec file had been
26 dnl present then the value is set to `date +0.%y.%W%w`.
27 dnl
28 dnl the version value itself is sanitized somewhat with making it to
29 dnl always carry atleast three digits (1.2.3) and clensing superflous
30 dnl "0" chars around from generating numbers elsewhere.
31 dnl
32 dnl additional macros are provided that extract a specific value from
33 dnl the spec file, among these:
34 dnl
35 dnl set PACKAGE_SUMMARY from the given specfile - default to package
36 dnl and try to detect a type suffix if "summary:" was not in the spec
37 dnl file
38 dnl
39 dnl set PACKAGE_LICENSE from the given specfile - if no "license:" tag
40 dnl was given in the spec file then various COPYING files are grepped
41 dnl to have a guess and the final fallback will be GNU GPL (or GNU
42 dnl LGPL).
43 dnl
44 dnl set PACKAGE_ICON from the given specfile - if no "icon:" tag was
45 dnl given in the spec file then we default to $PACKAGE-icon.png
46 dnl
47 dnl the final AX_SPEC_INIT(specfile) will initialize all variables to
48 dnl its defaults according to the spec file given.
49 dnl
50 dnl @category Misc
51 dnl @author Guido U. Draheim <[email protected]>
52 dnl @version 2005-01-21
53 dnl @license GPLWithACException
54
55 AC_DEFUN([AX_SPEC_PACKAGE_LICENSE],[AC_REQUIRE([AX_SPEC_FILE])dnl
56 AS_VAR_PUSHDEF([VAR],[PACKAGE_LICENSE])dnl
57 AC_MSG_CHECKING([for spec license type])
58 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
59 then k="(w/o spec)"
60 else k=""
61 AX_SPEC_EXTRACT(VAR,[license],m4_ifval($1,$1))
62 VAR=`echo $VAR | sed -e 's/ *License//g'`
63 fi fi
64 test ".$VAR" = "." && k="(fallback)"
65 ifelse($2,,[dnl here the defaults for LICENSE / COPYRIGHT
66 if test ".$VAR" = "." ; then
67 for ac_file in "$srcdir/COPYING" "$srcdir/COPYING" "$srcdir/LICENSE" ; do
68 test -f "$ac_file" || continue
69 dnl http://www.ibiblio.org/osrt/omf/omf_elements "16. Rights"
70 if grep "GNU LESSER GENERAL PUBLIC LICENSE" "$ac_file" >/dev/null
71 then VAR="GNU LGPL" ; break
72 elif grep "GNU GENERAL PUBLIC LICENSE" "$ac_file" >/dev/null
73 then VAR="GNU GPL" ; break
74 elif grep "MOZILLA PUBLIC LICENSE" "$ac_file" >/dev/null
75 then VAR="MPL" ; break
76 elif grep "Mozilla Public License" "$ac_file" >/dev/null
77 then VAR="MPL" ; break
78 elif grep -i "artistic license" "$ac_file" >/dev/null
79 then VAR="Artistic" ; break
80 elif grep -i "artistic control" "$ac_file" >/dev/null
81 then VAR="Artistic" ; break
82 elif grep -i "semblance of artistic" "$ac_file" >/dev/null
83 then VAR="Artistic" ; break
84 elif grep -i "above copyright notice" "$ac_file" >/dev/null
85 then VAR="BSD" ; break
86 fi
87 done
88 if test ".$VAR" = "." ; then
89 if test "$srcdir/COPYING.LIB" ; then VAR="GNU LGPL"
90 elif test ".$ltmain" != "." ; then VAR="GNU LGPL"
91 else VAR="GNU GPL"
92 fi
93 fi
94 fi
95 ],[test ".$VAR" = "." && VAR="$2"])
96 test "$VAR" = "GPL" && VAR="GNU GPL"
97 test "$VAR" = "LGPL" && VAR="GNU LGPL"
98 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
99 AS_VAR_POPDEF([VAR])dnl
100 ])
101
102 AC_DEFUN([AX_SPEC_PACKAGE_SUMMARY],[AC_REQUIRE([AX_SPEC_FILE])dnl
103 AS_VAR_PUSHDEF([VAR],[PACKAGE_SUMMARY])dnl
104 AC_MSG_CHECKING([for spec summary])
105 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
106 then k="(w/o spec)"
107 else k=""
108 AX_SPEC_EXTRACT(VAR,[summary],m4_ifval($1,$1))
109 fi fi
110 test ".$VAR" = "." && k="(fallback)"
111 ifelse($2,,[dnl here the defaults for SUMMARY
112 if test ".$VAR" = "." ; then VAR="$PACKAGE"
113 test ".$VAR" = "." && VAR="foo"
114 test ".$ltmain" != "." && VAR="$VAR library"
115 fi
116 ],[test ".$VAR" = "." && VAR="$2"])
117 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
118 AS_VAR_POPDEF([VAR])dnl
119 ])
120
121 AC_DEFUN([AX_SPEC_PACKAGE_ICON],[AC_REQUIRE([AX_SPEC_FILE])dnl
122 AS_VAR_PUSHDEF([VAR],[PACKAGE_ICON])dnl
123 AC_MSG_CHECKING([for spec icon])
124 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
125 then k="(w/o spec)"
126 else k=""
127 AX_SPEC_EXTRACT(VAR,[icon],m4_ifval($1,$1))
128 fi fi
129 test ".$VAR" = "." && k="(fallback)"
130 ifelse($2,,[dnl here the defaults for ICON
131 if test ".$VAR" = "." ; then VAR="$PACKAGE-icon.png" ; fi
132 ],[test ".$VAR" = "." && VAR="$2"])
133 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
134 AS_VAR_POPDEF([VAR])dnl
135 ])
136
137 AC_DEFUN([AX_SPEC_PACKAGE_CATEGORY],[AC_REQUIRE([AX_SPEC_FILE])dnl
138 AS_VAR_PUSHDEF([VAR],[PACKAGE_CATEGORY])dnl
139 AC_MSG_CHECKING([for spec category])
140 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
141 then k="(w/o spec)"
142 else k=""
143 AX_SPEC_EXTRACT(VAR,[group],m4_ifval($1,$1))
144 VAR=`echo $VAR | sed -e 's/ /-/g'`
145 fi fi
146 test ".$VAR" = "." && k="(fallback)"
147 ifelse($2,,[dnl here the defaults for CATEGORY
148 if test ".$VAR" = "." ; then if test ".$ltmain" != "."
149 then VAR="Development/Library"
150 else VAR="Development/Other"
151 fi fi
152 ],[test ".$VAR" = "." && VAR="$2"])
153 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
154 AS_VAR_POPDEF([VAR])dnl
155 ])
156
157 AC_DEFUN([AX_SPEC_PACKAGE_NAME],[AC_REQUIRE([AX_SPEC_FILE])dnl
158 AS_VAR_PUSHDEF([VAR],[PACKAGE_NAME])dnl
159 AC_MSG_CHECKING([for spec package])
160 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
161 then k="(w/o spec)"
162 else k=""
163 AX_SPEC_EXTRACT(VAR,[name],m4_ifval($1,$1))
164 VAR=`echo $VAR | sed -e 's/ /-/g'`
165 fi fi
166 test ".$VAR" = "." && k="(fallback)"
167 ifelse($2,,[dnl here the defaults for PACKAGE
168 test ".$VAR" = "." && VAR=`basename $ax_spec_file .spec`
169 test ".$VAR" = ".README" && VAR="TODO"
170 test ".$VAR" = ".TODO" && VAR="foo"
171 ],[test ".$VAR" = "." && VAR="$2"])
172 test "VAR" = "PACKAGE_NAME" && test ".$PACKAGE" = "." && PACKAGE="$VAR"
173 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
174 AS_VAR_POPDEF([VAR])dnl
175 ])
176
177 AC_DEFUN([AX_SPEC_PACKAGE_VERSION_],[AC_REQUIRE([AX_SPEC_FILE])dnl
178 AS_VAR_PUSHDEF([VAR],[PACKAGE_VERSION])dnl
179 AC_MSG_CHECKING([for spec version])
180 if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
181 then k="(w/o spec)"
182 else k=""
183 AX_SPEC_EXTRACT(VAR,[version],m4_ifval($1,$1))
184 VAR=`echo $VAR | sed -e 's/ /-/g'`
185 fi fi
186 test ".$VAR" = "." && k="(fallback)"
187 ifelse($2,,[dnl here the defaults for VERSION
188 test ".$VAR" = "." && VAR=`date +0.%y.%W%w`
189 ],[test ".$VAR" = "." && VAR="$2"])
190 test "VAR" = "PACKAGE_VERSION" && test ".$VERSION" = "." && VERSION="$VAR"
191 case "$VAR" in # note we set traditional VERSION before cleaning things up
192 *.*.) VAR="$VAR"`date +%W%w` ;;
193 *.*.*) ;;
194 *.) VAR="$VAR"`date +%y.%W%w` ;;
195 *.*) VAR="$VAR.0" ;;
196 *) VAR=AS_TR_SH([$VAR]) ; VAR="$VAR.`date +%y.%W%w`" ;;
197 esac
198 VAR=`echo $VAR | sed -e "s/[[.]][0]\\([0-9]\\)/.\\1/g"`
199 AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
200 AS_VAR_POPDEF([VAR])dnl
201 ])
202
203 dnl for compatibility, we define ax_spec_package_version
204 dnl to do all of ax_spec_package_name as well.
205 AC_DEFUN([AX_SPEC_PACKAGE_VERSION],[AC_REQUIRE([AX_SPEC_FILE])dnl
206 ifelse($1,,
207 AC_MSG_WARN([please use ax_spec_package_AND_version now!]),
208 AC_MSG_ERROR([please use ax_spec_package_AND_version now!]))
209 AX_SPEC_PACKAGE_NAME
210 AX_SPEC_PACKAGE_VERSION_
211
212 ])
213
214 AC_DEFUN([AX_SPEC_PACKAGE_AND_VERSION],[
215 m4_ifset([m4_ax_spec_file],,[AX_SPEC_FILE($1)])
216 AX_SPEC_PACKAGE_NAME
217 AX_SPEC_PACKAGE_VERSION_
218 ])
219
220 AC_DEFUN([AX_SPEC_DEFAULTS],[
221 m4_ifset([m4_ax_spec_file],,[AX_SPEC_FILE($1)])
222 AX_SPEC_PACKAGE_NAME
223 AX_SPEC_PACKAGE_VERSION_
224 AX_SPEC_PACKAGE_LICENSE
225 AX_SPEC_PACKAGE_SUMMARY
226 AX_SPEC_PACKAGE_CATEGORY
227 AX_SPEC_PACKAGE_ICON
228 ])
229