summaryrefslogtreecommitdiff
path: root/lib/make/known-architectures/darwin
blob: 1caf19b624898333ac0992d0b4ab293e102520b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#! /bin/sh
# /*@@
#   @file    darwin
#   @date    Sat 27 March 2004
#   @author  John Shalf, Gabrielle Allen, Tom Goodale
#   @desc
#            Known architecture stuff for MacOS X (Darwin)
#   @enddesc
#   @version $Header: /mnt/data2/cvs2svn/cvs-repositories/Cactus/lib/make/known-architectures/darwin,v 1.17 2006-07-19 11:02:05 schnetter Exp $
# @@*/

if test "$CCTK_CONFIG_STAGE" = 'preferred-compilers' ; then

  # Try to work out which FPP we need to use 
  if test -z "$FPP" -a -z "$FPPFLAGS"; then
    FPP='/usr/bin/cpp'

    FPP_VERSION="`$FPP --version | awk '{print $3; exit}'`"
    FPP_VERSION_MAJOR="`echo $FPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\1:'`"
    FPP_VERSION_MINOR="`echo $FPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\2:'`"

    if test $FPP_VERSION_MAJOR -lt 3 ; then
	FPP="$(PERL) $(CCTK_HOME)/lib/sbin/cpp.pl"
	FPPFLAGS=
	FPP_VERSION="`$FPP --version | awk '{print $3; exit}'`"
	FPP_VERSION_MAJOR="`echo $FPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\1:'`"
	FPP_VERSION_MINOR="`echo $FPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\2:'`"
    else
	FPPFLAGS='-traditional'
    fi

    echo Setting FPP to $FPP
    echo Setting FPPFLAGS to $FPPFLAGS
  fi

else

  if test "`$CC --version 2>&1 | head -n 1 | grep -i gcc`" ; then
      MAC_C_COMP=gcc
  elif test "`$CC -version 2>&1 | grep xlc`" ; then
      MAC_C_COMP=ibm
  else
      MAC_C_COMP=unknown
  fi

  if test "`$CXX --version 2>&1 | head -n 1 | grep -i gcc`" ; then
      MAC_CXX_COMP=gcc
  elif test "`$CXX -version 2>&1 | grep xlc`" ; then
      MAC_CXX_COMP=ibm
  else
      MAC_CXX_COMP=unknown
  fi

  # Find out which CPP we are using and its version

  if test "`$CPP --version | grep -i gcc`"; then 
      CPP_VENDOR=GNU
      CPP_VERSION="`cpp --version | awk '{print $3; exit}'`"
      CPP_VERSION_MAJOR="`echo $CPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\1:'`"
      CPP_VERSION_MINOR="`echo $CPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\2:'`"
  elif test "`$CPP --version | grep -i Cactus`"; then
      CPP_VENDOR=Cactus
      CPP_VERSION="`cpp --version | awk '{print $3; exit}'`"
      CPP_VERSION_MAJOR="`echo $CPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\1:'`"
      CPP_VERSION_MINOR="`echo $CPP_VERSION | sed 's:\([^. ]*\)\.\([^. ]*\).*:\2:'`"
  fi

  if test "$MAC_C_COMP" = "gcc" ; then
    C_DEPEND='$(CC) -M $(CPPFLAGS)'
    CXX_DEPEND='$(CXX) -M $(CPPFLAGS)'
  elif test -e '/usr/lib/gcc/darwin/3.3' ; then
    # This is dangerous -- it could pick up the wrong gcc
    # C_DEPEND='gcc -M -no-cpp-precomp $(CPPFLAGS)'
    C_DEPEND='gcc -M $(CPPFLAGS)'
    CXX_DEPEND='g++ -E -M $(CPPFLAGS)'
  else
    C_DEPEND='$(PERL) $(CCTK_HOME)/lib/sbin/cpp.pl -M $(CPPFLAGS)'
    CXX_DEPEND='$(PERL) $(CCTK_HOME)/lib/sbin/cpp.pl -M $(CPPFLAGS)'
  fi

  # Determine which Fortran 90 compiler is in use
  MAC_F90_COMP=none
  if test -n "$F90" && test "$F90" != 'none' ; then
    if test "`$F90 -version 2>&1 | grep xlf`" ; then
      MAC_F90_COMP=ibm
    elif test "`$F90 -? 2>&1 | grep -i absoft`" ; then
      MAC_F90_COMP=absoft
    elif test "`$F90 --version 2>&1 | head -n 1 | grep -i gcc`" ; then
      MAC_F90_COMP=gcc
    else
      # Ok, those were the easy ones, now try more
      # obscure things

      echo "      subroutine foo" > foo.f
      echo "      end subroutine foo" >> foo.f

      if test "`/opt/absoft/bin/f95 -V foo.f 2>&1 | grep -i absoft`" ; then
        MAC_F90_COMP=absoft
      else
	echo Unknown MacOS X f90 compiler.
	echo Please add appropriate information to
	echo $srcdir/known-architectures/darwin
	echo and send the updated file to CactusMaint
	echo We will try anyway ...
      fi
      rm foo.f
    fi
  elif test -n "$F77" ; then
    if test "`$F77 -version 2>&1 | grep xlf`" ; then
      MAC_F77_COMP=ibm77
    elif test "`$F77 -? 2>&1 | grep -i absoft`" ; then
      MAC_F77_COMP=absoft77
    elif test "`$F77 --version 2>&1 | head -n 1 | grep -i gcc`" ; then
      MAC_F77_COMP=gcc
    else
      echo Unknown MacOS X f77 compiler.
      echo Please add appropriate information to
      echo $srcdir/known-architectures/darwin
      echo and send the updated file to CactusMaint
      echo We will try anyway ...
    fi
  fi

  # Set the appropriate flags for C
 
  case "$MAC_C_COMP" in
      gcc)
      CC_VERSION="`$CC --version 2>&1 | head -n 1`"
      # : ${CFLAGS="-no-cpp-precomp -mlongcall"}
      # : ${CFLAGS="-mlongcall"}
      ;;
      *)
      :
      ;;
  esac

  case "$MAC_CXX_COMP" in
      gcc)
      CXX_VERSION="`$CXX --version 2>&1 | head -n 1`"
      # : ${CXXFLAGS="-no-cpp-precomp -mlongcall"}
      # : ${CXXFLAGS="-mlongcall"}
      ;;
      *)
      :
      ;;
  esac  

  #Set the appropriate flags for Fortran
  case "$MAC_F90_COMP" in
    absoft)
      : ${LIBS='f90math fio f77math m'}
      : ${F90FLAGS='-N11'}
      : ${F77FLAGS='-N11'}
      : ${F90_OPTIMISE_FLAGS='-s -O'}
      : ${F77_OPTIMISE_FLAGS='-s -O'}
      : ${F77_DEBUG_FLAGS='-g'}
      : ${F90_DEBUG_FLAGS='-g'}
      : ${F77_WARN_FLAGS='-m0'}
      : ${F90_WARN_FLAGS='-m0'}
      if test -z "$LIBDIRS" ; then
	  LIBDIRS="`which $F90 | sed 's,/bin/.*,/lib,'`"
      fi
      ;;
    absoft77)
      : ${LIBS='fio f77math m'}
      F90FLAGS='-f'
      # Test if it is a version of the absoft compiler which has the library 
      # in a custom place.
      if test -n "$ABSOFT" ; then
        : ${LIBDIRS='$(ABSOFT)/lib'}
      fi
      : ${F77_DEBUG_FLAGS='-g'}
      : ${F90_DEBUG_FLAGS='-g'}
      : ${F77_WARN_FLAGS='-m0'}
      : ${F90_WARN_FLAGS='-m0'}
      ;;
    gcc)
      F77_VERSION="`$F77 --version 2>&1 | head -n 1`"
      F90_VERSION="`$F90 --version 2>&1 | head -n 1`"
      # : ${F77FLAGS='-mlongcall'}
      # : ${F90FLAGS='-mlongcall'}
      : ${LIBS='gfortran'}
      ;;
    ibm)
