Ticket #33627: Portfile-pgplot

File Portfile-pgplot, 9.8 KB (added by Russell-Jones-OxPhys (Russell Jones), 13 years ago)

Add gcc46 variant.

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 81302 2011-07-29 05:38:23Z ryandesign@macports.org $
3
4PortSystem                      1.0
5
6name                            pgplot
7conflicts                       miriad
8version                         5.2.2
9revision                        6
10categories                      graphics devel
11maintainers                     mcalhoun openmaintainer
12description                     C/Fortran graphics library
13long_description \
14        The PGPLOT Graphics Subroutine Library is a Fortran- or C-callable, \
15        device-independent graphics package for making simple scientific \
16        graphs.  It is intended for making graphical images of publication \
17        quality with minimum effort on the part of the user. For most \
18        applications, the program can be device-independent, and the output can \
19        be directed to the appropriate device at run time.
20
21platforms                       darwin
22
23homepage                        http://www.astro.caltech.edu/~tjp/pgplot/
24master_sites            ftp://ftp.astro.caltech.edu/pub/pgplot/
25
26distname                        ${name}[join [split ${version} .] ""]
27worksrcdir                      ${name}
28configure.dir           ${workpath}/build
29build.dir                       ${configure.dir}
30
31checksums \
32    md5 e8a6e8d0d5ef9d1709dfb567724525ae \
33    sha1 1f1c9aa17eeec9a2fb23fd15a0e4a91dcc49ddc1 \
34    rmd160 4c21cad6613772f4104c65ac3d8d9a42e3c4afe1
35
36patchfiles     patch-makemake.diff patch-drivers.list.patch patch-proccom.c.diff
37depends_lib    port:libpng port:zlib port:xorg-libX11
38depends_build  bin:perl:perl5 port:pkgconfig
39
40# Tell the compiler not to treat backslash characters as C-style escape sequences.
41configure.fcflags-append  -fno-backslash
42
43set compat_version  [join [lrange [split ${version} .] 0 0] .]
44
45post-extract {
46    file mkdir ${build.dir}
47}
48
49post-patch {
50    # Ensure MacPorts libraries are being used.
51    reinplace "s|\\(-L\\\\`pwd\\\\`\\)|\\1 -L${prefix}/lib|" ${worksrcpath}/makemake
52
53    # Look in the correct place for run-time data files.
54    reinplace "s|/usr/local/pgplot/|${prefix}/share/${name}/|" ${worksrcpath}/src/grgfil.f
55
56    # /usr/local/bin/perl may not exist.
57    reinplace "s|#!/usr/local/bin/perl|#!/usr/bin/env perl|" ${worksrcpath}/makehtml ${worksrcpath}/maketex
58
59    copy ${worksrcpath}/drivers.list ${build.dir}
60
61    set drivers  "GIF VGIF LATEX PNG TPNG PS VPS CPS VCPS"
62
63    if {![variant_isset no_x11]} {
64        # XDISP does not work because the program figdisp can not be found.
65        lappend drivers XWINDOW XSERVE
66    }
67
68    if {[variant_isset aquaterm]} {
69        lappend drivers AQT
70    }
71
72    foreach driver ${drivers} {
73        reinplace "s|!\\(.*/${driver} .*\\)| \\1|" ${build.dir}/drivers.list
74    }
75}
76
77pre-configure {
78    set shlib_opts \
79        "-dynamiclib -single_module -current_version ${version} -compatibility_version ${compat_version}"
80
81    if {![variant_isset no_x11]} {
82        # XQuartz or MacPorts X11 (pkg-config gives precedence to MacPorts X11)
83        eval configure.ldflags-append   [exec pkg-config x11 --libs-only-L]
84        set x11Libs                     [exec pkg-config x11 --libs-only-l]
85        eval configure.cppflags-append  [exec pkg-config x11 --cflags]
86    } else {
87        set x11Libs  ""
88    }
89
90    if {[variant_isset aquaterm]} {
91        set aqtLibs  "-laquaterm -Wl,-framework -Wl,Foundation"
92    } else {
93        set aqtLibs  ""
94    }
95
96    # Create configuration file.
97    #    For a description of options, see ${worksrcpath}/sys_linux/g77_gcc.conf
98    lappend options  XINCL            "${configure.cppflags}"
99    lappend options  MOTIF_INCL       ""
100    lappend options  ATHENA_INCL      ""
101    lappend options  TK_INCL          ""
102    lappend options  RV_INCL          ""
103    lappend options  FCOMPL           "${configure.fc}"
104    lappend options  FFLAGC           "${configure.fcflags}"
105    lappend options  FFLAGD           ""
106    lappend options  CCOMPL           "${configure.cc}"
107    lappend options  CFLAGC           "${configure.cppflags} ${configure.cflags}"
108    lappend options  CFLAGD           ""
109    lappend options  PGBIND_FLAGS     "bsd"
110    lappend options  LIBS             "${configure.ldflags} ${x11Libs} ${aqtLibs}"
111    lappend options  MOTIF_LIBS       ""
112    lappend options  ATHENA_LIBS      ""
113    lappend options  TK_LIBS          ""
114    lappend options  RANLIB           "/usr/bin/ranlib"
115    lappend options  SHARED_LIB       "libpgplot${version}.dylib"
116    lappend options  SHARED_LD        "${configure.fc} ${shlib_opts} ${configure.ldflags} ${x11Libs} -install_name ${prefix}/lib/libpgplot${compat_version}.dylib"
117    lappend options  SHARED_LIB_LIBS  "${configure.ldflags} -lpng ${aqtLibs}"
118    lappend options  MCOMPL           "${configure.objc}"
119    lappend options  MFLAGC           "${configure.objcflags}"
120    lappend options  SYSDIR           "\\\$SYSDIR"
121
122    # The following variables are not part of the unpatched pgplot.
123    #     They have been added to facilitate building a shared C library.
124    lappend options  CSHARED_LIB      "libcpgplot${version}.dylib"
125    lappend options  CSHARED_LD       "${configure.fc} ${shlib_opts} ${configure.ldflags} ${x11Libs} -install_name ${prefix}/lib/libcpgplot${compat_version}.dylib"
126
127    file mkdir ${worksrcpath}/sys_darwin
128    foreach {var val} ${options} {
129        system "/bin/echo \"   ${var}=\\\"${val}\\\"\" >> ${worksrcpath}/sys_darwin/marcports.conf"
130    }
131
132    # Create optional routine which makemake will find and compile.
133    system "/bin/echo \"int iand_ (int *a, int *b) { return *a & *b;}\" >> ${worksrcpath}/sys_darwin/iand.c"
134}
135
136configure.cmd       ${worksrcpath}/makemake
137configure.pre_args
138configure.args      ${worksrcpath} ${os.platform}
139
140# When linking against fortran code, PG_PPU gets number of underscores correct.
141configure.cppflags-append  -DPG_PPU
142
143# Build the C PGPLOT wrapper library, HTML documentation, and TeX files.
144build.target-append cpg pgplot.html pgplot-routines.tex
145
146destroot {
147    # pgxwin_server is only built if the X11 drivers are requested.
148    # pgdisp is only built if the XDISP driver is requested.
149    foreach fl [glob -directory ${destroot.dir} -nocomplain pgxwin_server pgdisp] {
150        xinstall -m 755 ${fl} ${destroot}${prefix}/bin
151    }
152
153    foreach fl [glob -directory ${destroot.dir} -nocomplain *.dylib] {
154        xinstall -m 755 ${fl} ${destroot}${prefix}/lib
155    }
156
157    foreach fl [glob -directory ${destroot.dir} -nocomplain *.a] {
158        xinstall -m 644 ${fl} ${destroot}${prefix}/lib
159    }
160
161    foreach fl [glob -directory ${destroot.dir} -nocomplain *.h] {
162        xinstall -m 644 ${fl} ${destroot}${prefix}/include
163    }
164
165    # Install run-time data files.
166    xinstall -d -m 755 ${destroot}${prefix}/share/${name}
167    foreach fl [glob -directory ${destroot.dir} -nocomplain *.dat *.txt] {
168        xinstall -m 644 ${fl} ${destroot}${prefix}/share/${name}
169    }
170
171    # Install docs.
172    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
173    xinstall -m 644 ${worksrcpath}/copyright.notice ${destroot}${prefix}/share/doc/${name}
174    foreach fl [glob -directory ${destroot.dir} -nocomplain *.doc *.html *.pdf] {
175        xinstall -m 644 ${fl} ${destroot}${prefix}/share/doc/${name}
176    }
177
178    # Install examples.
179    xinstall -d -m 755 ${destroot}${prefix}/share/${name}/examples
180    foreach fl [glob -directory ${worksrcpath} examples/pgdemo*.f cpg/cpgdemo*.c drivers/*/pg*demo.*] {
181        xinstall -m 644 ${fl} ${destroot}${prefix}/share/${name}/examples
182    }
183    foreach fl [glob -directory ${destroot.dir} *demo*] {
184        xinstall -m 755 ${fl} ${destroot}${prefix}/share/${name}/examples
185    }
186
187    # Create more library names.
188    ln -s libcpgplot${version}.dylib ${destroot}${prefix}/lib/libcpgplot.dylib
189    ln -s libcpgplot${version}.dylib ${destroot}${prefix}/lib/libcpgplot[join [lrange [split ${version} .] 0 0] .].dylib
190    ln -s libcpgplot${version}.dylib ${destroot}${prefix}/lib/libcpgplot[join [lrange [split ${version} .] 0 1] .].dylib
191
192    ln -s libpgplot${version}.dylib  ${destroot}${prefix}/lib/libpgplot.dylib
193    ln -s libpgplot${version}.dylib  ${destroot}${prefix}/lib/libpgplot[join [lrange [split ${version} .] 0 0] .].dylib
194    ln -s libpgplot${version}.dylib  ${destroot}${prefix}/lib/libpgplot[join [lrange [split ${version} .] 0 1] .].dylib
195}
196
197use_parallel_build  no
198
199universal_variant no
200
201variant no_x11 {
202    depends_lib-delete    port:xorg-libX11
203    depends_build-delete  port:pkgconfig
204}
205
206variant aquaterm description {install driver for aquaterm} {
207    depends_lib-append port:aquaterm
208
209    post-extract {
210        copy ${prefix}/share/aquaterm/adapters/pgplot/aqdriv.m ${worksrcpath}/drivers
211    }
212}
213
214variant gcc42 description {build with gfortran from gcc42} conflicts gcc43 gcc44 gcc45 gcc46 g95 {
215    depends_lib-append    port:gcc42
216    configure.fc          ${prefix}/bin/gfortran-mp-4.2
217}
218
219variant gcc43 description {build with gfortran from gcc43} conflicts gcc42 gcc44 gcc45 gcc46 g95 {
220    depends_lib-append    port:gcc43
221    configure.fc          ${prefix}/bin/gfortran-mp-4.3
222    build.env-append      F77=${fc} F90=${fc}
223}
224
225variant gcc44 description {build with gfortran from gcc44} conflicts gcc42 gcc43 gcc45 gcc46 g95 {
226    depends_lib-append    port:gcc44
227    configure.fc          ${prefix}/bin/gfortran-mp-4.4
228}
229
230variant gcc45 description {build with gfortran from gcc45} conflicts gcc42 gcc43 gcc44 gcc46 g95 {
231    depends_lib-append    port:gcc45
232    configure.fc          ${prefix}/bin/gfortran-mp-4.5
233}
234
235variant gcc46 description {build with gfortran from gcc46} conflicts gcc42 gcc43 gcc44 gcc45 g95 {
236    depends_lib-append    port:gcc46
237    configure.fc          ${prefix}/bin/gfortran-mp-4.6
238}
239
240
241variant g95 description {build with gfortran from f95} conflicts gcc42 gcc43 gcc44 gcc45 gcc46 {
242    depends_lib-append    port:g95
243    configure.fc          ${prefix}/bin/g95
244}
245
246if {![variant_isset gcc42] && ![variant_isset gcc43] && ![variant_isset gcc45] && ![variant_isset g95]  && ![variant_isset gcc46]} {
247           default_variants +gcc44
248}
249
250variant docs description {Create and install docs} {
251    depends_build-append bin:pdflatex:texlive
252
253    post-build {
254        system "cd ${build.dir} && pdflatex pgplot-routines.tex && pdflatex pgplot-routines.tex"
255    }
256}