summaryrefslogtreecommitdiff
path: root/science/openfoam/Makefile
blob: 35a6cb30997f606b40b8a7de3ff088fd96459273 (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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# New ports collection makefile for:	OpenFOAM
# Date created:		Sat 17 dec 2005
# Whom:			thierry@pompo.net
#
# $FreeBSD$
#

PORTNAME=	${REALNAME:L}
PORTVERSION=	1.4
PORTREVISION=	1
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						\
		bash:${PORTSDIR}/shells/bash						\
		cmake:${PORTSDIR}/devel/cmake						\
		${X11BASE}/lib/libode.a:${PORTSDIR}/devel/ode				\
		${LOCALBASE}/lib/parmetis/libmetis.a:${PORTSDIR}/math/parmetis		\
		${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\
		${X11BASE}/lib/X11/fonts/freefont-ttf/FreeSans.ttf:${PORTSDIR}/x11-fonts/freefont-ttf
LIB_DEPENDS=	execinfo:${PORTSDIR}/devel/libexecinfo	\
		readline.5:${PORTSDIR}/devel/readline	\
		metis.1:${PORTSDIR}/math/metis
#		CGAL.0:${PORTSDIR}/math/cgal
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+	# Required to define GCC_VER
USE_JAVA=	yes
JAVA_VERSION=	1.5+
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.4
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
MALLOC2FIX=	src/MGridGenGamgAgglomeration/ParMGridGen-1.0/MGridGen/IMlib/IMlib.h	\
		src/MGridGenGamgAgglomeration/ParMGridGen-1.0/MGridGen/Lib/mgridgen.h
LOCAL2FIX=	wmake/rules/General/CGAL wmake/rules/${OPSYS}/general			\
		applications/utilities/parallelProcessing/decomposePar/Make/options	\
		applications/utilities/parallelProcessing/redistributeMeshPar/Make/options\
		applications/utilities/parallelProcessing/decompositionMethods/Make/options
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/lam
RUN_DEPENDS+=	${LOCALBASE}/bin/mpirun:${PORTSDIR}/net/lam
MAKE_ENV+=	WM_MPLIB=LAM LAM_ARCH_PATH=${LOCALBASE}
MPICH_VER=	1.0.5
LAM_VER=	`${LOCALBASE}/bin/laminfo -version lam full | ${AWK} '{print $$2}'`
MPI_LIB=	LAM
PLIST_SUB+=	MPI="@comment " LAM="" LAM_VER=${LAM_VERSION}
.else	# TODO: add support for OpenMPI
BUILD_DEPENDS+=	${LOCALBASE}/mpich2/bin/mpicc:${PORTSDIR}/net/mpich2
RUN_DEPENDS+=	${LOCALBASE}/mpich2/bin/mpirun:${PORTSDIR}/net/mpich2
MAKE_ENV+=	WM_MPLIB=MPICH MPICH_ARCH_PATH=${LOCALBASE}/mpich2
MPI_LIBPATH=	${LOCALBASE}/mpich2/lib
MPICH_VER=	`${LOCALBASE}/mpich2/bin/mpich2version --version`
LAM_VER=	7.1.2
MPI_LIB=	MPICH
PLIST_SUB+=	MPI="" LAM="@comment " MPICH_VER=${MPICH_VERSION}
.endif

.include <bsd.port.pre.mk>

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

.if defined(WITH_LAM)
. if exists(${LOCALBASE}/bin/laminfo)
LAM_VERSION!=	${LOCALBASE}/bin/laminfo -version lam full | ${AWK} '{print $$2}'
. else
LAM_VERSION=	${LAM_VER}
. endif
.else
. if exists(${LOCALBASE}/mpich2/bin/mpich2version)
MPICH_VERSION!=	${LOCALBASE}/mpich2/bin/mpich2version --version
. else
MPICH_VERSION=	${MPICH_VER}
. endif
.endif

OSVERMAJ=	${OSREL:R}

post-extract:
	${CP} -Rp ${WRKSRC}/wmake/rules/linux ${WRKSRC}/wmake/rules/${OPSYS}
	${RM} ${WRKSRC}/wmake/rules/${OPSYS}/dirToString
	${RM} -rf ${WRKSRC}/applications/utilities/mesh/manipulation/setSet/readline-5.0/platforms
	${FIND} ${WRKSRC}/applications/utilities/mesh/conversion/ccm26ToFoam/libccmio	\
		-name "\.#*" -delete

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|2\.3\.12|${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}/mpich2|"\
		-e "s|7\.1\.2|${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.1|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}/|}
	${REINPLACE_CMD} -e "s|<malloc.h>|<stdlib.h>|"	\
		${MALLOC2FIX: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.4|${PARAVIEW_VER}|"				\
		-e "s|paraview-2.4|paraview-${PARAVIEW_VER:R}|"		\
		${WRKSRC}/.${REALNAME}-${PORTVERSION}/apps/paraview/${f}
.endfor
.for f in ${LOCAL2FIX}
	${REINPLACE_CMD} -e "s|/usr/local|${LOCALBASE}|"	\
		${WRKSRC}/${f}
.endfor
	${REINPLACE_CMD} -e	\
		's|$$CURDIR/readline-5.0/platforms/$$WM_OPTIONS|${LOCALBASE}|'	\
		${WRKSRC}/applications/utilities/mesh/manipulation/setSet/Allwmake
.if defined(MPI_LIBPATH)
	${REINPLACE_CMD} -e	\
	'/LINKEXE/s|OPTIONS_DIR)|OPTIONS_DIR) -L${MPI_LIBPATH} -rpath-link ${MPI_LIBPATH}|'\
		${WRKSRC}/wmake/Makefile
.endif

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}/{} \;
	${TOUCH} ${PREFIX}/${REALNAME}/jobControl/.keepme
	@${RM} -f ${PREFIX}/${REALNAME}/applications/utilities/mesh/conversion/ccm26ToFoam/libccmio/libadf/wmkdep.core
.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>