source: users/ryandesign/minivmac-devel/Portfile @ 57914

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

minivmac, minivmac-devel: bail during the configuration phase if configuration fails, so the user can try again without needing to clean

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.5 KB
Line 
1# $Id: Portfile 57914 2009-09-18 19:25:03Z 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_bootstrap_app    "Mini vMac.app"
93set my_rom_file         vMac.ROM
94set my_base_options     "-maintainer MacPorts -homepage http://www.macports.org/ -cl -eol unx -nex"
95set my_target           ""
96
97options my_variations
98my_variations           {128K}      {-m 128K} \
99                        {512K}      {-m 128K -mem 512K} \
100                        {512Ke}     {-m 512Ke} \
101                        {Plus}      {-m Plus -im 1} \
102                        {SE}        {-m SE} \
103                        {SE FDHD}   {-m SEFDHD} \
104                        {Classic}   {-m Classic}
105
106variant unsupported description {Also build unfinished Macintosh II and IIx emulators} {
107    my_variations-append \
108                        {II}        {-m II -mem 8M -hres 800 -vres 600 -depth 3} \
109                        {IIx}       {-m IIx -mem 8M -hres 800 -vres 600 -depth 3}
110}
111
112platform powerpc {
113    set my_target mach
114}
115
116platform i386 {
117    set my_target imch
118}
119
120pre-fetch {
121    if { ! [file exists ${my_app_dir}/${my_rom_file}] } {
122        ui_msg "****************************************************************"
123        ui_msg "To build Mini vMac, you will need a ROM file from a Macintosh"
124        ui_msg "Plus or 512Ke. And to run it, you need a ROM file from the type"
125        ui_msg "of Mac you want to emulate. ROM files are not included with this"
126        ui_msg "package because they are copyrighted Apple software."
127        ui_msg "To create a ROM file, download the CopyRoms program from"
128        ui_msg "${homepage}extras/copyroms.html"
129        ui_msg "and transfer it to a real physical early Macintosh that you own."
130        ui_msg "Run the CopyRoms program there, then transfer the ROM file back"
131        ui_msg "to this Mac and put it in ${my_app_dir}."
132        ui_msg "****************************************************************"
133        return -code error "${my_rom_file} not found"
134    }
135}
136
137worksrcdir              stuff
138extract.mkdir           yes
139
140build.dir               ${workpath}/variations
141
142post-extract {
143    # Make the build directory.
144    file mkdir ${build.dir}
145   
146    # Copy the scripts we need.
147    xinstall -W ${filespath} attach.exp configure.applescript demacbinary.sh ${worksrcpath}
148    xinstall -W ${filespath} Makefile.in ${build.dir}/Makefile
149   
150    # Decode the system disk container image.
151    my_system "${worksrcpath}/demacbinary.sh ${distpath}/${my_system_disk_container_distfile} ${worksrcpath}"
152   
153    # Copy the Disk Tools image from the container image. The binary patchfile applied with bspatch
154    # places an alias of the output disk at System Folder:Preferences:Gryphel:Build:output.
155    set my_system_disk_container_mount [my_attach_disk_image ${worksrcpath}/${my_system_disk_container}]
156    my_system "bspatch '${my_system_disk_container_mount}/Disk Tools.image' '${worksrcpath}/Disk Tools.dsk' '${filespath}/Disk Tools.dsk.bsdiff'"
157    my_detach_disk_image ${my_system_disk_container_mount}
158   
159    # Get a large empty disk image to store the output.
160    my_system "unzip -q ${worksrcpath}/${my_blanks}/hfs24M.zip -d ${worksrcpath}"
161   
162    # Use the .img extension for the output disk image so that we can mount it on Mac OS X later.
163    file rename ${worksrcpath}/hfs24M.DSK ${worksrcpath}/output.img
164   
165    # Unrestrict the permissions on the output disk image so the Build program
166    # can write its output to it.
167    file attributes ${worksrcpath}/output.img -permissions 0777
168   
169    # Extract the bootstrap version of Mini vMac.
170    my_system "tar -x -z -C ${worksrcpath} -f ${distpath}/${my_bootstrap_distfile}"
171   
172    # Make the data directory, where Mini vMac looks for the files it needs.
173    set my_mnvm_dat "${worksrcpath}/${my_bootstrap_app}/Contents/mnvm_dat"
174    file mkdir ${my_mnvm_dat}
175   
176    # Symlink the ROM file into the data directory.
177    ln -s ${my_app_dir}/${my_rom_file} ${my_mnvm_dat}
178   
179    # Symlink the disk images into the data directory with sequentially-numbered
180    # names so Mini vMac will find them and automatically mount them.
181    ln -s "${worksrcpath}/Disk Tools.dsk" "${my_mnvm_dat}/disk1.dsk"
182    ln -s ${worksrcpath}/${my_src}/${my_src}.dsk "${my_mnvm_dat}/disk2.dsk"
183    ln -s ${worksrcpath}/${my_clipin}/${my_clipin}.dsk "${my_mnvm_dat}/disk3.dsk"
184    ln -s ${worksrcpath}/output.img "${my_mnvm_dat}/disk4.dsk"
185}
186
187pre-configure {
188    set i 0
189    foreach {my_machine my_variation_options} ${my_variations} {
190        if {${i} > 0} {
191            configure.args-append {\;}
192        }
193        configure.args-append \
194            ${my_base_options} \
195            -t ${my_target} \
196            ${my_variation_options} \
197            -n ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
198        incr i
199    }
200   
201    # Launch Mini vMac so the configure script can talk to it.
202    my_system "open '${worksrcpath}/${my_bootstrap_app}'"
203}
204
205configure.cmd           osascript
206configure.pre_args      configure.applescript
207
208post-configure {
209    set my_variation_dirs ""
210    set my_output_disk_mount [my_attach_disk_image ${worksrcpath}/output.img]
211    foreach my_variation_dir [glob -nocomplain -type d -tails -directory ${my_output_disk_mount} *] {
212        set my_variation_dirs "${my_variation_dirs} ${my_variation_dir}"
213       
214        # Get the configured source code.
215        file copy ${my_output_disk_mount}/${my_variation_dir} ${build.dir}
216       
217        # Use the right compiler.
218        reinplace "s|gcc|${configure.cc}|g" ${build.dir}/${my_variation_dir}/Makefile
219       
220        # Remove references to SDKs -- the 10.4u SDK is not installed by default on 10.6
221        # and even if you install it manually it does not work here.
222        reinplace -E {s|-isysroot /Developer/SDKs/[^ ]+||g} ${build.dir}/${my_variation_dir}/Makefile
223    }
224    my_detach_disk_image ${my_output_disk_mount}
225    reinplace "s|@SUBDIRS@|${my_variation_dirs}|" ${build.dir}/Makefile
226   
227    # If no variation directoriess were produced by configuration, either the flags we
228    # passed in were bad, or the automation script got out of sync with the emulator;
229    # if the latter, the delays in configure.applescript may need to be adjusted.
230    if {"" == ${my_variation_dirs}} {
231        return -code error "configuration failed!"
232    }
233}
234
235set my_share_dir        ${prefix}/share/${my_name}
236
237post-build {
238    # To save space, keep only a single copy of the Resources directory.
239    set i 0
240    foreach my_variation_dir [glob -type d -tails -directory ${build.dir} *] {
241        set my_resources_dir ${build.dir}/${my_variation_dir}/minivmac.app/Contents/Resources
242        if {0 == ${i}} {
243            move ${my_resources_dir} ${build.dir}
244        } else {
245            delete ${my_resources_dir}
246        }
247        ln -s ${my_share_dir}/Resources ${my_resources_dir}
248        incr i
249    }
250   
251    # Install the prettier icons.
252    eval xinstall -m 644 [glob ${worksrcpath}/${my_icons}/icons/*.icns] ${build.dir}/Resources
253}
254
255destroot {
256    # Install the global Resources directory.
257    xinstall -d ${destroot}${my_share_dir}
258    copy ${build.dir}/Resources ${destroot}${my_share_dir}
259   
260    # Install the programs.
261    xinstall -d ${destroot}${my_app_dir}
262    foreach {my_machine my_variation_options} ${my_variations} {
263        set my_variation_dir ${version}_${revision}-[strsed [string tolower ${my_machine}] {g/[^a-z0-9_-]//}]-${my_target}
264        file copy ${build.dir}/${my_variation_dir}/minivmac.app \
265            "${destroot}${my_app_dir}/Mini vMac ${my_machine}.app"
266    }
267}
268
269# Mounts a disk image.
270proc my_attach_disk_image {disk_image} {
271    global my_name worksrcpath
272    set mountpoint [mkdtemp "/tmp/${my_name}.XXXXXXXX"]
273    # Use this expect script instead of using hdiutil directly, because the
274    # system disk image has a license agreement we must agree to.
275    my_system "${worksrcpath}/attach.exp '${disk_image}' '${mountpoint}'"
276    return ${mountpoint}
277}
278
279# Unmounts a disk image.
280proc my_detach_disk_image {mountpoint} {
281    my_system "hdiutil detach ${mountpoint} -force"
282    file delete -force ${mountpoint}
283}
284
285proc my_system {cmd} {
286     ui_debug ${cmd}
287     system ${cmd}
288}
289
290livecheck.type          regex
291livecheck.url           ${homepage}beta/index.html
292livecheck.regex         ${my_name}-(\[0-9.\]+)\\.src
Note: See TracBrowser for help on using the repository browser.