aboutsummaryrefslogtreecommitdiffstats
path: root/science/openfoam/Makefile
blob: 1a572548f6166a75bb41d74e41e93666f39775f2 (plain) (blame)
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
# New ports collection makefile for:    OpenFOAM
# Date created:     Sat 17 dec 2005
# Whom:         thierry@pompo.net
#
# $FreeBSD$
#

PORTNAME=   ${REALNAME:L}
PORTVERSION=    1.3
CATEGORIES= science math
MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= foam
DISTNAME=   ${REALNAME}-${PORTVERSION}.General
EXTRACT_SUFX=   .gtgz

MAINTAINER= thierry@FreeBSD.org
COMMENT=    Open Field Operation and Manipulation - CFD Simulation Toolbox

BUILD_DEPENDS=  micod:${PORTSDIR}/devel/mico                        \
        cmake:${PORTSDIR}/devel/cmake                       \
        ${X11BASE}/lib/libode.a:${PORTSDIR}/devel/ode               \
        ${PARAVIEW_LIB}/ParaViewConfig.cmake:${PORTSDIR}/science/paraview   \
        ${LOCALBASE}/share/java/java3d/jar/j3dutils.jar:${PORTSDIR}/java/java3d \
        ${LOCALBASE}/include/libiberty/demangle.h:${PORTSDIR}/devel/gnulibiberty\
        ${LOCALBASE}/include/vtk/vtkDataSetSource.h:${PORTSDIR}/math/vtk-headers
LIB_DEPENDS=    execinfo:${PORTSDIR}/devel/libexecinfo
RUN_DEPENDS=    micod:${PORTSDIR}/devel/mico                        \
        dx:${PORTSDIR}/graphics/opendx                      \
        ${LOCALBASE}/lib/libiberty.a:${PORTSDIR}/devel/gnulibiberty     \
        ${LOCALBASE}/share/java/java3d/jar/j3dutils.jar:${PORTSDIR}/java/java3d \
        paraview:${PORTSDIR}/science/paraview

.if !defined(NOPORTDOCS)
BUILD_DEPENDS+= doxygen:${PORTSDIR}/devel/doxygen   \
        dot:${PORTSDIR}/graphics/graphviz
.endif

USE_GCC=    3.4+
USE_JAVA=   yes
JAVA_VERSION=   1.4+
USE_GL=     yes
REINPLACE_ARGS= -i ""

WRKSRC=     ${WRKDIR}/${REALNAME}-${PORTVERSION}
PKGMESSAGE= ${WRKDIR}/pkg-message
SUB_FILES=  pkg-message
SUB_LIST=   REALNAME=${REALNAME} VER=${PORTVERSION} APPSUBDIR=${APPSUBDIR}
PLIST_SUB=  ${SUB_LIST}

#MAKE_SHELL=    ${CSH}
MAKE_ENV=   WM_PROJECT_DIR=${BUILD_WRKSRC} WM_ARCH=${OPSYS}         \
        WM_PROJECT_INST_DIR=${PREFIX}/${REALNAME} WM_COMPILER=""    \
        WM_COMPILER_ARCH=${ARCH} WM_COMPILER_LIB_ARCH=${ARCH}       \
        WM_PROJECT_VERSION=${PORTVERSION} WM_PROJECT=${REALNAME}    \
        LD_LIBRARY_PATH="" WM_JAVAC_OPTION=${COMPOPT}           \
        WM_PROJECT_USER_DIR=${HOME}/${REALNAME}             \
        MICO_VERSION=${MICO_VER} MICO_ARCH_PATH=${LOCALBASE}        \
        WM_PRECISION_OPTION=${PRECISION} WM_COMPILE_OPTION=${COMPOPT}   \
        PTHREAD_CFLAGS=${PTHREAD_CFLAGS} PTHREAD_LIBS=${PTHREAD_LIBS}

CSH=        /bin/csh
REALNAME=   OpenFOAM
PRECISION?= DP
COMPOPT?=   Opt
PARAVIEW_VER?=  2.4.2
PARAVIEW_LIB=   ${LOCALBASE}/lib/paraview-${PARAVIEW_VER:R}
GCC_VER=    ${_GCCVERSION:S/0/-/:S/0/./g}

BATCHRC=    .bashrc .cshrc
SHELLRC=    bashrc cshrc
DIR2CLEAN=  .${REALNAME}-${PORTVERSION} bin wmake applications
DIR2INST=   .${REALNAME}-${PORTVERSION} bin lib wmake
APP2INST=   solvers test utilities
THRD2FIX=   c++ mplibLAM
VER2FIX=    applications/utilities/mesh/manipulation/patchTool/C++/PatchToolServer/Make/omniOptions \
        applications/utilities/mesh/manipulation/patchTool/C++/FoamXServer/Make/omniOptions \
        applications/utilities/preProcessing/FoamX/C++/FoamXLib/Make/omniOptions
