1 dnl @* AX_CREATE_PKGCONFIG_INFO [(outputfile, [requires [,libs [,summary [,cflags [,ldflags]]]]])]
3 dnl $1 = $PACKAGE_NAME.pc
5 dnl $3 = $PACKAGE_LIBS $LIBS (as set at that point in configure.ac)
6 dnl $4 = $PACKAGE_SUMMARY (or $1 Library)
7 dnl $5 = $CPPFLAGS $PACKAGE_CFLAGS (as set at the point in configure.ac)
8 dnl $6 = $LDFLAGS $PACKAGE_LDFLAGS (as set at the point in configure.ac)
10 dnl PACKAGE_NAME defaults to $PACKAGE if not set.
11 dnl PACKAGE_LIBS defaults to -l$PACKAGE_NAME if not set.
13 dnl the resulting file is called $PACKAGE.pc.in / $PACKAGE.pc
15 dnl You will find this macro most useful in conjunction with ax_spec_defaults
16 dnl that can read good initializers from the .spec file. In consequencd, most
17 dnl of the generatable installable stuff can be made from information being
18 dnl updated in a single place for the whole project.
20 dnl @$Id: ax_create_pkgconfig_info.m4,v 1.2 2005/01/06 19:56:30 guidod Exp $
22 AC_DEFUN([AX_CREATE_PKGCONFIG_INFO],[dnl
23 AS_VAR_PUSHDEF([PKGCONFIG_suffix],[ax_create_pkgconfig_suffix])dnl
24 AS_VAR_PUSHDEF([PKGCONFIG_libdir],[ax_create_pkgconfig_libdir])dnl
25 AS_VAR_PUSHDEF([PKGCONFIG_libfile],[ax_create_pkgconfig_libfile])dnl
26 AS_VAR_PUSHDEF([PKGCONFIG_libname],[ax_create_pkgconfig_libname])dnl
27 AS_VAR_PUSHDEF([PKGCONFIG_version],[ax_create_pkgconfig_version])dnl
28 AS_VAR_PUSHDEF([PKGCONFIG_description],[ax_create_pkgconfig_description])dnl
29 AS_VAR_PUSHDEF([PKGCONFIG_requires],[ax_create_pkgconfig_requires])dnl
30 AS_VAR_PUSHDEF([PKGCONFIG_pkglibs],[ax_create_pkgconfig_pkglibs])dnl
31 AS_VAR_PUSHDEF([PKGCONFIG_libs],[ax_create_pkgconfig_libs])dnl
32 AS_VAR_PUSHDEF([PKGCONFIG_ldflags],[ax_create_pkgconfig_ldflags])dnl
33 AS_VAR_PUSHDEF([PKGCONFIG_cppflags],[ax_create_pkgconfig_cppflags])dnl
34 AS_VAR_PUSHDEF([PKGCONFIG_generate],[ax_create_pkgconfig_generate])dnl
35 AS_VAR_PUSHDEF([PKGCONFIG_src_libdir],[ax_create_pkgconfig_src_libdir])dnl
36 AS_VAR_PUSHDEF([PKGCONFIG_src_headers],[ax_create_pkgconfig_src_headers])dnl
38 # we need the expanded forms...
39 test "x$prefix" = xNONE && prefix=$ac_default_prefix
40 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
42 AC_MSG_CHECKING(our pkgconfig libname)
43 test ".$PKGCONFIG_libname" != "." || \
44 PKGCONFIG_libname="ifelse($1,,${PACKAGE_NAME},`basename $1 .pc`)"
45 test ".$PKGCONFIG_libname" != "." || \
46 PKGCONFIG_libname="$PACKAGE"
47 PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"`
48 PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"`
49 AC_MSG_RESULT($PKGCONFIG_libname)
51 AC_MSG_CHECKING(our pkgconfig version)
52 test ".$PKGCONFIG_version" != "." || \
53 PKGCONFIG_version="${PACKAGE_VERSION}"
54 test ".$PKGCONFIG_version" != "." || \
55 PKGCONFIG_version="$VERSION"
56 PKGCONFIG_version=`eval echo "$PKGCONFIG_version"`
57 PKGCONFIG_version=`eval echo "$PKGCONFIG_version"`
58 AC_MSG_RESULT($PKGCONFIG_version)
60 AC_MSG_CHECKING(our pkgconfig_libdir)
61 test ".$pkgconfig_libdir" = "." && \
62 pkgconfig_libdir='${libdir}/pkgconfig'
63 PKGCONFIG_libdir=`eval echo "$pkgconfig_libdir"`
64 PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"`
65 PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"`
66 AC_MSG_RESULT($pkgconfig_libdir)
67 test "$pkgconfig_libdir" != "$PKGCONFIG_libdir" && (
68 AC_MSG_RESULT(expanded our pkgconfig_libdir... $PKGCONFIG_libdir))
69 AC_SUBST([pkgconfig_libdir])
71 AC_MSG_CHECKING(our pkgconfig_libfile)
72 test ".$pkgconfig_libfile" != "." || \
73 pkgconfig_libfile="ifelse($1,,$PKGCONFIG_libname.pc,`basename $1`)"
74 PKGCONFIG_libfile=`eval echo "$pkgconfig_libfile"`
75 PKGCONFIG_libfile=`eval echo "$PKGCONFIG_libfile"`
76 AC_MSG_RESULT($pkgconfig_libfile)
77 test "$pkgconfig_libfile" != "$PKGCONFIG_libfile" && (
78 AC_MSG_RESULT(expanded our pkgconfig_libfile... $PKGCONFIG_libfile))
79 AC_SUBST([pkgconfig_libfile])
81 AC_MSG_CHECKING(our package / suffix)
82 PKGCONFIG_suffix="$program_suffix"
83 test ".$PKGCONFIG_suffix" != .NONE || PKGCONFIG_suffix=""
84 AC_MSG_RESULT(${PACKAGE_NAME} / ${PKGCONFIG_suffix})
86 AC_MSG_CHECKING(our pkgconfig description)
87 PKGCONFIG_description="ifelse($4,,$PACKAGE_SUMMARY,$4)"
88 test ".$PKGCONFIG_description" != "." || \
89 PKGCONFIG_description="$PKGCONFIG_libname Library"
90 PKGCONFIG_description=`eval echo "$PKGCONFIG_description"`
91 PKGCONFIG_description=`eval echo "$PKGCONFIG_description"`
92 AC_MSG_RESULT($PKGCONFIG_description)
94 AC_MSG_CHECKING(our pkgconfig requires)
95 PKGCONFIG_requires="ifelse($2,,$PACKAGE_REQUIRES,$2)"
96 PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"`
97 PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"`
98 AC_MSG_RESULT($PKGCONFIG_requires)
100 AC_MSG_CHECKING(our pkgconfig ext libs)
101 PKGCONFIG_pkglibs="$PACKAGE_LIBS"
102 test ".$PKGCONFIG_pkglibs" != "." || PKGCONFIG_pkglibs="-l$PKGCONFIG_libname"
103 PKGCONFIG_libs="ifelse($3,,$PKGCONFIG_pkglibs $LIBS,$3)"
104 PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"`
105 PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"`
106 AC_MSG_RESULT($PKGCONFIG_libs)
108 AC_MSG_CHECKING(our pkgconfig cppflags)
109 PKGCONFIG_cppflags="ifelse($5,,$CPPFLAGS $PACKAGE_CFLAGS,$5)"
110 PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"`
111 PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"`
112 AC_MSG_RESULT($PKGCONFIG_cppflags)
114 AC_MSG_CHECKING(our pkgconfig ldflags)
115 PKGCONFIG_ldflags="ifelse($6,,$LDFLAGS $PACKAGE_LDFLAGS,$5)"
116 PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"`
117 PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"`
118 AC_MSG_RESULT($PKGCONFIG_ldflags)
120 test ".$PKGCONFIG_generate" != "." || \
121 PKGCONFIG_generate="ifelse($1,,$PKGCONFIG_libname.pc,$1)"
122 PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"`
123 PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"`
124 test "$pkgconfig_libfile" != "$PKGCONFIG_generate" && (
125 AC_MSG_RESULT(generate the pkgconfig later... $PKGCONFIG_generate))
127 if test ".$PKGCONFIG_src_libdir" = "." ; then
128 PKGCONFIG_src_libdir=`pwd`
129 PKGCONFIG_src_libdir=`AS_DIRNAME("$PKGCONFIG_src_libdir/$PKGCONFIG_generate")`
130 test ! -d $PKGCONFIG_src_libdir/src || \
131 PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/src"
133 *libs) PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/$objdir" ;; esac
134 AC_MSG_RESULT(noninstalled pkgconfig -L $PKGCONFIG_src_libdir)
137 if test ".$PKGCONFIG_src_headers" = "." ; then
138 PKGCONFIG_src_headers=`pwd`
140 test ".$v" != "." || v="$ax_spec_dir"
141 test ".$v" != "." || v="$srcdir"
142 case "$v" in /*) PKG_CONFIG_src_headers="" ;; esac
143 PKGCONFIG_src_headers=`AS_DIRNAME("$PKGCONFIG_src_headers/$v/x")`
144 test ! -d $PKGCONFIG_src_headers/incl[]ude || \
145 PKGCONFIG_src_headers="$PKGCONFIG_src_headers/incl[]ude"
146 AC_MSG_RESULT(noninstalled pkgconfig -I $PKGCONFIG_src_headers)
150 dnl AC_CONFIG_COMMANDS crap disallows to use $PKGCONFIG_libfile here...
151 AC_CONFIG_COMMANDS([$ax_create_pkgconfig_generate],[
152 pkgconfig_generate="$ax_create_pkgconfig_generate"
153 if test ! -f "$pkgconfig_generate.in"
155 elif grep ' generated by configure ' $pkgconfig_generate.in >/dev/null
157 else generate="false";
160 AC_MSG_NOTICE(creating $pkgconfig_generate.in)
161 cat > $pkgconfig_generate.in <<AXEOF
162 # generated by configure / remove this line to disable regeneration
164 exec_prefix=@exec_prefix@
167 datarootdir=@datarootdir@
169 sysconfdir=@sysconfdir@
170 includedir=@includedir@
175 Description: @PACKAGE_DESCRIPTION@
176 Version: @PACKAGE_VERSION@
177 Requires: @PACKAGE_REQUIRES@
178 Libs: -L\${libdir} @LDFLAGS@ @LIBS@
179 Cflags: -I\${includedir} @CPPFLAGS@
181 fi # DONE generate $pkgconfig_generate.in
182 AC_MSG_NOTICE(creating $pkgconfig_generate)
183 cat >conftest.sed <<AXEOF
184 s|@prefix@|${pkgconfig_prefix}|
185 s|@exec_prefix@|${pkgconfig_execprefix}|
186 s|@bindir@|${pkgconfig_bindir}|
187 s|@libdir@|${pkgconfig_libdir}|
188 s|@datarootdir@|${pkgconfig_datarootdir}|
189 s|@datadir@|${pkgconfig_datadir}|
190 s|@sysconfdir@|${pkgconfig_sysconfdir}|
191 s|@includedir@|${pkgconfig_includedir}|
192 s|@suffix@|${pkgconfig_suffix}|
193 s|@PACKAGE@|${pkgconfig_package}|
194 s|@PACKAGE_NAME@|${pkgconfig_libname}|
195 s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|
196 s|@PACKAGE_VERSION@|${pkgconfig_version}|
197 s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|
198 s|@LIBS@|${pkgconfig_libs}|
199 s|@LDFLAGS@|${pkgconfig_ldflags}|
200 s|@CPPFLAGS@|${pkgconfig_cppflags}|
202 sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_generate
203 if test ! -s $pkgconfig_generate ; then
204 AC_MSG_ERROR([$pkgconfig_generate is empty])
205 fi ; rm conftest.sed # DONE generate $pkgconfig_generate
206 pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.pc/'`
207 AC_MSG_NOTICE(creating $pkgconfig_uninstalled)
208 cat >conftest.sed <<AXEOF
209 s|@prefix@|${pkgconfig_prefix}|
210 s|@exec_prefix@|${pkgconfig_execprefix}|
211 s|@bindir@|${pkgconfig_bindir}|
212 s|@libdir@|${pkgconfig_src_libdir}|
213 s|@datarootdir@|${pkgconfig_datarootdir}|
214 s|@datadir@|${pkgconfig_datadir}|
215 s|@sysconfdir@|${pkgconfig_sysconfdir}|
216 s|@includedir@|${pkgconfig_src_headers}|
217 s|@suffix@|${pkgconfig_suffix}|
218 s|@PACKAGE@|${pkgconfig_package}|
219 s|@PACKAGE_NAME@|${pkgconfig_libname}|
220 s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|
221 s|@PACKAGE_VERSION@|${pkgconfig_version}|
222 s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|
223 s|@LIBS@|${pkgconfig_libs}|
224 s|@LDFLAGS@|${pkgconfig_ldflags}|
225 s|@CPPFLAGS@|${pkgconfig_cppflags}|
227 sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled
228 if test ! -s $pkgconfig_uninstalled ; then
229 AC_MSG_ERROR([$pkgconfig_uninstalled is empty])
230 fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled
231 pkgconfig_requires_add=`echo ${pkgconfig_requires}`
232 if test ".$pkgconfig_requires_add" != "." ; then
233 pkgconfig_requires_add="pkg-config $pkgconfig_requires_add"
234 else pkgconfig_requires_add=":" ; fi
235 pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.sh/'`
236 AC_MSG_NOTICE(creating $pkgconfig_uninstalled)
237 cat >conftest.sed <<AXEOF
238 s|@prefix@|\"${pkgconfig_prefix}\"|
239 s|@exec_prefix@|\"${pkgconfig_execprefix}\"|
240 s|@bindir@|\"${pkgconfig_bindir}\"|
241 s|@libdir@|\"${pkgconfig_src_libdir}\"|
242 s|@datarootdir@|\"${pkgconfig_datarootdir}\"|
243 s|@datadir@|\"${pkgconfig_datadir}\"|
244 s|@sysconfdir@|\"${pkgconfig_sysconfdir}\"|
245 s|@includedir@|\"${pkgconfig_src_headers}\"|
246 s|@suffix@|\"${pkgconfig_suffix}\"|
247 s|@PACKAGE@|\"${pkgconfig_package}\"|
248 s|@PACKAGE_NAME@|\"${pkgconfig_libname}\"|
249 s|@PACKAGE_DESCRIPTION@|\"${pkgconfig_description}\"|
250 s|@PACKAGE_VERSION@|\"${pkgconfig_version}\"|
251 s|@PACKAGE_REQUIRES@|\"${pkgconfig_requires}\"|
252 s|@LIBS@|\"${pkgconfig_libs}\"|
253 s|@LDFLAGS@|\"${pkgconfig_ldflags}\"|
254 s|@CPPFLAGS@|\"${pkgconfig_cppflags}\"|
255 s>Name:>for option\\; do case \"\$option\" in --list-all|--name) echo >
256 s>Description: *>\\;\\; --help) pkg-config --help \\; echo Buildscript Of >
257 s>Version: *>\\;\\; --modversion|--version) echo >
258 s>Requires:>\\;\\; --requires) echo $pkgconfig_requires_add>
259 s>Libs: *>\\;\\; --libs) echo >
260 s>Cflags: *>\\;\\; --cflags) echo >
262 $pkgconfig_requires_add
264 $pkgconfig_requires_add\\
265 ;; --variable=*) eval echo '\$'\`echo \$option | sed -e 's/.*=//'\`\\
266 ;; --uninstalled) exit 0 \\
269 sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled
270 if test ! -s $pkgconfig_uninstalled ; then
271 AC_MSG_ERROR([$pkgconfig_uninstalled is empty])
272 fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled
274 dnl AC_CONFIG_COMMANDS crap, the AS_PUSHVAR defines are invalid here...
275 ax_create_pkgconfig_generate="$ax_create_pkgconfig_generate"
276 pkgconfig_prefix='$prefix'
277 pkgconfig_execprefix='$exec_prefix'
278 pkgconfig_bindir='$bindir'
279 pkgconfig_libdir='$libdir'
280 pkgconfig_includedir='$includedir'
281 pkgconfig_datarootdir='$datarootdir'
282 pkgconfig_datadir='$datadir'
283 pkgconfig_sysconfdir='$sysconfdir'
284 pkgconfig_suffix='$ax_create_pkgconfig_suffix'
285 pkgconfig_package='$PACKAGE_NAME'
286 pkgconfig_libname='$ax_create_pkgconfig_libname'
287 pkgconfig_description='$ax_create_pkgconfig_description'
288 pkgconfig_version='$ax_create_pkgconfig_version'
289 pkgconfig_requires='$ax_create_pkgconfig_requires'
290 pkgconfig_libs='$ax_create_pkgconfig_libs'
291 pkgconfig_ldflags='$ax_create_pkgconfig_ldflags'
292 pkgconfig_cppflags='$ax_create_pkgconfig_cppflags'
293 pkgconfig_src_libdir='$ax_create_pkgconfig_src_libdir'
294 pkgconfig_src_headers='$ax_create_pkgconfig_src_headers'
296 AS_VAR_POPDEF([PKGCONFIG_suffix])dnl
297 AS_VAR_POPDEF([PKGCONFIG_libdir])dnl
298 AS_VAR_POPDEF([PKGCONFIG_libfile])dnl
299 AS_VAR_POPDEF([PKGCONFIG_libname])dnl
300 AS_VAR_POPDEF([PKGCONFIG_version])dnl
301 AS_VAR_POPDEF([PKGCONFIG_description])dnl
302 AS_VAR_POPDEF([PKGCONFIG_requires])dnl
303 AS_VAR_POPDEF([PKGCONFIG_pkglibs])dnl
304 AS_VAR_POPDEF([PKGCONFIG_libs])dnl
305 AS_VAR_POPDEF([PKGCONFIG_ldflags])dnl
306 AS_VAR_POPDEF([PKGCONFIG_cppflags])dnl
307 AS_VAR_POPDEF([PKGCONFIG_generate])dnl
308 AS_VAR_POPDEF([PKGCONFIG_src_libdir])dnl
309 AS_VAR_POPDEF([PKGCONFIG_src_headers])dnl