X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/9494d866a5d163b9ed6c74456f18c6fe4158fff8..48a10826fef7777bb8b061f4a121f481ced98bc0:/mkfiles.pl diff --git a/mkfiles.pl b/mkfiles.pl index 382a40b..f5a3d9b 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -135,9 +135,7 @@ foreach $i (@prognames) { $file = "$1.r"; $depends{$j} = [$file]; push @scanlist, $file; - } elsif ($j =~ /\.lib$/) { - # libraries don't have dependencies - } else { + } elsif ($j !~ /\./) { $file = "$j.c"; $file = "$j.m" unless &findfile($file); $depends{$j} = [$file]; @@ -259,7 +257,7 @@ sub objects { } elsif ($i =~ /^(.*)\.lib/) { $y = $1; ($x = $ltmpl) =~ s/X/$y/; - } else { + } elsif ($i !~ /\./) { ($x = $otmpl) =~ s/X/$i/; } push @ret, $x if $x ne ""; @@ -267,6 +265,19 @@ sub objects { return join " ", @ret; } +sub special { + my ($prog, $suffix) = @_; + my @ret; + my ($i, $x, $y); + @ret = (); + foreach $i (@{$programs{$prog}}) { + if (substr($i, (length $i) - (length $suffix)) eq $suffix) { + push @ret, $i; + } + } + return join " ", @ret; +} + sub splitline { my ($line, $width, $splitchar) = @_; my ($result, $len); @@ -863,11 +874,17 @@ if (defined $makefiles{'gtk'}) { "# You can define this path to point at your tools if you need to\n". "# TOOLPATH = /opt/gcc/bin\n". "CC = \$(TOOLPATH)cc\n". + "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n". + "# (depending on what works on your system) if you want to enforce\n". + "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n". + "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n". + "# to 1.2 if it isn't found.\n". + "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n". "\n". &splitline("CFLAGS = -O2 -Wall -Werror -g " . (join " ", map {"-I$dirpfx$_"} @srcdirs) . - " `gtk-config --cflags`")."\n". - "XLDFLAGS = `gtk-config --libs`\n". + " `\$(GTK_CONFIG) --cflags`")."\n". + "XLDFLAGS = `\$(GTK_CONFIG) --libs`\n". "ULDFLAGS =#\n". "INSTALL=install\n", "INSTALL_PROGRAM=\$(INSTALL)\n", @@ -1117,9 +1134,12 @@ if (defined $makefiles{'osx'}) { print "CC = \$(TOOLPATH)gcc\n". "\n". - &splitline("CFLAGS = -O2 -Wall -Werror -g -DMAC_OS_X " . + &splitline("CFLAGS = -O2 -Wall -Werror -g " . (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n". "LDFLAGS = -framework Cocoa\n". + &splitline("all:" . join "", map { " $_" } &progrealnames("MX")) . + "\n" . + $makefile_extra{'osx'} . "\n". ".SUFFIXES: .o .c .m\n". "\n". @@ -1128,15 +1148,27 @@ if (defined $makefiles{'osx'}) { ".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"; + $icon = &special($p, ".icns"); + $infoplist = &special($p, "info.plist"); + print "${prog}.app:\n\tmkdir -p \$\@\n"; + print "${prog}.app/Contents: ${prog}.app\n\tmkdir -p \$\@\n"; + print "${prog}.app/Contents/MacOS: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; + $targets = "${prog}.app/Contents/MacOS/$prog"; + if (defined $icon) { + print "${prog}.app/Contents/Resources: ${prog}.app/Contents\n\tmkdir -p \$\@\n"; + print "${prog}.app/Contents/Resources/${prog}.icns: ${prog}.app/Contents/Resources $icon\n\tcp $icon \$\@\n"; + $targets .= " ${prog}.app/Contents/Resources/${prog}.icns"; + } + if (defined $infoplist) { + print "${prog}.app/Contents/Info.plist: ${prog}.app/Contents/Resources $infoplist\n\tcp $infoplist \$\@\n"; + $targets .= " ${prog}.app/Contents/Info.plist"; + } + $targets .= " \$(${prog}_extra)"; + print &splitline("${prog}: $targets", 69) . "\n\n"; print &splitline("${prog}.app/Contents/MacOS/$prog: ". "${prog}.app/Contents/MacOS " . $objstr), "\n"; $libstr = &objects($p, undef, undef, "-lX"); @@ -1147,10 +1179,8 @@ if (defined $makefiles{'osx'}) { 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 -f *.o *.dmg\n". "\trm -rf *.app\n"; select STDOUT; close OUT; }