Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlfaultinjection / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / nl_prog_lndir.m4
1 #
2 #    Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
3 #
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
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
16
17 #
18 #    Description:
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.
22 #
23
24 AC_DEFUN([_NL_CHECK_CP_RS],
25 [
26     $1 -Rs 2>&1 | grep 'missing file operand' > /dev/null
27 ])
28
29 AC_DEFUN([_NL_CHECK_LNDIR],
30 [
31     $1 -silent 2>&1 | grep 'usage: lndir' > /dev/null
32 ])
33
34 #
35 # NL_PROG_LNDIR([fallback GNU cp path to test, fallback GNU cp path to set])
36 #
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.
41 #
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.
45 #
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
48 # was successful.
49 #
50 # ----------------------------------------------------------------------------
51 AC_DEFUN([NL_PROG_LNDIR],
52 [
53     AC_ARG_VAR(LNDIR, [Program and arguments to create a shadow directory of symbolic links to another directory tree (e.g. 'cp -Rs')])
54
55     AC_MSG_CHECKING([how to shadow a directory tree])
56
57     if test "x${LNDIR}" = "x"; then
58         if `_NL_CHECK_CP_RS(cp)`; then
59             LNDIR="cp -Rs"
60
61         elif `_NL_CHECK_LNDIR(lndir)`; then
62             LNDIR="lndir -silent"
63
64         elif `_NL_CHECK_CP_RS($1)`; then
65             LNDIR="$2 -Rs"
66
67         else
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/>.])
69
70         fi
71     fi
72
73     AC_MSG_RESULT(${LNDIR})
74
75     AC_SUBST(LNDIR)
76 ])