Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / wrappergen / bin / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / ac_cxx_depend_flag.m4
1 dnl  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
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 dnl @synopsis AC_C_DEPEND_FLAG
20 dnl define C_DEPEND_FLAG
21 dnl define CXX_DEPEND_FLAG
22 dnl @version $Id$
23 dnl @author Marc Tajchman
24 dnl
25 AC_DEFUN(AC_DEPEND_FLAG,
26 [AC_CACHE_CHECK(which flag for dependency information generation,
27 ac_cv_depend_flag,
28 [AC_LANG_SAVE
29  AC_LANG_C
30  echo "conftest.o: conftest.c" > conftest.verif
31  echo "int  main() { return 0; }" > conftest.c
32
33 dnl Evolution portage sur CCRT/osf system
34  case $host_os in
35    osf*)
36 dnl sur CCRT/osf pas d'equivalent de l'option -MG de gcc avec compilo natif
37 dnl on utilise donc gnu pour generer les dependances.
38      DEPCC=gcc
39      DEPCXX=g++
40      DEPCXXFLAGS="-Wno-deprecated"
41      DIFFFLAGS="-w"
42      MACHINE="OSF1"
43      ;;
44    *)
45      DEPCC=${CC-cc}
46      DEPCXX=${CXX-c++}
47      DEPCXXFLAGS="\${CXXFLAGS}"
48      DIFFFLAGS="-b -B"
49      MACHINE="PCLINUX"
50      ;;
51  esac
52  C_DEPEND_FLAG=
53  for ac_C_DEPEND_FLAG in -xM -MM -M ; do
54
55     rm -f conftest.d conftest.err
56     ${DEPCC} ${ac_C_DEPEND_FLAG} -c conftest.c 1> conftest.d 2> conftest.err
57     if test -f conftest.u ; then
58        mv conftest.u conftest.d
59     fi
60
61     rm -f conftest
62     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
63     if test ! -s conftest ; then
64        C_DEPEND_FLAG=${ac_C_DEPEND_FLAG}
65        break
66     fi
67  done
68
69 dnl use gcc option -MG : asume unknown file will be construct later
70  rm -f conftest.d conftest.err
71  ${DEPCC} ${C_DEPEND_FLAG} -MG -c conftest.c 1> conftest.d 2> conftest.err
72  if test -f conftest.u ; then
73     mv conftest.u conftest.d
74  fi
75  rm -f conftest
76  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
77  if test ! -s conftest ; then
78     C_DEPEND_FLAG=${C_DEPEND_FLAG}" -MG"
79  fi
80
81  rm -f conftest*
82  if test "x${C_DEPEND_FLAG}" = "x" ; then
83     echo "cannot determine flag (C language)"
84     exit
85  fi
86
87  printf " C :  ${DEPCC} ${C_DEPEND_FLAG}"
88
89  AC_LANG_CPLUSPLUS
90  echo "conftest.o: conftest.cxx" > conftest.verif
91  echo "int  main() { return 0; }" > conftest.cxx
92
93  CXX_DEPEND_FLAG=
94  for ac_CXX_DEPEND_FLAG in -xM -MM -M ; do
95
96     rm -f conftest.d conftest.err
97     ${DEPCXX} ${ac_CXX_DEPEND_FLAG} -c conftest.cxx 1> conftest.d 2> conftest.err
98     if test -f conftest.u ; then
99        mv conftest.u conftest.d
100     fi
101
102     rm -f conftest
103     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
104     if test ! -s conftest ; then
105        CXX_DEPEND_FLAG=${ac_CXX_DEPEND_FLAG}
106        break
107     fi
108  done
109
110 dnl use g++ option -MG : asume unknown file will be construct later
111  rm -f conftest.d conftest.err
112  ${DEPCXX} ${CXX_DEPEND_FLAG} -MG -c conftest.cxx 1> conftest.d 2> conftest.err
113  if test -f conftest.u ; then
114     mv conftest.u conftest.d
115  fi
116  rm -f conftest
117  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
118  if test ! -s conftest ; then
119     CXX_DEPEND_FLAG=${CXX_DEPEND_FLAG}" -MG"
120  fi
121
122
123  rm -f conftest*
124  if test "x${CXX_DEPEND_FLAG}" = "x" ; then
125     echo "cannot determine flag (C++ language)"
126     exit
127  fi
128
129  printf " C++ : ${DEPCXX} ${CXX_DEPEND_FLAG}"
130  AC_LANG_RESTORE
131
132  AC_SUBST(DEPCC)
133  AC_SUBST(DEPCXX)
134  AC_SUBST(DEPCXXFLAGS)
135  AC_SUBST(C_DEPEND_FLAG)
136  AC_SUBST(CXX_DEPEND_FLAG)
137  AC_SUBST(MACHINE)
138 ])
139 ])