@@ -206,6 +206,98 @@ AC_DEFUN([OAC_CHECK_PACKAGE],[
206206] )
207207
208208
209+ dnl Retrieve arguments from pkg-config file
210+ dnl
211+ dnl 1 -> package name
212+ dnl 2 -> prefix
213+ dnl 3 -> pcfile name (may be full path)
214+ dnl 4 -> action if found
215+ dnl 5 -> action if not found
216+ dnl
217+ dnl Read pkgconfig module $3 and set build variables based on return
218+ dnl value. Results are cached based on the value in $1, even if the
219+ dnl pkgconfig module name ($3) changes and that this macro is expanded
220+ dnl inside OAC_CHECK_PACKAGE, which can pollute the results cache.
221+ dnl
222+ dnl On return, <action if found> will be evaluated if it appears that
223+ dnl the pkg-config data is available. <action if not found> will be
224+ dnl evaluated if it appears that the package is not available. If it
225+ dnl appears the package is available, the following SHELL environment
226+ dnl variables will be set:
227+ dnl
228+ dnl <prefix>_CPPFLAGS - CPPFLAGS to add when compiling sources depending on the package
229+ dnl <prefix>_LDFLAGS - LDFLAGS to add when linking against the package
230+ dnl <prefix>_STATIC_LDFLAGS - LDFLAGS to add when linking against the package when
231+ dnl building a statically linked executable.
232+ dnl <prefix>_LIBS - Libraries to link to access the package
233+ dnl <prefix>_STATIC_LIBS - Libraries to link to access the package when building a
234+ dnl statically linked executable.
235+ dnl <prefix>_PC_MODULES - Module name of the pkgconfig module used to generate
236+ dnl the build information. Will be unset by OAC_CHECK_PACKAGE
237+ dnl if pkg-config was not used to configure the package. Note
238+ dnl that there is no need for a STATIC_PC_MODULES option,
239+ dnl as that functionality is built into pkgconfig modules
240+ dnl directly.
241+ AC_DEFUN ( [ OAC_CHECK_PACKAGE_PARSE_PKGCONFIG] , [
242+ AC_REQUIRE ( [ _OAC_CHECK_PACKAGE_PKGCONFIG_INIT] )
243+
244+ AC_CACHE_CHECK ( [ if $1 pkg-config module exists] ,
245+ [ check_package_cv_$1 _pkg_config_exists] ,
246+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --exists] , [ check_package_pkgconfig_internal_result] ,
247+ [ $2 _PC_MODULES=$3
248+ check_package_cv_$1 _pkg_config_exists=yes] ,
249+ [ check_package_cv_$1 _pkg_config_exists=no] )] )
250+
251+ # if pkg-config --exists works, but getting one of the standard flags fails, we consider
252+ # that a hard failure. It should not happen, outside of a weird system configuration
253+ # issue where we're probably not going to like the results anyway.
254+ AS_IF ( [ test "${check_package_cv_$1 _pkg_config_exists}" = "yes"] ,
255+ [ AC_CACHE_CHECK ( [ for $1 pkg-config cflags] ,
256+ [ check_package_cv_$1 _pkg_config_cppflags] ,
257+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --cflags] ,
258+ [ check_package_cv_$1 _pkg_config_cppflags] , [ ] ,
259+ [ AC_MSG_RESULT ( [ error] )
260+ AC_MSG_ERROR ( [ An error occurred retrieving $1 cppflags from pkg-config] ) ] )] )
261+ $2 _CPPFLAGS="${check_package_cv_$1 _pkg_config_cppflags}"
262+
263+ AC_CACHE_CHECK ( [ for $1 pkg-config ldflags] ,
264+ [ check_package_cv_$1 _pkg_config_ldflags] ,
265+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --libs-only-L --libs-only-other] ,
266+ [ check_package_cv_$1 _pkg_config_ldflags] , [ ] ,
267+ [ AC_MSG_RESULT ( [ error] )
268+ AC_MSG_ERROR ( [ An error occurred retrieving $1 ldflags from pkg-config] ) ] )] )
269+ $2 _LDFLAGS="${check_package_cv_$1 _pkg_config_ldflags}"
270+
271+ AC_CACHE_CHECK ( [ for $1 pkg-config static ldflags] ,
272+ [ check_package_cv_$1 _pkg_config_static_ldflags] ,
273+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --static --libs-only-L --libs-only-other] ,
274+ [ check_package_cv_$1 _pkg_config_static_ldflags] , [ ] ,
275+ [ AC_MSG_RESULT ( [ error] )
276+ AC_MSG_ERROR ( [ An error occurred retrieving $1 static ldflags from pkg-config] ) ] )] )
277+ $2 _STATIC_LDFLAGS="${check_package_cv_$1 _pkg_config_static_ldflags}"
278+
279+ AC_CACHE_CHECK ( [ for $1 pkg-config libs] ,
280+ [ check_package_cv_$1 _pkg_config_libs] ,
281+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --libs-only-l] ,
282+ [ check_package_cv_$1 _pkg_config_libs] , [ ] ,
283+ [ AC_MSG_RESULT ( [ error] )
284+ AC_MSG_ERROR ( [ An error occurred retrieving $1 libs from pkg-config] ) ] )] )
285+ $2 _LIBS="${check_package_cv_$1 _pkg_config_libs}"
286+
287+ AC_CACHE_CHECK ( [ for $1 pkg-config static libs] ,
288+ [ check_package_cv_$1 _pkg_config_static_libs] ,
289+ [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --static --libs-only-l] ,
290+ [ check_package_cv_$1 _pkg_config_static_libs] , [ ] ,
291+ [ AC_MSG_RESULT ( [ error] )
292+ AC_MSG_ERROR ( [ An error occurred retrieving $1 libs from pkg-config] ) ] )] )
293+ $2 _STATIC_LIBS="${check_package_cv_$1 _pkg_config_static_libs}"
294+
295+ $4 ] )
296+
297+ AS_UNSET ( [ check_package_pkgconfig_internal_result] )
298+ ] )
299+
300+
209301AC_DEFUN ( [ OAC_CHECK_PACKAGE_STATIC_CHECK] , [
210302 AC_CACHE_CHECK ( [ for static linker flag] ,
211303 [ check_package_cv_static_linker_flag] ,
@@ -321,71 +413,7 @@ to configure to help disambiguate.])],
321413 [ test -r "${check_package_prefix}/lib64/pkgconfig/pcname.pc"] ,
322414 [ check_package_cv_$1 _pcfilename="${check_package_prefix}/lib64/pkgconfig/pcname.pc"] ,
323415 [ check_package_cv_$1 _pcfilename="${check_package_prefix}/lib/pkgconfig/pcname.pc"] ) ] )
324- _OAC_CHECK_PACKAGE_PKGCONFIG_INTERNAL([ $1 ] , [ $2 ] , [ ${check_package_cv_$1 _pcfilename}] , [ $3 ] )] )
325- ] )
326-
327-
328- dnl 1 -> package name
329- dnl 2 -> prefix
330- dnl 3 -> pcfile name (may be full path)
331- dnl 4 -> action if found flag
332- AC_DEFUN ( [ _OAC_CHECK_PACKAGE_PKGCONFIG_INTERNAL] , [
333- AC_REQUIRE ( [ _OAC_CHECK_PACKAGE_PKGCONFIG_INIT] )
334-
335- AC_CACHE_CHECK ( [ if $1 pkg-config module exists] ,
336- [ check_package_cv_$1 _pkg_config_exists] ,
337- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --exists] , [ check_package_pkgconfig_internal_result] ,
338- [ $2 _PC_MODULES=$3
339- check_package_cv_$1 _pkg_config_exists=yes] ,
340- [ check_package_cv_$1 _pkg_config_exists=no] )] )
341-
342- # if pkg-config --exists works, but getting one of the standard flags fails, we consider
343- # that a hard failure. It should not happen, outside of a weird system configuration
344- # issue where we're probably not going to like the results anyway.
345- AS_IF ( [ test "${check_package_cv_$1 _pkg_config_exists}" = "yes"] ,
346- [ AC_CACHE_CHECK ( [ for $1 pkg-config cflags] ,
347- [ check_package_cv_$1 _pkg_config_cppflags] ,
348- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --cflags] ,
349- [ check_package_cv_$1 _pkg_config_cppflags] , [ ] ,
350- [ AC_MSG_RESULT ( [ error] )
351- AC_MSG_ERROR ( [ An error occurred retrieving $1 cppflags from pkg-config] ) ] )] )
352- $2 _CPPFLAGS="${check_package_cv_$1 _pkg_config_cppflags}"
353-
354- AC_CACHE_CHECK ( [ for $1 pkg-config ldflags] ,
355- [ check_package_cv_$1 _pkg_config_ldflags] ,
356- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --libs-only-L --libs-only-other] ,
357- [ check_package_cv_$1 _pkg_config_ldflags] , [ ] ,
358- [ AC_MSG_RESULT ( [ error] )
359- AC_MSG_ERROR ( [ An error occurred retrieving $1 ldflags from pkg-config] ) ] )] )
360- $2 _LDFLAGS="${check_package_cv_$1 _pkg_config_ldflags}"
361-
362- AC_CACHE_CHECK ( [ for $1 pkg-config static ldflags] ,
363- [ check_package_cv_$1 _pkg_config_static_ldflags] ,
364- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --static --libs-only-L --libs-only-other] ,
365- [ check_package_cv_$1 _pkg_config_static_ldflags] , [ ] ,
366- [ AC_MSG_RESULT ( [ error] )
367- AC_MSG_ERROR ( [ An error occurred retrieving $1 static ldflags from pkg-config] ) ] )] )
368- $2 _STATIC_LDFLAGS="${check_package_cv_$1 _pkg_config_static_ldflags}"
369-
370- AC_CACHE_CHECK ( [ for $1 pkg-config libs] ,
371- [ check_package_cv_$1 _pkg_config_libs] ,
372- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --libs-only-l] ,
373- [ check_package_cv_$1 _pkg_config_libs] , [ ] ,
374- [ AC_MSG_RESULT ( [ error] )
375- AC_MSG_ERROR ( [ An error occurred retrieving $1 libs from pkg-config] ) ] )] )
376- $2 _LIBS="${check_package_cv_$1 _pkg_config_libs}"
377-
378- AC_CACHE_CHECK ( [ for $1 pkg-config static libs] ,
379- [ check_package_cv_$1 _pkg_config_static_libs] ,
380- [ _OAC_CHECK_PACKAGE_PKGCONFIG_RUN([ $3 ] , [ --static --libs-only-l] ,
381- [ check_package_cv_$1 _pkg_config_static_libs] , [ ] ,
382- [ AC_MSG_RESULT ( [ error] )
383- AC_MSG_ERROR ( [ An error occurred retrieving $1 libs from pkg-config] ) ] )] )
384- $2 _STATIC_LIBS="${check_package_cv_$1 _pkg_config_static_libs}"
385-
386- $4 ] )
387-
388- AS_UNSET ( [ check_package_pkgconfig_internal_result] )
416+ OAC_CHECK_PACKAGE_PARSE_PKGCONFIG([ $1 ] , [ $2 ] , [ ${check_package_cv_$1 _pcfilename}] , [ $3 ] )] )
389417] )
390418
391419
0 commit comments