source: trunk/dports/emulators/minivmac-devel/Portfile @ 67387

Last change on this file since 67387 was 67387, checked in by ryandesign@…, 10 years ago

minivmac, minivmac-devel: ensure the bootstrap app always gets quit

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.4 KB
Line 
1# $Id: Portfile 67387 2010-05-07 04:17:33Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    minivmac-devel
6conflicts               minivmac
7set my_name             minivmac
8epoch                   1
9version                 3.3-20100504
10set my_version          [strsed ${version} {g/^.*-20//}]
11categories              emulators aqua
12maintainers             ryandesign
13license                 GPLv2
14homepage                http://minivmac.sourceforge.net/
15use_zip                 yes
16platforms               macosx
17universal_variant       no
18use_parallel_build      yes
19dist_subdir             ${my_name}
20if {${version} != ${my_version}} {
21    # Development versions:
22    distname            ${my_name}${my_version}
23} else {
24    # Alpha and beta versions:
25    distname            ${my_name}-${version}
26}
27
28description             an emulator of the Macintosh Plus and other early Macintosh models
29
30long_description        The Mini vMac emulator helps preserve software made for early \
31                        Macintosh computers -- those sold by Apple from 1984 to 1996 \
32                        based on Motorola's 680x0 microprocessors. \
33                        The best-tested version emulates a Macintosh Plus, but there are \
34                        also emulations of the Macintosh 128K, 512K, 512Ke, SE, Classic, \
35                        and SE FDHD, and work on Macintosh II emulation is in progress.
36
37master_sites            sourceforge:${my_name}:minivmac \
38                        macports:${my_name}:macports \
39                        http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/:apple
40
41set my_src                                  ${distname}.src
42set my_src_distfile                         ${my_src}.zip
43set my_bootstrap_distfile                   ${my_name}-bootstrap-3.1.2_1.zip
44set my_blanks                               blanks
45set my_blanks_distfile                      ${my_blanks}-0.2.0.zip
46set my_clipin                               clipin-1.1.0
47set my_clipin_distfile                      ${my_clipin}.zip
48set my_icons                                icnsosx-1.0.0
49set my_icons_distfile                       ${my_icons}.zip
50set my_system_disk_container                System_7.0.1.smi
51set my_system_disk_container_distfile       ${my_system_disk_container}.bin
52
53distfiles               ${my_src_distfile}:minivmac \
54                        ${my_bootstrap_distfile}:macports \
55                        ${my_icons_distfile}:minivmac \
56                        ${my_clipin_distfile}:minivmac \
57                        ${my_blanks_distfile}:minivmac \
58                        ${my_system_disk_container_distfile}:apple
59
60extract.only            ${my_src_distfile} \
61                        ${my_bootstrap_distfile} \
62                        ${my_icons_distfile} \
63                        ${my_blanks_distfile} \
64                        ${my_clipin_distfile}
65
66checksums               ${my_src_distfile} \
67                        md5     f964a8721787a4537380c9fee072d155 \
68                        sha1    496b3c05f4aebea47d2d3d7c394c1b807d3387a7 \
69                        rmd160  0b26305cfd3302aeb9d2c681971d21d85b8c696d \
70                        ${my_bootstrap_distfile} \
71                        md5     65fa9b7fb19a24dc6c9e711387c1bc30 \
72                        sha1    4ad44559e75894d45e91ae62cc7ddb420062f968 \
73                        rmd160  58884cac487a537b5d00fc6093fdfecb6ccc5a2f \
74                        ${my_icons_distfile} \
75                        md5     2af006506de7549be14f94317918d59a \
76                        sha1    4ef79bb56b988fedfeb82a8b6cafd8066f5bbab2 \
77                        rmd160  cef6d7d7578464538d0042b0d98379ae7f18fab7 \
78                        ${my_clipin_distfile} \
79                        md5     e094de97d1c6c214a80fb74895124c3e \
80                        sha1    725f622ad6681c77e7f9f4a64d05ac1d6a103beb \
81                        rmd160  5699b56c8db62b2568c8de88b6d419180b1fb73d \
82                        ${my_blanks_distfile} \
83                        md5     b16321d0d78048d5ec9b635f4f86b19c \
84                        sha1    9b8d7e77bd05633709907f8806d976279d7a20b7 \
85                        rmd160  a0784c17c5a5ca2e159762fb836c1c800762b213 \
86                        ${my_system_disk_container_distfile} \
87                        md5     8a4776350b15b5a516cdf7dd18e27290 \
88                        sha1    d4c8b8653de9c7a9b2594dd6126ec7120e3e2e9e \
89                        rmd160  89fc3780c9c5d575a8da4068dc810c1f56c70211
90
91depends_extract         port:bsdiff \
92                        bin:expect:expect
93
94if {${os.major} < 9} {
95    depends_extract-append port:macutil
96}
97
98set my_app_dir          "${applications_dir}/Mini vMac"
99set my_rom_dir          "~/Library/Preferences/Gryphel/mnvm_rom"
100set my_bootstrap_app    "Mini vMac Bootstrap.app"
101set my_rom_file         vMac.ROM
102set my_base_options     "-maintainer MacPorts -homepage http://www.macports.org/ -cl -eol unx -nex"
103set my_archs            {}
104
105options my_variations
106my_variations           {128K}      {-m 128K} \
107                        {512K}      {-m 128K -mem 512K} \
108                        {512Ke}     {-m 512Ke} \
109                        {Plus}      {-m Plus -im 1} \
110                        {SE}        {-m SE} \
111                        {SE FDHD}   {-m SEFDHD} \
112                        {Classic}   {-m Classic}
113
114variant unsupported description {Also build unfinished Macintosh II and IIx emulators} {
115    my_variations-append \
116                        {II}        {-m II -mem 8M -hres 800 -vres 600 -depth 3} \
117                        {IIx}       {-m IIx -mem 8M -hres 800 -vres 600 -depth 3}
118}
119
120# The universal variant is disabled until MacPorts 1.8.3 is released.
121if {0} {
122# To build the bootstrap, use "sudo port install bootstrap=yes".
123# The variant is hidden because it is useful only to the port maintainer.
124if {[tbool bootstrap]} {
125    variant bootstrap conflicts unsupported requires universal description {Build the bootstrap version of Mini vMac} {
126        my_variations   {Bootstrap} {-m Plus -sound 0 -bg 1 -speed a}
127        depends_build-append port:p7zip
128        post-destroot {
129            exec 7za a ${destroot}${my_app_dir}/${my_name}-bootstrap-${version}_${revision}.zip ${destroot}${my_app_dir}/${my_bootstrap_app}
130        }
131    }
132    default_variants +bootstrap
133}
134
135variant universal {
136    configure.universal_args
137    configure.universal_archs ppc i386
138    set my_archs ${configure.universal_archs}
139}
140}
141if {[info exists supported_archs]} {
142    supported_archs i386 ppc
143}
144if {![variant_exists universal] || ![variant_isset universal]} {
145    switch ${os.arch} {
146        powerpc {
147            configure.build_arch ppc
148        }
149        default {
150            configure.build_arch ${os.arch}
151        }
152    }
153    set my_archs ${configure.build_arch}
154}
155
156pre-fetch {
157    set my_real_rom_dir [exec osascript ${filespath}/readalias.applescript [file normalize ${my_rom_dir}]]
158    if {![file exists ${my_real_rom_dir}/${my_rom_file}] && ![file exists ${my_app_dir}/${my_rom_file}]} {
159        ui_msg "****************************************************************"
160        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
161        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
162        ui_msg "of Mac you want to emulate. ROM files are not included with this"
163        ui_msg "package because they are copyrighted Apple software."
164        ui_msg "To create a ROM file, download the CopyRoms program from"
165        ui_msg "${homepage}extras/copyroms.html"
166        ui_msg "and transfer it to a real physical early Macintosh that you own."
167        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
168        ui_msg "to this Mac and put it in ${my_rom_dir}"
169        ui_msg "(which can be an alias or symlink if desired) or"
170        ui_msg "${my_app_dir}."
171        ui_msg "****************************************************************"
172        return -code error "${my_rom_file} not found"
173    }
174}
175
176worksrcdir              stuff
177extract.mkdir           yes
178
179post-extract {
180    # Decode the system disk container image.
181    my_system "sh ${filespath}/demacbinary.sh ${distpath}/${my_system_disk_container_distfile} ${worksrcpath}"
182   
183    # Copy the Disk Tools image from the container image. The binary patchfile applied with bspatch
184    # places an alias of the output disk at System Folder:Preferences:Gryphel:Build:output.
185    set my_system_disk_container_mount [my_attach_disk_image ${worksrcpath}/${my_system_disk_container}]
186    my_system "bspatch '${my_system_disk_container_mount}/Disk Tools.image' '${worksrcpath}/Disk Tools.dsk' '${filespath}/Disk Tools.dsk.bsdiff'"
187    my_detach_disk_image ${my_system_disk_container_mount}
188   
189    # Get a large empty disk image to store the output.
190    my_system "unzip -q ${worksrcpath}/${my_blanks}/hfs24M.zip -d ${worksrcpath}"
191   
192    # Make the data directory, where Mini vMac looks for the files it needs.
193    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
194    file mkdir ${my_mnvm_dat}
195   
196    # Symlink the ROM file into the data directory.
197    ln -s ${my_app_dir}/${my_rom_file} ${my_mnvm_dat}
198   
199    # Symlink the disk images into the data directory with sequentially-numbered
200    # names so Mini vMac will find them and automatically mount them.
201    ln -s "${worksrcpath}/Disk Tools.dsk" "${my_mnvm_dat}/disk1.dsk"
202    ln -s ${worksrcpath}/output.img "${my_mnvm_dat}/disk2.dsk"
203    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk3.dsk"
204    ln -s ${worksrcpath}/${my_clipin}/${my_clipin}.dsk "${my_mnvm_dat}/disk4.dsk"
205}
206
207pre-configure {
208    # Set the name of the bootstrap app in the configure script.
209    xinstall -m 755 ${filespath}/configure.applescript.in ${worksrcpath}/configure.applescript
210    reinplace "s|@BOOTSTRAP_APP@|${my_bootstrap_app}|g" ${worksrcpath}/configure.applescript
211   
212    # Copy the large blank disk image to store the output.
213    # Use the .img extension so that we can mount it on Mac OS X later.
214    copy -force ${worksrcpath}/hfs24M.DSK ${worksrcpath}/output.img
215   
216    # Unrestrict the permissions on the output disk image so the MnvM_bld program
217    # can write its output to it.
218    file attributes ${worksrcpath}/output.img -permissions 0777
219   
220    # Build up the combined configure args for all variations.
221    set i 0
222    foreach my_arch ${my_archs} {
223        set my_target [my_arch_to_target ${my_arch}]
224        foreach {my_machine my_variation_options} ${my_variations} {
225            if {${i} > 0} {
226                configure.args-append {\;}
227            }
228            configure.args-append \
229                ${my_base_options} \
230                -t ${my_target} \
231                ${my_variation_options} \
232                -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
233            incr i
234        }
235    }
236   
237    # Launch the bootstrap Mini vMac so the configure script can talk to it.
238    global my_bootstrap_pid
239    if {[catch {exec "${worksrcpath}/${my_bootstrap_app}/Contents/MacOS/minivmac" &} my_bootstrap_pid]} {
240        return -code error "couldn't launch bootstrap"
241    }
242}
243
244configure.cmd           osascript
245configure.pre_args      ./configure.applescript
246
247build.dir               ${workpath}/variations
248
249post-configure {
250    # Kill the bootstrap Mini vMac.
251    global my_bootstrap_pid
252    exec kill ${my_bootstrap_pid}
253   
254    file mkdir ${build.dir}
255    set my_variation_dirs {}
256    set my_output_disk_mount [my_attach_disk_image ${worksrcpath}/output.img]
257    foreach my_arch ${my_archs} {
258        file mkdir ${build.dir}/${my_arch}
259        set my_target [my_arch_to_target ${my_arch}]
260        foreach {my_machine unused} ${my_variations} {
261            set my_src_dir ${my_output_disk_mount}/${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
262            if {[file isdirectory ${my_src_dir}]} {
263                set my_variation_dir ${my_arch}/${my_machine}
264                lappend my_variation_dirs [strsed ${my_variation_dir} {g/ /\\\\ /}]
265               
266                # Get the configured source code.
267                file copy ${my_src_dir} ${build.dir}/${my_variation_dir}
268               
269                # Use the right compiler.
270                reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
271               
272                # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
273                # and even if you install it manually it does not work here.
274                reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
275            }
276        }
277    }
278    my_detach_disk_image ${my_output_disk_mount}
279   
280    # Set up the global Makefile.
281    xinstall ${filespath}/Makefile.in ${build.dir}/Makefile
282    reinplace "s|@SUBDIRS@|[join ${my_variation_dirs}]|" ${build.dir}/Makefile
283   
284    # If no variation directories were produced by configuration, either the flags we
285    # passed in were bad, or the automation script got out of sync with the emulator;
286    # if the latter, the delays in configure.applescript may need to be adjusted.
287    if {"" == ${my_variation_dirs}} {
288        return -code error "configuration failed!"
289    }
290}
291
292set my_share_dir        ${prefix}/share/${my_name}
293
294post-build {
295    set i 0
296    foreach my_arch ${my_archs} {
297        set my_target [my_arch_to_target ${my_arch}]
298        foreach {my_machine unused} ${my_variations} {
299            if {[variant_exists universal] && [variant_isset universal]} {
300                reinplace "s|${my_target}|umch|" ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Info.plist
301            }
302            if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
303                # To save space, keep only a single copy of the Resources directory.
304                set my_resources_dir ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Resources
305                if {0 == ${i}} {
306                    move ${my_resources_dir} ${build.dir}
307                } else {
308                    delete ${my_resources_dir}
309                }
310                ln -s ${my_share_dir}/Resources ${my_resources_dir}
311            }
312            incr i
313        }
314    }
315   
316    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
317        # Install the prettier icons.
318        eval xinstall -m 644 [glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
319    }
320}
321
322destroot {
323    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
324        # Install the global Resources directory.
325        xinstall -d ${destroot}${my_share_dir}
326        copy ${build.dir}/Resources ${destroot}${my_share_dir}
327    }
328   
329    # Install the programs.
330    foreach my_arch ${my_archs} {
331        if {[variant_exists universal] && [variant_isset universal]} {
332            set my_dest ${workpath}/pre-dest/${my_arch}
333        } else {
334            set my_dest ${destroot}
335        }
336        xinstall -d ${my_dest}${my_app_dir}
337        foreach {my_machine unused} ${my_variations} {
338            copy ${build.dir}/${my_arch}/${my_machine}/minivmac.app \
339                "${my_dest}${my_app_dir}/Mini vMac ${my_machine}.app"
340        }
341    }
342    if {[variant_exists universal] && [variant_isset universal]} {
343        merge ${workpath}/pre-dest
344    }
345}
346
347# Converts normal arch names into Mini vMac target names.
348proc my_arch_to_target {arch} {
349    switch ${arch} {
350        i386 {
351            return imch
352        }
353        ppc {
354            return mach
355        }
356        default {
357            return -code error "unsupported architecture ${arch}"
358        }
359    }
360}
361
362# Mounts a disk image.
363proc my_attach_disk_image {disk_image} {
364    global my_name filespath
365    set mountpoint [mkdtemp "/tmp/${my_name}.XXXXXXXX"]
366    # Use this expect script instead of using hdiutil directly, because the
367    # system disk image has a license agreement we must agree to.
368    my_system "expect ${filespath}/attach.exp '${disk_image}' '${mountpoint}'"
369    return ${mountpoint}
370}
371
372# Unmounts a disk image.
373proc my_detach_disk_image {mountpoint} {
374    my_system "hdiutil detach ${mountpoint} -force"
375    file delete -force ${mountpoint}
376}
377
378proc my_system {cmd} {
379     ui_debug ${cmd}
380     system ${cmd}
381}
382
383livecheck.type          regex
384livecheck.version       ${my_version}
385livecheck.regex         ${my_name}-?(\[0-9.\]+)\\.src
386
387if {${version} != ${my_version}} {
388    # Development versions:
389    livecheck.url       ${homepage}develop/index.html
390} else {
391    # Alpha versions:
392    livecheck.url       ${homepage}alpha/index.html
393   
394    # Beta versions:
395    #livecheck.url       ${homepage}beta/index.html
396}
Note: See TracBrowser for help on using the repository browser.