aboutsummaryrefslogtreecommitdiff
path: root/mkfiles.pl
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-03-30 20:16:21 +0000
committerSimon Tatham <anakin@pobox.com>2013-03-30 20:16:21 +0000
commit49fba922eac8c4022b002e340080be9a7134132e (patch)
tree57b6947202a0235c3d3053a31fff36d9f8a69d2f /mkfiles.pl
parente2c84a5fd2b1ca6d3d8be0279466079b35b6c189 (diff)
downloadpuzzles-49fba922eac8c4022b002e340080be9a7134132e.zip
puzzles-49fba922eac8c4022b002e340080be9a7134132e.tar.gz
puzzles-49fba922eac8c4022b002e340080be9a7134132e.tar.bz2
puzzles-49fba922eac8c4022b002e340080be9a7134132e.tar.xz
New front end! To complement the webification of my puzzles via Java
applets, here's an alternative webification in Javascript, using Emscripten in asm.js mode (so that as browsers incorporate asm.js optimisation, the game generation should run really fast). [originally from svn r9781]
Diffstat (limited to 'mkfiles.pl')
-rwxr-xr-xmkfiles.pl58
1 files changed, 57 insertions, 1 deletions
diff --git a/mkfiles.pl b/mkfiles.pl
index 625b9ab..9629a29 100755
--- a/mkfiles.pl
+++ b/mkfiles.pl
@@ -287,7 +287,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","nestedvm","osx","wce","gnustep")) {
+ ("vc","vcproj","cygwin","borland","lcc","gtk","mpw","nestedvm","osx","wce","gnustep","emcc")) {
return 1;
}
warn "$.:unknown makefile type '$type'\n";
@@ -1589,3 +1589,59 @@ if (defined $makefiles{'gnustep'}) {
"\trm -rf *.app\n";
select STDOUT; close OUT;
}
+
+if (defined $makefiles{'emcc'}) {
+ $mftyp = 'emcc';
+ $dirpfx = &dirpfx($makefiles{'emcc'}, "/");
+
+ ##-- Makefile for building Javascript puzzles via Emscripten
+
+ open OUT, ">$makefiles{'emcc'}"; select OUT;
+ print
+ "# Makefile for $project_name using Emscripten. Requires GNU make.\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";
+ # emcc command line option is -D not /D
+ ($_ = $help) =~ s/=\/D/=-D/gs;
+ print $_;
+ print
+ "\n".
+ "# This can be set on the command line to point at the emcc command,\n".
+ "# if it is not on your PATH.\n".
+ "EMCC = emcc\n".
+ "\n".
+ &splitline("CFLAGS = -DSLOW_SYSTEM " .
+ (join " ", map {"-I$dirpfx$_"} @srcdirs))."\n".
+ "\n";
+ $output_js_files = join "", map { " \$(OUTPREFIX)$_.js" } &progrealnames("X");
+ print &splitline("all:" . $output_js_files);
+ print "\n\n";
+ foreach $p (&prognames("X")) {
+ ($prog, $type) = split ",", $p;
+ $objstr = &objects($p, "X.o", undef, undef);
+ $objstr =~ s/gtk\.o/emcc\.o/g;
+ print &splitline("\$(OUTPREFIX)" . $prog . ".js: " . $objstr . " emccpre.js emcclib.js emccx.json"), "\n";
+ print "\t\$(EMCC) -o \$(OUTPREFIX)".$prog.".js ".
+ "-O2 ".
+ "-s ASM_JS=1 ".
+ "--pre-js emccpre.js ".
+ "--js-library emcclib.js ".
+ "-s EXPORTED_FUNCTIONS=\"`sed 's://.*::' emccx.json | tr -d ' \\n'`\" " . $objstr . "\n\n";
+ }
+ foreach $d (&deps("X.o", undef, $dirpfx, "/")) {
+ $oobjs = $d->{obj};
+ $ddeps= join " ", @{$d->{deps}};
+ $oobjs =~ s/gtk/emcc/g;
+ $ddeps =~ s/gtk/emcc/g;
+ print &splitline(sprintf("%s: %s", $oobjs, $ddeps)),
+ "\n";
+ $deflist = join "", map { " -D$_" } @{$d->{defs}};
+ print "\t\$(EMCC) \$(CFLAGS) \$(XFLAGS)$deflist" .
+ " -c \$< -o \$\@\n";
+ }
+ print "\n";
+ print $makefile_extra{'emcc'} || "";
+ print "\nclean:\n".
+ "\trm -rf *.o $output_js_files\n";
+ select STDOUT; close OUT;
+}