automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/4] Add basic support for Mono/.NET


From: Raja R Harinath
Subject: [PATCH 1/4] Add basic support for Mono/.NET
Date: Thu, 28 Jun 2007 18:43:16 +0530

* automake.in (register_language): Add 'cli'.
(handle_cli, handle_cli_assembly, lang_cli_rewrite): New.
(generate_makefile): Call 'handle_cli'.
* lib/am/Makefile.am (dist_am_DATA): Update.
* lib/am/cli.am, lib/am/cli-assembly.am: New.
* tests/cli1.test: Simple test for Mono/.NET support.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog              |   11 ++++
 automake.in            |  127 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/am/Makefile.am     |    2 +
 lib/am/cli-assembly.am |   22 ++++++++
 lib/am/cli.am          |   25 +++++++++
 tests/Makefile.am      |    1 +
 tests/cli1.test        |   40 +++++++++++++++
 7 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 lib/am/cli-assembly.am
 create mode 100644 lib/am/cli.am
 create mode 100755 tests/cli1.test

diff --git a/ChangeLog b/ChangeLog
index 0730b31..b246d80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-06-27  Raja R Harinath  <address@hidden>
+
+       Add basic support for Mono/.NET
+       * automake.in (register_language): Add 'cli'.
+       (handle_cli, handle_cli_assembly, lang_cli_rewrite): New.
+       (generate_makefile): Call 'handle_cli'.
+       * lib/am/Makefile.am (dist_am_DATA): Update.
+       * lib/am/cli.am, lib/am/cli-assembly.am: New.
+       * tests/cli1.test: Simple test for Mono/.NET support.
+       * tests/Makefile.am (TESTS): Update.
+
 2007-06-23  Paul Eggert  <address@hidden>
            Ralf Wildenhues  <address@hidden>
 
diff --git a/automake.in b/automake.in
index 083b6fa..de33217 100755
--- a/automake.in
+++ b/automake.in
@@ -983,6 +983,16 @@ register_language ('name' => 'java',
                   'pure' => 1,
                   'extensions' => ['.java', '.class', '.zip', '.jar']);
 
+# CLI - C#, VB
+register_language ('name' => 'cli',
+                  'Name' => 'Common Language Infrastructure (C# or VB)',
+                  'extensions' => ['.cs', '.vb'],
+                  # No output.
+                  'output_extensions' => sub { return () },
+                  # Nothing to do.
+                  '_finish' => sub { });
+
+
 ################################################################
 
 # Error reporting functions.
@@ -4673,6 +4683,114 @@ sub handle_java
     push (@all, 'class' . $dir . '.stamp');
 }
 
+sub handle_cli_assembly ($$$%)
+{
+  my ($one_file, $unxformed, $where, %transform) = @_;
+  my $compiler = '';
+  my @cmdsrcs = ();
+  my $seen_extn = 0;
+
+  foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
+                     'dist_EXTRA_', 'nodist_EXTRA_')
+    {
+      my $varname = $prefix . $one_file . "_SOURCES";
+      my $var = var $varname;
+      next unless $var;
+      my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
+      my $outvarname = $xpfx . $one_file . "_CMDSRCS";
+      my $nodist = ($prefix =~ /^nodist_/);
+      my $nodefine = ($prefix =~ /EXTRA_/);
+
+      push @cmdsrcs, "\$($outvarname)";
+
+      push @sources, "\$($varname)";
+      push @dist_sources, shadow_unconditionally ($varname, $where)
+       unless (option ('no-dist') || $nodist);
+
+      $output_rules .= "$unxformed: \$($varname)\n";
+
+      $var->transform_variable_recursively
+       ($outvarname, 'am__cli', $nodefine, $where,
+        sub {
+          my ($subvar, $val, $cond, $full_cond) = @_;
+          return ()
+            unless $val =~ /($KNOWN_EXTENSIONS_PATTERN)$/;
+          my $extn = $1;
+
+          if ($seen_extn)
+            {
+              msg_var 'error', $varname, "multi-language assemblies not 
supported: $seen_extn $extn"
+                unless $extn eq $seen_extn;
+            }
+          else
+            {
+              $seen_extn = $extn;
+            }
+
+          if (rule $val)
+            {
+              return $val if $nodist;
+              msg_var 'error', $subvar, "`$val' has a rule to build it, but is 
also distributed";
+            }
+          return '$(srcdir)/' . $val;
+        });
+    }
+
+  msg 'error', $where, "`$unxformed' doesn't have any source defined"
+    unless scalar @cmdsrcs;
+
+  define_pretty_variable ($one_file . '_CMDSRCS', TRUE, $where, sort @cmdsrcs);
+
+  my $lang = uc substr $seen_extn, 1;
+  my $dirstamp = require_build_directory_maybe ($unxformed);
+  my $progflags = "${one_file}_${lang}FLAGS";
+
+  require_variables ($unxformed, "Seen CLI source file with extension 
$seen_extn", TRUE, $lang . 'C');
+  define_variable ($progflags, "\$(AM_${lang}FLAGS)", INTERNAL)
+    unless var $progflags;
+
+  $output_rules .=
+    file_contents ('cli-assembly', $where,
+                  %transform,
+                  ASSEMBLY => $unxformed,
+                  XASSEMBLY => $one_file,
+                  LANG => $lang,
+                  DIRSTAMP => $dirstamp);
+}
+
+# Handle Mono/.NET
+sub handle_cli
+{
+  my %targets = ( EXE => 'exe', WINEXE => 'winexe', DLL => 'library', MODULE 
=> 'module' );
+  my %outextns = ( EXE => '.exe', WINEXE => '.exe', DLL => '.dll', MODULE => 
'.netmodule' );
+  foreach my $target (keys %targets)
+    {
+      my @assemblies = &am_install_var ('cli', 'CLI' . $target . 'S',
+                                       'noinst', 'check', 'lib' #, 'gac'
+                                      );
+
+      next unless @assemblies;
+
+      define_variable ('INSTALL_CLI' . $target,
+                      ($target =~ /EXE$/) ? '$(INSTALL_SCRIPT)' : 
'$(INSTALL_DATA)',
+                      INTERNAL);
+
+      foreach my $pair (@assemblies)
+       {
+         my ($where, $one_file) = @$pair;
+
+         msg_am 'syntax', "CLI $target doesn't have $outextns{$target} 
extension"
+           unless $one_file =~ /$outextns{$target}$/;
+
+         my $xname = &check_canonical_spelling ($one_file, '_SOURCES', 
'_RESOURCES', '_REFERENCES');
+         $where->push_context ("while processing CLI assembly '$one_file'");
+         $where->set (INTERNAL->get);
+
+         &handle_cli_assembly ($xname, $one_file, $where, TARGET => 
$targets{$target});
+       }
+    }
+}
+
 
 # Handle some of the minor options.
 sub handle_minor_options
