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