Allwmake 9.6 KB
Newer Older
Henry's avatar
Henry committed
1
2
3
4
5
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
6
#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
7
#    \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
Henry's avatar
Henry committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM.
#
#     OpenFOAM is free software: you can redistribute it and/or modify it
#     under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#     for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
#
# Script
#     Allwmake
#
# Description
#     Build script for ThirdParty
#
31
32
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
Henry's avatar
Henry committed
33
#------------------------------------------------------------------------------
34
# Run from third-party directory only
35
cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
36
37
    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
    echo "    Check your OpenFOAM environment and installation"
Henry's avatar
Henry committed
38
39
40
    exit 1
}
[ -n "$FOAM_EXT_LIBBIN" ] || {
41
    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set for ThirdParty"
42
    echo "    Check your OpenFOAM environment and installation"
Henry's avatar
Henry committed
43
44
45
46
    exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
47
# Compiler/linker settings for CMake/configure
Henry's avatar
Henry committed
48
49
50
51
52
53
[ -n "$WM_CC" ]         &&  export CC="$WM_CC"
[ -n "$WM_CXX" ]        &&  export CXX="$WM_CXX"
[ -n "$WM_CFLAGS" ]     &&  export CFLAGS="$WM_CFLAGS"
[ -n "$WM_CXXFLAGS" ]   &&  export CXXFLAGS="$WM_CXXFLAGS"
[ -n "$WM_LDFLAGS" ]    &&  export LDFLAGS="$WM_LDFLAGS"

54
useGccFlag $@           # Scan arguments for a '-gcc' option
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

warnBuildIssues()
{
    echo
    echo "    ---------------------------------------------------"
    echo "    Optional component ($1) had build issues"
    echo "    OpenFOAM will nonetheless remain largely functional"
    echo "    ---------------------------------------------------"
    echo
}

warnNotFound()
{
    echo "    Optional component ($1) was not found"
    echo
}

#------------------------------------------------------------------------------

Henry's avatar
Henry committed
74
75
76
77
echo
echo ========================================
echo Start ThirdParty Allwmake
echo ========================================
78
echo
Henry's avatar
Henry committed
79
80
echo ========================================
echo Build MPI libraries if required
mark's avatar
mark committed
81
echo "    $MPI_ARCH_PATH"
Henry's avatar
Henry committed
82
case "$WM_MPLIB" in
mark's avatar
mark committed
83
84
(OPENMPI | MPICH)
    ./make$WM_MPLIB -test "$MPI_ARCH_PATH" || ./make$WM_MPLIB
Henry's avatar
Henry committed
85
86
87
88
    ;;
esac


89
#------------------------------------------------------------------------------
mark's avatar
mark committed
90
# Building scotch on different platforms is still a bit of a pain
91

92
# Get SCOTCH_VERSION, SCOTCH_ARCH_PATH
93
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
Henry's avatar
Henry committed
94
95
96
97
then
    . $settings
else
    echo
98
    echo "Error: no config.sh/scotch settings"
Henry's avatar
Henry committed
99
100
101
    echo
fi

102
echo
Henry's avatar
Henry committed
103
104
105
106
echo ========================================
echo "Build Scotch decomposition library $SCOTCH_VERSION"
echo "    $SCOTCH_ARCH_PATH"

107
108
SCOTCH_SOURCE_DIR=$sourceBASE/$SCOTCH_VERSION

109
# Needs generalizing, but works fairly well
mark's avatar
mark committed
110
scotchMakefile=../../etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM
Henry's avatar
Henry committed
111
112
113
114
115
116
117

if [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
  -a -r $FOAM_EXT_LIBBIN/libscotch.so \
  -a -r $FOAM_EXT_LIBBIN/libscotcherrexit.so ]
then
    echo "    scotch header in $SCOTCH_ARCH_PATH/include"
    echo "    scotch libs   in $FOAM_EXT_LIBBIN"
118
elif [ -d "$SCOTCH_SOURCE_DIR" ]
119
then
Henry's avatar
Henry committed
120
(
121
    cd $SCOTCH_SOURCE_DIR/src || exit 1
122
    export GIT_DIR=$SCOTCH_SOURCE_DIR/.git # Mask seeing our own git-repo
123
124
    rm -rf $SCOTCH_ARCH_PATH

125
    applyPatch $SCOTCH_VERSION ..       # patch at parent-level
Henry's avatar
Henry committed
126
127

    prefixDIR=$SCOTCH_ARCH_PATH
128
    incDIR=$SCOTCH_ARCH_PATH/include
Henry's avatar
Henry committed
129
130
131
    libDIR=$FOAM_EXT_LIBBIN

    mkdir -p $prefixDIR 2>/dev/null
132
133
    mkdir -p $incDIR    2>/dev/null
    mkdir -p $libDIR    2>/dev/null
Henry's avatar
Henry committed
134
135
136
137
138
139
140
141
142
143
144

    if [ -f $scotchMakefile ]
    then
        rm -f Makefile.inc
        ln -s $scotchMakefile Makefile.inc
    fi
    [ -f Makefile.inc ] || {
        echo " Error: scotch needs an appropriate Makefile.inc"
        exit 1
    }

145
146
    export CCS="${CC:-$WM_CC}"  # CCS (serial compiler)   default=$(CC)
    export CCP=$(whichMpicc)    # CCP (parallel compiler) default=mpicc
Henry's avatar
Henry committed
147

148
149
150
    # Consistency for Intel-MPI and non-icc compilers
    [ -n "$I_MPI_CC" ] || export I_MPI_CC="${CC:-$WM_CC}"

151
    make realclean 2>/dev/null  # Extra safety
152
153
154
155
156
157
    make -j $WM_NCOMPPROCS scotch \
     && make \
        prefix=$prefixDIR \
        includedir=$incDIR \
        libdir=$libDIR \
        install
Henry's avatar
Henry committed
158

159
    make realclean 2>/dev/null || true      # Failed cleanup is uncritical
160
) || warnBuildIssues SCOTCH
161
else
162
    warnNotFound SCOTCH
Henry's avatar
Henry committed
163
164
fi

165
# Build ptscotch if MPI (ThirdParty or system) is available
166
# and normal scotch was built (has include and library)
167
if [ "${FOAM_MPI:-dummy}" != dummy ] && \
168
169
   [ -f $SCOTCH_ARCH_PATH/include/scotch.h \
  -a -r $FOAM_EXT_LIBBIN/libscotch.so ] || \
170
{
171
    # Report that the above tests failed and pass-through the failure
Henry's avatar
Henry committed
172
    echo
173
    echo "    WARNING: skipping pt-scotch - no mpi or <scotch.h> not found"
174
    false
Henry's avatar
Henry committed
175
176
}
then
177
    echo
Henry's avatar
Henry committed
178
    echo ========================================
179
    echo "Build pt-scotch decomposition library $SCOTCH_VERSION (with $FOAM_MPI)"
Henry's avatar
Henry committed
180
181
182
183
184
185
186
187
188
189
    echo "    $SCOTCH_ARCH_PATH"

    if [ -f $SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h \
      -a -r $FOAM_EXT_LIBBIN/$FOAM_MPI/libptscotch.so \
      -a -r $FOAM_EXT_LIBBIN/$FOAM_MPI/libptscotcherrexit.so ]
    then
        echo "    ptscotch header in $SCOTCH_ARCH_PATH/include/$FOAM_MPI"
        echo "    ptscotch libs   in $FOAM_EXT_LIBBIN/$FOAM_MPI"
    else
    (
190
        cd $SCOTCH_SOURCE_DIR/src || exit 1
191
        export GIT_DIR=$SCOTCH_SOURCE_DIR/.git # Mask seeing our own git-repo
192
        echo
Henry's avatar
Henry committed
193
194
195

        prefixDIR=$SCOTCH_ARCH_PATH
        incDIR=$SCOTCH_ARCH_PATH/include/$FOAM_MPI
196
        libDIR=$FOAM_EXT_LIBBIN/$FOAM_MPI
Henry's avatar
Henry committed
197
198

        mkdir -p $prefixDIR 2>/dev/null
199
200
        mkdir -p $incDIR    2>/dev/null
        mkdir -p $libDIR    2>/dev/null
Henry's avatar
Henry committed
201
202
203
204
205
206
207

        if [ -f $scotchMakefile ]
        then
            rm -f Makefile.inc
            ln -s $scotchMakefile Makefile.inc
        fi
        [ -f Makefile.inc ] || {
208
            echo " Error: ptscotch needs an appropriate Makefile.inc"
Henry's avatar
Henry committed
209
210
211
            exit 1
        }

212
213
        export CCS="${CC:-$WM_CC}"  # CCS (serial compiler)   default=$(CC)
        export CCP=$(whichMpicc)    # CCP (parallel compiler) default=mpicc
Henry's avatar
Henry committed
214

215
216
217
        # Consistency for Intel-MPI and non-icc compilers
        [ -n "$I_MPI_CC" ] || export I_MPI_CC="${CC:-$WM_CC}"

218
        make realclean 2>/dev/null  # Extra safety
219
220
221
222
223
224
        make -j $WM_NCOMPPROCS ptscotch \
         && make \
            prefix=$prefixDIR \
            includedir=$incDIR \
            libdir=$libDIR \
            install
Henry's avatar
Henry committed
225

226
        make realclean 2>/dev/null || true  # Failed cleanup is uncritical
227
    ) || warnBuildIssues PTSCOTCH
Henry's avatar
Henry committed
228
229
    fi

230
    # Verify existence of ptscotch include
Henry's avatar
Henry committed
231
232
233
234
235
236
    [ -f $SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h ] || {
        echo
        echo "    WARNING: required include file 'ptscotch.h' not found!"
    }
fi

237
238
# Could now remove $SCOTCH_SOURCE_DIR/src/Makefile.inc

Henry's avatar
Henry committed
239

240
#------------------------------------------------------------------------------
Henry's avatar
Henry committed
241
242

# Metis is optional
243
echo
Henry's avatar
Henry committed
244
245
246
echo ========================================
echo Build Metis decomposition

247
# Get METIS_VERSION, METIS_ARCH_PATH
248
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis)
Henry's avatar
Henry committed
249
250
251
then
    . $settings