GL2FIX=     applications/utilities/miscellaneous/foamDebugSwitches/Make/options
PARARC=     bashrc cshrc
PS2FIX=     runFoamXHB patchTool foamJob killFoamX foamEndJob
BASH2FIX=   wmake/bashScripts/makeFiles wmake/bashScripts/makeOptions wmake/bashScripts/addCompile  \
        wmake/bashScripts/mkObjectDir .OpenFOAM-${PORTVERSION}/apps/ensightFoam/bashrc
DIR2PRUNE=  applications/utilities/mesh/manipulation/setSet/readline-5.0/platforms
APPSUBDIR=  ${OPSYS}${PRECISION}${COMPOPT}
APPDIR=     applications/bin/${APPSUBDIR}

DOCS=       README doc/Guides-a4 doc/Guides-usletter

.if defined(WITH_LAM)
BUILD_DEPENDS+= ${LOCALBASE}/bin/mpicc:${PORTSDIR}/net/lam7
RUN_DEPENDS+=   ${LOCALBASE}/bin/mpirun:${PORTSDIR}/net/lam7
MAKE_ENV+=  WM_MPLIB=LAM LAM_ARCH_PATH=${LOCALBASE}
MPICH_VER=  1.2.6
LAM_VER=    `${GREP} LAM_VERSION ${LOCALBASE}/include/lam_config.h | ${AWK} '{print $$3}'`
MPI_LIB=    LAM
PLIST_SUB+= MPI="@comment " LAM="" LAM_VER=7.1.1
IGNORE=     does not run with lam7 at the moment
.else   # TODO: add support for OpenMPI
BUILD_DEPENDS+= ${LOCALBASE}/mpich/bin/mpicc:${PORTSDIR}/net/mpich
RUN_DEPENDS+=   ${LOCALBASE}/mpich/bin/mpirun:${PORTSDIR}/net/mpich
MAKE_ENV+=  WM_MPLIB=MPICH MPICH_ARCH_PATH=${LOCALBASE}/mpich
MPICH_VER=  `${LOCALBASE}/mpich/bin/mpichversion | ${HEAD} -1 | ${AWK} '{print $$3}'`
LAM_VER=    7.1.1
MPI_LIB=    MPICH
PLIST_SUB+= MPI="" LAM="@comment " MPICH_VER=1.2.6
.endif

.include <bsd.port.pre.mk>

.if ${OSVERSION} < 500000
BROKEN= Does not compile with gcc-2.95
.endif

.if ${OSVERSION} <= 504103
EXTRACT_DEPENDS+=   bsdtar:${PORTSDIR}/archivers/bsdtar
TAR=        ${LOCALBASE}/bin/bsdtar
.endif

.if exists(${LOCALBASE}/bin/mico-config)
MICO_VER=   `${LOCALBASE}/bin/mico-config --version`
.else
MICO_VER=   2.3.11
.endif

OSVERMAJ=   ${OSREL:R}

post-extract:
    ${CP} -Rp ${WRKSRC}/wmake/rules/linux ${WRKSRC}/wmake/rules/${OPSYS}
    ${RM} ${WRKSRC}/wmake/rules/${OPSYS}/dirToString

pre-configure:
    ${FIND} ${DIR2CLEAN:S|^|${WRKSRC}/|} -name "*.orig" -delete
    ${REINPLACE_CMD} -e "s|/usr/local|${PREFIX}|"       \
        -e "s|#!/bin/bash|#!${LOCALBASE}/bin/bash|" \
        -e "s|%%MPILIB%%|${MPI_LIB}|"           \
        ${SHELLRC:S|^|${WRKSRC}/.${REALNAME}-${PORTVERSION}/|}
    ${REINPLACE_CMD} -e "s|%%JAVA_HOME%%|${JAVA_HOME}|"         \
        -e "s|^#!/bin/bash|#! ${LOCALBASE}/bin/bash|"           \
        -e "s|gcc-3.4.3|gcc${GCC_VER}|"                 \
        -e "s|2\.3\.11|${MICO_VER}|"                    \
        -e "s|\$$MICO_PATH/platforms/\$$WM_OPTIONS|${LOCALBASE}|"   \
        -e "s|1\.2\.4|${MPICH_VER}|"                    \
        -e "s|\$$MPICH_PATH/platforms/\$$WM_OPTIONS|${LOCALBASE}/mpich|"\
        -e "s|7\.1\.1|${LAM_VER}|"                  \
        -e "s|\$$LAMHOME/platforms/\$$WM_OPTIONS|${LOCALBASE}|"     \
        -e "s|^SOURCE |source |"                    \
        ${BATCHRC:S|^|${WRKSRC}/|}
    ${REINPLACE_CMD} -e "s|-lGL|-L${X11BASE}/lib -lGL|" \
        ${GL2FIX:S|^|${WRKSRC}/|}
    ${REINPLACE_CMD} -e "s|GCC_VERSION=4.1.0|GCC_VERSION=${GCC_VER:S/_//}|" \
        -e "s|JAVA_VERSION=1.4.2+|JAVA_VERSION=${JAVA_PORT_VERSION}|"   \
        ${WRKSRC}/bin/foamInstallationTest
    ${REINPLACE_CMD} -e "s|#!/bin/bash|#! ${LOCALBASE}/bin/bash|"   \
        ${BASH2FIX:S|^|${WRKSRC}/|}
