summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-05-14 22:53:42 -0400
committerPaul Smith <psmith@gnu.org>2013-05-14 22:53:42 -0400
commitc21c1455fdfc6e87d75941f48841c72903e1e0f4 (patch)
tree07578812e5d846bc943a114db1c3f37a99079982
parent58dae243526bd322ae6bec0c4394a117a5fe0171 (diff)
downloadgunmake-c21c1455fdfc6e87d75941f48841c72903e1e0f4.tar.gz
Add requirement for plugin_is_GPL_compatible symbol in loaded objects.
-rw-r--r--ChangeLog6
-rw-r--r--doc/make.texi20
-rw-r--r--load.c6
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/scripts/features/load2
-rw-r--r--tests/scripts/features/loadapi2
6 files changed, 41 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d482c2c..c317594 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-14 Paul Smith <psmith@gnu.org>
+
+ * doc/make.texi (Loaded Object API): Document the requirement for
+ the plugin_is_GPL_compatible symbol.
+ * load.c (load_object): Check for plugin_is_GPL_compatible symbol.
+
2013-05-13 Paul Smith <psmith@gnu.org>
* filedef.h (struct file): Add a builtin flag.
diff --git a/doc/make.texi b/doc/make.texi
index e3e5135..d1ceefb 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -11058,6 +11058,24 @@ functions may make use of the @code{gmk_expand} and @code{gmk_eval}
routines to perform their tasks, then optionally return a string as
the result of the function expansion.
+@subsubheading Loaded Object Licensing
+@cindex loaded object licensing
+@cindex plugin_is_GPL_compatible
+
+Every dynamic extension should define the global symbol
+@code{plugin_is_GPL_compatible} to assert that it has been licensed
+under a GPL-compatible license. If this symbol does not exist,
+@code{make} emits a fatal error and exits when it tries to load your
+extension.
+
+The declared type of the symbol should be @code{int}. It does not need
+to be in any allocated section, though. The code merely asserts that
+the symbol exists in the global scope. Something like this is enough:
+
+@example
+int plugin_is_GPL_compatible;
+@end example
+
@subsubheading Data Structures
@table @code
@@ -11185,6 +11203,8 @@ function in a file @file{mk_temp.c}:
#include <gnumake.h>
+int plugin_is_GPL_compatible;
+
char *
gen_tmpfile(const char *nm, int argc, char **argv)
@{
diff --git a/load.c b/load.c
index f20c1c7..655928a 100644
--- a/load.c
+++ b/load.c
@@ -71,6 +71,12 @@ load_object (const gmk_floc *flocp, int noerror,
return NULL;
}
+ /* Assert that the GPL license symbol is defined. */
+ symp = dlsym (*dlp, "plugin_is_GPL_compatible");
+ if (! symp)
+ fatal (flocp, _("Loaded object %s is not declared to be GPL compatible"),
+ ldname);
+
symp = dlsym (*dlp, symname);
if (! symp)
fatal (flocp, _("Failed to load symbol %s from %s: %s"),
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 34e8cc2..0abe96f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-14 Paul Smith <psmith@gnu.org>
+
+ * scripts/features/loadapi: Add plugin_is_GPL_compatible symbol.
+ * scripts/features/load: Ditto.
+
2013-05-13 Paul Smith <psmith@gnu.org>
* scripts/features/output-sync (output_sync_set): Update for new
diff --git a/tests/scripts/features/load b/tests/scripts/features/load
index 78d5c51..2e3f263 100644
--- a/tests/scripts/features/load
+++ b/tests/scripts/features/load
@@ -20,6 +20,8 @@ print $F <<'EOF' ;
#include "gnumake.h"
+int plugin_is_GPL_compatible;
+
int
testload_gmk_setup (gmk_floc *pos)
{
diff --git a/tests/scripts/features/loadapi b/tests/scripts/features/loadapi
index 94a48a7..4976ce3 100644
--- a/tests/scripts/features/loadapi
+++ b/tests/scripts/features/loadapi
@@ -20,6 +20,8 @@ print $F <<'EOF' ;
#include "gnumake.h"
+int plugin_is_GPL_compatible;
+
static char *
test_eval (const char *buf)
{