fi
252

253
254
METIS_SOURCE_DIR=$sourceBASE/$METIS_VERSION

255
256
if [ -f $METIS_ARCH_PATH/include/metis.h \
  -a -r $FOAM_EXT_LIBBIN/libmetis.so ]
Henry's avatar
Henry committed
257
then
258
259
    echo "    metis header in $METIS_ARCH_PATH/include"
    echo "    metis libs   in $FOAM_EXT_LIBBIN"
260
elif [ -d "$METIS_SOURCE_DIR" ]
261
262
then
(
263
    cd $METIS_SOURCE_DIR || exit 1
264
    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
265
266
    rm -rf $METIS_ARCH_PATH

267
    # Adjust metis integer size to match OpenFOAM label-size
268
269
    sed -i -e 's=\(#define IDXTYPEWIDTH\).*=\1 '$WM_LABEL_SIZE'=' \
        include/metis.h
270

271
272
    # No config option for the library location.
    # - build normally and use mv to relocate it
273

274
    make config shared=1 prefix=$METIS_ARCH_PATH \
275
276
     && make -j $WM_NCOMPPROCS install \
     && mv $METIS_ARCH_PATH/lib/libmetis.so $FOAM_EXT_LIBBIN
277

278
    rmdir $METIS_ARCH_PATH/lib 2>/dev/null || true # Failed rmdir is uncritical
279
) || warnBuildIssues METIS
Henry's avatar
Henry committed
280
else
281
    warnNotFound METIS
