Salome HOME
9e4cf9f4655864a019681fc51b114c004e13385a
[tools/configuration.git] / autotools / m4 / ac_cxx_depend_flag.m4
1 dnl Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License, or (at your option) any later version.
10 dnl
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl Lesser General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22
23 dnl @synopsis AC_C_DEPEND_FLAG
24 dnl define C_DEPEND_FLAG
25 dnl define CXX_DEPEND_FLAG
26 dnl @version $Id$
27 dnl @author Marc Tajchman
28 dnl
29 AC_DEFUN([AC_DEPEND_FLAG],[
30  AC_MSG_CHECKING([which flag for dependency information generation])
31  AC_LANG_SAVE
32  AC_LANG_C
33  echo "conftest.o: conftest.c" > conftest.verif
34  echo "int  main() { return 0; }" > conftest.c
35
36 f77int="F77INT32"
37 case  $host_os in
38    irix5.* | irix6.* | osf4.* | osf5.* | linux*  )
39
40         linux64="true"
41 # porting on intel processor 64 bits
42         expr "$host_os" : 'linux' >/dev/null && ( test ! x"$host_cpu" = x"x86_64" && test ! x"$host_cpu" = x"ia64" ) && linux64="false"
43         if test ! x"$linux64" = "xfalse" ; then
44           echo "$as_me:$LINENO: checking for 64bits integers size in F77/F90" >&5
45 echo $ECHO_N "checking for 64bits integers size in F77/F90... $ECHO_C" >&6
46           # Check whether --enable-int64 or --disable-int64 was given.
47 if test "${enable_int64+set}" = set; then
48   enableval="$enable_int64"
49
50 fi;
51           case "X-$enable_int64" in
52             X-no)
53              echo "$as_me:$LINENO: result: \"disabled\"" >&5
54 echo "${ECHO_T}\"disabled\"" >&6
55              SUFFIXES="_32"
56              ;;
57             *)
58              echo "$as_me:$LINENO: result: \"enabled\"" >&5
59 echo "${ECHO_T}\"enabled\"" >&6
60              SUFFIXES=""
61              f77int="F77INT64"
62              ;;
63           esac
64         fi
65      ;;
66    *)
67      ;;
68 esac
69
70 case $host_os in
71     linux*)
72 # porting on intel processor 64 bits: if 64 bits processor, by default compilation in 64 bits
73         if test x"$linux64" = x"true"; then \
74           MACHINE="PCLINUX64${SUFFIXES}";
75           CFLAGS=" -D_OCC64 ${CXXFLAGS}";
76           CXXFLAGS=" -D_OCC64 ${CXXFLAGS}";\
77         else \
78           MACHINE=PCLINUX; \
79         fi
80         ;;
81     hpux*)
82         MACHINE=HP9000
83         ;;
84     aix4.*)
85         MACHINE=RS6000
86         host_os_novers=aix4.x
87         ;;
88     irix5.*)
89         MACHINE="IRIX64${SUFFIXES}"
90         host_os_novers=irix5.x
91         ;;
92     irix6.*)
93         MACHINE="IRIX64${SUFFIXES}"
94         host_os_novers=irix6.x
95         ;;
96     osf4.*)
97         MACHINE="OSF1${SUFFIXES}"
98         host_os_novers=osf4.x
99         ;;
100     osf5.*)
101         MACHINE="OSF1${SUFFIXES}"
102          host_os_novers=osf5.x
103          ;;
104     solaris2.*)
105         MACHINE=SUN4SOL2
106          host_os_novers=solaris2.x
107          ;;
108     uxpv*)
109         MACHINE=VPP5000
110          ;;
111     *)
112         MACHINE=
113          host_os_novers=$host_os
114          ;;
115 esac
116
117 dnl Evolution portage sur CCRT/osf system
118  case $host_os in
119    osf*)
120 dnl sur CCRT/osf pas d'equivalent de l'option -MG de gcc avec compilo natif
121 dnl on utilise donc gnu pour generer les dependances.
122      DEPCC=gcc
123      DEPCXX=g++
124      DEPCXXFLAGS=
125      DIFFFLAGS="-w"
126 dnl  MACHINE="OSF1"
127      ;;
128    *)
129      DEPCC=${CC-cc}
130      DEPCXX=${CXX-c++}
131      DEPCXXFLAGS="\${CXXFLAGS}"
132      DIFFFLAGS="-b -B"
133 dnl  MACHINE="PCLINUX"
134      ;;
135  esac
136  C_DEPEND_FLAG=
137  for ac_C_DEPEND_FLAG in -xM -MM -M ; do
138
139     rm -f conftest.d conftest.err
140     ${DEPCC} ${ac_C_DEPEND_FLAG} -c conftest.c 1> conftest.d 2> conftest.err
141     if test -f conftest.u ; then
142        mv conftest.u conftest.d
143     fi
144
145     rm -f conftest
146     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
147     if test ! -s conftest ; then
148        C_DEPEND_FLAG=${ac_C_DEPEND_FLAG}
149        break
150     fi
151  done
152
153 dnl use gcc option -MG : asume unknown file will be construct later
154  rm -f conftest.d conftest.err
155  ${DEPCC} ${C_DEPEND_FLAG} -MG -c conftest.c 1> conftest.d 2> conftest.err
156  if test -f conftest.u ; then
157     mv conftest.u conftest.d
158  fi
159  rm -f conftest
160  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
161  if test ! -s conftest ; then
162     C_DEPEND_FLAG=${C_DEPEND_FLAG}" -MG"
163  fi
164
165  rm -f conftest*
166  if test "x${C_DEPEND_FLAG}" = "x" ; then
167     echo "cannot determine flag (C language)"
168     exit
169  fi
170
171  printf " C :  ${DEPCC} ${C_DEPEND_FLAG}"
172
173  AC_LANG_CPLUSPLUS
174  echo "conftest.o: conftest.cxx" > conftest.verif
175  echo "int  main() { return 0; }" > conftest.cxx
176
177  CXX_DEPEND_FLAG=
178  for ac_CXX_DEPEND_FLAG in -xM -MM -M ; do
179
180     rm -f conftest.d conftest.err
181     ${DEPCXX} ${ac_CXX_DEPEND_FLAG} -c conftest.cxx 1> conftest.d 2> conftest.err
182     if test -f conftest.u ; then
183        mv conftest.u conftest.d
184     fi
185
186     rm -f conftest
187     diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
188     if test ! -s conftest ; then
189        CXX_DEPEND_FLAG=${ac_CXX_DEPEND_FLAG}
190        break
191     fi
192  done
193
194 dnl use g++ option -MG : asume unknown file will be construct later
195  rm -f conftest.d conftest.err
196  ${DEPCXX} ${CXX_DEPEND_FLAG} -MG -c conftest.cxx 1> conftest.d 2> conftest.err
197  if test -f conftest.u ; then
198     mv conftest.u conftest.d
199  fi
200  rm -f conftest
201  diff ${DIFFFLAGS} conftest.d conftest.verif > conftest
202  if test ! -s conftest ; then
203     CXX_DEPEND_FLAG=${CXX_DEPEND_FLAG}" -MG"
204  fi
205
206
207  rm -f conftest*
208  if test "x${CXX_DEPEND_FLAG}" = "x" ; then
209     echo "cannot determine flag (C++ language)"
210     exit
211  fi
212
213  printf " C++ : ${DEPCXX} ${CXX_DEPEND_FLAG}"
214  AC_LANG_RESTORE
215
216  AC_MSG_RESULT([ ... done])
217
218  AC_SUBST(DEPCC)
219  AC_SUBST(DEPCXX)
220  AC_SUBST(DEPCXXFLAGS)
221  AC_SUBST(C_DEPEND_FLAG)
222  AC_SUBST(CXX_DEPEND_FLAG)
223  AC_SUBST(MACHINE)
224 ])