#      : ${LD='xlC'}
      : ${LIBS='xlf90 xlfmath m'}

      if test -z "$LIBDIRS" ; then
	  LIBDIRS="`which $F90 | sed 's,/bin/.*,/lib,'`"
      fi
#      : ${LIBDIRS='/opt/ibmcmp/lib'}
#      : ${ARFLAGS='-rucs'}
                    # suppress congratulatory message on successful compilation
      : ${F90FLAGS='-qnullterm -qsuffix=f=f -qsuppress=1501-510:cmpmsg'}
      : ${F77FLAGS='-qnullterm -qsuffix=f=f -qsuppress=1501-510:cmpmsg'}
                    # -O3 -qhot moves some instructions...but improves speed
                    # -qarch etc optimises for the architecture on which code
                    #        is compiled
      : ${F90_OPTIMISE_FLAGS='-O3 -qhot -qarch=auto -qtune=auto -qcache=auto'}
      : ${F77_OPTIMISE_FLAGS='-O3 -qhot -qarch=auto -qtune=auto -qcache=auto'}
      : ${F90_SUFFIX='f'}

      CCTK_WriteLine make.arch.defn 'F90FLAGS += $(DARWIN_$(subst .,,$(suffix $<))_FLAGS)'
      CCTK_WriteLine make.arch.defn 'F77FLAGS += $(DARWIN_$(subst .,,$(suffix $<))_FLAGS)'
      CCTK_WriteLine make.arch.defn 'DARWIN_F90_FLAGS ='
      CCTK_WriteLine make.arch.defn 'DARWIN_f90_FLAGS ='
      CCTK_WriteLine make.arch.defn 'DARWIN_F77_FLAGS = -qfixed'
      CCTK_WriteLine make.arch.defn 'DARWIN_f77_FLAGS = -qfixed'
      CCTK_WriteLine make.arch.defn 'DARWIN_F_FLAGS = -qfixed'
      CCTK_WriteLine make.arch.defn 'DARWIN_f_FLAGS = -qfixed'
      ;;
    *)
      : ${LIBS='m'}
      ;;
  esac

  # Darwin's ar command doesn't understand the '-s' flag
  # so we have to use ranlib to add a table of contents to libraries
  : ${ARFLAGS='ruc'}
  : ${USE_RANLIB='yes'}

  # MPI stuff
  #
  # Darwin has no native MPI, so we don't set any NATIVE_MPI_XXX variables.
  # This is caught later on by lib/make/extras/MPI/NATIVE.

fi