Ticket #23323: Portfile.2

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