Ticket #26799: Portfile

File Portfile, 16.1 KB (added by cristiano.fontana@…, 13 years ago)

Upgrate to 4.9.4.p02

Line 
1# $Id: Portfile 63242 2010-01-30 15:21:59Z ryandesign@macports.org $
2
3PortSystem          1.0
4
5name                geant4
6version             4.9.4.p02
7revision            1
8categories          science
9maintainers         pd.infn.it:cristiano.fontana
10license             Geant4
11description         Geant4 is a toolkit for the simulation of the passage of particles through matter.
12long_description    Geant4 is a toolkit for the simulation of the passage of particles through matter. \
13                    Its areas of application include high energy, nuclear and accelerator physics, as well as studies in medical and space science. \
14                    The two main reference papers for Geant4 are published in Nuclear Instruments and Methods in Physics Research A 506 (2003) 250-303, \
15                    and IEEE Transactions on Nuclear Science 53 No. 1 (2006) 270-278.
16homepage            http://geant4.web.cern.ch/
17notes               GEANT4 needs some environment variables to run, they can be set using either ${prefix}/src/geant4/env.sh or ${prefix}/src/geant4/env.csh
18platforms           darwin
19
20# Data files versions
21set G4NDL_v             3.14
22set G4EMLOW_v           6.19
23set PhotonEvaporation_v 2.1
24set RadioactiveDecay_v  3.3
25set G4ABLA_v            3.0
26set G4NEUTRONXS_v       1.0
27set G4PII_v             1.2
28set RealSurface_v       1.0
29
30distfiles           geant${version}.tar.gz \
31                    G4NDL.${G4NDL_v}.tar.gz \
32                    G4EMLOW.${G4EMLOW_v}.tar.gz \
33                    G4PhotonEvaporation.${PhotonEvaporation_v}.tar.gz \
34                    G4RadioactiveDecay.${RadioactiveDecay_v}.tar.gz \
35                    G4ABLA.${G4ABLA_v}.tar.gz \
36                    G4NEUTRONXS.${G4NEUTRONXS_v}.tar.gz \
37                    G4PII.${G4PII_v}.tar.gz \
38                    RealSurface.${RealSurface_v}.tar.gz
39
40master_sites        http://geant4.cern.ch/support/source/
41
42checksums           geant4.9.4.p02.tar.gz \
43                    md5     d4e95badeb536d82278e690280633846 \
44                    sha1    304d45b8c77a80965a54ca34228f5fdace4ba3fa \
45                    rmd160  674bc1531b916dac99a15a015dd816d9ac01d329 \
46                    G4NDL.3.14.tar.gz \
47                    md5     b9b6869bc28c83d9160f674785a9f09f \
48                    sha1    dc8b7a5fa0fcd06a85071c1b09730de6d04362d3 \
49                    rmd160  8393b5e0301526ec747da133b6972c70b8c44210 \
50                    G4EMLOW.6.19.tar.gz \
51                    md5     c0fe7c8a59a2abde60d13e947f566718 \
52                    sha1    f63e41a43a3d0c793a04dbb6cce0bdcfeedf6889 \
53                    rmd160  ba67b3f1ee215966adc99661a1db4a5bf09c5511 \
54                    G4PhotonEvaporation.2.1.tar.gz \
55                    md5     d1ee8ac49515109c34ae3714c22d59dd \
56                    sha1    56937f579e2134259963093ca735afc2b5a6ec5c \
57                    rmd160  be5e5ef9db4b85f916017561cc2dfbc5a1b226d7 \
58                    G4RadioactiveDecay.3.3.tar.gz \
59                    md5     2a1b24863d5c5a4d165303f189c5b08e \
60                    sha1    877a31ddf673729aad5b5f5892333495a1803784 \
61                    rmd160  065769a13b45dd335a6c6bd3b265c6d0370dcf96 \
62                    G4ABLA.3.0.tar.gz \
63                    md5     d2d4e99b14f7a5057f4c10d9c2d647dd \
64                    sha1    5f38676f1650a508e49d35f9405ac96984388135 \
65                    rmd160  5a032ee8e90d00f39b67114fe257ec47001f347b \
66                    G4NEUTRONXS.1.0.tar.gz \
67                    rmd160  c8ddf1d50e7fdbc3d53959bb45bb84615467f96d \
68                    sha256  577d28b7faa41caacb001a30384028cd5e3b7018755ab94a427ce0a7feeab365 \
69                    G4PII.1.2.tar.gz \
70                    rmd160  de024c7462c8bca4ace2b21da116edbc9705ab7e \
71                    sha256  ad03a22444c4020b9ee8e4ed88bf00cfd8b227b9d1e71e16b847e3075151f12c \
72                    RealSurface.1.0.tar.gz \
73                    md5     0dde95e00fcd3bcd745804f870bb6884 \
74                    sha1    9b4bd95c647dc702458eeaf89ebf62c5885e2ece \
75                    rmd160  030513fe340e0cccbfe0b9ae9acb3ba6b5291ebb
76
77worksrcdir          geant${version}/source
78
79depends_lib         port:clhep \
80                    port:zlib
81
82default_variants    +global +motif +shared +gdml +raytracerx +aida
83
84
85variant debug description {Compile with debug flags on} {
86    build.env-append    G4DEBUG=1
87}
88
89variant global description {Build with global libraries} conflicts granular {
90    build.target        global
91}
92
93variant granular description {Build with granular libraries} conflicts global {
94    build.env-append    G4LIB_USE_GRANULAR=1
95
96    build.target
97}
98
99variant shared description {Build shared libraries} conflicts static {
100    build.env-append    G4LIB_BUILD_SHARED=1
101}
102
103variant static description {Build static libraries} conflicts shared {
104    build.env-append    G4LIB_BUILD_STATIC=1
105}
106
107variant aida description {Enable the use with AIDA} {
108    depends_lib-append  port:iAIDA
109
110    build.env-append    G4ANALYSIS_USE=1
111}
112
113variant no_ui description {Build without user interface nor visualization driver} conflicts motif athena raytracerx {
114    build.env-append    G4UI_NONE=1
115    build.env-append    G4VIS_NONE=1
116}
117
118variant motif description {Build with Motif user interface and visualization driver} {
119    depends_lib-append  port:mesa \
120                        port:openmotif
121
122    build.env-append    XMFLAGS=-I${prefix}/include
123    build.env-append    XMLIBS='-L${prefix}/lib -lXm -lXpm'
124
125    build.env-append    G4VIS_USE_OPENGLX=1
126    build.env-append    G4VIS_BUILD_OPENGLX_DRIVER=1
127
128    build.env-append    G4VIS_USE_OPENGLXM=1
129    build.env-append    G4VIS_BUILD_OPENGLXM_DRIVER=1
130
131    build.env-append    G4UI_USE_XM=1
132    build.env-append    G4UI_BUILD_XM_SESSION=1
133}
134
135variant athena description {Build with Athena user interface} {
136    depends_lib-append  port:mesa
137
138    build.env-append    G4UI_BUILD_XAW_SESSION=1
139    build.env-append    G4UI_USE_XAW=1
140
141    build.env-append    XAWFLAGS=
142    build.env-append    XAWLIBS=
143}
144
145variant raytracerx description {Build with Raytracer visualization driver} {
146    depends_lib-append  port:mesa
147
148    build.env-append    G4VIS_USE_OPENGLX=1
149    build.env-append    G4VIS_BUILD_OPENGLX_DRIVER=1
150
151    build.env-append    G4VIS_USE_RAYTRACERX=1
152    build.env-append    G4VIS_BUILD_RAYTRACERX_DRIVER=1
153}
154
155variant gdml description {Build with Geometry Description Markup Language (GDML)} {
156    depends_lib-append  port:xercesc3
157
158    build.env-append    XERCESCROOT=${prefix}
159
160    build.env-append    G4LIB_BUILD_GDML=1
161}
162
163
164post-patch {
165    # Propagate user's flags and compiler settings
166    reinplace "s/-o/\$(LDFLAGS) -o/g" ${worksrcpath}/GNUmakefile
167
168    reinplace "/\\\$(G4LIB)\\\/\\\$(G4SYSTEM)/d" ${workpath}/geant${version}/config/architecture.gmk
169
170    # Replaces g++ with standard compiler and fixes some paths
171    fs-traverse file ${workpath}/geant${version}/config {
172        if {".gmk" == [file extension ${file}]} {
173            reinplace "s:g++:${configure.cxx}:g" ${file}
174            reinplace "s:gfortran:${configure.fc}:g" ${file}
175            reinplace "s:CXXFLAGS += \$(INCFLAGS):CXXFLAGS += \$(INCFLAGS) -I\$(CLHEP_INCLUDE_DIR):g" ${file}
176            reinplace "s:CPPFLAGS += \$(INCFLAGS):CXXFLAGS += \$(INCFLAGS) -I\$(CLHEP_INCLUDE_DIR):g" ${file}
177
178            reinplace "s:\$(G4LIB)/\$(G4SYSTEM):\$(G4LIB):g" ${file}
179            reinplace "s:\$(G4BIN)/\$(G4SYSTEM):\$(G4BIN):g" ${file}
180            reinplace "s:\$(G4TMP)/\$(G4SYSTEM):\$(G4TMP):g" ${file}
181        }
182    }
183
184    # Fix an error message in build phase (I hope that it will not cause any problems)
185    reinplace "s:LDFLAGS += -bind_at_load -arch_multiple:LDFLAGS += -bind_at_load:g" ${workpath}/geant${version}/config/sys/Darwin-g++.gmk
186
187    reinplace "s:Darwin-${configure.cxx}:Darwin-g++:g" ${workpath}/geant${version}/config/sys/Darwin-g++.gmk
188
189    reinplace "s:\$(G4LIB)/\$(G4SYSTEM):\$(G4LIB):g" ${workpath}/geant${version}/source/GNUmakefile
190    reinplace "s:\$(G4BIN)/\$(G4SYSTEM):\$(G4BIN):g" ${workpath}/geant${version}/source/GNUmakefile
191    reinplace "s:\$(G4TMP)/\$(G4SYSTEM):\$(G4TMP):g" ${workpath}/geant${version}/source/GNUmakefile
192
193    fs-traverse file ${workpath}/geant${version}/examples {
194        if [string match {/GNUmakefile$} ${file}] {
195            reinplace "s:\$(G4LIB)/\$(G4SYSTEM):\$(G4LIB):g" ${file}
196            reinplace "s:\$(G4BIN)/\$(G4SYSTEM):\$(G4BIN):g" ${file}
197            reinplace "s:\$(G4TMP)/\$(G4SYSTEM):\$(G4TMP):g" ${file}
198        }
199    }
200
201    # Fixes paths in shell setup scripts
202    foreach fileextension {sh csh} {
203        file copy ${filespath}/env.${fileextension} ${worksrcpath}
204
205        set file ${worksrcpath}/env.${fileextension}
206
207        reinplace "s:@PREFIX@:${prefix}:g" ${file}
208        reinplace "s:@WORKSRCPATH@:${worksrcpath}:g" ${file}
209        reinplace "s:@DESTROOT@:${destroot}:g" ${file}
210        reinplace "s:@VERSION@:${version}:g" ${file}
211
212        reinplace "s:@G4NDL_V@:${G4NDL_v}:g" ${file}
213        reinplace "s:@G4EMLOW_V@:${G4EMLOW_v}:g" ${file}
214        reinplace "s:@PHOTONEVAPORATION_V@:${PhotonEvaporation_v}:g" ${file}
215        reinplace "s:@RADIOACTIVEDECAY_V@:${RadioactiveDecay_v}:g" ${file}
216        reinplace "s:@G4ABLA_V@:${G4ABLA_v}:g" ${file}
217        reinplace "s:@G4NEUTRONXS_V@:${G4NEUTRONXS_v}:g" ${file}
218        reinplace "s:@G4PII_V@:${G4PII_v}:g" ${file}
219        reinplace "s:@REALSURFACE_V@:${RealSurface_v}:g" ${file}
220
221        if {${fileextension} == "sh"} {
222            set export "export"
223        } else {
224            set export "setenv"
225        }
226
227        set env_file_stream [open ${file} "a"]
228
229        if {[variant_isset aida]} {
230            puts ${env_file_stream} "${export} G4ANALYSIS_USE=1"
231        }
232
233        if {[variant_isset athena]} {
234            puts ${env_file_stream} "${export} G4UI_BUILD_XAW_SESSION=1"
235            puts ${env_file_stream} "${export} G4UI_USE_XAW=1"
236
237            puts ${env_file_stream} "${export} XAWFLAGS="
238            puts ${env_file_stream} "${export} XAWLIBS="
239        }
240
241        if {[variant_isset debug]} {
242            puts ${env_file_stream} "${export} G4DEBUG=1"
243        }
244
245        if {[variant_isset gdml]} {
246            puts ${env_file_stream} "${export} XERCESCROOT=${prefix}"
247            puts ${env_file_stream} "${export} G4LIB_BUILD_GDML=1"
248        }
249
250        if {[variant_isset granular]} {
251            puts ${env_file_stream} "${export} G4LIB_USE_GRANULAR=1"
252        }
253
254        if {[variant_isset motif]} {
255            puts ${env_file_stream} "${export} XMFLAGS=-I${prefix}/include"
256            puts ${env_file_stream} "${export} XMLIBS='-L${prefix}/lib -lXm -lXpm'"
257
258            puts ${env_file_stream} "${export} G4VIS_USE_OPENGLX=1"
259            puts ${env_file_stream} "${export} G4VIS_BUILD_OPENGLX_DRIVER=1"
260
261            puts ${env_file_stream} "${export} G4VIS_USE_OPENGLXM=1"
262            puts ${env_file_stream} "${export} G4VIS_BUILD_OPENGLXM_DRIVER=1"
263
264            puts ${env_file_stream} "${export} G4UI_USE_XM=1"
265            puts ${env_file_stream} "${export} G4UI_BUILD_XM_SESSION=1"
266        }
267
268        if {[variant_isset noui]} {
269            puts ${env_file_stream} "${export} G4UI_NONE=1"
270            puts ${env_file_stream} "${export} G4VIS_NONE=1"
271        }
272
273        if {[variant_isset raytracerx]} {
274            puts ${env_file_stream} "${export} G4VIS_USE_OPENGLX=1"
275            puts ${env_file_stream} "${export} G4VIS_BUILD_OPENGLX_DRIVER=1"
276
277            puts ${env_file_stream} "${export} G4VIS_USE_RAYTRACERX=1"
278            puts ${env_file_stream} "${export} G4VIS_BUILD_RAYTRACERX_DRIVER=1"
279        }
280
281        if {[variant_isset shared]} {
282            puts ${env_file_stream} "${export} G4LIB_BUILD_SHARED=1"
283        }
284
285        if {[variant_isset static]} {
286            puts ${env_file_stream} "${export} G4LIB_BUILD_STATIC=1"
287        }
288
289        flush ${env_file_stream}
290        close ${env_file_stream}
291    }
292}
293
294use_configure       no
295
296build.env-append    CXX=${configure.cxx}
297build.env-append    CC=${configure.cc}
298build.env-append    G4SYSTEM=Darwin-g++
299build.env-append    G4INSTALL=${workpath}/geant${version}
300build.env-append    G4INCLUDE=${workpath}/geant${version}/include
301build.env-append    G4TMP=${workpath}/geant${version}/tmp
302build.env-append    G4LIB=${workpath}/geant${version}/lib
303build.env-append    G4BIN=${workpath}/geant${version}/bin
304
305build.env-append    G4LEVELGAMMADATA=${prefix}/share/geant4/data/PhotonEvaporation${PhotonEvaporation_v}
306build.env-append    G4RADIOACTIVEDATA=${prefix}/share/geant4/data/RadioactiveDecay${RadioactiveDecay_v}
307build.env-append    G4LEDATA=${prefix}/share/geant4/data/G4EMLOW${G4EMLOW_v}
308build.env-append    G4NEUTRONHPDATA=${prefix}/share/geant4/data/G4NDL${G4NDL_v}
309build.env-append    G4ABLADATA=${prefix}/share/geant4/data/G4ABLA${G4ABLA_v}
310build.env-append    G4NEUTRONXSDATA=${prefix}/share/geant4/data/G4NEUTRONXS${G4NEUTRONXS_v}
311build.env-append    G4PIIDATA=${prefix}/share/geant4/data/G4PII${G4PII_v}
312#build.env-append    G4ELASTICDATA=
313
314build.env-append    CLHEP_BASE_DIR=${prefix}
315build.env-append    CLHEP_INCLUDE_DIR=${prefix}/include
316build.env-append    CLHEP_LIB_DIR=${prefix}/lib
317build.env-append    CLHEP_LIB=CLHEP
318
319# Next variables need more work to be put in a variant...
320
321# I do not know what is this for.
322#build.env-append    OGLHOME=
323
324# These are needed to include Qt interfaces
325#build.env-append    QTFLAGS=
326#build.env-append    QTLIBS=
327#build.env-append    QTMOC=
328#build.env-append    G4UI_USE_QT=1
329#build.env-append    G4UI_BUILD_QT_SESSION=1
330#build.env-append    G4VIS_USE_OPENGLQT=1
331#build.env-append    G4VIS_BUILD_OPENGLQT_DRIVER=1
332
333# These are needed to include DAWN interfaces, but I can not find DAWN
334#build.env-append    G4VIS_USE_DAWN=1
335#build.env-append    G4VIS_BUILD_DAWN_DRIVER=1
336
337# To be used with DAWN
338#build.env-append    G4LIB_USE_ZLIB=1
339#build.env-append    G4LIB_BUILD_ZLIB=1
340
341# These are needed to include OpenInventor, but its Portfile does not exist
342#build.env-append    OIVHOME=
343#build.env-append    G4VIS_USE_OIX=1
344#build.env-append    G4VIS_BUILD_OIX_DRIVER=1
345
346# These are needed to include VRML
347#build.env-append    G4VIS_USE_VRML=1
348#build.env-append    G4VIS_BUILD_VRML_DRIVER=1
349
350# These are needed to include a converter from GEANT3 to GEANT4, but require CERNlib
351#build.env-append    G4LIB_BUILD_G3TOG4=1
352#build.env-append    G4LIB_USE_G3TOG4=1
353
354build.args
355
356build {
357    ui_debug "Preparing make database"
358    system "cd ${worksrcpath} && env ${build.env} ${build.cmd} -n -p -f ${workpath}/geant${version}/config/scripts/GNUmakefile > ${workpath}/geant${version}/source/GNUmakefile.db"
359
360    if {[variant_isset global]} {
361        # In Gentoo's mailing list they say that a rebuild is needed
362        ui_debug "Building global libraries"
363        system "cd ${worksrcpath} && env ${build.env} ${build.cmd} global"
364    }
365
366    ui_debug "Building libraries"
367    system "cd ${worksrcpath} && env ${build.env} ${build.cmd}"
368
369    ui_debug "Preparing header files"
370    system "cd ${worksrcpath} && env ${build.env} ${build.cmd}  includes dependencies=\"\""
371}
372
373destroot {
374    ui_debug "Installing env scripts to ${prefix}/src/geant4"
375
376    xinstall -d ${destroot}${prefix}/src/geant4
377
378    xinstall -m 755 -W ${worksrcpath} env.sh env.csh ${destroot}${prefix}/src/geant4
379
380    ui_debug "Installing GEANT4 data to ${prefix}/share/geant4/data"
381
382    xinstall -d ${destroot}${prefix}/share/geant4/data
383
384    foreach data "G4NDL${G4NDL_v} G4EMLOW${G4EMLOW_v} PhotonEvaporation${PhotonEvaporation_v} RadioactiveDecay${RadioactiveDecay_v} G4ABLA${G4ABLA_v} RealSurface${RealSurface_v} G4NEUTRONXS${G4NEUTRONXS_v} G4PII${G4PII_v}" {
385set G4NEUTRONXS_v       1.0
386set G4PII_v             1.2
387        ui_debug "Installing ${data} to ${prefix}/share/geant4/data"
388        file copy ${workpath}/${data} ${destroot}${prefix}/share/geant4/data
389    }
390
391    ui_debug "Installing sources to ${prefix}/src/geant4"
392
393    foreach sources {config source environments examples} {
394        ui_debug "Installing ${sources} to ${prefix}/src/geant4"
395        file copy ${workpath}/geant${version}/${sources} ${destroot}${prefix}/src/geant4
396    }
397
398    foreach sources {include lib bin} {
399        ui_debug "Installing ${sources} to ${prefix}/${sources}"
400        fs-traverse file ${workpath}/geant${version}/${sources} {
401            switch -exact [file type ${file}] {
402                directory {
403                    set stripped [string map {${workpath}/geant${version}/ ""} ${file}]
404                    xinstall -d -m 755 ${destroot}${prefix}/${stripped}
405                }
406                file { xinstall ${file} ${destroot}${prefix}/${sources} }
407            }
408        }
409    }
410}