[svn] ksba - r317 - in trunk: . src
svn author wk
cvs at cvs.gnupg.org
Thu May 6 14:29:31 CEST 2010
Author: wk
Date: 2010-05-06 14:29:31 +0200 (Thu, 06 May 2010)
New Revision: 317
Added:
trunk/src/gen-help.c
trunk/src/gen-help.h
Modified:
trunk/NEWS
trunk/configure.ac
trunk/src/ChangeLog
trunk/src/Makefile.am
trunk/src/asn1-func.c
trunk/src/asn1-func.h
trunk/src/asn1-gentables.c
trunk/src/asn1-parse.y
trunk/src/util.h
Log:
Make it build from SVN even when cross compiling
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/ChangeLog 2010-05-06 12:29:31 UTC (rev 317)
@@ -1,3 +1,22 @@
+2010-05-06 Werner Koch <wk at g10code.com>
+
+ * gen-help.c, gen-help.h: New.
+ * Makefile.am: Build asn1-gentables and ber-dump also when cross
+ compiling.
+ (asn1_gentables_SOURCES, asn1_gentables_LDADD)
+ (asn1_gentables_CFLAGS): Remove.
+ (asn1-gentables): New rule.
+ (asn1-parse.c): Add gen-help.h as dependency.
+ (EXTRA_DIST): Add gen-help.c and gen-help.h.
+ * asn1-parse.y [BUILD_GENTOOLS]: Include gen-help.h instead of
+ util.h and ksba.h.
+ (ksba_asn_parse_file): Use gpg_error_from_syserror.
+ * asn1-func.c [BUILD_GENTOOLS]: Include gen-help.h instead of
+ util.h and ksba.h.
+ (resolve_identifier): Avoid the alloca.
+ * asn1-gentables.c: Include gen-help instead of util.h and ksba.h.
+ (sort_string_table): Remove useless printing of the string table.
+
2010-01-22 Werner Koch <wk at g10code.com>
* util.c (ksba_calloc): Use gpg_er_set_errno.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/NEWS 2010-05-06 12:29:31 UTC (rev 317)
@@ -3,7 +3,9 @@
* Support for WindowsCE.
+ * Builds cleaning from SVN even when cross-compiling.
+
Noteworthy changes in version 1.0.7 (2009-07-03)
------------------------------------------------
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/configure.ac 2010-05-06 12:29:31 UTC (rev 317)
@@ -100,7 +100,19 @@
AC_PROG_YACC
AC_C_INLINE
+# We need to compile and run a program on the build machine.
+# The AC_PROG_CC_FOR_BUILD macro in the AC archive is broken for
+# autoconf 2.57.
+AC_MSG_CHECKING(for cc for build)
+if test "$cross_compiling" = "yes"; then
+ CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
+else
+ CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
+fi
+AC_MSG_RESULT($CC_FOR_BUILD)
+AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
+
# This is handy for debugging so the compiler doesn't rearrange
# things and eliminate variables.
AC_ARG_ENABLE(optimization,
@@ -371,11 +383,3 @@
Platform: $host
"
-if test x$cross_compiling != xno; then
-echo "Hint: If you encounter make problems like
- \"No rule to make target 'asn1-tables.c'\"
-you should first do a native build without installing
-the software, then a \"make distclean\" and then
-run the cross compilation again.
-"
-fi
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/Makefile.am 2010-05-06 12:29:31 UTC (rev 317)
@@ -20,20 +20,21 @@
asn1_modules = tmttv2.asn cms.asn
+buildtool_src = asn1-gentables.c gen-help.c gen-help.h
EXTRA_DIST = ksba-config.in $(asn1_modules) ksba.m4 libksba.vers libksba.def \
- asn1-parse.c asn1-tables.c
+ asn1-parse.c asn1-tables.c $(buildtool_src)
BUILT_SOURCES = asn1-parse.c asn1-tables.c
bin_SCRIPTS = ksba-config
include_HEADERS = ksba.h
lib_LTLIBRARIES = libksba.la
+noinst_PROGRAMS = ber-dump
-if ! CROSS_COMPILING
-noinst_PROGRAMS = asn1-gentables ber-dump
-endif
-
m4datadir = $(datadir)/aclocal
m4data_DATA = ksba.m4
+CLEANFILES = asn1-gentables
+DISTCLEANFILES = asn1-tables.c
+
AM_CPPFLAGS = -I$(top_builddir)/gl -I$(top_srcdir)/gl
AM_CFLAGS = $(GPG_ERROR_CFLAGS)
@@ -106,27 +107,25 @@
sexp-parse.h \
asn1-tables.c
-asn1_gentables_SOURCES = asn1-gentables.c asn1-parse.c asn1-func.c oid.c util.c
-asn1_gentables_LDADD = $(GPG_ERROR_LIBS) ../gl/libgnu.la
-# Note that we need to use per-target flags to force renaming of the
-# object files to avoid clashes with libtool.
-asn1_gentables_CFLAGS = $(AM_CFLAGS)
-
ber_dump_SOURCES = ber-dump.c \
ber-decoder.c ber-help.c reader.c writer.c asn1-parse.c \
asn1-func.c oid.c util.c
ber_dump_LDADD = $(GPG_ERROR_LIBS) ../gl/libgnu.la
ber_dump_CFLAGS = $(AM_CFLAGS)
-asn1-parse.c : asn1-func.h
+asn1-parse.c : asn1-func.h gen-help.h
-if ! CROSS_COMPILING
-asn1-tables.c : $(asn1_modules)
- $(MAKE) $(AM_MAKEFLAGS) asn1-gentables
+asn1-gentables: asn1-gentables.c asn1-parse.c asn1-func.c gen-help.c gen-help.h
+ $(CC_FOR_BUILD) -I$(srcdir) -DBUILD_GENTOOLS -o $@ \
+ $(srcdir)/asn1-gentables.c \
+ `test -f 'asn1-parse.c' || echo '$(srcdir)/'`asn1-parse.c \
+ $(srcdir)/asn1-func.c \
+ $(srcdir)/gen-help.c
+
+asn1-tables.c : $(asn1_modules) asn1-gentables
@set -e; list=""; \
for file in $(asn1_modules); do list="$$list $(srcdir)/$$file";done;\
./asn1-gentables $$list > asn1-tables.c
-endif
install-data-local: install-def-file
Modified: trunk/src/asn1-func.c
===================================================================
--- trunk/src/asn1-func.c 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/asn1-func.c 2010-05-06 12:29:31 UTC (rev 317)
@@ -1,6 +1,6 @@
-/* asn1-func.c - Manage ASN.1 definitions
+/* asn1-func.c - Fucntions for the ASN.1 data structures.
* Copyright (C) 2000, 2001 Fabio Fiorina
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2010 Free Software Foundation, Inc.
*
* This file is part of GNUTLS.
*
@@ -18,22 +18,27 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef BUILD_GENTOOLS
#include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
-#include <alloca.h>
+#ifdef BUILD_GENTOOLS
+# include "gen-help.h"
+#else
+# include "util.h"
+# include "ksba.h"
+#endif
-#include "util.h"
-#include "ksba.h"
#include "asn1-func.h"
-static AsnNode
-resolve_identifier (AsnNode root, AsnNode node, int nestlevel);
+static AsnNode resolve_identifier (AsnNode root, AsnNode node, int nestlevel);
static AsnNode
@@ -1051,8 +1056,10 @@
static AsnNode
resolve_identifier (AsnNode root, AsnNode node, int nestlevel)
{
+ char buf_space[50];
char *buf;
AsnNode n;
+ size_t bufsize;
if (nestlevel > 20)
return NULL;
@@ -1060,13 +1067,24 @@
return_null_if_fail (root);
return_null_if_fail (node->valuetype == VALTYPE_CSTR);
- buf = alloca (strlen(root->name)+strlen(node->value.v_cstr)+2);
- return_null_if_fail (buf);
+ bufsize = strlen (root->name) + strlen (node->value.v_cstr) + 2;
+ if (bufsize <= sizeof buf_space)
+ buf = buf_space;
+ else
+ {
+ buf = xtrymalloc (bufsize);
+ return_null_if_fail (buf);
+ }
strcpy (stpcpy (stpcpy (buf, root->name), "."), node->value.v_cstr);
n = _ksba_asn_find_node (root, buf);
- /* we do just a simple indirection */
+
+ /* We do just a simple indirection. */
if (n && n->type == TYPE_IDENTIFIER)
n = resolve_identifier (root, n, nestlevel+1);
+
+ if (buf != buf_space)
+ xfree (buf);
+
return n;
}
@@ -1270,8 +1288,3 @@
}
return NULL;
}
-
-
-
-
-
Modified: trunk/src/asn1-func.h
===================================================================
--- trunk/src/asn1-func.h 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/asn1-func.h 2010-05-06 12:29:31 UTC (rev 317)
@@ -124,10 +124,11 @@
unsigned long v_ulong;
};
-/******************************************************/
-/* Structure definition used for the node of the tree */
-/* that rappresent an ASN.1 DEFINITION. */
-/******************************************************/
+
+/*
+ * Structure definition used for the node of the tree that represents
+ * an ASN.1 DEFINITION.
+ */
#ifndef HAVE_TYPEDEFD_ASNNODE
typedef struct asn_node_struct *AsnNode;
typedef struct asn_node_struct *asn_node_t;
@@ -167,10 +168,11 @@
} static_asn;
+/*-- asn1-parse.y --*/
+void _ksba_asn_release_nodes (AsnNode node);
-/***************************************/
-/* Functions used by ASN.1 parser */
-/***************************************/
+
+/*-- asn1-func.c --*/
void _ksba_asn_set_value (AsnNode node, enum asn_value_type vtype,
const void *value, size_t len);
void _ksba_asn_set_name (AsnNode node, const char *name);
@@ -186,11 +188,6 @@
AsnNode _ksba_asn_expand_tree (AsnNode parse_tree, const char *name);
AsnNode _ksba_asn_insert_copy (AsnNode node);
-/*-- asn1-parse.y --*/
-void _ksba_asn_release_nodes (AsnNode node);
-
-
-/*-- asn1-func.c --*/
int _ksba_asn_is_primitive (node_type_t type);
AsnNode _ksba_asn_new_node (node_type_t type);
void _ksba_asn_node_dump (AsnNode p, FILE *fp);
@@ -204,8 +201,8 @@
int _ksba_asn_delete_structure (AsnNode root);
/*-- asn2-func.c --*/
+/*(functions are all declared in ksba.h)*/
-
/*-- asn1-tables.c (generated) --*/
const static_asn *_ksba_asn_lookup_table (const char *name,
const char **stringtbl);
Modified: trunk/src/asn1-gentables.c
===================================================================
--- trunk/src/asn1-gentables.c 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/asn1-gentables.c 2010-05-06 12:29:31 UTC (rev 317)
@@ -17,16 +17,13 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
-#include "util.h"
-
-#include "ksba.h"
+#include "gen-help.h"
#include "asn1-func.h"
#define PGMNAME "asn1-gentables"
@@ -134,8 +131,8 @@
for (i=0; i < arraylen; i++)
insert_string (array[i]->name);
xfree (array);
- for (item = string_table,arraylen = 0; item; item = item->next)
- fprintf (stderr, " `%s'\n", item->name);
+ /* for (item = string_table,arraylen = 0; item; item = item->next) */
+ /* fprintf (stderr, " `%s'\n", item->name); */
}
Modified: trunk/src/asn1-parse.y
===================================================================
--- trunk/src/asn1-parse.y 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/asn1-parse.y 2010-05-06 12:29:31 UTC (rev 317)
@@ -1,6 +1,6 @@
-/*
+/* asn1-parse.y - ASN.1 grammar
* Copyright (C) 2000,2001 Fabio Fiorina
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2010 Free Software Foundation, Inc.
*
* This file is part of GNUTLS.
*
@@ -28,7 +28,9 @@
%{
-#include <config.h>
+#ifndef BUILD_GENTOOLS
+# include <config.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -36,8 +38,13 @@
#include <ctype.h>
#include <errno.h>
-#include "util.h"
-#include "ksba.h"
+#ifdef BUILD_GENTOOLS
+# include "gen-help.h"
+#else
+# include "util.h"
+# include "ksba.h"
+#endif
+
#include "asn1-parse.h"
#include "asn1-func.h"
@@ -992,7 +999,7 @@
parsectl.fp = file_name? fopen (file_name, "r") : NULL;
if ( !parsectl.fp )
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
parsectl.lineno = 0;
parsectl.debug = debug;
@@ -1039,7 +1046,7 @@
void
_ksba_asn_release_nodes (AsnNode node)
{
- /* FIXME: it does not work yet becuase the allocation function in
+ /* FIXME: it does not work yet because the allocation function in
asn1-func.c does not link all nodes together */
release_all_nodes (node);
}
Added: trunk/src/gen-help.c
===================================================================
--- trunk/src/gen-help.c (rev 0)
+++ trunk/src/gen-help.c 2010-05-06 12:29:31 UTC (rev 317)
@@ -0,0 +1,111 @@
+/* gen-help.c - Helper functions used by build time tools
+ * Copyright (C) 2010 g10 Code GmbH
+ *
+ * This file is part of KSBA.
+ *
+ * KSBA 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 Fountion; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KSBA 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* No config.h - this file needs to build as plain ISO-C. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gen-help.h"
+
+
+static void
+out_of_core(void)
+{
+ fputs ("\nfatal: out of memory\n", stderr);
+ exit (2);
+}
+
+
+
+/* Implementation of the common xfoo() memory allocation functions */
+void *
+xmalloc (size_t n )
+{
+ void *p = malloc (n);
+ if (!p)
+ out_of_core ();
+ return p;
+}
+
+void *
+xcalloc (size_t n, size_t m)
+{
+ void *p = calloc (n, m);
+ if (!p)
+ out_of_core ();
+ return p;
+}
+
+void *
+xrealloc (void *mem, size_t n)
+{
+ void *p = realloc (mem, n);
+ if (!p)
+ out_of_core ();
+ return p;
+}
+
+
+char *
+xstrdup (const char *str)
+{
+ char *p = strdup (str);
+ if (!p)
+ out_of_core ();
+ return p;
+}
+
+void
+xfree (void *a)
+{
+ if (a)
+ free (a);
+}
+
+
+/* Our version of stpcpy to avoid conflicts with already availabale
+ implementations. */
+char *
+gen_help_stpcpy (char *a, const char *b)
+{
+ while (*b)
+ *a++ = *b++;
+ *a = 0;
+
+ return a;
+}
+
+
+/* Simple replacement function to avoid the need for a build libgpg-error */
+const char *
+gpg_strerror (int err)
+{
+ switch (err)
+ {
+ case 0: return "Success";
+ case GPG_ERR_GENERAL: return "General error";
+ case GPG_ERR_SYNTAX: return "Syntax error";
+ case GPG_ERR_INV_VALUE: return "Invalid value";
+ case GPG_ERR_BUG: return "Bug";
+ case GPG_ERR_ELEMENT_NOT_FOUND: return "Not found";
+ case GPG_ERR_IDENTIFIER_NOT_FOUND: return "Identifier not found";
+ default: return "Unknown error";
+ }
+}
Added: trunk/src/gen-help.h
===================================================================
--- trunk/src/gen-help.h (rev 0)
+++ trunk/src/gen-help.h 2010-05-06 12:29:31 UTC (rev 317)
@@ -0,0 +1,96 @@
+/* gen-help.c - Helper functions used by build time tools
+ * Copyright (C) 2010 g10 Code GmbH
+ *
+ * This file is part of KSBA.
+ *
+ * KSBA 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 Fountion; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KSBA 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This header has definitions used by programs which are only run on
+ the build platform as part of the build process. They need to be
+ plain ISO C and don't make use of any information gathered from the
+ configure run. */
+
+#ifndef GEN_HELP_H
+#define GEN_HELP_H
+
+#ifndef BUILD_GENTOOLS
+#error file may only be used for build time tools
+#endif
+
+
+void *xmalloc (size_t n);
+void *xcalloc (size_t n, size_t m);
+void *xrealloc (void *mem, size_t n);
+char *xstrdup (const char *str);
+void xfree (void *a);
+#define xtrymalloc(a) malloc ((a))
+
+char *gen_help_stpcpy (char *a, const char *b);
+#define stpcpy(a, b) gen_help_stpcpy ((a), (b))
+
+
+
+
+#define DIM(v) (sizeof(v)/sizeof((v)[0]))
+#define DIMof(type,member) DIM(((type *)0)->member)
+#ifndef STR
+# define STR(v) #v
+#endif
+#ifndef STR2
+# define STR2(v) STR(v)
+#endif
+
+#define return_if_fail(expr) do { \
+ if (!(expr)) { \
+ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
+ __FILE__, __LINE__, #expr ); \
+ return; \
+ } } while (0)
+#define return_null_if_fail(expr) do { \
+ if (!(expr)) { \
+ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
+ __FILE__, __LINE__, #expr ); \
+ return NULL; \
+ } } while (0)
+#define return_val_if_fail(expr,val) do { \
+ if (!(expr)) { \
+ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
+ __FILE__, __LINE__, #expr ); \
+ return (val); \
+ } } while (0)
+#define never_reached() do { \
+ fprintf (stderr, "%s:%d: oops; should never get here\n", \
+ __FILE__, __LINE__ ); \
+ } while (0)
+
+
+/* Replacement for gpg_error.h stuff. */
+#define GPG_ERR_GENERAL 1
+#define GPG_ERR_SYNTAX 29
+#define GPG_ERR_INV_VALUE 55
+#define GPG_ERR_BUG 59
+#define GPG_ERR_ELEMENT_NOT_FOUND 136
+#define GPG_ERR_IDENTIFIER_NOT_FOUND 137
+
+#define gpg_error(a) (a)
+#define gpg_error_from_syserror() (GPG_ERR_GENERAL);
+const char *gpg_strerror (int err);
+
+/* Duplicated type definitions from ksba.h. */
+typedef struct ksba_asn_tree_s *ksba_asn_tree_t;
+
+
+#endif /*GEN_HELP_H*/
+
Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h 2010-04-14 14:33:14 UTC (rev 316)
+++ trunk/src/util.h 2010-05-06 12:29:31 UTC (rev 317)
@@ -20,6 +20,11 @@
#ifndef UTIL_H
#define UTIL_H
+#ifdef BUILD_GENTOOLS
+#error file may not be be used for build time tools
+#endif
+
+
#include "visibility.h"
More information about the Gnupg-commits
mailing list