2 # Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 # This file defines a GNU autoconf M4-style macro for checking
20 # for a build host-based tool that can shadow a directory using
21 # symbolic links, ostensibly either GNU cp or X11 lndir.
24 AC_DEFUN([_NL_CHECK_CP_RS],
26 $1 -Rs 2>&1 | grep 'missing file operand' > /dev/null
29 AC_DEFUN([_NL_CHECK_LNDIR],
31 $1 -silent 2>&1 | grep 'usage: lndir' > /dev/null
35 # NL_PROG_LNDIR([fallback GNU cp path to test, fallback GNU cp path to set])
37 # test path - The fallback GNU cp path and arguments to test if a system
38 # GNU cp cannot be found.
39 # set path - The fallback GNU cp path and arguments to set to LNDIR if
40 # the test path succeeds.
42 # Determine and assign to LNDIR, a build host-based tool that can shadow
43 # a directory using symbolic links, attempting either GNU cp or X11 lndir
44 # as preferred defaults.
46 # If the host doesn't have GNU cp natively, the caller can specify
47 # both a GNU cp path to test and a GNU cp path to set if the test path
50 # ----------------------------------------------------------------------------
51 AC_DEFUN([NL_PROG_LNDIR],
53 AC_ARG_VAR(LNDIR, [Program and arguments to create a shadow directory of symbolic links to another directory tree (e.g. 'cp -Rs')])
55 AC_MSG_CHECKING([how to shadow a directory tree])
57 if test "x${LNDIR}" = "x"; then
58 if `_NL_CHECK_CP_RS(cp)`; then
61 elif `_NL_CHECK_LNDIR(lndir)`; then
64 elif `_NL_CHECK_CP_RS($1)`; then
68 AC_MSG_ERROR([Cannot determine how to shadow a directory tree. Neither 'cp -Rs' nor 'lndir -silent' appear to be available or functional. Please consider installing or making available in your PATH one of: GNU coreutils <http://www.gnu.org/software/coreutils/>, XQuartz (Mac OS X-only) <http://xquartz.macosforge.org/>, or lndir <http://www.mit.edu/afs/sipb/project/sipbsrc/rt/lndir/>.])
73 AC_MSG_RESULT(${LNDIR})