Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[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) 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      MACHINE="OSF1"
48      ;;
49    *)
50      DEPCC=${CC-cc}
51      DEPCXX=${CXX-c++}
52      DEPCXXFLAGS="\${CXXFLAGS}"
53      DIFFFLAGS="-b -B"
54      MACHINE="PCLINUX"
55      ;;
56  esac
57  C_DEPEND_FLAG=
58  for ac_C_DEPEND_FLAG in -xM -MM -M ; do
59
60     rm -f conftest.d conftest.err
61     ${DEPCC} ${ac_C_DEPEND_FLAG} -c conftest.c 1> conftest.d 2> conftest.err
62     if test -f conftest.u ; then
63        mv conftest.u conftest.d
64     fi
65
66     rm -f conftest
67     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
68     if test ! -s conftest ; then
69        C_DEPEND_FLAG=${ac_C_DEPEND_FLAG}
70        break
71     fi
72  done
73
74 dnl use gcc option -MG : asume unknown file will be construct later
75  rm -f conftest.d conftest.err
76  ${DEPCC} ${C_DEPEND_FLAG} -MG -c conftest.c 1> conftest.d 2> conftest.err
77  if test -f conftest.u ; then
78     mv conftest.u conftest.d
79  fi
80  rm -f conftest
81  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
82  if test ! -s conftest ; then
83     C_DEPEND_FLAG=${C_DEPEND_FLAG}" -MG"
84  fi
85
86  rm -f conftest*
87  if test "x${C_DEPEND_FLAG}" = "x" ; then
88     echo "cannot determine flag (C language)"
89     exit
90  fi
91
92  printf " C :  ${DEPCC} ${C_DEPEND_FLAG}"
93
94  AC_LANG_CPLUSPLUS
95  echo "conftest.o: conftest.cxx" > conftest.verif
96  echo "int  main() { return 0; }" > conftest.cxx
97
98  CXX_DEPEND_FLAG=
99  for ac_CXX_DEPEND_FLAG in -xM -MM -M ; do
100
101     rm -f conftest.d conftest.err
102     ${DEPCXX} ${ac_CXX_DEPEND_FLAG} -c conftest.cxx 1> conftest.d 2> conftest.err
103     if test -f conftest.u ; then
104        mv conftest.u conftest.d
105     fi
106
107     rm -f conftest
108     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
109     if test ! -s conftest ; then
110        CXX_DEPEND_FLAG=${ac_CXX_DEPEND_FLAG}
111        break
112     fi
113  done
114
115 dnl use g++ option -MG : asume unknown file will be construct later
116  rm -f conftest.d conftest.err
117  ${DEPCXX} ${CXX_DEPEND_FLAG} -MG -c conftest.cxx 1> conftest.d 2> conftest.err
118  if test -f conftest.u ; then
119     mv conftest.u conftest.d
120  fi
121  rm -f conftest
122  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
123  if test ! -s conftest ; then
124     CXX_DEPEND_FLAG=${CXX_DEPEND_FLAG}" -MG"
125  fi
126
127
128  rm -f conftest*
129  if test "x${CXX_DEPEND_FLAG}" = "x" ; then
130     echo "cannot determine flag (C++ language)"
131     exit
132  fi
133
134  printf " C++ : ${DEPCXX} ${CXX_DEPEND_FLAG}"
135  AC_LANG_RESTORE
136
137  AC_SUBST(DEPCC)
138  AC_SUBST(DEPCXX)
139  AC_SUBST(DEPCXXFLAGS)
140  AC_SUBST(C_DEPEND_FLAG)
141  AC_SUBST(CXX_DEPEND_FLAG)
142  AC_SUBST(MACHINE)
143 ])
144 ])