source: trunk/dports/emulators/minivmac/Portfile @ 67388

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

minivmac, minivmac-devel: work properly when the ROM file is in the preferences folder instead of in the applications folder

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.2 KB
Line 
1# $Id: Portfile 67388 2010-05-07 06:34:07Z 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    if {"" == [my_real_rom_file]} {
150        ui_msg "****************************************************************"
151        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
152        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
153        ui_msg "of Mac you want to emulate. ROM files are not included with this"
154        ui_msg "package because they are copyrighted Apple software."
155        ui_msg "To create a ROM file, download the CopyRoms program from"
156        ui_msg "${homepage}extras/copyroms.html"
157        ui_msg "and transfer it to a real physical early Macintosh that you own."
158        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
159        ui_msg "to this Mac and put it in ${my_rom_dir}"
160        ui_msg "(which can be an alias or symlink if desired) or"
161        ui_msg "${my_app_dir}."
162        ui_msg "****************************************************************"
163        return -code error "${my_rom_file} not found"
164    }
165}
166
167worksrcdir              stuff
168extract.mkdir           yes
169
170post-extract {
171    # Decode the system disk container image.
172    my_system "sh ${filespath}/demacbinary.sh ${distpath}/${my_system_disk_container_distfile} ${worksrcpath}"
173   
174    # Copy the Disk Tools image from the container image. The binary patchfile applied with bspatch
175    # places an alias of the output disk at System Folder:Preferences:Gryphel:Build:output.
176    set my_system_disk_container_mount [my_attach_disk_image ${worksrcpath}/${my_system_disk_container}]
177    my_system "bspatch '${my_system_disk_container_mount}/Disk Tools.image' '${worksrcpath}/Disk Tools.dsk' '${filespath}/Disk Tools.dsk.bsdiff'"
178    my_detach_disk_image ${my_system_disk_container_mount}
179   
180    # Get a large empty disk image to store the output.
181    my_system "unzip -q ${worksrcpath}/${my_blanks}/hfs24M.zip -d ${worksrcpath}"
182   
183    # Make the data directory, where Mini vMac looks for the files it needs.
184    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
185    file mkdir ${my_mnvm_dat}
186   
187    # Symlink the ROM file into the data directory.
188    ln -s [my_real_rom_file] ${my_mnvm_dat}
189   
190    # Symlink the disk images into the data directory with sequentially-numbered
191    # names so Mini vMac will find them and automatically mount them.
192    ln -s "${worksrcpath}/Disk Tools.dsk" "${my_mnvm_dat}/disk1.dsk"
193    ln -s ${worksrcpath}/output.img "${my_mnvm_dat}/disk2.dsk"
194    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk3.dsk"
195    ln -s ${worksrcpath}/${my_clipin}/${my_clipin}.dsk "${my_mnvm_dat}/disk4.dsk"
196}
197
198pre-configure {
199    # Set the name of the bootstrap app in the configure script.
200    xinstall -m 755 ${filespath}/configure.applescript.in ${worksrcpath}/configure.applescript
201    reinplace "s|@BOOTSTRAP_APP@|${my_bootstrap_app}|g" ${worksrcpath}/configure.applescript
202   
203    # Copy the large blank disk image to store the output.
204    # Use the .img extension so that we can mount it on Mac OS X later.
205    copy -force ${worksrcpath}/hfs24M.DSK ${worksrcpath}/output.img
206   
207    # Unrestrict the permissions on the output disk image so the Build program
208    # can write its output to it.
209    file attributes ${worksrcpath}/output.img -permissions 0777
210   
211    # Build up the combined configure args for all variations.
212    set i 0
213    foreach my_arch ${my_archs} {
214        set my_target [my_arch_to_target ${my_arch}]
215        foreach {my_machine my_variation_options} ${my_variations} {
216            if {${i} > 0} {
217                configure.args-append {\;}
218            }
219            configure.args-append \
220                ${my_base_options} \
221                -t ${my_target} \
222                ${my_variation_options} \
223                -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
224            incr i
225        }
226    }
227   
228    # Launch the bootstrap Mini vMac so the configure script can talk to it.
229    global my_bootstrap_pid
230    if {[catch {exec "${worksrcpath}/${my_bootstrap_app}/Contents/MacOS/minivmac" &} my_bootstrap_pid]} {
231        return -code error "couldn't launch bootstrap"
232    }
233}
234
235configure.cmd           osascript
236configure.pre_args      ./configure.applescript
237
238build.dir               ${workpath}/variations
239
240post-configure {
241    # Kill the bootstrap Mini vMac.
242    global my_bootstrap_pid
243    exec kill ${my_bootstrap_pid}
244   
245    file mkdir ${build.dir}
246    set my_variation_dirs {}
247    set my_output_disk_mount [my_attach_disk_image ${worksrcpath}/output.img]
248    foreach my_arch ${my_archs} {
249        file mkdir ${build.dir}/${my_arch}
250        set my_target [my_arch_to_target ${my_arch}]
251        foreach {my_machine unused} ${my_variations} {
252            set my_src_dir ${my_output_disk_mount}/${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
253            if {[file isdirectory ${my_src_dir}]} {
254                set my_variation_dir ${my_arch}/${my_machine}
255                lappend my_variation_dirs [strsed ${my_variation_dir} {g/ /\\\\ /}]
256               
257                # Get the configured source code.
258                file copy ${my_src_dir} ${build.dir}/${my_variation_dir}
259               
260                # Use the right compiler.
261                reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
262               
263                # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
264                # and even if you install it manually it does not work here.
265                reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
266            }
267        }
268    }
269    my_detach_disk_image ${my_output_disk_mount}
270   
271    # Set up the global Makefile.
272    xinstall ${filespath}/Makefile.in ${build.dir}/Makefile
273    reinplace "s|@SUBDIRS@|[join ${my_variation_dirs}]|" ${build.dir}/Makefile
274   
275    # If no variation directories were produced by configuration, either the flags we
276    # passed in were bad, or the automation script got out of sync with the emulator;
277    # if the latter, the delays in configure.applescript may need to be adjusted.
278    if {"" == ${my_variation_dirs}} {
279        return -code error "configuration failed!"
280    }
281}
282
283set my_share_dir        ${prefix}/share/${my_name}
284
285post-build {
286    set i 0
287    foreach my_arch ${my_archs} {
288        set my_target [my_arch_to_target ${my_arch}]
289        foreach {my_machine unused} ${my_variations} {
290            if {[variant_exists universal] && [variant_isset universal]} {
291                reinplace "s|${my_target}|umch|" ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Info.plist
292            }
293            if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
294                # To save space, keep only a single copy of the Resources directory.
295                set my_resources_dir ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Resources
296                if {0 == ${i}} {
297                    move ${my_resources_dir} ${build.dir}
298                } else {
299                    delete ${my_resources_dir}
300                }
301                ln -s ${my_share_dir}/Resources ${my_resources_dir}
302            }
303            incr i
304        }
305    }
306   
307    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
308        # Install the prettier icons.
309        eval xinstall -m 644 [glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
310    }
311}
312
313destroot {
314    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
315        # Install the global Resources directory.
316        xinstall -d ${destroot}${my_share_dir}
317        copy ${build.dir}/Resources ${destroot}${my_share_dir}
318    }
319   
320    # Install the programs.
321    foreach my_arch ${my_archs} {
322        if {[variant_exists universal] && [variant_isset universal]} {
323            set my_dest ${workpath}/pre-dest/${my_arch}
324        } else {
325            set my_dest ${destroot}
326        }
327        xinstall -d ${my_dest}${my_app_dir}
328        foreach {my_machine unused} ${my_variations} {
329            copy ${build.dir}/${my_arch}/${my_machine}/minivmac.app \
330                "${my_dest}${my_app_dir}/Mini vMac ${my_machine}.app"
331        }
332    }
333    if {[variant_exists universal] && [variant_isset universal]} {
334        merge ${workpath}/pre-dest
335    }
336}
337
338# Returns the full path to the ROM file, wherever the user has it,
339# or the empty string if the user doesn't have it.
340proc my_real_rom_file {} {
341    global filespath my_app_dir my_rom_dir my_rom_file
342    if {[file exists ${my_app_dir}/${my_rom_file}]} {
343        return ${my_app_dir}/${my_rom_file}
344    }
345    set my_real_rom_dir [exec osascript ${filespath}/readalias.applescript [file normalize ${my_rom_dir}]]
346    if {[file exists ${my_real_rom_dir}/${my_rom_file}]} {
347        return ${my_real_rom_dir}/${my_rom_file}
348    }
349    return ""
350}
351
352# Converts normal arch names into Mini vMac target names.
353proc my_arch_to_target {arch} {
354    switch ${arch} {
355        i386 {
356            return imch
357        }
358        ppc {
359            return mach
360        }
361        default {
362            return -code error "unsupported architecture ${arch}"
363        }
364    }
365}
366
367# Mounts a disk image.
368proc my_attach_disk_image {disk_image} {
369    global my_name filespath
370    set mountpoint [mkdtemp "/tmp/${my_name}.XXXXXXXX"]
371    # Use this expect script instead of using hdiutil directly, because the
372    # system disk image has a license agreement we must agree to.
373    my_system "expect ${filespath}/attach.exp '${disk_image}' '${mountpoint}'"
374    return ${mountpoint}
375}
376
377# Unmounts a disk image.
378proc my_detach_disk_image {mountpoint} {
379    my_system "hdiutil detach ${mountpoint} -force"
380    file delete -force ${mountpoint}
381}
382
383proc my_system {cmd} {
384     ui_debug ${cmd}
385     system ${cmd}
386}
387
388livecheck.type          regex
389livecheck.url           ${homepage}doc/download.html
390livecheck.regex         ${my_name}-(\[0-9.\]+)\\.src
Note: See TracBrowser for help on using the repository browser.