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

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

minivmac-devel: update to 3.4.0alpha-20141109

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