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