Ticket #16055: Portfile_v3

File Portfile_v3, 5.0 KB (added by jens.traube@…, 16 years ago)

Portfile -- version 3

Line 
1PortSystem 1.0
2                   
3name                TeXworks
4version             20080720_105
5revision            0
6categories          editors aqua tex
7platforms           macosx
8maintainers         nomaintainer
9description         TeX previewer for Mac OS X
10long_description \
11    TeXworks is a TeX previewer for Mac OS X, Linux, and Windows. \
12    It uses the Qt4 GUI framework and the Poppler PDF rendering library \
13    (compiled with Qt4 wrapper). \
14    The TeXworks project has been founded by Jonathan Kew (scripts.sil.org/XeTeX), \
15    the developer of XeTeX. It is inspired by TeXShop, the only TeX previewer \
16    with a relative simple user interface. \
17    Jonathan Kew: \"TeXworks aims to provide a simple TeX environment \
18    based on modern standards (including Unicode encoding and PDF output by default) \
19    with an uncluttered interface that does not overwhelm the newcomer. \
20    It is built using cross-platform, open-source tools and libraries, \
21    so as to be available on all today's major operating systems, \
22    with a native look and feel for each.\" \
23    ( --> tug.org/tug2008/abstracts/kew.pdf  and  tug.org/texworks/ )
24
25homepage            http://code.google.com/p/texworks/
26
27fetch.type          svn
28svn.url             http://texworks.googlecode.com/svn/trunk/
29
30set worksrcdir      trunk
31
32depends_build       port:subversion
33
34depends_lib         port:qt4-mac \
35                    port:poppler \
36                    port:hunspell
37
38# poppler has to be build with Qt4 frontend and Splash rendering backend
39
40variant HEAD description {subversion checkout of last source revision} {
41    ui_msg "------------------------------------------------------------------------"
42    ui_msg "Variant \"HEAD\" is untested. It may not compile, and may have major bugs."
43    ui_msg "TeXworks is a free and open source software project, and"
44    ui_msg "Jonathan Kew invites you to participate."
45    ui_msg "------------------------------------------------------------------------"
46}
47
48pre-fetch {
49    if {![variant_isset HEAD]} then {
50        set svn.tag [lindex [split ${version} "_"] end]
51    }
52}
53
54post-fetch {
55    set info [exec svn info --xml ${worksrcpath}]
56
57    if {[variant_isset HEAD]} then {
58        regexp "<commit.*?revision.*?=.*?\"(.*?)\".*?>" "${info}" commitElement svnRevision
59        regexp "<date>(.*?)T.*?</date>" "${info}" datetimeElement dateOfLastCommit
60        set version [join [list [join [split $dateOfLastCommit "-"] ""] $svnRevision] "_"]
61        ui_debug "version: $version"
62    }
63
64    ui_debug "+++++ svn info +++++\n"
65    ui_debug "$info"
66    ui_debug "++++++++++++++++++++"
67}
68
69
70post-patch {
71    ui_debug "Tcl version is [info patchlevel]"
72
73    set project [exec cat ${worksrcpath}/TeXworks.pro]
74    regexp {(^.*?)(macx \{.*?\})(.*$)} "$project"  wholeText  preMacx  macx  postMacx
75    unset project
76
77    set query1 [regexp {/usr/local/include/hunspell} $macx]
78    set query2 [regexp {/usr/local/include[ \t]*\n} $macx]
79    set query3 [regexp {QMAKE_MACOSX_DEPLOYMENT_TARGET} $macx]
80
81    if "! ($query1 && $query2 && $query3)" then {
82        file copy ${worksrcpath}/TeXworks.pro ${worksrcpath}/TeXworks.pro.orig
83        exec echo "$preMacx" > ${worksrcpath}/TeXworks.pro
84        set macxLines [split "$macx" "\n"]
85        unset macx
86        set nLines [llength "$macxLines"]
87        if "! $query1" then {
88            set macxLines [linsert "$macxLines" end-1 "\tINCLUDEPATH += ${prefix}/include/hunspell"]
89            set nLines [expr $nLines + 1]
90        }
91        if "! $query2" then {
92            set macxLines [linsert "$macxLines" end-1 "\tINCLUDEPATH += ${prefix}/include"]
93            set nLines [expr $nLines + 1]
94        }
95
96        set darwinMajorVersion [lindex [split ${os.version} "."] 0]
97        set deploymentTarget "10.5"
98        if "$darwinMajorVersion == 8" then {
99            set deploymentTarget "10.4"
100        } elseif "$darwinMajorVersion == 7" then {
101            set deploymentTarget "10.3"
102        } elseif "$darwinMajorVersion == 6" then {
103            set deploymentTarget "10.2"
104        }
105        ui_debug "MACOSX_DEPLOYMENT_TARGET = $deploymentTarget"
106
107        if "! $query3" then {
108#            set deploymentTarget [option macosx_deployment_target] ;# MacPorts base version > 1.6.0
109            set macxLines [linsert "$macxLines" end-1 "\tQMAKE_MACOSX_DEPLOYMENT_TARGET = $deploymentTarget"]
110            set nLines [expr $nLines + 1]
111        }
112        set macx [join "$macxLines" "\n"]
113        exec echo "$macx" >> ${worksrcpath}/TeXworks.pro
114        exec echo "$postMacx" >> ${worksrcpath}/TeXworks.pro
115    }
116
117    reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/TeXworks.pro
118}
119
120configure {
121    system "cd ${worksrcpath}  && \
122            qmake -makefile -macx -d"
123}
124
125post-configure {
126    # wrong library path in pkgconfig files *.pc of port qt4-mac.
127    # see bug report, Ticket no.16120
128    reinplace "s|-L${portdbpath}/build/.*/lib||g" ${worksrcpath}/Makefile
129}
130
131destroot {
132    set app ${destroot}/Applications/MacPorts
133    xinstall -d ${app}
134    file copy ${worksrcpath}/TexWorks.app ${app}
135}