.for f in ${THRD2FIX}
    ${REINPLACE_CMD} -e "s|-pthread|${PTHREAD_LIBS}|"   \
        -e "s|-lpthread|${PTHREAD_LIBS}|"       \
        ${WRKSRC}/wmake/rules/${OPSYS}/${f}
.endfor
    ${REINPLACE_CMD} -e "s|/usr/X11R6|${X11BASE}|"      \
        ${WRKSRC}/wmake/rules/${OPSYS}/X
.for f in ${VER2FIX}
    ${REINPLACE_CMD} -e "s|%%ARCH%%|${ARCH}|"   \
        -e "s|%%OSVERMAJ%%|${OSVERMAJ}|"    \
        -e "s|-lpthread|${PTHREAD_LIBS}|"   \
        ${WRKSRC}/${f}
.endfor
.for f in ${PS2FIX}
    ${REINPLACE_CMD} -e "s|ps -u|ps -U|" ${WRKSRC}/bin/${f}
.endfor
.for f in ${PARARC}
    ${REINPLACE_CMD} -e "s|/usr/local|${LOCALBASE}|"        \
        -e "s|#!/bin/bash|#!${LOCALBASE}/bin/bash|"     \
        -e "s|2.4.2|${PARAVIEW_VER}|"               \
        -e "s|paraview-2.4|paraview-${PARAVIEW_VER:R}|"     \
        ${WRKSRC}/.${REALNAME}-${PORTVERSION}/apps/paraview/${f}
.endfor

do-build:
    (cd ${BUILD_WRKSRC};            \
    ${SETENV} ${MAKE_ENV} ./Allwmake)

.if !defined(NOPORTDOCS)
post-build:
    @${ECHO_MSG} "===>  Building documentation."
    (cd ${BUILD_WRKSRC};            \
    ${SETENV} ${MAKE_ENV} ./Allwmake doc)
.endif

do-install:
    ${MKDIR} ${PREFIX}/${REALNAME}/applications
    ${CP} -R ${BATCHRC:S|^|${WRKSRC}/|} ${PREFIX}/${REALNAME}
    ${CP} -R ${DIR2INST:S|^|${WRKSRC}/|} ${PREFIX}/${REALNAME}
    ${CP} -R ${APP2INST:S|^|${WRKSRC}/applications/|} ${PREFIX}/${REALNAME}/applications
    ${FIND} ${PREFIX}/${REALNAME}/applications -type d          \
        \( -name ${APPSUBDIR} -o -name linuxDebug -o -name linuxOpt \)  \
        -exec ${RM} -rf {} \; 2>/dev/null || ${TRUE}
    ${MKDIR} ${PREFIX}/${REALNAME}/${APPDIR} ${PREFIX}/${REALNAME}/jobControl
    cd ${WRKSRC}/${APPDIR}                  \
    && ${FIND} . -type f -exec ${INSTALL_PROGRAM} {}    \
        ${PREFIX}/${REALNAME}/${APPDIR}/{} \;
    @${RMDIR} ${DIR2PRUNE:S|^|${PREFIX}/${REALNAME}/|}
    ${TOUCH} ${PREFIX}/${REALNAME}/jobControl/.keepme

.if !defined(NOPORTDOCS)
    ${CP} -R ${DOCS:S|^|${WRKSRC}/|} ${PREFIX}/${REALNAME}
    ${CP} -R ${WRKSRC}/tutorials ${PREFIX}/${REALNAME}
.endif

post-install:
    @${ECHO_MSG}
    @${CAT} ${PKGMESSAGE}
    @${ECHO_MSG}

.include <bsd.port.post.mk>