xref: /freebsd/contrib/ntp/sntp/m4/ntp_vpathhack.m4 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1dnl ######################################################################
2dnl NTP_VPATH_HACK
3dnl
4dnl Compiling ntpd doesn't require YACC or Bison unless ntp_parser.y is
5dnl modified, because the output ntp_parser.[ch] are committed.  This
6dnl raises an issue with Automake-generated Makefiles on non-GNU make
7dnl used from a build tree outside the source tree.
8dnl
9dnl With GNU make, ylwrap updates $srcdir/ntp_parser.[ch] directly.
10dnl Under Sun or BSD make, ylwrap needs those files to be in the build
11dnl tree.
12dnl
13dnl With VPATH_HACK enabled, ntpd/Makefile.am includes code to symlink
14dnl from ntp_parser.[ch] in the build tree to the corresponding files
15dnl in $srcdir, and to check for ylwrap replacing the .h with a normal
16dnl file, and in that case copy the updated .h to $srcdir and restore
17dnl the symlink.
18dnl
19dnl if we are building outside the srcdir and either
20dnl   force_ntp_vpath_hack is yes
21dnl     or
22dnl   we're not using GNU make
23dnl then we want VPATH_HACK to be true for .am tests
24dnl
25AC_DEFUN([NTP_VPATH_HACK], [
26AC_MSG_CHECKING([to see if we need ylwrap VPATH hack])
27ntp_vpath_hack="no"
28case "$srcdir::${force_ntp_vpath_hack-no}" in
29 .::*)
30    ;; # VPATH_HACK path is for VPATH builds only.
31 *::yes)
32    ntp_vpath_hack="yes"
33    ;;
34 *::*)
35    case "`${MAKE-make} -v -f /dev/null 2>/dev/null | grep 'GNU Make'`" in
36     '')
37	ntp_vpath_hack="yes"
38    esac
39esac
40AC_MSG_RESULT([$ntp_vpath_hack])
41AM_CONDITIONAL([VPATH_HACK], [test x$ntp_vpath_hack = xyes])
42])
43dnl ======================================================================
44