Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / adm_local_without_kernel / unix / config_files / local_install.m4
1 dnl Copyright (C) 2007-2012  CEA/DEN, EDF R&D, 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.
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 The purpose of below autoconf macro is to generate custom install script
25 dnl to be used instead of global /usr/bin/install one.
26 dnl The difference is that resulting install script does not install file passed
27 dnl as parameter if its target copy exists and the file is not changed, i.e 
28 dnl source and target files are the identical.
29 dnl The check is performed by the diff command.
30 dnl
31 AC_DEFUN([AC_LOCAL_INSTALL],
32 [
33 GLOBAL_INSTALL=$INSTALL
34 absdir=`pwd`
35 INSTALL=${absdir}/local-install.sh
36 cat > ${INSTALL} << EOF
37 #!/bin/sh
38
39 nb_args=\$[#]
40 args=\$[*]
41 if test \$nb_args -gt 1 ; then
42     nb=\$(expr \$nb_args - 2)
43     shift \$nb
44     target=\$[2]
45     if test -f \$target ; then
46     orig=\$[1]
47     if test -f \$orig ; then
48         diff \$orig \$target > /dev/null 2>&1
49         if test \$[?] = 0 ; then
50         echo \$orig and \$target are identical
51         exit 0
52         fi
53     fi
54     fi
55 fi
56 ${GLOBAL_INSTALL} \$args 
57 EOF
58 chmod +x ${INSTALL}
59 AC_SUBST(INSTALL)
60 AC_SUBST(GLOBAL_INSTALL)
61 ])dnl