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

Last change on this file was 149430, checked in by ryandesign@…, 17 months ago

minivmac-devel: update to 3.4.1

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