Merge [1473] from 0.5.x branch ([1463] from trunk) missed earlier.
svn path=/tags/yasm-0.5.0rc2/; revision=1474
diff --git a/COPYING b/COPYING
index 1947b34..be3cec0 100644
--- a/COPYING
+++ b/COPYING
@@ -1,27 +1,39 @@
+Yasm is Copyright (c) 2001-2006 Peter Johnson and other Yasm developers.
+
+Yasm developers and/or contributors include:
+ Peter Johnson
+ Michael Urman
+ Stanislav Karchebny
+ Brian Gladman
+
-----------------------------------
-YASM licensing overview and summary
+Yasm licensing overview and summary
-----------------------------------
-Note: This document does not provide legal advice nor is it the actual license
-of any part of YASM. See the individual licenses for complete details.
-Consult a laywer for legal advice.
+Note: This document does not provide legal advice nor is it the actual
+license of any part of Yasm. See the individual licenses for complete
+details. Consult a lawyer for legal advice.
-The primary license of YASM is the 2-clause BSD license. Please use this
+The primary license of Yasm is the 2-clause BSD license. Please use this
license if you plan on submitting code to the project.
+Yasm has absolutely no warranty; not even for merchantibility or fitness
+for a particular purpose.
+
-------
Libyasm
-------
-Libyasm is 2-clause or 3-clause BSD licensed, with the exception of bitvect,
-which is triple-licensed under the Artistic license, GPL, and LGPL. Libyasm
-is thus GPL and LGPL compatible. In addition, this also means that libyasm
-is free for binary-only distribution as long as the terms of the 3-clause BSD
-license and Artistic license (as it applies to bitvect) are fulfilled.
+Libyasm is 2-clause or 3-clause BSD licensed, with the exception of
+bitvect, which is triple-licensed under the Artistic license, GPL, and
+LGPL. Libyasm is thus GPL and LGPL compatible. In addition, this also
+means that libyasm is free for binary-only distribution as long as the
+terms of the 3-clause BSD license and Artistic license (as it applies to
+bitvect) are fulfilled.
-------
Modules
-------
-Most of the modules are 2-clause BSD licensed, with the exception of:
+The modules are 2-clause or 3-clause BSD licensed, with the exception of:
preprocs/nasm - LGPL licensed
---------
@@ -32,9 +44,10 @@
-------------
License Texts
-------------
-The full text of all licenses are provided in separate files in this
-distribution. Each file may include the entire license (in the case of the BSD
-and Artistic licenses), or may reference the GPL or LGPL license file.
+The full text of all licenses are provided in separate files in the source
+distribution. Each source file may include the entire license (in the case
+of the BSD and Artistic licenses), or may reference the GPL or LGPL license
+file.
BSD.txt - 2-clause and 3-clause BSD licenses
Artistic.txt - Artistic license
diff --git a/Makefile.am b/Makefile.am
index bec47ba..f1c46d6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,7 @@
bin_PROGRAMS =
dist_man_MANS =
TESTS =
-noinst_PROGRAMS =
+noinst_PROGRAMS = genstring
check_PROGRAMS = test_hd
@@ -19,6 +19,7 @@
noinst_HEADERS = util.h
BUILT_SOURCES =
+
# configure.lineno doesn't clean up after itself?
CLEANFILES = configure.lineno
EXTRA_DIST = config/config.rpath
@@ -106,3 +107,12 @@
MAINTAINERCLEANFILES = $(dist_man_MANS)
endif
+# genstring build
+genstring_SOURCES =
+EXTRA_DIST += genstring.c
+genstring_LDADD = genstring.$(OBJEXT)
+genstring_LINK = $(CCLD_FOR_BUILD) -o $@
+
+genstring.$(OBJEXT): genstring.c
+ $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f genstring.c || echo '$(srcdir)/'`genstring.c
+
diff --git a/frontends/yasm/Makefile.inc b/frontends/yasm/Makefile.inc
index 5431136..1e0a836 100644
--- a/frontends/yasm/Makefile.inc
+++ b/frontends/yasm/Makefile.inc
@@ -12,6 +12,14 @@
yasm_SOURCES += frontends/yasm/yasm-options.c
yasm_SOURCES += frontends/yasm/yasm-options.h
+$(srcdir)/frontends/yasm/yasm.c: license.c
+
+license.c: $(srcdir)/COPYING genstring$(EXEEXT)
+ $(top_builddir)/genstring$(EXEEXT) license_msg $@ $(srcdir)/COPYING
+
+BUILT_SOURCES += license.c
+CLEANFILES += license.c
+
yasm_LDADD = libyasm.a $(INTLLIBS)
EXTRA_DIST += frontends/yasm/yasm.xml
diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c
index de31f28..b7bc7e4 100644
--- a/frontends/yasm/yasm.c
+++ b/frontends/yasm/yasm.c
@@ -38,6 +38,7 @@
#include "yasm-options.h"
+#include "license.c"
#define DEFAULT_OBJFMT_MODULE "bin"
@@ -118,13 +119,16 @@
/* values for special_options */
#define SPECIAL_SHOW_HELP 0x01
#define SPECIAL_SHOW_VERSION 0x02
-#define SPECIAL_LISTED 0x04
+#define SPECIAL_SHOW_LICENSE 0x04
+#define SPECIAL_LISTED 0x08
/* command line options */
static opt_option options[] =
{
{ 0, "version", 0, opt_special_handler, SPECIAL_SHOW_VERSION,
N_("show version text"), NULL },
+ { 0, "license", 0, opt_special_handler, SPECIAL_SHOW_LICENSE,
+ N_("show license text"), NULL },
{ 'h', "help", 0, opt_special_handler, SPECIAL_SHOW_HELP,
N_("show help text"), NULL },
{ 'a', "arch", 1, opt_arch_handler, 0,
@@ -237,8 +241,12 @@
help_msg(help_head, help_tail, options, NELEMS(options));
return EXIT_SUCCESS;
case SPECIAL_SHOW_VERSION:
- for (i=0; i<sizeof(version_msg)/sizeof(char *); i++)
- printf("%s", gettext(version_msg[i]));
+ for (i=0; i<NELEMS(version_msg); i++)
+ printf("%s\n", version_msg[i]);
+ return EXIT_SUCCESS;
+ case SPECIAL_SHOW_LICENSE:
+ for (i=0; i<NELEMS(license_msg); i++)
+ printf("%s\n", license_msg[i]);
return EXIT_SUCCESS;
case SPECIAL_LISTED:
/* Printed out earlier */
diff --git a/genstring.c b/genstring.c
new file mode 100644
index 0000000..c00901c
--- /dev/null
+++ b/genstring.c
@@ -0,0 +1,103 @@
+/* $Id$
+ *
+ * Generate array-of-const-string from text file.
+ *
+ * Copyright (C) 2006 Peter Johnson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXLINE 1024
+
+int
+main(int argc, char *argv[])
+{
+ FILE *in, *out;
+ int i;
+ char *str;
+ char *strp;
+ char *charp;
+ size_t len;
+
+ if (argc < 4) {
+ fprintf(stderr, "Usage: %s <string> <outfile> <file> [<file> ...]\n",
+ argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ out = fopen(argv[2], "wt");
+
+ if (!out) {
+ fprintf(stderr, "Could not open `%s'.\n", argv[2]);
+ return EXIT_FAILURE;
+ }
+
+ str = malloc(MAXLINE);
+
+ fprintf(out, "/* This file auto-generated from %s by genstring.c"
+ " - don't edit it */\n\n"
+ "static const char *%s[] = {\n", argv[3], argv[1]);
+
+ for (i=3; i<argc; i++) {
+ in = fopen(argv[i], "rt");
+ if (!in) {
+ fprintf(stderr, "Could not open `%s'.\n", argv[i]);
+ fclose(out);
+ remove(argv[2]);
+ return EXIT_FAILURE;
+ }
+
+ while (fgets(str, MAXLINE, in)) {
+ strp = str;
+
+ /* strip off trailing whitespace */
+ len = strlen(strp);
+ while (len > 0 && (strp[len-1] == ' ' || strp[len-1] == '\t' ||
+ strp[len-1] == '\n')) {
+ strp[len-1] = '\0';
+ len--;
+ }
+
+ /* output as string to output file */
+ fprintf(out, " \"");
+ while (*strp != '\0') {
+ if (*strp == '\\' || *strp == '"')
+ fputc('\\', out);
+ fputc(*strp, out);
+ strp++;
+ }
+ fprintf(out, "\",\n");
+ }
+
+ fclose(in);
+ }
+
+ fprintf(out, "};\n");
+ fclose(out);
+
+ free(str);
+
+ return EXIT_SUCCESS;
+}