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

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

minivmac, minivmac-devel: add machinery to build for multiple architectures; universal build is not possible until a new version of MacPorts with a fixed merge procedure (see r58777 and r58788) is released

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.4 KB
Line 
1# $Id: Portfile 58792 2009-10-05 12:35:02Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    minivmac-devel
6conflicts               minivmac
7set my_name             minivmac
8version                 3.1.2
9revision                1
10categories              emulators aqua
11maintainers             ryandesign
12license                 GPLv2
13homepage                http://minivmac.sourceforge.net/
14use_zip                 yes
15platforms               macosx
16universal_variant       no
17use_parallel_build      yes
18dist_subdir             ${my_name}
19
20description \
21    a Mac 128K, Mac 512K, Mac 512KE, Mac Plus and Mac SE emulator
22
23long_description \
24    Mini vMac is a Macintosh emulator. It emulates the earliest Macs, \
25    from the original Mac 128K (built 1984-85) to the Mac SE (1987-1990). \
26    The default is to emulate a Mac Plus (1986-1990)\; this is also \
27    the best-tested and therefore recommended emulation.
28
29master_sites \
30    sourceforge:${my_name}:minivmac \
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
33distname                                    ${my_name}-${version}
34set my_src                                  ${distname}.src
35set my_src_distfile                         ${my_src}.zip
36set my_bootstrap_distfile                   ${my_name}-3.1.2-umch.bin.tgz
37set my_blanks                               blanks
38set my_blanks_distfile                      ${my_blanks}-0.2.0.zip
39set my_clipin                               clipin-1.1.0
40set my_clipin_distfile                      ${my_clipin}.zip
41set my_icons                                icnsosx-1.0.0
42set my_icons_distfile                       ${my_icons}.zip
43set my_system_disk_container                System_7.0.1.smi
44set my_system_disk_container_distfile       ${my_system_disk_container}.bin
45
46distfiles \
47    ${my_src_distfile}:minivmac \
48    ${my_bootstrap_distfile}:minivmac \
49    ${my_icons_distfile}:minivmac \
50    ${my_clipin_distfile}:minivmac \
51    ${my_blanks_distfile}:minivmac \
52    ${my_system_disk_container_distfile}:apple
53
54extract.only \
55    ${my_src_distfile} \
56    ${my_icons_distfile} \
57    ${my_blanks_distfile} \
58    ${my_clipin_distfile}
59
60checksums \
61    ${my_src_distfile} \
62        md5     e02e2e762c5f9df3451efb71733d75c4 \
63        sha1    b395715983ba651b96ef941e27b0f5e18f624aea \
64        rmd160  186d2672bf3d67f9bf61b0960a157fa36a616f4c \
65    ${my_bootstrap_distfile} \
66        md5     53239cda5f1827fcc00d9254ee1ee9e0 \
67        sha1    d6c16c541d72241cabafcbb94eec7c198e8b1670 \
68        rmd160  f3925e194c59f704f6fac391609ccc72dd12c718 \
69    ${my_icons_distfile} \
70        md5     2af006506de7549be14f94317918d59a \
71        sha1    4ef79bb56b988fedfeb82a8b6cafd8066f5bbab2 \
72        rmd160  cef6d7d7578464538d0042b0d98379ae7f18fab7 \
73    ${my_clipin_distfile} \
74        md5     e094de97d1c6c214a80fb74895124c3e \
75        sha1    725f622ad6681c77e7f9f4a64d05ac1d6a103beb \
76        rmd160  5699b56c8db62b2568c8de88b6d419180b1fb73d \
77    ${my_blanks_distfile} \
78        md5     b16321d0d78048d5ec9b635f4f86b19c \
79        sha1    9b8d7e77bd05633709907f8806d976279d7a20b7 \
80        rmd160  a0784c17c5a5ca2e159762fb836c1c800762b213 \
81    ${my_system_disk_container_distfile} \
82        md5     8a4776350b15b5a516cdf7dd18e27290 \
83        sha1    d4c8b8653de9c7a9b2594dd6126ec7120e3e2e9e \
84        rmd160  89fc3780c9c5d575a8da4068dc810c1f56c70211
85
86depends_extract \
87    port:macutil \
88    port:bsdiff \
89    bin:expect:expect
90
91set my_app_dir          "${applications_dir}/Mini vMac"
92set my_rom_dir          "~/Library/Preferences/Gryphel/mnvm_rom"
93set my_bootstrap_app    "Mini vMac.app"
94set my_rom_file         vMac.ROM
95set my_base_options     "-maintainer MacPorts -homepage http://www.macports.org/ -cl -eol unx -nex"
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# The universal variant is disabled until MacPorts 1.8.2 is released.
114if {0} {
115variant universal {
116    configure.universal_args
117    configure.universal_archs ppc i386
118    set my_archs ${configure.universal_archs}
119}
120}
121if {![variant_isset universal]} {
122    switch ${os.arch} {
123        powerpc {
124            configure.build_arch ppc
125        }
126        default {
127            configure.build_arch ${os.arch}
128        }
129    }
130    set my_archs ${configure.build_arch}
131}
132
133pre-fetch {
134    set my_real_rom_dir [exec osascript ${filespath}/readalias.applescript [file normalize ${my_rom_dir}]]
135    if {![file exists ${my_real_rom_dir}/${my_rom_file}] && ![file exists ${my_app_dir}/${my_rom_file}]} {
136        ui_msg "****************************************************************"
137        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
138        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
139        ui_msg "of Mac you want to emulate. ROM files are not included with this"
140        ui_msg "package because they are copyrighted Apple software."
141        ui_msg "To create a ROM file, download the CopyRoms program from"
142        ui_msg "${homepage}extras/copyroms.html"
143        ui_msg "and transfer it to a real physical early Macintosh that you own."
144        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
145        ui_msg "to this Mac and put it in ${my_rom_dir}"
146        ui_msg "(which can be an alias or symlink if desired) or"
147        ui_msg "${my_app_dir}."
148        ui_msg "****************************************************************"
149        return -code error "${my_rom_file} not found"
150    }
151}
152
153worksrcdir              stuff
154extract.mkdir           yes
155
156post-extract {
157    # Decode the system disk container image.
158    my_system "sh ${filespath}/demacbinary.sh ${distpath}/${my_system_disk_container_distfile} ${worksrcpath}"
159   
160    # Copy the Disk Tools image from the container image. The binary patchfile applied with bspatch
161    # places an alias of the output disk at System Folder:Preferences:Gryphel:Build:output.
162    set my_system_disk_container_mount [my_attach_disk_image ${worksrcpath}/${my_system_disk_container}]
163    my_system "bspatch '${my_system_disk_container_mount}/Disk Tools.image' '${worksrcpath}/Disk Tools.dsk' '${filespath}/Disk Tools.dsk.bsdiff'"
164    my_detach_disk_image ${my_system_disk_container_mount}
165   
166    # Get a large empty disk image to store the output.
167    my_system "unzip -q ${worksrcpath}/${my_blanks}/hfs24M.zip -d ${worksrcpath}"
168   
169    # Use the .img extension for the output disk image so that we can mount it on Mac OS X later.
170    file rename ${worksrcpath}/hfs24M.DSK ${worksrcpath}/output.img
171   
172    # Unrestrict the permissions on the output disk image so the Build program
173    # can write its output to it.
174    file attributes ${worksrcpath}/output.img -permissions 0777
175   
176    # Extract the bootstrap version of Mini vMac.
177    my_system "tar -x -z -C ${worksrcpath} -f ${distpath}/${my_bootstrap_distfile}"
178   
179    # Make the data directory, where Mini vMac looks for the files it needs.
180    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
181    file mkdir ${my_mnvm_dat}
182   
183    # Symlink the ROM file into the data directory.
184    ln -s ${my_app_dir}/${my_rom_file} ${my_mnvm_dat}
185   
186    # Symlink the disk images into the data directory with sequentially-numbered
187    # names so Mini vMac will find them and automatically mount them.
188    ln -s "${worksrcpath}/Disk Tools.dsk" "${my_mnvm_dat}/disk1.dsk"
189    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk2.dsk"
190    ln -s ${worksrcpath}/${my_clipin}/${my_clipin}.dsk "${my_mnvm_dat}/disk3.dsk"
191    ln -s ${worksrcpath}/output.img "${my_mnvm_dat}/disk4.dsk"
192}
193
194pre-configure {
195    set i 0
196    foreach my_arch ${my_archs} {
197        set my_target [my_arch_to_target ${my_arch}]
198        foreach {my_machine my_variation_options} ${my_variations} {
199            if {${i} > 0} {
200                configure.args-append {\;}
201            }
202            configure.args-append \
203                ${my_base_options} \
204                -t ${my_target} \
205                ${my_variation_options} \
206                -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
207            incr i
208        }
209    }
210   
211    # Launch Mini vMac so the configure script can talk to it.
212    my_system "open '${worksrcpath}/${my_bootstrap_app}'"
213}
214
215configure.cmd           osascript
216configure.pre_args      ${filespath}/configure.applescript
217
218build.dir               ${workpath}/variations
219
220post-configure {
221    file mkdir ${build.dir}
222    set my_variation_dirs ""
223    set my_output_disk_mount [my_attach_disk_image ${worksrcpath}/output.img]
224    foreach my_arch ${my_archs} {
225        file mkdir ${build.dir}/${my_arch}
226        set my_target [my_arch_to_target ${my_arch}]
227        foreach {my_machine unused} ${my_variations} {
228            set my_src_dir ${my_output_disk_mount}/${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
229            if {[file isdirectory ${my_src_dir}]} {
230                set my_variation_dir ${my_arch}/${my_machine}
231                set my_variation_dirs "${my_variation_dirs} [strsed ${my_variation_dir} {g/ /\\\\ /}]"
232               
233                # Get the configured source code.
234                file copy ${my_src_dir} ${build.dir}/${my_variation_dir}
235               
236                # Use the right compiler.
237                reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
238               
239                # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
240                # and even if you install it manually it does not work here.
241                reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
242            }
243        }
244    }
245    my_detach_disk_image ${my_output_disk_mount}
246   
247    # Set up the global Makefile.
248    xinstall ${filespath}/Makefile.in ${build.dir}/Makefile
249    reinplace "s|@SUBDIRS@|${my_variation_dirs}|" ${build.dir}/Makefile
250   
251    # If no variation directoriess were produced by configuration, either the flags we
252    # passed in were bad, or the automation script got out of sync with the emulator;
253    # if the latter, the delays in configure.applescript may need to be adjusted.
254    if {"" == ${my_variation_dirs}} {
255        return -code error "configuration failed!"
256    }
257}
258
259set my_share_dir        ${prefix}/share/${my_name}
260
261post-build {
262    # To save space, keep only a single copy of the Resources directory.
263    set i 0
264    foreach my_arch ${my_archs} {
265        set my_target [my_arch_to_target ${my_arch}]
266        foreach {my_machine unused} ${my_variations} {
267            if {[variant_isset universal]} {
268                reinplace "s|${my_target}|umch|" ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Info.plist
269            }
270            set my_resources_dir ${build.dir}/${my_arch}/${my_machine}/minivmac.app/Contents/Resources
271            if {0 == ${i}} {
272                move ${my_resources_dir} ${build.dir}
273            } else {
274                delete ${my_resources_dir}
275            }
276            ln -s ${my_share_dir}/Resources ${my_resources_dir}
277            incr i
278        }
279    }
280   
281    # Install the prettier icons.
282    eval xinstall -m 644 [glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
283}
284
285destroot {
286    # Install the global Resources directory.
287    xinstall -d ${destroot}${my_share_dir}
288    copy ${build.dir}/Resources ${destroot}${my_share_dir}
289   
290    # Install the programs.
291    foreach my_arch ${my_archs} {
292        if {[variant_isset universal]} {
293            set my_dest ${workpath}/pre-dest/${my_arch}
294        } else {
295            set my_dest ${destroot}
296        }
297        xinstall -d ${my_dest}${my_app_dir}
298        foreach {my_machine unused} ${my_variations} {
299            copy ${build.dir}/${my_arch}/${my_machine}/minivmac.app \
300                "${my_dest}${my_app_dir}/Mini vMac ${my_machine}.app"
301        }
302    }
303    if {[variant_isset universal]} {
304        merge ${workpath}/pre-dest
305    }
306}
307
308# Converts normal arch names into Mini vMac target names.
309proc my_arch_to_target {arch} {
310    switch ${arch} {
311        i386 {
312            return imch
313        }
314        ppc {
315            return mach
316        }
317        default {
318            return -code error "unsupported architecture ${arch}"
319        }
320    }
321}
322
323# Mounts a disk image.
324proc my_attach_disk_image {disk_image} {
325    global my_name filespath
326    set mountpoint [mkdtemp "/tmp/${my_name}.XXXXXXXX"]
327    # Use this expect script instead of using hdiutil directly, because the
328    # system disk image has a license agreement we must agree to.
329    my_system "expect ${filespath}/attach.exp '${disk_image}' '${mountpoint}'"
330    return ${mountpoint}
331}
332
333# Unmounts a disk image.
334proc my_detach_disk_image {mountpoint} {
335    my_system "hdiutil detach ${mountpoint} -force"
336    file delete -force ${mountpoint}
337}
338
339proc my_system {cmd} {
340     ui_debug ${cmd}
341     system ${cmd}
342}
343
344livecheck.type          regex
345livecheck.url           ${homepage}beta/index.html
346livecheck.regex         ${my_name}-(\[0-9.\]+)\\.src
Note: See TracBrowser for help on using the repository browser.