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