ref: 22ebad30e4c29e1063c0076a67973b0110c11e53
parent: d0ff371b144d4bfe3cbfb062388347c08e431393
author: Simon Tatham <anakin@pobox.com>
date: Sun May 6 10:01:32 EDT 2012
Add a section to mkfiles.pl to build a makefile that compiles the OS X front end using GNUstep, yielding a Unix program built from the same code. Should make it easier to check OS X behaviour without having to move as far as a Mac :-) However, it doesn't compile as is, so I'll apply fixes to the code until it does. [originally from svn r9498]
--- a/Recipe
+++ b/Recipe
@@ -13,6 +13,7 @@
!makefile wce Makefile.wce
!makefile cygwin Makefile.cyg
!makefile osx Makefile.osx
+!makefile gnustep Makefile.gnustep
!makefile nestedvm Makefile.nestedvm
!srcdir icons/
--- a/mkfiles.pl
+++ b/mkfiles.pl
@@ -287,7 +287,7 @@
# 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","nestedvm","osx","wce")) {
+ ("vc","vcproj","cygwin","borland","lcc","gtk","mpw","nestedvm","osx","wce","gnustep")) {
return 1;
}
warn "$.:unknown makefile type '$type'\n";
@@ -1498,6 +1498,93 @@
}
print "\nclean:\n".
"\trm -f *.o *.dmg". (join "", map { my $a=$_; (" $a", map { " ${a}.$_" } @osxarchs) } &progrealnames("U")) . "\n".
+ "\trm -rf *.app\n";
+ select STDOUT; close OUT;
+}
+
+if (defined $makefiles{'gnustep'}) {
+ $mftyp = 'gnustep';
+ $dirpfx = &dirpfx($makefiles{'gnustep'}, "/");
+
+ ##-- GNUstep makefile (use with 'gs_make -f Makefile.gnustep')
+
+ # This is a pretty evil way to do things. In an ideal world, I'd
+ # use the approved GNUstep makefile mechanism which just defines a
+ # variable or two saying what source files go into what binary and
+ # then includes application.make. Unfortunately, that has the
+ # automake-ish limitation that it doesn't let you choose different
+ # command lines for each object, so I can't arrange for all those
+ # files with -DTHIS and -DTHAT to Just Work.
+ #
+ # A simple if ugly fix would be to have mkfiles.pl construct a
+ # directory full of stub C files of the form '#define thing',
+ # '#include "real_source_file"', and then reference those in this
+ # makefile. That would also make it easy to build a proper
+ # automake makefile.
+ open OUT, ">$makefiles{'gnustep'}"; select OUT;
+ "# Makefile for $project_name under GNUstep.\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 $_;
+ "NEEDS_GUI=yes\n".
+ "include \$(GNUSTEP_MAKEFILES)/common.make\n".
+ "include \$(GNUSTEP_MAKEFILES)/rules.make\n".
+ "include \$(GNUSTEP_MAKEFILES)/Instance/rules.make\n".
+ "\n".
+ &splitline("all::" . join "", map { " $_" } &progrealnames("MX:U")) .
+ "\n";
+ print $makefile_extra{'gnustep'} || "";
+ print "\n".
+ ".SUFFIXES: .o .c .m\n".
+ "\n";
+ print "\n\n";
+ foreach $p (&prognames("MX")) {
+ ($prog, $type) = split ",", $p;
+ $icon = &special($p, ".icns");
+ $infoplist = &special($p, "info.plist");
+ print "${prog}.app:\n\tmkdir -p \$\@\n";
+ $targets = "${prog}.app ${prog}.app/$prog";
+ if (defined $icon) {
+ print "${prog}.app/Resources: ${prog}.app\n\tmkdir -p \$\@\n";
+ print "${prog}.app/Resources/${prog}.icns: ${prog}.app/Resources $icon\n\tcp $icon \$\@\n";
+ $targets .= " ${prog}.app/Resources/${prog}.icns";
+ }
+ if (defined $infoplist) {
+ print "${prog}.app/Info.plist: ${prog}.app $infoplist\n\tcp $infoplist \$\@\n";
+ $targets .= " ${prog}.app/Info.plist";
+ }
+ $targets .= " \$(${prog}_extra)";
+ print &splitline("${prog}: $targets", 69) . "\n\n";
+ $libstr = &objects($p, undef, undef, "-lX");
+ $objstr = &objects($p, "X.o", undef, undef);
+ print &splitline("${prog}.app/$prog: " . $objstr), "\n";
+ print &splitline("\t\$(CC) \$(ALL_LDFLAGS) -o \$@ " . $objstr . " \$(ALL_LIB_DIRS) $libstr \$(ALL_LIBS)", 69), "\n\n";
+ }
+ foreach $p (&prognames("U")) {
+ ($prog, $type) = split ",", $p;
+ $libstr = &objects($p, undef, undef, "-lX");
+ $objstr = &objects($p, "X.o", undef, undef);
+ print &splitline("${prog}: " . $objstr), "\n";
+ print &splitline("\t\$(CC) \$(ULDFLAGS) -o \$@ " . $objstr . " $libstr", 69), "\n\n";
+ }
+ foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
+ print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
+ "\n";
+ $deflist = join "", map { " -D$_" } @{$d->{defs}};
+ if ($d->{deps}->[0] =~ /\.m$/) {
+ print "\t\$(CC) -DGNUSTEP \$(ALL_OBJCFLAGS) \$(COMPAT) \$(FWHACK) \$(OBJCFLAGS)".
+ " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
+ } else {
+ print "\t\$(CC) \$(ALL_CFLAGS) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
+ " -c \$< -o \$\@\n";
+ }
+ }
+ print "\nclean::\n".
+ "\trm -f *.o ". (join " ", &progrealnames("U")) . "\n".
"\trm -rf *.app\n";
select STDOUT; close OUT;
}