Salome HOME
845788fe91a13e69b8ca88f578793879c51c7740
[tools/configuration.git] / autotools / m4 / local_install.m4
1 dnl Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 dnl ---
21 dnl File   : local_install.m4
22 dnl Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
23 dnl ---
24 dnl
25 dnl The purpose of below autoconf macro is to generate custom install script
26 dnl to be used instead of global /usr/bin/install one.
27 dnl The difference is that resulting install script does not install file passed
28 dnl as parameter if its target copy exists and the file is not changed, i.e 
29 dnl source and target files are the identical.
30 dnl The check is performed by the diff command.
31
32 AC_DEFUN([AC_LOCAL_INSTALL],
33 [
34 GLOBAL_INSTALL=$INSTALL
35 absdir=`pwd`
36 INSTALL=${absdir}/local-install.sh
37 cat > ${INSTALL} << EOF
38 #!/bin/sh
39
40 nb_args=\$[#]
41 args=\$[*]
42 if test \$nb_args -gt 1 ; then
43     nb=\$(expr \$nb_args - 2)
44     shift \$nb
45     target=\$[2]
46     if test -f \$target ; then
47     orig=\$[1]
48     if test -f \$orig ; then
49         diff \$orig \$target > /dev/null 2>&1
50         if test \$[?] = 0 ; then
51         echo \$orig and \$target are identical
52         exit 0
53         fi
54     fi
55     fi
56 fi
57 ${GLOBAL_INSTALL} \$args 
58 EOF
59 chmod +x ${INSTALL}
60 AC_SUBST(INSTALL)
61 AC_SUBST(GLOBAL_INSTALL)
62 ])dnl