1290001Sglebiusdnl ######################################################################
2290001Sglebiusdnl NTP_VPATH_HACK
3290001Sglebiusdnl
4290001Sglebiusdnl Compiling ntpd doesn't require YACC or Bison unless ntp_parser.y is
5290001Sglebiusdnl modified, because the output ntp_parser.[ch] are committed.  This
6290001Sglebiusdnl raises an issue with Automake-generated Makefiles on non-GNU make
7290001Sglebiusdnl used from a build tree outside the source tree.
8290001Sglebiusdnl
9290001Sglebiusdnl With GNU make, ylwrap updates $srcdir/ntp_parser.[ch] directly.
10290001Sglebiusdnl Under Sun or BSD make, ylwrap needs those files to be in the build
11290001Sglebiusdnl tree.
12290001Sglebiusdnl
13290001Sglebiusdnl With VPATH_HACK enabled, ntpd/Makefile.am includes code to symlink
14290001Sglebiusdnl from ntp_parser.[ch] in the build tree to the corresponding files
15290001Sglebiusdnl in $srcdir, and to check for ylwrap replacing the .h with a normal
16290001Sglebiusdnl file, and in that case copy the updated .h to $srcdir and restore
17290001Sglebiusdnl the symlink.
18290001Sglebiusdnl
19290001Sglebiusdnl if we are building outside the srcdir and either
20290001Sglebiusdnl   force_ntp_vpath_hack is yes
21290001Sglebiusdnl     or
22290001Sglebiusdnl   we're not using GNU make
23290001Sglebiusdnl then we want VPATH_HACK to be true for .am tests
24290001Sglebiusdnl
25290001SglebiusAC_DEFUN([NTP_VPATH_HACK], [
26290001SglebiusAC_MSG_CHECKING([to see if we need ylwrap VPATH hack])
27290001Sglebiusntp_vpath_hack="no"
28290001Sglebiuscase "$srcdir::${force_ntp_vpath_hack-no}" in
29290001Sglebius .::*)
30290001Sglebius    ;; # VPATH_HACK path is for VPATH builds only.
31290001Sglebius *::yes)
32290001Sglebius    ntp_vpath_hack="yes"
33290001Sglebius    ;;
34290001Sglebius *::*)
35290001Sglebius    case "`${MAKE-make} -v -f /dev/null 2>/dev/null | grep 'GNU Make'`" in
36290001Sglebius     '')
37290001Sglebius	ntp_vpath_hack="yes"
38290001Sglebius    esac
39290001Sglebiusesac
40290001SglebiusAC_MSG_RESULT([$ntp_vpath_hack])
41290001SglebiusAM_CONDITIONAL([VPATH_HACK], [test x$ntp_vpath_hack = xyes])
42290001Sglebius])
43290001Sglebiusdnl ======================================================================
44