diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-01-22 18:34:18 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-01-22 18:34:18 +0000 |
| commit | 11dad948a371f9b67be7a3141b7ac7a84e822a2a (patch) | |
| tree | f367d282bb340ece7c155ff8afad82d4e4bc1257 /mkfiles.pl | |
| parent | a99de1be8f01f619b965e446ff4ff85d4324f487 (diff) | |
| download | puzzles-11dad948a371f9b67be7a3141b7ac7a84e822a2a.zip puzzles-11dad948a371f9b67be7a3141b7ac7a84e822a2a.tar.gz puzzles-11dad948a371f9b67be7a3141b7ac7a84e822a2a.tar.bz2 puzzles-11dad948a371f9b67be7a3141b7ac7a84e822a2a.tar.xz | |
Initial checkin of a Mac OS X port of puzzles, using Cocoa. All
puzzles are compiled together into a single monolithic application
which allows you to select each one from one of its menus.
[originally from svn r5173]
Diffstat (limited to 'mkfiles.pl')
| -rwxr-xr-x | mkfiles.pl | 103 |
1 files changed, 80 insertions, 23 deletions
@@ -91,8 +91,8 @@ while (<IN>) { if ($groups{$i}) { foreach $j (@{$groups{$i}}) { unshift @objs, $j; } } elsif (($i eq "[G]" or $i eq "[C]" or $i eq "[M]" or - $i eq "[X]" or $i eq "[U]") and defined $prog) { - $type = substr($i,1,1); + $i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) { + $type = substr($i,1,(length $i)-2); } else { push @$listref, $i; } @@ -121,7 +121,8 @@ foreach $i (@prognames) { sort @{$programs{$i}}; $programs{$i} = [@list]; foreach $j (@list) { - # Dependencies for "x" start with "x.c". + # Dependencies for "x" start with "x.c" or "x.m" (depending on + # which one exists). # Dependencies for "x.res" start with "x.rc". # Dependencies for "x.rsrc" start with "x.r". # Both types of file are pushed on the list of files to scan. @@ -138,6 +139,7 @@ foreach $i (@prognames) { # libraries don't have dependencies } else { $file = "$j.c"; + $file = "$j.m" unless &findfile($file); $depends{$j} = [$file]; push @scanlist, $file; } @@ -208,7 +210,7 @@ sub mfval($) { # Returns true if the argument is a known makefile type. Otherwise, # prints a warning and returns false; if (grep { $type eq $_ } - ("vc","vcproj","cygwin","borland","lcc","gtk","mpw")) { + ("vc","vcproj","cygwin","borland","lcc","gtk","mpw","osx")) { return 1; } warn "$.:unknown makefile type '$type'\n"; @@ -230,14 +232,16 @@ sub dirpfx { sub findfile { my ($name) = @_; - my $dir, $i, $outdir = ""; + my $dir; + my $i; + my $outdir = undef; unless (defined $findfilecache{$name}) { $i = 0; foreach $dir (@srcdirs) { $outdir = $dir, $i++ if -f "$dir$name"; } die "multiple instances of source file $name\n" if $i > 1; - $findfilecache{$name} = $outdir . $name; + $findfilecache{$name} = (defined $outdir ? $outdir . $name : undef); } return $findfilecache{$name}; } @@ -309,7 +313,7 @@ sub prognames { @ret = (); foreach $n (@prognames) { ($prog, $type) = split ",", $n; - push @ret, $n if index($types, $type) >= 0; + push @ret, $n if index(":$types:", ":$type:") >= 0; } return @ret; } @@ -321,7 +325,7 @@ sub progrealnames { @ret = (); foreach $n (@prognames) { ($prog, $type) = split ",", $n; - push @ret, $prog if index($types, $type) >= 0; + push @ret, $prog if index(":$types:", ":$type:") >= 0; } return @ret; } @@ -330,7 +334,7 @@ sub manpages { my ($types,$suffix) = @_; # assume that all UNIX programs have a man page - if($suffix eq "1" && $types =~ /X/) { + if($suffix eq "1" && $types =~ /:X:/) { return map("$_.1", &progrealnames($types)); } return (); @@ -379,9 +383,9 @@ if (defined $makefiles{'cygwin'}) { "%.res.o: %.rc\n". "\t\$(RC) \$(FWHACK) \$(RCFL) \$(RCFLAGS) \$< \$\@\n". "\n"; - print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); + print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); print "\n\n"; - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; $objstr = &objects($p, "X.o", "X.res.o", undef); print &splitline($prog . ".exe: " . $objstr), "\n"; @@ -451,16 +455,16 @@ if (defined $makefiles{'borland'}) { &splitline("\tbrcc32 \$(FWHACK) \$(RCFL) -i \$(BCB)\\include -r". " -DNO_WINRESRC_H -DWIN32 -D_WIN32 -DWINVER=0x0401 \$*.rc",69)."\n". "\n"; - print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); + print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); print "\n\n"; - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; $objstr = &objects($p, "X.obj", "X.res", undef); print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n"; my $ap = ($type eq "G") ? "-aa" : "-ap"; print "\tilink32 $ap -Gn -L\$(BCB)\\lib \@$prog.rsp\n\n"; } - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; print $prog, ".rsp: \$(MAKEFILE)\n"; $objstr = &objects($p, "X.obj", undef, undef); @@ -533,15 +537,15 @@ if (defined $makefiles{'vc'}) { ".rc.res:\n". "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 -DWINVER=0x0400 \$*.rc\n". "\n"; - print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); + print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); print "\n\n"; - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; $objstr = &objects($p, "X.obj", "X.res", undef); print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n"; print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n"; } - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; print $prog, ".rsp: \$(MAKEFILE)\n"; $objstr = &objects($p, "X.obj", "X.res", "X.lib"); @@ -608,7 +612,7 @@ if (defined $makefiles{'vcproj'}) { %all_object_deps = map {$_->{obj} => $_->{deps}} @deps; # Create the project files # Get names of all Windows projects (GUI and console) - my @prognames = &prognames("GC"); + my @prognames = &prognames("G:C"); foreach $progname (@prognames) { create_project(\%all_object_deps, $progname); } @@ -879,9 +883,9 @@ if (defined $makefiles{'gtk'}) { "%.o:\n". "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n". "\n"; - print &splitline("all:" . join "", map { " $_" } &progrealnames("XU")); + print &splitline("all:" . join "", map { " $_" } &progrealnames("X:U")); print "\n\n"; - foreach $p (&prognames("XU")) { + foreach $p (&prognames("X:U")) { ($prog, $type) = split ",", $p; $objstr = &objects($p, "X.o", undef, undef); print &splitline($prog . ": " . $objstr), "\n"; @@ -896,7 +900,7 @@ if (defined $makefiles{'gtk'}) { print "\n"; print $makefile_extra{'gtk'}; print "\nclean:\n". - "\trm -f *.o". (join "", map { " $_" } &progrealnames("XU")) . "\n"; + "\trm -f *.o". (join "", map { " $_" } &progrealnames("X:U")) . "\n"; select STDOUT; close OUT; } @@ -1071,9 +1075,9 @@ if (defined $makefiles{'lcc'}) { ".rc.res:\n". &splitline("\tlrc \$(FWHACK) \$(RCFL) -r \$*.rc",69)."\n". "\n"; - print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("GC")); + print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G:C")); print "\n\n"; - foreach $p (&prognames("GC")) { + foreach $p (&prognames("G:C")) { ($prog, $type) = split ",", $p; $objstr = &objects($p, "X.obj", "X.res", undef); print &splitline("$prog.exe: " . $objstr ), "\n"; @@ -1097,3 +1101,56 @@ if (defined $makefiles{'lcc'}) { select STDOUT; close OUT; } + +if (defined $makefiles{'osx'}) { + $dirpfx = &dirpfx($makefiles{'osx'}, "/"); + + ##-- Mac OS X makefile + open OUT, ">$makefiles{'osx'}"; select OUT; + print + "# Makefile for $project_name under Mac OS X.\n". + "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". + "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; + # gcc command line option is -D not /D + ($_ = $help) =~ s/=\/D/=-D/gs; + print $_; + print + "CC = \$(TOOLPATH)gcc\n". + "\n". + &splitline("CFLAGS = -O2 -Wall -Werror -g -DMAC_OS_X " . + (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". + "LDFLAGS = -framework Cocoa\n". + "\n". + ".SUFFIXES: .o .c .m\n". + "\n". + ".c.o:\n". + "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n". + ".m.o:\n". + "\t\$(CC) -x objective-c \$(COMPAT) \$(FWHACK) \$(XFLAGS) \$(CFLAGS) -c \$<\n". + "\n"; + print &splitline("all:" . join "", map { " $_" } &progrealnames("MX")); + print "\n\n"; + foreach $p (&prognames("MX")) { + ($prog, $type) = split ",", $p; + $objstr = &objects($p, "X.o", undef, undef); + print "${prog}: ${prog}.app/Contents/MacOS/$prog\n\n"; + print "${prog}.app:\n\tmkdir \$\@\n"; + print "${prog}.app/Contents: ${prog}.app\n\tmkdir \$\@\n"; + print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir \$\@\n"; + print &splitline("${prog}.app/Contents/MacOS/$prog: ". + "${prog}.app/Contents/MacOS " . $objstr), "\n"; + $libstr = &objects($p, undef, undef, "-lX"); + print &splitline("\t\$(CC)" . $mw . " \$(LDFLAGS) -o \$@ " . + $objstr . " $libstr", 69), "\n\n"; + } + foreach $d (&deps("X.o", undef, $dirpfx, "/")) { + print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})), + "\n"; + } + print "\n"; + print $makefile_extra{'osx'}; + print "\nclean:\n". + "\trm -f *.o\n". + "\trm -rf *.app\n"; + select STDOUT; close OUT; +} |