source: trunk/dports/emulators/minivmac/Portfile

Last change on this file was 135584, checked in by ryandesign@…, 2 years ago

minivmac, minivmac-devel: use expand operator instead of eval

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.2 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 135584 2015-04-27 05:12:31Z ryandesign@macports.org $
3
4PortSystem              1.0
5
6# Please keep the minivmac and minivmac-devel ports as similar as possible.
7
8name                    minivmac
9conflicts               minivmac-devel
10set my_name             minivmac
11version                 3.2.3
12revision                1
13categories              emulators aqua
14maintainers             ryandesign
15license                 GPL-2
16homepage                http://www.gryphel.com/c/minivmac/
17use_zip                 yes
18platforms               macosx
19use_parallel_build      yes
20dist_subdir             ${my_name}
21distname                ${my_name}-${version}
22
23description             an emulator of the Macintosh Plus and other early Macintosh models
24
25long_description        The Mini vMac emulator helps preserve software made for early \
26                        Macintosh computers -- those sold by Apple from 1984 to 1996 \
27                        based on Motorola's 680x0 microprocessors. \
28                        The best-tested version emulates a Macintosh Plus, but there are \
29                        also emulations of the Macintosh 128K, 512K, 512Ke, SE, Classic, \
30                        and SE FDHD, and work on Macintosh II emulation is in progress.
31
32master_sites            sourceforge:project/minivmac/minivmac/${version}:minivmacsource \
33                        sourceforge:project/minivmac/minivmac-extras/extras6:minivmacextras6 \
34                        http://www.ryandesign.com/macports/distfiles/minivmac:bootstrap \
35                        http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/:apple
36
37set my_src                                  ${distname}.src
38set my_src_distfile                         ${my_src}.zip
39set my_bootstrap_distfile                   ${my_name}-bootstrap-3.2.3_0.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}:minivmacsource \
46                        ${my_bootstrap_distfile}:bootstrap \
47                        ${my_icons_distfile}:minivmacextras6 \
48                        ${my_system_disk_container_distfile}:apple
49
50extract.only            ${my_src_distfile} \
51                        ${my_bootstrap_distfile} \
52                        ${my_icons_distfile}
53
54checksums               ${my_src_distfile} \
55                        rmd160  24e2a29db9ea54dfc41889ef16184daa3f054ef5 \
56                        sha256  f3b8c5dc3f4a48267d0a2666b9c71109a59fd5edf96a6d0ed12158df303c878f \
57                        ${my_bootstrap_distfile} \
58                        rmd160  32e803a75d4f9ab6b7dfa5a7b1ec2ef9d3a057c2 \
59                        sha256  e6fe692683ab54e08b0350fe9901e872f7bf3c3a62f69b45773254fce45a4fae \
60                        ${my_icons_distfile} \
61                        md5     2af006506de7549be14f94317918d59a \
62                        sha1    4ef79bb56b988fedfeb82a8b6cafd8066f5bbab2 \
63                        rmd160  cef6d7d7578464538d0042b0d98379ae7f18fab7 \
64                        ${my_system_disk_container_distfile} \
65                        md5     8a4776350b15b5a516cdf7dd18e27290 \
66                        sha1    d4c8b8653de9c7a9b2594dd6126ec7120e3e2e9e \
67                        rmd160  89fc3780c9c5d575a8da4068dc810c1f56c70211
68
69depends_extract         port:bsdiff
70
71set my_app_dir          "${applications_dir}/Mini vMac"
72set my_rom_dir          "~/Library/Preferences/Gryphel/mnvm_rom"
73set my_bootstrap_app    "Mini vMac Bootstrap.app"
74set my_rom_file         vMac.ROM
75set my_base_options     "-maintainer MacPorts -homepage http://www.macports.org/ -cl -eol unx -sony-sum 1 -sony-tag 1"
76set my_archs            {}
77
78options my_variations
79my_variations           {128K}      {-m 128K} \
80                        {512K}      {-m 128K -mem 512K} \
81                        {512Ke}     {-m 512Ke} \
82                        {Plus}      {-m Plus -im 1} \
83                        {SE}        {-m SE} \
84                        {SE FDHD}   {-m SEFDHD} \
85                        {Classic}   {-m Classic}
86
87variant unsupported description {Also build unfinished Macintosh II and IIx emulators} {
88    my_variations-append \
89                        {II}        {-m II -mem 8M -hres 800 -vres 600 -depth 3} \
90                        {IIx}       {-m IIx -mem 8M -hres 800 -vres 600 -depth 3}
91}
92
93# To build the bootstrap, use "sudo port install bootstrap=yes +bootstrap".
94# The variant is hidden because it is useful only to the port maintainer.
95if {[tbool bootstrap]} {
96    variant bootstrap conflicts unsupported requires universal description {Build the bootstrap version of Mini vMac} {
97        my_variations   {Bootstrap} {-m Plus -sound 0 -bg 1 -speed a -as 0}
98        depends_build-append port:p7zip
99        depends_skip_archcheck p7zip
100        post-destroot {
101            exec 7za a ${destroot}${my_app_dir}/${my_name}-bootstrap-${version}_${revision}.zip ${destroot}${my_app_dir}/${my_bootstrap_app}
102        }
103    }
104    default_variants +bootstrap
105}
106
107variant universal {
108    configure.universal_args
109    configure.universal_archs ppc i386
110    set my_archs ${configure.universal_archs}
111}
112supported_archs         i386 ppc
113if {![variant_isset universal]} {
114    set my_archs ${configure.build_arch}
115}
116
117pre-extract {
118    if {[my_real_rom_file] eq ""} {
119        ui_msg "****************************************************************"
120        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
121        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
122        ui_msg "of Mac you want to emulate. ROM files are not included with this"
123        ui_msg "package because they are copyrighted Apple software."
124        ui_msg "To create a ROM file, download the CopyRoms program from"
125        ui_msg "${homepage}extras/copyroms.html"
126        ui_msg "and transfer it to a real physical early Macintosh that you own."
127        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
128        ui_msg "to this Mac and put it in ${my_rom_dir}"
129        ui_msg "(which can be an alias or symlink if desired) or"
130        ui_msg "${my_app_dir}."
131        ui_msg "****************************************************************"
132        return -code error "${my_rom_file} not found"
133    }
134}
135
136worksrcdir              configure
137build.dir               ${workpath}/build
138extract.mkdir           yes
139extract.asroot          yes
140
141post-extract {
142    # Decompress the system disk container image.
143    ui_debug "Decompressing ${my_system_disk_container_distfile}."
144    set my_system_disk_container_decompressed "[file rootname ${my_system_disk_container}].dmg"
145    system -W ${worksrcpath} "hdiutil convert '${distpath}/${my_system_disk_container_distfile}' -format UDRO -o '${my_system_disk_container_decompressed}'"
146   
147    # The images on the container image. Images we don't need are commented out for future reference.
148    set my_images {
149        {Disk Tools.image}    58368 eb1979132c843560ebab490faeb7520d9a94757ecef3121a21abace8d3ae63ff
150        {Tidbits.image}     1902848 3e3600bed1b5c7c595bc176b5eaadcc8c1517032489efc548b9b781c0ee1f062
151    }
152#        {Fonts.image}        427264 8b06f086a96b75bd23b16ae018bd334696239cb56e65bfa20166ea00d14cdef0
153#        {Install 1.image}    796160 8c3ea898eeb88b795041108cd8a09bf4ebdf920d7d4763e4419df14713dbd952
154#        {Install 2.image}   1165056 0fc558475df55f3aed217d2eceebfa29e4a465a795807cd627b258740a9ec55b
155#        {Printing.image}    1533952 246cbf69ad1c2e588ee482fddec781135a67fbfe02734bb0f732eb055faa15fa
156   
157    # Extract the disk images from the system disk container image. `hdiutil` on OS X 10.8 Mountain Lion
158    # does not mount this disk image correctly, so extract the files manually using `dd`.
159    foreach {my_image_filename my_image_offset my_image_sha256} ${my_images} {
160        ui_debug "Extracting ${my_image_filename} from ${my_system_disk_container_decompressed}."
161        system -W ${worksrcpath} "dd if='${my_system_disk_container_decompressed}' bs=4 count=368661 skip=${my_image_offset} of='${my_image_filename}'"
162        if {${my_image_sha256} ne [sha256 file ${worksrcpath}/${my_image_filename}]} {
163            return -code error "extract failed"
164        }
165    }
166   
167    # Delete temporary files we no longer need.
168    delete ${worksrcpath}/${my_system_disk_container_decompressed}
169   
170    # Make the data directory, where Mini vMac looks for the files it needs.
171    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
172    file mkdir ${my_mnvm_dat}
173   
174    # Symlink the ROM file into the data directory.
175    ln -s [my_real_rom_file] ${my_mnvm_dat}
176   
177    # Symlink the disk images into the data directory with sequentially-numbered
178    # names so Mini vMac will find them and automatically mount them.
179    ln -s "${worksrcpath}/Disk Tools.image" "${my_mnvm_dat}/disk1.dsk"
180    ln -s ${worksrcpath}/Tidbits.image "${my_mnvm_dat}/disk2.dsk"
181    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk3.dsk"
182   
183    # Use the prettier icon on the bootstrap app.
184    copy -force ${worksrcpath}/${my_icons}/icons//AppIcon.icns ${worksrcpath}/${my_bootstrap_app}/Contents/Resources/
185}
186
187post-patch {
188    # Place an 8192-byte TeachText file called "configure.args" (containing "@START@",
189    # 8180 spaces, and "@END@") onto the Tidbits disk.
190    system -W ${worksrcpath} "${prefix}/bin/bspatch Tidbits.image Tidbits.image.in '${filespath}/patch-Tidbits.image.bsdiff'"
191   
192    # Place an alias of the configure.args file in the Startup Items folder on the Disk Tools disk.
193    system -W ${worksrcpath} "${prefix}/bin/bspatch 'Disk Tools.image' 'Disk Tools.image.tmp' '${filespath}/patch-Disk Tools.image.bsdiff'"
194    move -force "${worksrcpath}/Disk Tools.image.tmp" "${worksrcpath}/Disk Tools.image"
195}
196
197pre-configure {
198    # Set the name of the bootstrap app in the configure script.
199    xinstall -m 755 ${filespath}/configure.applescript.in ${worksrcpath}/configure.applescript
200    reinplace "s|@BOOTSTRAP_APP@|${my_bootstrap_app}|g" ${worksrcpath}/configure.applescript
201   
202    # Copy the template Tidbits disk image.
203    copy -force ${worksrcpath}/Tidbits.image.in ${worksrcpath}/Tidbits.image
204   
205    # Build up the combined configure args for all variations.
206    set i 0
207    foreach my_arch ${my_archs} {
208        set my_target [my_arch_to_target ${my_arch}]
209        foreach {my_machine my_variation_options} ${my_variations} {
210            if {${i} > 0} {
211                lappend configure_args \;
212            }
213            lappend configure_args \
214                ${my_base_options} \
215                -t ${my_target} \
216                ${my_variation_options} \
217                -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
218            incr i
219        }
220    }
221   
222    # Write the configure args into the configure.args file on the Tidbits disk image.
223    set max_configure_args_length 8192
224    set padded_args [format "%-${max_configure_args_length}s" [join ${configure_args}]]
225    if {[string length ${padded_args}] > ${max_configure_args_length}} {
226        return -code error "configure args too long"
227    }
228    reinplace -locale C "s|@START@ *@END@|${padded_args}|" ${worksrcpath}/Tidbits.image
229   
230    # Set the real configure.args that get passed to the AppleScript to the number
231    # of variations being assembled, so that it knows how long to wait.
232    configure.args ${i}
233   
234    # Launch the bootstrap Mini vMac so the configure AppleScript can talk to it.
235    global my_bootstrap_pid
236    if {[catch {exec "${worksrcpath}/${my_bootstrap_app}/Contents/MacOS/minivmac" &} my_bootstrap_pid]} {
237        return -code error "couldn't launch bootstrap"
238    }
239}
240
241configure.cmd           osascript
242configure.pre_args      ./configure.applescript
243
244post-configure {
245    # Kill the bootstrap Mini vMac.
246    global my_bootstrap_pid
247    exec kill ${my_bootstrap_pid}
248   
249    file mkdir ${build.dir}
250    set my_variation_dirs {}
251    foreach my_arch ${my_archs} {
252        file mkdir ${build.dir}/${my_arch}
253        set my_target [my_arch_to_target ${my_arch}]
254        foreach {my_machine unused} ${my_variations} {
255            set my_variation ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
256            set my_src_tarball ${worksrcpath}/${my_variation}.tar
257            if {[file isfile ${my_src_tarball}]} {
258                set my_variation_dir ${my_arch}/${my_machine}
259                lappend my_variation_dirs [strsed ${my_variation_dir} {g/ /\\\\ /}]
260               
261                # Untar the configured source code.
262                system -W ${build.dir} "tar xf '${my_src_tarball}'"
263                move ${build.dir}/${my_variation} ${build.dir}/${my_variation_dir}
264               
265                if {[variant_exists bootstrap] && [variant_isset bootstrap]} {
266                    # Change the "export" function so that exported files are written to the same
267                    # directory as Mini vMac, instead of prompting for a location.
268                    system -W ${build.dir}/${my_variation_dir} "patch -p0 < ${filespath}/patch-src-MYOSGLUE.c.diff"
269                }
270               
271                # Use the right compiler.
272                reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
273               
274                # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
275                # and even if you install it manually it does not work here.
276                reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
277            }
278        }
279    }
280   
281    # Set up the global Makefile.
282    xinstall ${filespath}/Makefile.in ${build.dir}/Makefile
283    reinplace "s|@SUBDIRS@|[join ${my_variation_dirs}]|" ${build.dir}/Makefile
284   
285    # If no variation directories were produced by configuration, either the flags we
286    # passed in were bad, or the automation script got out of sync with the emulator;
287    # if the latter, the delays in configure.applescript may need to be adjusted.
288    if {${my_variation_dirs} eq ""} {
289        return -code error "configuration failed!"
290    }
291}
292
293set my_share_dir        ${prefix}/share/${my_name}
294
295post-build {
296    set i 0
297    foreach my_arch ${my_archs} {
298        set my_target [my_arch_to_target ${my_arch}]
299        foreach {my_machine unused} ${my_variations} {
300            if {[variant_isset universal]} {
301                reinplace "s|${my_target}|umch|" ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Info.plist
302            }
303            if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
304                # To save space, keep only a single copy of the Resources directory.
305                set my_resources_dir ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Resources
306                if {0 == ${i}} {
307                    move ${my_resources_dir} ${build.dir}
308                } else {
309                    delete ${my_resources_dir}
310                }
311                ln -s ${my_share_dir}/Resources ${my_resources_dir}
312            }
313            incr i
314        }
315    }
316   
317    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
318        # Install the prettier icons.
319        xinstall -m 644 {*}[glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
320    }
321}
322
323destroot {
324    if {![variant_exists bootstrap] || ![variant_isset bootstrap]} {
325        # Install the global Resources directory.
326        xinstall -d ${destroot}${my_share_dir}
327        copy ${build.dir}/Resources ${destroot}${my_share_dir}
328    }
329   
330    # Install the programs.
331    foreach my_arch ${my_archs} {
332        if {[variant_isset universal]} {
333            set my_dest ${workpath}/pre-dest/${my_arch}
334        } else {
335            set my_dest ${destroot}
336        }
337        xinstall -d ${my_dest}${my_app_dir}
338        foreach {my_machine unused} ${my_variations} {
339            copy ${build.dir}/${my_arch}/${my_machine}/minivmac.app \
340                "${my_dest}${my_app_dir}/Mini vMac ${my_machine}.app"
341        }
342    }
343    if {[variant_isset universal]} {
344        merge ${workpath}/pre-dest
345    }
346}
347
348# Returns the full path to the ROM file, wherever the user has it,
349# or the empty string if the user doesn't have it.
350proc my_real_rom_file {} {
351    global my_app_dir my_rom_dir my_rom_file
352    if {[file exists ${my_app_dir}/${my_rom_file}]} {
353        return ${my_app_dir}/${my_rom_file}
354    }
355    set my_real_rom_dir [my_read_alias ${my_rom_dir}]
356    if {[file exists ${my_real_rom_dir}/${my_rom_file}]} {
357        return ${my_real_rom_dir}/${my_rom_file}
358    }
359    return ""
360}
361
362# Resolves a Mac OS X alias.
363proc my_read_alias {file} {
364    global filespath
365    return [exec osascript ${filespath}/readalias.applescript [file normalize ${file}]]
366}
367
368# Converts normal arch names into Mini vMac target names.
369proc my_arch_to_target {arch} {
370    switch ${arch} {
371        i386 {
372            return imch
373        }
374        ppc {
375            return mach
376        }
377        default {
378            return -code error "unsupported architecture ${arch}"
379        }
380    }
381}
382
383livecheck.type          regex
384livecheck.url           ${homepage}doc/download.html
385livecheck.regex         ${my_name}-(\[0-9.\]+)\\.src
Note: See TracBrowser for help on using the repository browser.