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