aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-07 17:24:18 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-07 18:55:38 +0300
commit4b0e477181f51c12f62236ec91f4bb714125393d (patch)
tree9ddb2c5c16549ce5bf6056e45aef3646402accbc /src
parentcede19f7c5a151c1aeb7c93d1793183bca8e8289 (diff)
downloadgrecs-4b0e477181f51c12f62236ec91f4bb714125393d.tar.gz
grecs-4b0e477181f51c12f62236ec91f4bb714125393d.tar.bz2
Support standalone compilation.
* AUTHORS, COPYING, NEWS, README: New files. * .gitignore: Update. * am/.gitignore: New file. * build-aux/.gitignore: New file. * build-aux/ylwrap: Remove. * Makefile.am: Define ACLOCAL_AMFLAGS [GRECS_CHANGELOG]: Build ChangeLog. * am/grecs.m4: Define GRECS_CHANGELOG and GRECS_SRCDIR. Fixup first argument, if it is [.]. * configure.ac: New file. * src/Make-inst.am (include_HEADERS): Add wordsplit.h. Install libgrecs.m4. * Make-shared.am (noinst_HEADERS): Add wordsplit.h. * src/Make-static.am: Likewise. * src/Make.am (GRECS_SRC): Remove wordsplit.h (noinst_HEADERS): Add yygrecs.h (YLWRAP): Remove. * src/libgrecs.m4: New file. * src/yygrecs.h: New file. * src/grecs-gram.y: Include yygrecs.h. * src/grecs-lex.l: Likewise. * src/preproc.c (yy_grecs_flex_debug): Rename to grecs_yy_flex_debug.
Diffstat (limited to 'src')
-rw-r--r--src/Make-inst.am4
-rw-r--r--src/Make-shared.am2
-rw-r--r--src/Make-static.am2
-rw-r--r--src/Make.am7
-rw-r--r--src/grecs-gram.y1
-rw-r--r--src/grecs-lex.l1
-rw-r--r--src/libgrecs.m447
-rw-r--r--src/preproc.c8
-rw-r--r--src/yygrecs.h28
9 files changed, 89 insertions, 11 deletions
diff --git a/src/Make-inst.am b/src/Make-inst.am
index d895a7e..c6860c5 100644
--- a/src/Make-inst.am
+++ b/src/Make-inst.am
@@ -17,4 +17,6 @@
include Make.am
lib_LTLIBRARIES=libgrecs.la
libgrecs_la_SOURCES = $(GRECS_SRC)
-include_HEADERS = grecs.h
+include_HEADERS = grecs.h wordsplit.h
+m4datadir = $(datadir)/aclocal
+dist_m4data_DATA = libgrecs.m4
diff --git a/src/Make-shared.am b/src/Make-shared.am
index fb6f806..8d9f9ff 100644
--- a/src/Make-shared.am
+++ b/src/Make-shared.am
@@ -16,4 +16,4 @@
include Make.am
noinst_LT_LIBRARIES=libgrecs.la
libgrecs_la_SOURCES = $(GRECS_SRC)
-noinst_HEADERS = grecs.h
+noinst_HEADERS += grecs.h wordsplit.h
diff --git a/src/Make-static.am b/src/Make-static.am
index 6029f2d..709cfb7 100644
--- a/src/Make-static.am
+++ b/src/Make-static.am
@@ -16,4 +16,4 @@
include Make.am
noinst_LIBRARIES=libgrecs.a
libgrecs_a_SOURCES = $(GRECS_SRC)
-noinst_HEADERS = grecs.h
+noinst_HEADERS += grecs.h wordsplit.h
diff --git a/src/Make.am b/src/Make.am
index f246099..50f9170 100644
--- a/src/Make.am
+++ b/src/Make.am
@@ -29,16 +29,15 @@ GRECS_SRC = \
text.c\
tree.c\
version.c\
- wordsplit.c\
- wordsplit.h
+ wordsplit.c
+
+noinst_HEADERS = yygrecs.h
EXTRA_DIST=grecs-gram.h $(PP_SETUP_FILE) Make.am Make-inst.am Make-shared.am Make-static.am
INCLUDES = -I$(srcdir) @GRECS_INCLUDES@
AM_YFLAGS = -dtv
AM_LFLAGS = -d
-# Use a modified ylwrap implementation that understands the --prefix option.
-YLWRAP = $(top_srcdir)/$(grex_topdir)grecs/build-aux/ylwrap --prefix yy_grecs
incdir=$(pkgdatadir)/$(VERSION)/include
inc_DATA = $(PP_SETUP_FILE)
diff --git a/src/grecs-gram.y b/src/grecs-gram.y
index 3d4cb2f..a805702 100644
--- a/src/grecs-gram.y
+++ b/src/grecs-gram.y
@@ -18,6 +18,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include "yygrecs.h"
#include <grecs.h>
#include <grecs-gram.h>
#include <stdlib.h>
diff --git a/src/grecs-lex.l b/src/grecs-lex.l
index d474548..faf6c4c 100644
--- a/src/grecs-lex.l
+++ b/src/grecs-lex.l
@@ -3,6 +3,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+#include "yygrecs.h"
}
%{
/* grecs - Gray's Extensible Configuration System
diff --git a/src/libgrecs.m4 b/src/libgrecs.m4
new file mode 100644
index 0000000..88ce312
--- /dev/null
+++ b/src/libgrecs.m4
@@ -0,0 +1,47 @@
+# libgrecs.m4 serial 1
+dnl This file is part of Grecs
+dnl Copyright (C) 2007, 2009-2011 Sergey Poznyakoff
+dnl
+dnl Grecs is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl
+dnl Grecs is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+dnl AM_LIBGRECS([minversion],[if-found],[if-notfound])
+AC_DEFUN([AM_LIBGRECS],[
+ cv_libgrecs=no
+ save_LIBS=$LIBS
+ AC_CHECK_LIB([grecs],[grecs_parse],
+ [AC_CHECK_HEADER([grecs.h], [cv_libgrecs=yes])])
+ if test "$cv_libgrecs" = "yes"; then
+ LIBS="$save_LIBS -lgrecs"
+ m4_if($1,,,[
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
+ #include <grecs.h>
+ ]],
+ [exit(grecs_version_cmp("[libgrecs ]$1"));])],
+ [],
+ [cv_libgrecs=no])])
+ if test "$cv_libgrecs" = "yes"; then
+ m4_if($2,,[
+ AC_DEFINE([HAVE_GRECS_H],[1],
+ [Define if <grecs.h> is available])
+ AC_DEFINE([HAVE_LIBGRECS],[1],
+ [Define if libgrecs is available])
+ save_LIBS=$LIBS
+ ],[
+ $2])
+ else
+ m4_if($3,,:,[$3])
+ fi
+ LIBS=$save_LIBS
+ fi
+ ])
diff --git a/src/preproc.c b/src/preproc.c
index 28f473f..cff8224 100644
--- a/src/preproc.c
+++ b/src/preproc.c
@@ -48,7 +48,7 @@ struct buffer_ctx {
FILE *infile;
};
-extern int yy_grecs_flex_debug;
+extern int grecs_yy_flex_debug;
static struct buffer_ctx *context_stack;
static char *linebufbase = NULL;
static size_t linebufsize = 0;
@@ -432,7 +432,7 @@ push_source(const char *name, int once)
ctx->prev = context_stack;
context_stack = ctx;
- if (yy_grecs_flex_debug)
+ if (grecs_yy_flex_debug)
fprintf (stderr, "Processing file `%s'\n", name);
pp_line_stmt();
@@ -456,14 +456,14 @@ pop_source()
context_stack = ctx;
if (!context_stack) {
- if (yy_grecs_flex_debug)
+ if (grecs_yy_flex_debug)
fprintf (stderr, "End of input\n");
return 1;
}
LOCUS.line++;
- if (yy_grecs_flex_debug)
+ if (grecs_yy_flex_debug)
fprintf (stderr, "Resuming file `%s' at line %lu\n",
LOCUS.file, (unsigned long) LOCUS.line);
diff --git a/src/yygrecs.h b/src/yygrecs.h
new file mode 100644
index 0000000..1b3bf31
--- /dev/null
+++ b/src/yygrecs.h
@@ -0,0 +1,28 @@
+/* grecs - Gray's Extensible Configuration System
+ Copyright (C) 2007-2011 Sergey Poznyakoff
+
+ Grecs 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 3 of the License, or (at your
+ option) any later version.
+
+ Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>. */
+
+#define yyparse grecs_yyparse
+#define yylex grecs_yylex
+#define yyerror grecs_yyerror
+#define yynerrs grecs_yynerrs
+#define yylval grecs_yylval
+#define yylloc grecs_yylloc
+#define yychar grecs_yychar
+#define yydebug grecs_yydebug
+#define yy_flex_debug grecs_yy_flex_debug
+
+int yylex(void);
+int yyerror(char *s);

Return to:

Send suggestions and report system problems to the System administrator.