Ticket #16275: Portfile

File Portfile, 9.0 KB (added by Jacobus.Geluk@…, 16 years ago)
Line 
1# $Id$
2
3PortSystem                      1.0
4
5name                            openamq
6version                         1.2d0
7categories                      net
8maintainers                     Jacobus.Geluk@gmail.com
9description                     A complete AMQP message queueing broker
10long_description                ${description}
11
12homepage                        http://www.openamq.org
13
14platforms                       darwin
15
16master_sites                    http://download.imatix.com/openamq/stable
17
18distname                        OpenAMQ-${version}
19
20checksums                       md5 cfb4ef1fa53b6df63b36e2ea76a1482e \
21                                sha1 03e37e80b5428253a685a16c1b1950db6bd7e25f \
22                                rmd160 eafc0796917dbffefe7a879d58537e7ebe7d457d
23
24depends_lib                     port:gmake \
25                                port:apr \
26                                port:pcre
27
28patchfiles                      patch-base-2.2b1-smt-smt_socket_request.icl.diff \
29                                patch-base-2.2b1-smt-smt_socket_request.c.diff \
30                                patch-base-2.2b1-ipr-ipr_file.icl.diff \
31                                patch-base-2.2b1-ipr-ipr_file.c.diff \
32                                patch-foreign-1.1d8-boomake.diff \
33                                patch-foreign-1.1d8-c-c.diff
34
35use_configure                   no
36
37set IBASE                       "${workpath}/ibase"
38set SH                          "/bin/sh"
39set BUILDSCRIPT                 "${workpath}/portbuild.sh"
40set DIR_FOREIGN                 "foreign-1.1d8"
41set DIR_BASE1                   "base-1.2d8"
42set DIR_BASE2                   "base-2.2b1"
43set DIR_GSL                     "gsl-4.0c19"
44set LOG_PATH                    "${prefix}/var/log/${name}"
45set BUILDDEBUG                  "no"
46
47variant debug  description {Build OpenAMQ with debug symbols} {
48set BUILDDEBUG                  "yes"
49}
50
51proc arrow {line} {
52       
53        global UI_PREFIX
54       
55        ui_msg "${UI_PREFIX}  ${line}"
56}
57
58#
59# Extract phase
60#
61pre-extract {
62       
63        system "rm -rf ${workpath}"
64        system "mkdir -p ${workpath}"
65}
66
67post-extract {
68
69        global IBASE DIR_FOREIGN
70
71        arrow "Post Extract"
72        #
73        # Change work/OpenAMQ-${version}/OpenAMQ-${version} into
74        # work/OpenAMQ-${version}
75        #
76        move ${workpath}/${distname}/${distname} ${workpath}/${distname}XX
77        eval move [glob ${workpath}/${distname}/*] ${workpath}
78        system "rm -rf ${workpath}/${distname}"
79        move ${workpath}/${distname}XX ${workpath}/${distname}
80        #
81        # Do not use xinstall -d below since that generates verbose messages we
82        # do not need here, we're not really installing anything...
83        #
84        system "mkdir -p ${IBASE}/bin"
85        system "mkdir -p ${IBASE}/include"
86        file copy "${workpath}/${DIR_FOREIGN}/apr/base_apr.h" "${IBASE}/include"
87
88        arrow "Finished Post Extract"
89}
90
91#
92# Patch phase
93#
94proc patchBoomake {file} {
95
96        ui_debug "Patching ${file}..."
97
98        reinplace "s|Linux|Darwin|g" ${file}
99}
100
101proc patchCscript {file} {
102
103        ui_debug "Patching ${file}..."
104
105        reinplace "s|Linux|Darwin|g" ${file}
106        reinplace "s|BOOM_SUPPORTS_MT=.*#|BOOM_SUPPORTS_MT=1 #|g" ${file}
107}
108
109proc patchFreeBSDHeader {file} {
110
111        ui_debug "Patching ${file}..."
112
113        reinplace "s|FreeBSD|Darwin|g" ${file}
114        reinplace "s|FREEBSD|DARWIN|g" ${file}
115}
116
117proc patchServerConfig {file} {
118       
119        global LOG_PATH
120
121        ui_debug "Patching ${file}..."
122
123        reinplace "s|\"logs\"|\"${LOG_PATH}\"|g" ${file}
124        reinplace "s|'logs'|'${LOG_PATH}'|g" ${file}
125        reinplace "s|\"archive\"|\"${LOG_PATH}/archive\"|g" ${file}
126        reinplace "s|'archive'|'${LOG_PATH}/archive'|g" ${file}
127}
128
129proc patchIprFile {file} {
130       
131        global prefix
132
133        ui_debug "Patching ${file}..."
134
135        set etcPath "${prefix}/etc"
136
137        if {[string compare "${etcPath}" "/opt/local/etc"] == 0} {
138                ui_info "We do not have te patch ${file}"
139        } else {
140                reinplace "s|/opt/local/etc|${etcPath}|g" ${file}
141        }
142}
143
144post-patch {
145
146        arrow "Post Patch patches"
147        foreach file [exec find ${workpath} -type f -name boomake] {
148                patchBoomake ${file}
149        }
150        foreach file [exec find ${workpath} -type f -name configure] {
151                patchBoomake ${file}
152        }
153        foreach file [exec find ${workpath} -type f -name c] {
154                patchCscript ${file}
155        }
156        foreach file [exec grep -lR __FreeBSD__ ${workpath}] {
157                patchFreeBSDHeader ${file}
158        }
159       
160        patchServerConfig ${workpath}/${distname}/server/amq_server_config.icl
161        patchServerConfig ${workpath}/${distname}/server/amq_server_config.c
162       
163        patchIprFile ${workpath}/${distname}/${DIR_BASE2}/ipr/ipr_file.icl
164        patchIprFile ${workpath}/${distname}/${DIR_BASE2}/ipr/ipr_file.c
165               
166        arrow "Post Patch patches finished"
167}
168
169#
170# Configure phase
171#
172configure {}
173
174#
175# Build phase
176#
177proc create-build-script-section {bs name} {
178
179        global SH workpath
180
181        puts $bs "cd ${workpath}/${name} > /dev/null 2>&1 || {"
182        puts $bs "  echo \"E: ${name} does not exist\" 1>&2"
183        puts $bs "  exit 1"
184        puts $bs "}"
185        puts $bs "${SH} ./boomake build test install || {"
186        puts $bs "  echo \"E: Build of ${name} failed\" 1>&2"
187        puts $bs "  exit 1"
188        puts $bs "}"
189}
190
191proc create-build-script {} {
192
193        global BUILDSCRIPT IBASE DIR_FOREIGN DIR_BASE1 DIR_BASE2 DIR_GSL BUILDDEBUG SH
194        global workpath distname prefix os.platform portverbose porttrace macports
195
196        arrow "Creating build script ${BUILDSCRIPT}"
197        set bs [open ${BUILDSCRIPT} w]
198        puts $bs "#!${SH}"
199        puts $bs "echo \"Executing \$0 in directory \$(pwd)...\""
200        puts $bs "export UTYPE=\"Darwin\""
201        puts $bs "export MAKE=${prefix}/bin/gmake"
202        puts $bs "export CC=/usr/bin/gcc"
203        puts $bs "export CCNAME=\${CC}"
204        puts $bs "export CXX=/usr/bin/g++"
205        puts $bs "export CCPLUS=\${CXX}"
206        puts $bs "export IBASE=${IBASE}"
207        puts $bs "export PATH=\${IBASE}\bin:\${PATH}"
208        puts $bs "export PATH=\${IBASE}:\${PATH}"
209        puts $bs "export PATH=${workpath}/${DIR_FOREIGN}/_install/bin:\${PATH}"
210        puts $bs "export BUILDDEBUG=\"[option BUILDDEBUG]\""
211        if {[tbool BUILDDEBUG]} {
212                puts $bs "export BOOM_MODEL=\"mt,debug\""
213        } else {
214                puts $bs "export BOOM_MODEL=\"mt,release\""
215        }
216        puts $bs "export BOOM_MODEL_MT=1"
217        puts $bs "export BOOM_SUPPORTS_MT=1"
218        puts $bs "export BOOM_TRACE=1"
219        puts $bs "export INCDIR=\${IBASE}/include"
220        puts $bs "export LIBDIR=\${IBASE}/lib"
221        puts $bs "export STDLIBS=\"-lm\""
222        puts $bs "export STDLIBS=\"\${STDLIBS} -lapr-1\""
223        puts $bs "export STDLIBS=\"\${STDLIBS} -laprutil-1\""
224        puts $bs "export STDLIBS=\"\${STDLIBS} -lpcre\""
225        puts $bs "export STDLIBS=\"\${STDLIBS} -L/opt/local/lib\""
226        puts $bs "export CCOPTS=\"-I/opt/local/include\""
227        puts $bs "export CCOPTS=\"\${CCOPTS} -I/opt/local/include/apr-1\""
228        puts $bs "export CCOPTS=\"\${CCOPTS} -Wall\""
229        puts $bs "export CCOPTS=\"\${CCOPTS} -pthread\""
230        puts $bs "export CCOPTS=\"\${CCOPTS} -D_REENTRANT\""
231        puts $bs "export CCOPTS=\"\${CCOPTS} -DICL_MEM_DEFAULT_DIRECT\""
232        puts $bs "export CCOPTS=\"\${CCOPTS} -D_GNU_SOURCE\""
233        puts $bs "export CCOPTS=\"\${CCOPTS} -D_LARGEFILE64_SOURCE\""
234        if {[string compare "${os.platform}" "darwin"] == 0} {
235                puts $bs "export CCOPTS=\"\${CCOPTS} -D__Darwin__\""
236        } else {
237                if {[string compare "${os.platform}" "freebsd"] == 0} {
238                        puts $bs "export CCOPTS=\"\${CCOPTS} -D__FreeBSD__\""
239                } else {
240                        ui_error "Unknown platform ${os.platform}"
241                }
242        }
243        if {[tbool BUILDDEBUG]} {
244                puts $bs "export CCDEBUG=\"-O\""
245        } else {
246                puts $bs "export CCNODEBUG=\"-O2\""
247        }
248        puts $bs "export LINKTYPE=after"
249        if {! [tbool portverbose]} {
250                puts $bs "export QUIET=yes"
251        } else {
252                puts $bs "export QUIET=no"
253        }
254        #
255        # Since there seems no way to know if the -d option was given on the
256        # port command line, we set VERBOSE to [option portverbose] although it
257        # would be better if [option portdebug] would work.
258        #
259        puts $bs "export VERBOSE=[option portverbose]"
260       
261        #
262        # The apr and pcre components in the foreignX directory are not used, we
263        # simply install the apr & pcre ports. Some other foreign components are
264        # still used, like "minizip"...
265        #
266        create-build-script-section $bs ${DIR_FOREIGN}
267        create-build-script-section $bs ${DIR_BASE1}
268        create-build-script-section $bs ${DIR_GSL}
269        create-build-script-section $bs ${DIR_BASE2}
270        create-build-script-section $bs ${distname}
271        close $bs
272        if {[tbool portverbose]} {
273                arrow "Created build script:"
274                system "cat ${BUILDSCRIPT}"
275        }
276}
277
278proc execute-build-script {} {
279
280        global BUILDSCRIPT SH
281
282        arrow "Executing build script... ${BUILDSCRIPT}"
283        set rc [system "${SH} ${BUILDSCRIPT}"]
284        arrow "Executed build script"
285}
286
287pre-build {
288        create-build-script
289}
290
291build {
292        execute-build-script
293}
294
295#
296# Destroot phase
297#
298destroot.clean "yes"
299
300destroot {
301
302        global IBASE
303
304        set cp "cp -R"
305        set mv "mv -v"
306        set targetIBASE "${prefix}/share/${name}"
307        set optlocalbin "${destroot}${prefix}/bin"
308        set optlocaldoc "${destroot}${prefix}/share/doc/${name}"
309        set optlocalinc "${destroot}${prefix}/include/${name}"
310        set optlocallib "${destroot}${prefix}/lib/${name}"
311
312        xinstall -m 755 -d ${destroot}${targetIBASE}
313
314        ui_info "Copying all ${name} files into ${destroot}${targetIBASE}"
315        system "${cp} ${IBASE}/ ${destroot}${targetIBASE}"
316
317        ui_info "Creating links to the files in ${targetIBASE}"
318
319        ui_debug "link to amq_client"
320        ln -fs ${targetIBASE}/bin/amq_client ${optlocalbin}
321        ui_debug "link to amq_server"
322        ln -fs ${targetIBASE}/bin/amq_server ${optlocalbin}
323        ui_debug "link to amq_shell"
324        ln -fs ${targetIBASE}/bin/amq_shell ${optlocalbin}
325        ui_debug "link to doc"
326        ln -fs ${targetIBASE}/include ${optlocalinc}
327        ui_debug "link to include"
328        ln -fs ${targetIBASE}/include ${optlocalinc}
329        ui_debug "link to lib"
330        ln -fs ${targetIBASE}/lib ${optlocallib}
331
332        xinstall -d ${destroot}${LOG_PATH}/archive
333        touch ${destroot}${LOG_PATH}/archive/keepthis
334
335        ui_info "Copying default configuration file to ${prefix}/etc"
336        xinstall -m 644 \
337                ${IBASE}/bin/amq_server_base.cfg \
338                ${destroot}${prefix}/etc
339
340        arrow "${distname} is installed in destroot ${destroot}!"
341}
342
343#
344# Test phase
345#
346test {
347        #
348        # We do not have to test since the OpenAMQ build scripts already
349        # performed all tests. If it builds, it works.
350        #
351}