@@ -5407,6 +5525,13 @@ sub lang_java_rewrite
     return LANG_SUBDIR;
 }
 
+# Rewrite a single CLI source file.
+sub lang_cli_rewrite
+{
+    # CLI files are ignored for rewrites.
+    return LANG_IGNORE;
+}
+
 # The lang_X_finish functions are called after all source file
 # processing is done.  Each should handle defining rules for the
 # language, etc.  A finish function is only called if a source file of
@@ -7490,6 +7615,8 @@ sub generate_makefile ($$)
   handle_languages;
   handle_libtool;
 
+  handle_cli;
+
   # Variables used by distdir.am and tags.am.
   define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
   if (! option 'no-dist')
diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am
index 52afd40..cd7ce1c 100644
--- a/lib/am/Makefile.am
+++ b/lib/am/Makefile.am
@@ -27,6 +27,8 @@ ansi2knr.am \
 check.am \
 clean-hdr.am \
 clean.am \
+cli-assembly.am \
+cli.am \
 compile.am \
 configure.am \
 data.am \
diff --git a/lib/am/cli-assembly.am b/lib/am/cli-assembly.am
new file mode 100644
index 0000000..f85710c
--- /dev/null
+++ b/lib/am/cli-assembly.am
@@ -0,0 +1,22 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 2007
+## Free Software Foundation, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+%ASSEMBLY%: $(%XASSEMBLY%_DEPENDENCIES) %DIRSTAMP%
+       @rm -f %ASSEMBLY%
+       $(%LANG%C) $(%XASSEMBLY%_%LANG%FLAGS) $(%LANG%FLAGS) -out:$@ 
-target:%TARGET% \
+               $(%XASSEMBLY%_CMDSRCS) $(%XASSEMBLY%_CMDRSRCS) 
$(%XASSEMBLY%_REFERENCES)
diff --git a/lib/am/cli.am b/lib/am/cli.am
new file mode 100644
index 0000000..8ddbc4f
--- /dev/null
+++ b/lib/am/cli.am
@@ -0,0 +1,25 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 1994, 1995, 1996, 1998, 1999, 2001, 2003, 2004, 2006
+## Free Software Foundation, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+include data.am
+
+.PHONY clean-am: clean-%DIR%%PRIMARY%
+clean-%DIR%%PRIMARY%:
+       -list='$(%DIR%_%PRIMARY%)'; for p in $$list; do \
+         rm -f $$p $$p.mdb $$p.pdb; done
diff --git a/tests/Makefile.am b/tests/Makefile.am
index df6ff87..f5af67f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -91,6 +91,7 @@ check7.test \
 checkall.test \
 clean.test \
 clean2.test \
+cli1.test \
 colneq.test \
 colneq2.test \
 colon.test \
diff --git a/tests/cli1.test b/tests/cli1.test
new file mode 100755
index 0000000..29314eb
--- /dev/null
+++ b/tests/cli1.test
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test that basic CLI functionality works.
+
+. ./defs || exit 1
+
+set -e
+
+cat >Makefile.am <<END
+CSC = mcs
+VBC = vbnc
+noinst_CLIEXES = foo.exe bar/foo.exe
+noinst_CLIDLLS = foo.dll
+foo_exe_SOURCES = a.cs baz/b.cs quux/c.cs
+foo_exe_CSFLAGS = -debug+
+bar_foo_exe_SOURCES = baz/b.cs
+foo_dll_SOURCES = b.vb
+foo_dll_VBFLAGS = -debug+
+END
+
+$ACLOCAL
+$AUTOMAKE
-- 
1.5.2.1.174.gcd03





reply via email to

[Prev in Thread] Current Thread [Next in Thread]