1 dnl Copyright © 2020-2021 Nick Bowler
3 dnl License WTFPL2: Do What the Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
7 dnl DX_PROG_GOB2([min-version], [action-if-found], [action-if-not-found])
9 dnl Search PATH for a working gob2 utility with the given minimum version,
10 dnl which may be empty to accept any version. If found, the GOB2 variable
11 dnl (which is substituted with AC_SUBST) is set with the result, and
12 dnl action-if-found is executed. Otherwise, action-if-not-found is
13 dnl executed if nonempty, else configure will exit with a fatal error.
15 AC_DEFUN([DX_PROG_GOB2], [AC_ARG_VAR([GOB2], [GOBject Builder command])dnl
17 cat >conftest.gob <<'EOF'
18 m4_ifnblank([$1], [requires $1
20 class :Conftest from G:Object
24 AC_CACHE_CHECK([for GObject Builder], [ac_cv_path_GOB2],
26 AC_PATH_PROGS_FEATURE_CHECK([GOB2], [gob2],
28 $ac_path_GOB2 conftest.gob >&AS_MESSAGE_LOG_FD 2>&1 && test -f conftest.c && {
29 DX_BASENAME([gob_relcmd], ["$ac_path_GOB2"])
30 gob_bypath=`{ command -v "$gob_relcmd"; } 2>/dev/null` # ''
31 ac_cv_path_GOB2=$ac_path_GOB2
32 test x"$gob_bypath" = x"$ac_path_GOB2" && ac_cv_path_GOB2=$gob_relcmd
35 }], [ac_cv_path_GOB2=no dx_cv_gob_found=false])
37 AS_IF([$dx_cv_gob_found],
38 [GOB2=$ac_cv_path_GOB2
39 AC_CACHE_CHECK([whether $GOB2 works], [dx_cv_gob_works],
41 if $GOB2 conftest.gob >&AS_MESSAGE_LOG_FD 2>&1 && test -f conftest.c; then
46 AS_IF([test x"$dx_cv_gob_works" = x"yes"],
47 [$2], [m4_default([$3], [AC_MSG_FAILURE(
48 [GObject Builder m4_ifnblank([$1], [version at least $1 ])is required.
50 The latest version may be found at <https://draconx.ca/projects/gob-dx/>.
52 rm -f conftest.c conftest.gob