Salome HOME
PR: mergefrom_BR_CCRT_11Nov04
[modules/kernel.git] / salome_adm / unix / config_files / ac_cxx_depend_flag.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22 dnl @synopsis AC_C_DEPEND_FLAG
23 dnl
24 dnl define C_DEPEND_FLAG
25 dnl define CXX_DEPEND_FLAG
26 dnl
27 dnl @version $Id$
28 dnl @author Marc Tajchman
29 dnl
30 AC_DEFUN(AC_DEPEND_FLAG,
31 [AC_CACHE_CHECK(which flag for dependency information generation,
32 ac_cv_depend_flag,
33 [AC_LANG_SAVE
34  AC_LANG_C
35  echo "conftest.o: conftest.c" > conftest.verif
36  echo "int  main() { return 0; }" > conftest.c
37
38 dnl Evolution portage sur CCRT/osf system
39  case $host_os in
40    osf*)
41 dnl sur CCRT/osf pas d'equivalent de l'option -MG de gcc avec compilo natif
42 dnl on utilise donc gnu pour generer les dependances.
43      DEPCC=gcc
44      DEPCXX=g++
45      DEPCXXFLAGS="-Wno-deprecated"
46      DIFFFLAGS="-w"
47      ;;
48    *)
49      DEPCC=${CC-cc}
50      DEPCXX=${CXX-c++}
51      DEPCXXFLAGS="\${CXXFLAGS}"
52      DIFFFLAGS="-b -B"
53      ;;
54  esac
55  C_DEPEND_FLAG=
56  for ac_C_DEPEND_FLAG in -xM -MM -M ; do
57
58     rm -f conftest.d conftest.err
59     ${DEPCC} ${ac_C_DEPEND_FLAG} -c conftest.c 1> conftest.d 2> conftest.err
60     if test -f conftest.u ; then
61        mv conftest.u conftest.d
62     fi
63
64     rm -f conftest
65     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
66     if test ! -s conftest ; then
67        C_DEPEND_FLAG=${ac_C_DEPEND_FLAG}
68        break
69     fi
70  done
71
72 dnl use gcc option -MG : asume unknown file will be construct later
73  rm -f conftest.d conftest.err
74  ${DEPCC} ${C_DEPEND_FLAG} -MG -c conftest.c 1> conftest.d 2> conftest.err
75  if test -f conftest.u ; then
76     mv conftest.u conftest.d
77  fi
78  rm -f conftest
79  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
80  if test ! -s conftest ; then
81     C_DEPEND_FLAG=${C_DEPEND_FLAG}" -MG"
82  fi
83
84  rm -f conftest*
85  if test "x${C_DEPEND_FLAG}" = "x" ; then
86     echo "cannot determine flag (C language)"
87     exit
88  fi
89
90  printf " C :  ${DEPCC} ${C_DEPEND_FLAG}"
91
92  AC_LANG_CPLUSPLUS
93  echo "conftest.o: conftest.cxx" > conftest.verif
94  echo "int  main() { return 0; }" > conftest.cxx
95
96  CXX_DEPEND_FLAG=
97  for ac_CXX_DEPEND_FLAG in -xM -MM -M ; do
98
99     rm -f conftest.d conftest.err
100     ${DEPCXX} ${ac_CXX_DEPEND_FLAG} -c conftest.cxx 1> conftest.d 2> conftest.err
101     if test -f conftest.u ; then
102        mv conftest.u conftest.d
103     fi
104
105     rm -f conftest
106     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
107     if test ! -s conftest ; then
108        CXX_DEPEND_FLAG=${ac_CXX_DEPEND_FLAG}
109        break
110     fi
111  done
112
113 dnl use g++ option -MG : asume unknown file will be construct later
114  rm -f conftest.d conftest.err
115  ${DEPCXX} ${CXX_DEPEND_FLAG} -MG -c conftest.cxx 1> conftest.d 2> conftest.err
116  if test -f conftest.u ; then
117     mv conftest.u conftest.d
118  fi
119  rm -f conftest
120  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
121  if test ! -s conftest ; then
122     CXX_DEPEND_FLAG=${CXX_DEPEND_FLAG}" -MG"
123  fi
124
125
126  rm -f conftest*
127  if test "x${CXX_DEPEND_FLAG}" = "x" ; then
128     echo "cannot determine flag (C++ language)"
129     exit
130  fi
131
132  printf " C++ : ${DEPCXX} ${CXX_DEPEND_FLAG}"
133  AC_LANG_RESTORE
134
135  AC_SUBST(DEPCC)
136  AC_SUBST(DEPCXX)
137  AC_SUBST(DEPCXXFLAGS)
138  AC_SUBST(C_DEPEND_FLAG)
139  AC_SUBST(CXX_DEPEND_FLAG)
140 ])
141 ])