Ticket #16055: Portfile_v5

File Portfile_v5, 6.6 KB (added by jens.traube@…, 16 years ago)

Portfile -- version 5

Line 
1PortSystem 1.0
2                   
3name                texworks
4version             20080926_168
5revision            5
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       bin:svn: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# ( poppler +qt4Splash +quartz )
40
41variant HEAD description {subversion checkout of last source revision} {
42    ui_msg "------------------------------------------------------------------------"
43    ui_msg "Variant \"HEAD\" is untested. It may not compile, and may have major bugs."
44    ui_msg "TeXworks is a free and open source software project, and"
45    ui_msg "Jonathan Kew invites you to participate."
46    ui_msg "------------------------------------------------------------------------"
47}
48
49pre-fetch {
50    if {![variant_isset HEAD]} then {
51        set svn.tag [lindex [split ${version} "_"] end]
52    }
53}
54
55post-fetch {
56    set info [exec svn info --xml ${worksrcpath}]
57
58    if {[variant_isset HEAD]} then {
59        regexp "<commit.*?revision.*?=.*?\"(.*?)\".*?>" "${info}" commitElement svnRevision
60        regexp "<date>(.*?)T.*?</date>" "${info}" datetimeElement dateOfLastCommit
61        set version [join [list [join [split $dateOfLastCommit "-"] ""] $svnRevision] "_"]
62        ui_msg "version: $version"
63    }
64
65    # save version number just in case of a stepwise installation process
66    exec echo "$version"  >  ${worksrcpath}/TeXworks_version
67
68    ui_debug "+++++ svn info +++++\n"
69    ui_debug "$info"
70    ui_debug "++++++++++++++++++++"
71}
72
73
74post-patch {
75    ui_debug "Tcl version is [info patchlevel]"
76
77    set project [exec cat ${worksrcpath}/TeXworks.pro]
78    regexp {(^.*?\n)(macx \{.*?\})(.*$)} "$project"  wholeText  preMacx  macx  postMacx
79    unset project
80
81    set query1 [regexp {/usr/local/include/hunspell} $macx]
82    set query2 [regexp {/usr/local/include[ \t]*\n} $macx]
83    set query3 [regexp {QMAKE_MACOSX_DEPLOYMENT_TARGET} $macx]
84    set query4 [regexp {CONFIG[ \t]*[+]?=} $macx]
85
86    if "! ($query1 && $query2 && $query3)" then {
87        set macxLines [split "$macx" "\n"]
88        unset macx
89        if "! $query1" then {
90            set macxLines [linsert "$macxLines" end-1 "\tINCLUDEPATH += ${prefix}/include/hunspell"]
91        }
92        if "! $query2" then {
93            set macxLines [linsert "$macxLines" end-1 "\tINCLUDEPATH += ${prefix}/include"]
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        }
111
112        if {[variant_isset universal]} then {
113            set os_archs "x86 ppc"
114        } else {
115            if {${os.arch} == "powerpc"} then {
116                set os_archs "ppc"
117            } else {
118                set os_archs "x86"
119            }
120        }
121
122        if "! $query4" then {
123            set macxLines [linsert "$macxLines" end-1 "\tCONFIG += $os_archs"]
124        } else {
125            set iLine [lsearch -regexp $macxLines {CONFIG[ \t]*[+]?=}]
126            set macxLines [lreplace $macxLines $iLine $iLine "\tCONFIG += $os_archs"]
127        }
128
129        set macx [join "$macxLines" "\n"]
130
131        file copy ${worksrcpath}/TeXworks.pro ${worksrcpath}/TeXworks.pro.orig
132        exec echo "$preMacx"  >  ${worksrcpath}/TeXworks.pro
133        exec echo "$macx"     >> ${worksrcpath}/TeXworks.pro
134        exec echo "$postMacx" >> ${worksrcpath}/TeXworks.pro
135    }
136
137    reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/TeXworks.pro
138
139
140    ### search path for tex/latex binaries ###
141
142    set TWApp.cpp  [exec cat ${worksrcpath}/src/TWApp.cpp]
143    regexp {(^.*?)(void TWApp::setDefaultPaths.*?\{.*?\})(.*$)} "${TWApp.cpp}"  wholeText  preFunc  func  postFunc
144    unset TWApp.cpp
145
146    regexp {(^.*?#ifdef Q_WS_MAC)(.*?)(#endif.*$)} "$func"  wholeText  ifdef searchPath  endif
147
148    set searchPathLines [split [string trim "$searchPath" "\n"] "\n"]
149    set searchPathLines [linsert "$searchPathLines" end "\t\t<< \"${prefix}/bin\""]
150    set searchPath [join "$searchPathLines" "\n"]
151
152    file copy ${worksrcpath}/src/TWApp.cpp ${worksrcpath}/src/TWApp.cpp.orig
153    exec echo "$preFunc"    >  ${worksrcpath}/src/TWApp.cpp
154    exec echo "$ifdef"      >> ${worksrcpath}/src/TWApp.cpp
155    exec echo "$searchPath" >> ${worksrcpath}/src/TWApp.cpp
156    exec echo "$endif"      >> ${worksrcpath}/src/TWApp.cpp
157    exec echo "$postFunc"   >> ${worksrcpath}/src/TWApp.cpp
158}
159
160configure {
161    system "cd ${worksrcpath}  && \
162            qmake -makefile -macx -d"
163}
164
165post-configure {
166    # wrong library path in pkgconfig files *.pc of port qt4-mac.
167    # see bug report, Ticket no.16120
168    reinplace "s|-L${portdbpath}/build/.*/lib||g" ${worksrcpath}/Makefile
169}
170
171destroot {
172    set app ${destroot}/Applications/MacPorts
173    xinstall -d ${app}
174    file copy ${worksrcpath}/TexWorks.app ${app}
175}
176
177pre-install {
178    set version [exec cat ${worksrcpath}/TeXworks_version]
179}
180
181variant texlive {
182    depends_run  port:texlive
183}