Henry's avatar
Henry committed
282
283
284
fi


285
#------------------------------------------------------------------------------
286
echo
Henry's avatar
Henry committed
287
288
echo ========================================
echo Build CGAL
mark's avatar
mark committed
289
if [ -n "$CGAL_ARCH_PATH" ]
290
then
mark's avatar
mark committed
291
    ./makeCGAL -test "$CGAL_ARCH_PATH" "$BOOST_ARCH_PATH" || \
292
293
    ./makeCGAL || warnBuildIssues CGAL
else
mark's avatar
mark committed
294
    warnNotFound CGAL   # CGAL is optional
295
296
fi

297
echo
298
299
echo ========================================
echo Build FFTW
mark's avatar
mark committed
300
if [ -n "$FFTW_ARCH_PATH" ]
301
then
mark's avatar
mark committed
302
    ./makeFFTW -test "$FFTW_ARCH_PATH" || \
303
    ./makeFFTW || warnBuildIssues FFTW
Henry's avatar
Henry committed
304
else
mark's avatar
mark committed
305
    warnNotFound FFTW   # FFTW is optional
Henry's avatar
Henry committed
306
307
308
309
310
311
312
313
fi

echo
echo ========================================
echo Done ThirdParty Allwmake
echo ========================================
echo

314
#------------------------------------------------------------------------------