diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-08-11 16:45:31 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-10-18 12:43:06 +0000 |
commit | 7c432b265ed7ca5f8304938db73912df8ce35032 (patch) | |
tree | c95de7bee7b742ed92b9924d904adca706e48d80 /getdefs | |
download | autogen-a3e93d54c56a526903e9e0915a50e72ea9e22811.tar.gz |
Imported from /srv/lorry/lorry-area/autogen/autogen-5.16.2.tar.gz.HEADautogen-5.16.2master
Diffstat (limited to 'getdefs')
-rw-r--r-- | getdefs/Makefile.am | 93 | ||||
-rw-r--r-- | getdefs/Makefile.in | 891 | ||||
-rw-r--r-- | getdefs/gdemit.c | 602 | ||||
-rw-r--r-- | getdefs/gdinit.c | 490 | ||||
-rw-r--r-- | getdefs/getdefs.c | 1196 | ||||
-rw-r--r-- | getdefs/getdefs.h | 120 | ||||
-rw-r--r-- | getdefs/opts.def | 466 | ||||
-rw-r--r-- | getdefs/proto.h | 46 | ||||
-rw-r--r-- | getdefs/test/Makefile.am | 41 | ||||
-rw-r--r-- | getdefs/test/Makefile.in | 551 | ||||
-rwxr-xr-x | getdefs/test/cfg.test | 115 | ||||
-rw-r--r-- | getdefs/test/defs | 86 | ||||
-rwxr-xr-x | getdefs/test/index.test | 130 | ||||
-rwxr-xr-x | getdefs/test/option.test | 107 | ||||
-rwxr-xr-x | getdefs/test/subblock.test | 105 |
15 files changed, 5039 insertions, 0 deletions
diff --git a/getdefs/Makefile.am b/getdefs/Makefile.am new file mode 100644 index 0000000..825a127 --- /dev/null +++ b/getdefs/Makefile.am @@ -0,0 +1,93 @@ +## -*- Mode: Makefile -*- +## --------------------------------------------------------------------- +## Makefile.am -- process this file with automake to produce Makefile.in +## +## Time-stamp: "2012-03-04 19:21:12 bkorb" +## Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. +## --------------------------------------------------------------------- +TARG = getdefs + +bin_PROGRAMS = getdefs +gdsrcs = getdefs.h proto.h getdefs.c gdemit.c gdinit.c +getdefs_SOURCES = proto.h +BUILT_SOURCES = gd.c +nodist_getdefs_SOURCES = $(BUILT_SOURCES) + +SUBDIRS = test +EXTRA_DIST = opts.def $(gdsrcs) +RUNAG = $(AGexe) -L$(top_srcdir)/autoopts/tpl \ + -L$(top_builddir)/autoopts/tpl + +if AMDEP +DEP_ARG = -MF$(DEPDIR)/opts-dep -MT$@ -MP +INF_DEP = -b$(TARG) -MF$(DEPDIR)/info-dep -MT$@ -MP +MAN_DEP = -b$(TARG) -MF$(DEPDIR)/man-dep -MTstamp-man -MP +include $(DEPDIR)/opts-dep +include $(DEPDIR)/info-dep +include $(DEPDIR)/man-dep +else +DEP_ARG = +INF_DEP = +MAN_DEP = +endif + +getdefs_LDADD = $(top_builddir)/autoopts/libopts.la +man_MANS = $(TARG).1 +DOCFILES = $(TARG).texi $(TARG).menu $(TARG).1 +DISTCLEANFILES = $(DOCFILES) $(nodist_getdefs_SOURCES) *-stamp +INCLUDES = @INCLIST@ +AG_ENV = top_builddir=$(top_builddir) \ + top_srcdir=$(top_srcdir) PATH=`cd ../columns >/dev/null && pwd`:$$PATH ; \ + export top_builddir top_srcdir PATH + +all : gen +gen : $(BUILT_SOURCES) $(DOCFILES) + +gd.c : $(gdsrcs) + exec > $@ ; \ + echo '#undef PKGDATADIR' ; \ + echo '#define PKGDATADIR "$(pkgdatadir)"' ; \ + echo ; echo '#define DEFINING 1' ; \ + echo '#include "autoopts/project.h"' ; \ + for f in opts.c $(gdsrcs) ; \ + do echo "#include \"$$f\"" ; done + +$(getdefs_OBJECTS) opts.h opts.c : stamp-opts +stamp-opts : opts.def + @test -x $(AGexe) || { cd ../agen5 && $(MAKE) $(AGnam) ; } + @test -x $(CLexe) || { cd ../columns && $(MAKE) $(CLnam) ; } + $(AG_ENV) ; DEPFILE=$(DEPFILE_opts) \ + $(RUNAG) $(DEP_ARG) $(srcdir)/opts.def + +$(DOCFILES) : stamp-doc +stamp-doc : + @test -x $(TARG)$(EXEEXT) || $(MAKE) $(TARG)$(EXEEXT) + @test -x $(AGexe) || { cd ../agen5 && $(MAKE) $(AGnam) ; } + @test -x $(CLexe) || { cd ../columns && $(MAKE) $(CLnam) ; } + $(AG_ENV) ; \ + $(RUNAG) $(MAN_DEP) -Tagman-cmd $(srcdir)/opts.def ; \ + $(RUNAG) $(INF_DEP) -Tagtexi-cmd -DLEVEL=section $(srcdir)/opts.def + +.NOTPARALLEL: + +.PHONY : local-maintainer-clean +local-maintainer-clean : clean-stamp-opts clean-stamp-doc clean-stamp-man + rm -f *~ + +# getdefs/Makefile.am ends here diff --git a/getdefs/Makefile.in b/getdefs/Makefile.in new file mode 100644 index 0000000..cc87383 --- /dev/null +++ b/getdefs/Makefile.in @@ -0,0 +1,891 @@ +# Makefile.in generated by automake 1.12.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = getdefs$(EXEEXT) +subdir = getdefs +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/config/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/config/ag_macros.m4 \ + $(top_srcdir)/config/extensions.m4 \ + $(top_srcdir)/config/libopts.m4 \ + $(top_srcdir)/config/libtool.m4 \ + $(top_srcdir)/config/ltoptions.m4 \ + $(top_srcdir)/config/ltsugar.m4 \ + $(top_srcdir)/config/ltversion.m4 \ + $(top_srcdir)/config/lt~obsolete.m4 \ + $(top_srcdir)/config/onceonly.m4 \ + $(top_srcdir)/config/snprintfv.m4 \ + $(top_srcdir)/config/unlocked-io.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +PROGRAMS = $(bin_PROGRAMS) +am_getdefs_OBJECTS = +am__objects_1 = gd.$(OBJEXT) +nodist_getdefs_OBJECTS = $(am__objects_1) +getdefs_OBJECTS = $(am_getdefs_OBJECTS) $(nodist_getdefs_OBJECTS) +getdefs_DEPENDENCIES = $(top_builddir)/autoopts/libopts.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(getdefs_SOURCES) $(nodist_getdefs_SOURCES) +DIST_SOURCES = $(getdefs_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AGEN5_TESTS = @AGEN5_TESTS@ +AG_GUILE = @AG_GUILE@ +AG_LDFLAGS = @AG_LDFLAGS@ +AG_MAJOR_VERSION = @AG_MAJOR_VERSION@ +AG_MINOR_VERSION = @AG_MINOR_VERSION@ +AG_TIMEOUT = @AG_TIMEOUT@ +AG_VERSION = @AG_VERSION@ +AG_XML2 = @AG_XML2@ +AGexe = @AGexe@ +AGnam = @AGnam@ +AMTAR = @AMTAR@ +AO_AGE = @AO_AGE@ +AO_CURRENT = @AO_CURRENT@ +AO_REVISION = @AO_REVISION@ +AO_TEMPLATE_VERSION = @AO_TEMPLATE_VERSION@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CLexe = @CLexe@ +CLnam = @CLnam@ +CONFIG_SHELL = @CONFIG_SHELL@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUG_ENABLED = @DEBUG_ENABLED@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DYNAMIC_AG = @DYNAMIC_AG@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_STATIC = @ENABLE_STATIC@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDexe = @GDexe@ +GDnam = @GDnam@ +GO_AGE = @GO_AGE@ +GO_CURRENT = @GO_CURRENT@ +GO_REVISION = @GO_REVISION@ +GREP = @GREP@ +GUILE_VERSION = @GUILE_VERSION@ +INCLIST = @INCLIST@ +INCSNPRINTFV = @INCSNPRINTFV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBGUILE_CFLAGS = @LIBGUILE_CFLAGS@ +LIBGUILE_LIBS = @LIBGUILE_LIBS@ +LIBGUILE_PATH = @LIBGUILE_PATH@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSNPRINTFV = @LIBSNPRINTFV@ +LIBTOOL = @LIBTOOL@ +LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ +LIBXML2_LIBS = @LIBXML2_LIBS@ +LIBXML2_PATH = @LIBXML2_PATH@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +M4_SRC = @M4_SRC@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPTS_TESTDIR = @OPTS_TESTDIR@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSIX_SHELL = @POSIX_SHELL@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEXI2HTML = @TEXI2HTML@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_aux_dir = @ac_aux_dir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +TARG = getdefs +gdsrcs = getdefs.h proto.h getdefs.c gdemit.c gdinit.c +getdefs_SOURCES = proto.h +BUILT_SOURCES = gd.c +nodist_getdefs_SOURCES = $(BUILT_SOURCES) +SUBDIRS = test +EXTRA_DIST = opts.def $(gdsrcs) +RUNAG = $(AGexe) -L$(top_srcdir)/autoopts/tpl \ + -L$(top_builddir)/autoopts/tpl + +@AMDEP_FALSE@DEP_ARG = +@AMDEP_TRUE@DEP_ARG = -MF$(DEPDIR)/opts-dep -MT$@ -MP +@AMDEP_FALSE@INF_DEP = +@AMDEP_TRUE@INF_DEP = -b$(TARG) -MF$(DEPDIR)/info-dep -MT$@ -MP +@AMDEP_FALSE@MAN_DEP = +@AMDEP_TRUE@MAN_DEP = -b$(TARG) -MF$(DEPDIR)/man-dep -MTstamp-man -MP +getdefs_LDADD = $(top_builddir)/autoopts/libopts.la +man_MANS = $(TARG).1 +DOCFILES = $(TARG).texi $(TARG).menu $(TARG).1 +DISTCLEANFILES = $(DOCFILES) $(nodist_getdefs_SOURCES) *-stamp +INCLUDES = @INCLIST@ +AG_ENV = top_builddir=$(top_builddir) \ + top_srcdir=$(top_srcdir) PATH=`cd ../columns >/dev/null && pwd`:$$PATH ; \ + export top_builddir top_srcdir PATH + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu getdefs/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu getdefs/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +getdefs$(EXEEXT): $(getdefs_OBJECTS) $(getdefs_DEPENDENCIES) $(EXTRA_getdefs_DEPENDENCIES) + @rm -f getdefs$(EXEEXT) + $(LINK) $(getdefs_OBJECTS) $(getdefs_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gd.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(RECURSIVE_TARGETS) $(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done +cscopelist-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @list='$(MANS)'; if test -n "$$list"; then \ + list=`for p in $$list; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ + if test -n "$$list" && \ + grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ + echo "error: found man pages containing the 'missing help2man' replacement text:" >&2; \ + grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ + echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ + echo " typically 'make maintainer-clean' will remove them" >&2; \ + exit 1; \ + else :; fi; \ + else :; fi + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + cscopelist-recursive ctags-recursive install install-am \ + install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool cscopelist cscopelist-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-man1 install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-man uninstall-man1 + +@AMDEP_TRUE@include $(DEPDIR)/opts-dep +@AMDEP_TRUE@include $(DEPDIR)/info-dep +@AMDEP_TRUE@include $(DEPDIR)/man-dep + +all : gen +gen : $(BUILT_SOURCES) $(DOCFILES) + +gd.c : $(gdsrcs) + exec > $@ ; \ + echo '#undef PKGDATADIR' ; \ + echo '#define PKGDATADIR "$(pkgdatadir)"' ; \ + echo ; echo '#define DEFINING 1' ; \ + echo '#include "autoopts/project.h"' ; \ + for f in opts.c $(gdsrcs) ; \ + do echo "#include \"$$f\"" ; done + +$(getdefs_OBJECTS) opts.h opts.c : stamp-opts +stamp-opts : opts.def + @test -x $(AGexe) || { cd ../agen5 && $(MAKE) $(AGnam) ; } + @test -x $(CLexe) || { cd ../columns && $(MAKE) $(CLnam) ; } + $(AG_ENV) ; DEPFILE=$(DEPFILE_opts) \ + $(RUNAG) $(DEP_ARG) $(srcdir)/opts.def + +$(DOCFILES) : stamp-doc +stamp-doc : + @test -x $(TARG)$(EXEEXT) || $(MAKE) $(TARG)$(EXEEXT) + @test -x $(AGexe) || { cd ../agen5 && $(MAKE) $(AGnam) ; } + @test -x $(CLexe) || { cd ../columns && $(MAKE) $(CLnam) ; } + $(AG_ENV) ; \ + $(RUNAG) $(MAN_DEP) -Tagman-cmd $(srcdir)/opts.def ; \ + $(RUNAG) $(INF_DEP) -Tagtexi-cmd -DLEVEL=section $(srcdir)/opts.def + +.NOTPARALLEL: + +.PHONY : local-maintainer-clean +local-maintainer-clean : clean-stamp-opts clean-stamp-doc clean-stamp-man + rm -f *~ + +# getdefs/Makefile.am ends here + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/getdefs/gdemit.c b/getdefs/gdemit.c new file mode 100644 index 0000000..f6bfbbf --- /dev/null +++ b/getdefs/gdemit.c @@ -0,0 +1,602 @@ +/** + * \file gdemit.c + * + * getdefs Copyright (c) 1999-2012 by Bruce Korb - all rights reserved + * + * Author: Bruce Korb <bkorb@gnu.org> + * Time-stamp: "2012-03-31 13:39:34 bkorb" + * + * This file is part of AutoGen. + * AutoGen copyright (c) 1992-2012 by Bruce Korb - all rights reserved + * + * AutoGen 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. + * + * AutoGen 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/>. + */ + +/* = = = START-STATIC-FORWARD = = = */ +static void +compress_def(char * pz); + +static char * +list_attrib(char * pzText, char * pzOut); + +static char * +emit_quote(char ** ppzText, char * pzOut); + +static void +next_def_entry(char ** txt_pp, char const ** def_pp); + +static void +emit_attribute(char const ** def_pp, char ** out_pp); + +static char* +emit_subblock(char const * pzDefList, char * pzText, char * pzOut); + +static char* +subblock_str(char ** ppzText, uint_t sepChar, char * pzOut); +/* = = = END-STATIC-FORWARD = = = */ + +/* + * compress_def + * + * Compress the definition text. Each input line has some prefix + * stuff to ensure it is a comment as seen by the normal processor + * of the file. In "C", the entire block is surrounded by the + * '/'-'*' and '*'-'/' pairs. In shell, every line would start + * with a hash character ('#'). Etc. To make life easy, we require + * that every line be prefixed with something that matches the + * pattern: + * + * "^[^*]*\*+" + * + * and any line that does not is ignored. So, here we strip off + * that prefix before we go ahead and try to parse it. + */ +static void +compress_def(char * pz) +{ + char * pzStrt = pz; + char * pzDest = pz; + char * pzSrc = pz; + int nlCt = 0; + + /* + * Search until we find a line that contains an asterisk + * and is followed by something other than whitespace. + */ + nlCt = 0; + +skip_leading_space: + while (isspace( *pzSrc )) { + if (*(pzSrc++) == '\n') { + nlCt++; + for (;;) { + switch (*(pzSrc++)) { + case '*': + while (*pzSrc == '*') pzSrc++; + goto skip_leading_space; + + case NUL: + *pzStrt = NUL; + return; + + case '\n': + nlCt++; + } + } + } + } + + if (*pzSrc == NUL) { + *pzStrt = NUL; + return; + } + + /* + * FOR as long as we still have more text, ... + */ + for (;;) { + /* + * IF we passed over one or more newlines while looking for + * an asterisk, then insert one extra newline into the output + */ + if (nlCt > 0) { + *pzDest++ = '\n'; + nlCt = 0; + } + + /* + * FOR all the data on the current input line, ... + */ + for (;;) { + /* + * Move the source to destination until we find + * either a new-line or a NUL. + */ + switch (*pzDest++ = *pzSrc++) { + case '\n': + if (*pzSrc != NUL) + goto lineDone; + + case NUL: + pzDest--; + goto compressDone; + + default: + ; + } + } lineDone:; + + /* + * Trim trailing white space off the end of the line. + */ + if ((pzDest[-2] == ' ') || (pzDest[-2] == '\t')) { + do { + pzDest--; + } while ((pzDest[-2] == ' ') || (pzDest[-2] == '\t')); + pzDest[-1] = '\n'; + } + + /* + * We found a new-line. Skip forward to an asterisk. + */ + foundNewline: + while (*pzSrc != '*') { + if (*pzSrc == NUL) + goto compressDone; + if (*pzSrc == '\n') + nlCt++; + pzSrc++; + } + + /* + * Skip over the asterisk we found and all the ones that follow + */ + while (*pzSrc == '*') pzSrc++; + while (isspace( *pzSrc )) { + /* + * IF we stumble into another newline, + * THEN we go back to look for an asterisk. + */ + if (*pzSrc == '\n') + goto foundNewline; + pzSrc++; + } + } compressDone:; + + /* + * Trim off all the trailing white space, including newlines + */ + while ((pzDest > pzStrt) && isspace( pzDest[-1] )) pzDest--; + *pzDest = NUL; +} + + +/* + * emitDefinition + */ +LOCAL char* +emitDefinition(char* pzDef, char* pzOut) +{ + char sep_char; + char zEntryName[ MAXNAMELEN ]; + + /* + * Indent attribute definitions four spaces + */ + { + char* p = zEntryName; + *pzOut++ = ' '; *pzOut++ = ' '; *pzOut++ = ' '; *pzOut++ = ' '; + + while (AG_NAME_CHAR(*pzDef)) + *p++ = *pzOut++ = *pzDef++; + + if (p >= zEntryName + sizeof(zEntryName)) + die("names are constrained to %d bytes\n", MAXNAMELEN); + + *p = NUL; + } + + /* + * Strip the prefixes from all the definition lines + * (viz., the "^.*\*" text, except that it is a shortest match + * instead of longest match). Skip the ':' before starting. + */ + compress_def(++pzDef); + + if (HAVE_OPT( SUBBLOCK )) { + int ct = STACKCT_OPT( SUBBLOCK ); + char const ** ppz = STACKLST_OPT( SUBBLOCK ); + + do { + char const * pz = *ppz++; + if (strcmp(pz, zEntryName) == 0) + return emit_subblock(pz, pzDef, pzOut); + } while (--ct > 0); + } + + if (HAVE_OPT( LISTATTR )) { + int ct = STACKCT_OPT( LISTATTR ); + char const ** ppz = STACKLST_OPT( LISTATTR ); + + do { + if (strcmp(*ppz++, zEntryName) == 0) + return list_attrib(pzDef, pzOut); + } while (--ct > 0); + } + + if (isspace(*pzDef)) + sep_char = *pzDef++; + else sep_char = ' '; + + switch (*pzDef) { + case NUL: + *pzOut++ = ';'; *pzOut++ = '\n'; + break; + + case '"': + case '\'': + case '{': + /* + * Quoted entries or subblocks do their own stringification + * sprintf is safe because we are copying strings around + * and *always* making the result smaller than the original + */ + pzOut += sprintf(pzOut, " =%c%s;\n", sep_char, pzDef); + break; + + default: + *pzOut++ = ' '; *pzOut++ = '='; *pzOut++ = sep_char; + *pzOut++ = '\''; + + for (;;) { + switch (*pzOut++ = *pzDef++) { + case '\\': + *pzOut++ = '\\'; + break; + + case '\'': + pzOut[-1] = '\\'; + *pzOut++ = '\''; + break; + + case NUL: + goto unquotedDone; + } + } unquotedDone:; + pzOut[-1] = '\''; *pzOut++ = ';'; *pzOut++ = '\n'; + break; + } + return pzOut; +} + + +/* + * list_attrib + */ +static char * +list_attrib(char * pzText, char * pzOut) +{ + static char const zStart[] = " = "; + + uint_t sepChar = ','; + int FirstAttr = 1; + + strcpy(pzOut, zStart); + pzOut += sizeof(zStart) - 1; + + /* + * See if there is an alternate separator character. + * It must be a punctuation character that is not also + * a quote character. + */ + if (ispunct(*pzText) && (*pzText != '"') && (*pzText != '\'')) + sepChar = (uint_t)*(pzText++); + while (isspace(*pzText)) pzText++; + + /* + * Loop for as long as we have text entries + */ + while (*pzText != NUL) { + + if (FirstAttr) + FirstAttr = 0; + else + *(pzOut++) = ','; + + /* + * If the first thing we find is the separator char, + * then emit the empty string. + */ + if ((uint_t)*pzText == sepChar) { + *(pzOut++) = '\''; *(pzOut++) = '\''; + pzText++; + continue; + } + + /* + * Emit whatever we have. The call will consume any trailing + * separator character. + */ + pzOut = subblock_str(&pzText, sepChar, pzOut); + } + + /* + * IF there were no definitions, THEN emit an empty one + */ + if (FirstAttr) + pzOut -= sizeof(zStart) - 1; + + *(pzOut++) = ';'; + *(pzOut++) = '\n'; + + return pzOut; +} + + +/* + * The text is quoted, so copy it as is, ensuring that escaped + * characters are not used to end the quoted text. + */ +static char * +emit_quote(char ** ppzText, char * pzOut) +{ + char* pzText = *ppzText; + char svch = (*pzOut++ = *pzText++); + + for (;;) { + switch (*pzOut++ = *pzText++) { + + case '\\': + if ((*pzOut++ = *pzText++) != NUL) + break; + + case NUL: + pzText--; + pzOut[-1] = svch; + svch = NUL; + /* FALLTHROUGH */ + + case '"': + case '\'': + if (pzOut[-1] == svch) + goto quoteDone; + + break; + } + } + +quoteDone: + *ppzText = pzText; + return pzOut; +} + +static void +next_def_entry(char ** txt_pp, char const ** def_pp) +{ + char const * p = *def_pp; + (*txt_pp)++; + for (;;) { + switch (*++p) { + case ' ': p++; /* FALLTHROUGH */ + case NUL: + *def_pp = p; + return; + } + } +} + +static void +emit_attribute(char const ** def_pp, char ** out_pp) +{ + static char const pfx[] = "\n "; + + char * out = *out_pp; + char const * def = *def_pp; + + memcpy(out, pfx, sizeof(pfx) - 1); + out += sizeof(pfx) - 1; + + for (;;) { + *out++ = *def++; + switch (*def) { + case ' ': def++; /* FALLTHROUGH */ + case NUL: + goto leave_emit_attribute; + } + } + +leave_emit_attribute: + + *out++ = ';'; + *out_pp = out; + *def_pp = def; +} + +/* + * emit_subblock + */ +static char* +emit_subblock(char const * pzDefList, char * pzText, char * pzOut) +{ + static char const zStart[] = " = {"; + static char const zEnd[] = "\n };\n"; + + uint_t sepChar = ','; + int FirstAttr = 1; + + /* + * Advance past subblock name to the entry name list + */ + pzDefList += strlen(pzDefList) + 1; + strcpy(pzOut, zStart); + pzOut += sizeof(zStart) - 1; + + /* + * See if there is an alternate separator character. + * It must be a punctuation character that is not also + * a quote character. + */ + if (ispunct(*pzText) && (*pzText != '"') && (*pzText != '\'')) + sepChar = (uint_t)*(pzText++); + + /* + * Loop for as long as we have text entries and subblock + * attribute names, ... + */ + do { + /* + * IF the first character is the separator, + * THEN this entry is skipped. + */ + if ((uint_t)*pzText == sepChar) { + next_def_entry(&pzText, &pzDefList); + continue; + } + + /* + * Skip leading white space in the attribute and check for done. + */ + while (isspace(*pzText)) pzText++; + if (*pzText == NUL) { + /* + * IF there were no definitions, THEN emit one anyway + */ + if (FirstAttr) + emit_attribute(&pzDefList, &pzOut); + + break; + } + + /* + * Copy out the attribute name + */ + emit_attribute(&pzDefList, &pzOut); + FirstAttr = 0; + + /* + * IF there are no data for this attribute, + * THEN we leave the definition empty. + */ + if ((uint_t)*pzText == sepChar) { + pzText++; + continue; + } + + /* + * Copy out the assignment operator and emit the string + */ + pzOut[-1] = ' '; *pzOut++ = '='; *pzOut++ = ' '; + pzOut = subblock_str(&pzText, sepChar, pzOut); + *pzOut++ = ';'; + + } while (isalpha(*pzDefList)); + + memcpy(pzOut, zEnd, sizeof(zEnd)); + return pzOut + sizeof(zEnd) - 1; +} + + +/* + * Emit a string in a fashion that autogen will be able to + * correctly reconstruct it. + */ +static char* +subblock_str(char ** ppzText, uint_t sepChar, char * pzOut) +{ + char * pzText = *ppzText; + char * pcComma; + char * pcEnd; + + /* + * Skip leading space + */ + while (isspace(*pzText)) pzText++; + + /* + * IF the text is already quoted, + * THEN call the quoted text emitting routine + */ + if ((*pzText == '"') || (*pzText == '\'')) { + pzOut = emit_quote(&pzText, pzOut); + + /* + * Make sure we strip off trailing white space and any + * separation character. + */ + while (isspace(*pzText)) pzText++; + if ((uint_t)*pzText == sepChar) { + pzText++; + while (isspace(*pzText)) pzText++; + } + *ppzText = pzText; + return pzOut; + } + + /* + * Look for the character that separates this entry text + * from the entry text for the next attribute. Leave 'pcComma' + * pointing to the character _before_ the character where we + * are to resume our text scan. (i.e. at the comma, or the + * last character in the string) + */ + pcComma = strchr(pzText, (int)sepChar); + if (pcComma == (char*)NULL) { + pcEnd = pzText + strlen(pzText); + pcComma = pcEnd-1; + } else { + pcEnd = pcComma; + } + + /* + * Clean off trailing white space. + */ + while ((pcEnd > pzText) && isspace(pcEnd[-1])) pcEnd--; + + /* + * Copy the text, surrounded by single quotes + */ + *pzOut++ = '\''; + { + char svch = *pcEnd; + *pcEnd = NUL; + for (;;) { + char ch = *pzText++; + switch (ch) { + case '\'': + *pzOut++ = '\\'; + default: + *pzOut++ = ch; + break; + case NUL: + goto copyDone; + } + } copyDone: ; + + pzText = pcComma+1; + *pcEnd = svch; + } + + *pzOut++ = '\''; + while (isspace(*pzText)) pzText++; + *ppzText = pzText; + return pzOut; +} + +/* emacs + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of getdefs/gdemit.c */ diff --git a/getdefs/gdinit.c b/getdefs/gdinit.c new file mode 100644 index 0000000..321a582 --- /dev/null +++ b/getdefs/gdinit.c @@ -0,0 +1,490 @@ +/** + * \file gdinit.c + * + * getdefs Copyright (c) 1999-2012 by Bruce Korb - all rights reserved + * + * Author: Bruce Korb <bkorb@gnu.org> + * Time-stamp: "2011-12-29 10:02:47 bkorb" + * + * This file is part of AutoGen. + * AutoGen copyright (c) 1992-2012 by Bruce Korb - all rights reserved + * + * AutoGen 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. + * + * AutoGen 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/>. + */ + +static char const zNoList[] = "ERROR: block attr must have name list:\n\t%s\n"; + +/* = = = START-STATIC-FORWARD = = = */ +static char* +compressOptionText(char* pzS, char* pzE); + +static char* +fixupSubblockString(char const * pzSrc); + +static void +loadStdin(void); + +static void +set_define_re(void); + +static void +set_modtime(void); +/* = = = END-STATIC-FORWARD = = = */ + +LOCAL void +die(char const * fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s error: ", getdefsOptions.pzProgName); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + +LOCAL void +fserr_die(char const * fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + fprintf(stderr, "%s fserr %d (%s): ", getdefsOptions.pzProgName, + errno, strerror(errno)); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); +} + +/* + * compressOptionText + */ +static char* +compressOptionText(char* pzS, char* pzE) +{ + char* pzR = pzS; /* result */ + char* pzD = pzS; /* destination */ + + for (;;) { + char ch; + + if (pzS >= pzE) + break; + + ch = (*(pzD++) = *(pzS++)); + + /* + * IF At end of line, skip to next '*' + */ + if (ch == '\n') { + while (*pzS != '*') { + pzS++; + if (pzS >= pzE) + goto compressDone; + } + } + } compressDone:; + + { + size_t len = (pzD - pzR); + pzD = malloc(len + 1); + if (pzD == NULL) + die("cannot dup %d byte string\n", (int)(pzD - pzR)); + + memcpy(pzD, pzR, len); + pzD[ len ] = NUL; + } + + /* + * Blank out trailing data. + */ + while (pzS < pzE) *(pzS++) = ' '; + return pzD; +} + + +/* + * fixupSubblockString + */ +static char* +fixupSubblockString(char const * pzSrc) +{ + char * pzString; + char * pzDest; + char * pzCopy; + + pzString = strdup(pzSrc); + + /* + * Make sure we find the '=' separator + */ + { + char * p = strchr(pzString, '='); + if (p == NULL) + die(zNoList, pzString); + + /* + * Trim the name + */ + pzDest = p++; + while ((pzDest > pzString) && IS_HORIZ_WHITE_CHAR(pzDest[-1])) pzDest--; + *(pzDest++) = NUL; + + /* + * Make sure at least one attribute name is defined + */ + while (IS_WHITESPACE_CHAR(*p)) p++; + if (*p == NUL) + die(zNoList, pzString); + + pzCopy = p; + } + + for (;;) { + /* + * Attribute names must start with an alpha + */ + if (! IS_ALPHABETIC_CHAR(*pzCopy)) { + fprintf(stderr, "ERROR: attribute names must start " + "with an alphabetic character:\n\t%s\n", + pzString); + USAGE(EXIT_FAILURE); + } + + /* + * Copy the name. + */ + while (IS_OPTION_NAME_CHAR(*pzCopy)) + *pzDest++ = *pzCopy++; + + /* + * Skip over one comma (optional) and any white space. + * If there is a newline, it must be after the comma. + */ + while (IS_HORIZ_WHITE_CHAR(*pzCopy)) pzCopy++; + if (*pzCopy == ',') + pzCopy++; + + while (IS_WHITESPACE_CHAR(*pzCopy)) pzCopy++; + if (*pzCopy == NUL) + break; + /* + * The final string contains only one space between attributes + */ + *pzDest++ = ' '; + } + + *pzDest = NUL; + + return pzString; +} + + +/* + * loadStdin + * + * The input file list is from stdin. + * + * We make some simplifying assumptions: + * *ALL* input lines are less than 4096 bytes. If this is not true, + * we may strip some white space in the middle of a line and presume + * a comment begins in the middle of a line or we only comment out + * the first 4096 bytes of a comment line. So, rather than all these + * problems, we just choke on it. + */ +static void +loadStdin(void) +{ + char z[ 4096 ]; + int ct = 0; + tCC** ppz = STACKLST_OPT(INPUT); + + if (isatty(STDIN_FILENO)) { + fputs("getdefs error: no inputs were specified and stdin is a tty\n", + stderr); + USAGE(EXIT_FAILURE); + } + + while (fgets(z, (int)sizeof(z), stdin) != NULL) { + char* pz = z + strlen(z); + + if (pz[-1] != '\n') { + tSCC zErr[] = + "getdefs error: input line not newline terminated\n"; + fputs(zErr, stderr); + exit(EXIT_FAILURE); + } + + while ((pz > z) && isspace(pz[-1])) pz--; + *pz = '\0'; + pz = z; + while (isspace(*pz)) pz++; + if ((*pz == '\0') || (*pz == '#')) continue; + if (access(pz, R_OK) != 0) continue; + + if (ct++ == 0) + *ppz = strdup(z); /* replace the "-" */ + else + SET_OPT_INPUT(strdup(z)); /* if 'strdup' fails, we die later */ + } +} + + +/* + * processEmbeddedOptions + * + * This routine processes the text contained within "/\*==--" + * and "=\*\/" as a single option. If that option is the SUBBLOCK + * option, it will need to be massaged for use. + */ +LOCAL void +processEmbeddedOptions(char* pzText) +{ + tSCC zStStr[] = "/*=--"; + tSCC zEndSt[] = "=*/"; + + for (;;) { + char* pzStart = strstr(pzText, zStStr); + char* pzEnd; + int sblct = 0; + + if (pzStart == NULL) + return; + + if (HAVE_OPT(SUBBLOCK)) + sblct = STACKCT_OPT(SUBBLOCK); + + pzEnd = strstr(pzStart, zEndSt); + if (pzEnd == NULL) + return; + + pzStart = compressOptionText(pzStart + sizeof(zStStr)-1, pzEnd); + + optionLoadLine(&getdefsOptions, pzStart); + + if (HAVE_OPT(SUBBLOCK) && (sblct != STACKCT_OPT(SUBBLOCK))) { + tCC** ppz = STACKLST_OPT(SUBBLOCK); + ppz[ sblct ] = fixupSubblockString(ppz[sblct]); + } + pzText = pzEnd + sizeof(zEndSt); + } +} + +/** + * set up the regular expression we search for + */ +static void +set_define_re(void) +{ + static char const default_pat[] = + "/\\*=(\\*|" + "([a-z][a-z0-9_]*(\\[[0-9]+\\]){0,1}|\\*)[ \t]+[a-z])"; + static char const pat_wrapper[] = "/\\*=(%s)"; + + char const * def_pat; + bool free_pat = false; + + /* + * Our default pattern is to accept all names following + * the '/' '*' '=' character sequence. We ignore case. + */ + if ((! HAVE_OPT(DEFS_TO_GET)) || (*OPT_ARG(DEFS_TO_GET) == NUL)) { + def_pat = default_pat; + + } else if (strncmp(OPT_ARG(DEFS_TO_GET), default_pat, 4) == 0) { + def_pat = OPT_ARG(DEFS_TO_GET); + + } else { + char const * pz = OPT_ARG(DEFS_TO_GET); + size_t len = strlen((char *)pz) + 16; + char * bf = malloc(len); + + if (bf == NULL) + die(zMallocErr, (int)len, "definition pattern"); + + /* + * IF a pattern has been supplied, enclose it with + * the '/' '*' '=' part of the pattern. + */ + snprintf(bf, len, pat_wrapper, pz); + def_pat = bf; + free_pat = true; + } + + /* + * Compile the regular expression that we are to search for + * to find each new definition in the source files. + */ + { + char zRER[MAXNAMELEN]; + static char const zReErr[] = + "Regex error %d (%s): Cannot compile reg expr:\n\t%s\n"; + + int rerr = regcomp(&define_re, def_pat, REG_EXTENDED | REG_ICASE); + if (rerr != 0) { + regerror(rerr, &define_re, zRER, sizeof(zRER)); + die(zReErr, rerr, zRER, def_pat); + } + + if (free_pat) + free((void *)def_pat); + + rerr = regcomp(&attrib_re, zAttribRe, REG_EXTENDED | REG_ICASE); + if (rerr != 0) { + regerror(rerr, &attrib_re, zRER, sizeof(zRER)); + die(zReErr, rerr, zRER, zAttribRe); + } + } +} + +/** + * Make sure each of the input files is findable. + * Also, while we are at it, compute the output file mod time + * based on the mod time of the most recent file. + */ +static void +set_modtime(void) +{ + int ct = STACKCT_OPT(INPUT); + char const ** ppz = STACKLST_OPT(INPUT); + struct stat stb; + + if ((ct == 1) && (strcmp(*ppz, "-") == 0)) { + /* + * Read the list of input files from stdin. + */ + loadStdin(); + ct = STACKCT_OPT( INPUT); + ppz = STACKLST_OPT(INPUT); + } + + do { + if (stat(*ppz++, &stb) != 0) + break; + + if (! S_ISREG(stb.st_mode)) { + errno = EINVAL; + break; + } + + if (++(stb.st_mtime) > modtime) + modtime = stb.st_mtime; + } while (--ct > 0); + + if (ct > 0) + fserr_die("stat-ing %s for text file\n", ppz[-1]); +} + +/** + * validateOptions + * + * - Sanity check the options + * - massage the SUBBLOCK options into something + * more easily used during the source text processing. + * - compile the regular expressions + * - make sure we can find all the input files and their mod times + * - Set up our entry ordering database (if specified) + * - Make sure we have valid strings for SRCFILE and LINENUM + * (if we are to use these things). + * - Initialize the user name characters array. + */ +LOCAL void +validateOptions(void) +{ + set_define_re(); + + /* + * Prepare each sub-block entry so we can parse easily later. + */ + if (HAVE_OPT(SUBBLOCK)) { + int ct = STACKCT_OPT( SUBBLOCK); + tCC** ppz = STACKLST_OPT(SUBBLOCK); + + /* + * FOR each SUBBLOCK argument, + * DO condense each name list to be a list of names + * separated by a single space and NUL terminated. + */ + do { + *ppz = fixupSubblockString(*ppz); + ppz++; + } while (--ct > 0); + } + + if (! HAVE_OPT(INPUT)) + SET_OPT_INPUT("-"); + + set_modtime(); + + /* + * IF the output is to have order AND it is to be based on a file, + * THEN load the contents of that file. + * IF we cannot load the file, + * THEN it must be new or empty. Allocate several K to start. + */ + if ( HAVE_OPT(ORDERING) + && (OPT_ARG(ORDERING) != NULL)) { + tSCC zIndexPreamble[] = + "# -*- buffer-read-only: t -*- vi: set ro:\n" + "#\n# DO NOT EDIT THIS FILE - it is auto-edited by getdefs\n"; + + pzIndexText = loadFile(OPT_ARG(ORDERING)); + if (pzIndexText == NULL) { + pzIndexText = pzEndIndex = pzIndexEOF = malloc((size_t)0x4000); + indexAlloc = 0x4000; + pzEndIndex += sprintf(pzEndIndex, "%s", zIndexPreamble); + } else { + pzEndIndex = pzIndexEOF = pzIndexText + strlen(pzIndexText); + indexAlloc = (pzEndIndex - pzIndexText) + 1; + } + + /* + * We map the name entries to a connonical form. + * By default, everything is mapped to lower case already. + * This call will map these three characters to '_'. + */ + strequate("_-^"); + } + + { + char const * pz = OPT_ARG(SRCFILE); + if ((pz == NULL) || (*pz == NUL)) + OPT_ARG(SRCFILE) = "srcfile"; + + pz = OPT_ARG(LINENUM); + if ((pz == NULL) || (*pz == NUL)) + OPT_ARG(LINENUM) = "linenum"; + } + + { + tSCC zAgNameChars[] = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" "_-^"; + tSCC zUserNameChs[] = ":.$%*!~<>&@"; + tCC* p = zAgNameChars; + + while (*p) + zUserNameCh[(unsigned)(*p++)] = 3; + + p = zUserNameChs; + while (*p) + zUserNameCh[(unsigned)(*p++)] = 1; + } +} + + +/* emacs + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of getdefs/gdinit.c */ diff --git a/getdefs/getdefs.c b/getdefs/getdefs.c new file mode 100644 index 0000000..26dd5d1 --- /dev/null +++ b/getdefs/getdefs.c @@ -0,0 +1,1196 @@ +/** + * \file getdefs.c + * + * getdefs Copyright (c) 1999-2012 by Bruce Korb - all rights reserved + * + * Time-stamp: "2012-04-14 11:15:08 bkorb" + * Author: Bruce Korb <bkorb@gnu.org> + * + * This file is part of AutoGen. + * AutoGen copyright (c) 1992-2012 by Bruce Korb - all rights reserved + * + * AutoGen 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. + * + * AutoGen 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/>. + */ + +static char const zBogusDef[] = "Bogus definition:\n%s\n"; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Forward procedure pointers + */ +typedef int (compar_func)(const void *, const void *); +static compar_func compar_text, compar_defname; + +/* START-STATIC-FORWARD */ +static char* +assignIndex(char* pzOut, char* pzDef); + +static int +awaitAutogen(void); + +static void +buildDefinition(char * pzDef, char const * pzFile, int line, char * pzOut); + +static tSuccess +buildPreamble(char ** ppzDef, char ** ppzOut, char const * pzFile, int line); + +static int +compar_defname(const void* p1, const void* p2); + +static int +compar_text(const void* p1, const void* p2); + +static void +doPreamble(FILE* outFp); + +static void +printEntries(FILE* fp); + +static void +processFile(char const * pzFile); + +static void +set_first_idx(void); + +static FILE* +open_ag_file(char ** pzBase); + +static FILE* +open_ag_proc_pipe(char ** pzBase); + +static void +exec_autogen(char ** pzBase); + +static FILE* +startAutogen(void); + +static void +update_db(void); +/* END-STATIC-FORWARD */ + +#ifndef HAVE_STRSIGNAL +# include "compat/strsignal.c" +#endif + +#ifndef HAVE_CHMOD +# include "compat/chmod.c" +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * MAIN + */ +int +main(int argc, char ** argv) +{ + FILE* outFp; + + optionProcess(&getdefsOptions, argc, argv); + validateOptions(); + + outFp = startAutogen(); + + doPreamble(outFp); + + /* + * Process each input file + */ + { + int ct = STACKCT_OPT(INPUT); + char const ** ppz = STACKLST_OPT(INPUT); + + do { + processFile(*ppz++); + } while (--ct > 0); + } + + /* + * IF we don't have an ordering file, but we do have a "first index", + * THEN alphabetize by definition name. + */ + if ((pzIndexText == NULL) && HAVE_OPT(FIRST_INDEX)) { + qsort((void*)papzBlocks, blkUseCt, sizeof(char*), compar_defname); + set_first_idx(); + } + + else if (ENABLED_OPT(ORDERING) && (blkUseCt > 1)) + qsort((void*)papzBlocks, blkUseCt, sizeof(char*), &compar_text); + + printEntries(outFp); +#ifdef HAVE_FCHMOD + fchmod(fileno(outFp), S_IRUSR|S_IRGRP|S_IROTH); +#endif + fclose(outFp); + + /* + * IF output is to a file + * THEN set the permissions and modification times + */ + if ( (WHICH_IDX_AUTOGEN == INDEX_OPT_OUTPUT) + && (outFp != stdout) ) { + struct utimbuf tbuf; + tbuf.actime = time((time_t*)NULL); + tbuf.modtime = modtime + 1; + utime(OPT_ARG(OUTPUT), &tbuf); +#ifndef HAVE_CHMOD + chmod(OPT_ARG(OUTPUT), S_IRUSR|S_IRGRP|S_IROTH); +#endif + } + + /* + * IF we are keeping a database of indexes + * AND we have augmented the contents, + * THEN append the new entries to the file. + */ + if ((pzIndexText != NULL) && (pzEndIndex != pzIndexEOF)) + update_db(); + + if (agPid != -1) + return awaitAutogen(); + + return EXIT_SUCCESS; +} + + +/* + * assignIndex + */ +static char* +assignIndex(char* pzOut, char* pzDef) +{ + char* pzMatch; + size_t len = strlen(pzDef); + int idx; + + /* + * Make the source text all lower case and map + * '-', '^' and '_' characters to '_'. + */ + strtransform(pzDef, pzDef); + + /* + * IF there is already an entry, + * THEN put the index into the output. + */ + pzMatch = strstr(pzIndexText, pzDef); + if (pzMatch != NULL) { + pzMatch += len; + while (isspace(*pzMatch)) pzMatch++; + while ((*pzOut++ = *pzMatch++) != ']') ; + return pzOut; + } + + /* + * We have a new entry. Make sure we have room for it + * in our in-memory string + */ + if (((pzEndIndex - pzIndexText) + len + 64 ) > indexAlloc) { + char* pz; + indexAlloc += 0x1FFF; + indexAlloc &= ~0x0FFF; + pz = (char*)realloc((void*)pzIndexText, indexAlloc); + if (pz == NULL) { + fputs("Realloc of index text failed\n", stderr); + exit(EXIT_FAILURE); + } + + /* + * IF the allocation moved, + * THEN adjust all our pointers. + */ + if (pz != pzIndexText) { + pzIndexEOF = pz + (pzIndexEOF - pzIndexText); + pzEndIndex = pz + (pzEndIndex - pzIndexText); + pzIndexText = pz; + } + } + + /* + * IF there are no data in our text database, + * THEN use default index. + */ + if (pzEndIndex == pzIndexText) + idx = OPT_VALUE_FIRST_INDEX; + else do { + char* pz = strrchr(pzDef, ' '); + *pz = NUL; + len = strlen(pzDef); + + /* + * Find the last entry for the current category of entries + */ + pzMatch = strstr(pzIndexText, pzDef); + if (pzMatch == NULL) { + /* + * No entries for this category. Use default index. + */ + idx = OPT_VALUE_FIRST_INDEX; + *pz = ' '; + break; + } + + for (;;) { + char* pzn = strstr(pzMatch + len, pzDef); + if (pzn == NULL) + break; + pzMatch = pzn; + } + + /* + * Skip forward to the '[' character and convert the + * number that follows to a long. + */ + *pz = ' '; + pzMatch = strchr(pzMatch + len, '['); + idx = strtol(pzMatch+1, (char**)NULL, 0)+1; + } while (false); + + /* + * Add the new entry to our text database and + * place a copy of the value into our output. + */ + pzEndIndex += sprintf(pzEndIndex, "%-40s [%d]\n", pzDef, idx); + pzOut += sprintf(pzOut, "[%d]", idx); + + return pzOut; +} + + +/* + * awaitAutogen + */ +static int +awaitAutogen(void) +{ + int status; + waitpid(agPid, &status, 0); + if (WIFEXITED(status)) { + status = WEXITSTATUS(status); + if (status != EXIT_SUCCESS) { + fprintf(stderr, "ERROR: %s exited with status %d\n", + pzAutogen, status); + } + return status; + } + + if (WIFSIGNALED( status )) { + status = WTERMSIG( status ); + fprintf(stderr, "ERROR: %s exited due to %d signal (%s)\n", + pzAutogen, status, strsignal(status)); + } + else + fprintf(stderr, "ERROR: %s exited due to unknown reason %d\n", + pzAutogen, status); + + return EXIT_FAILURE; +} + + +/* + * buildDefinition + */ +static void +buildDefinition(char * pzDef, char const * pzFile, int line, char * pzOut) +{ + static char const zSrcFile[] = " %s = '%s';\n"; + static char const zLineNum[] = " %s = '%d';\n"; + + bool these_are_global_defs; + tSuccess preamble; + int re_res; + char* pzNextDef = NULL; + regmatch_t match[2]; + + if (*pzDef == '*') { + these_are_global_defs = true; + strcpy(pzOut, zGlobal); + pzOut += sizeof(zGlobal)-1; + pzOut += sprintf(pzOut, zLineId, line, pzFile); + + pzDef = strchr(pzDef, '\n'); + preamble = PROBLEM; + + } else { + these_are_global_defs = false; + preamble = buildPreamble(&pzDef, &pzOut, pzFile, line); + if (FAILED(preamble)) { + *pzOut = NUL; + return; + } + } + + /* + * FOR each attribute for this entry, ... + */ + for (;;) { + /* + * Find the next attribute regular expression + */ + re_res = regexec(&attrib_re, pzDef, COUNT(match), match, 0); + switch (re_res) { + case 0: + /* + * NUL-terminate the current attribute. + * Set the "next" pointer to the start of the next attribute name. + */ + pzDef[ match[0].rm_so ] = NUL; + if (pzNextDef != NULL) + pzOut = emitDefinition(pzNextDef, pzOut); + pzNextDef = pzDef = pzDef + match[1].rm_so; + break; + + case REG_NOMATCH: + /* + * No more attributes. + */ + if (pzNextDef == NULL) { + *pzOut++ = '\n'; *pzOut++ = '#'; + sprintf(pzOut, zNoData, pzFile, line); + fputs(pzOut, stderr); + pzOut += strlen(pzOut); + return; + } + + pzOut = emitDefinition(pzNextDef, pzOut); + goto eachAttrDone; + break; + + default: + { + char zRER[ MAXNAMELEN ]; + static char const zErr[] = "error %d (%s) finding `%s' in\n%s\n\n"; + regerror(re_res, &attrib_re, zRER, sizeof(zRER)); + *pzOut++ = '\n'; + *pzOut++ = '#'; + sprintf(pzOut, zErr, re_res, zRER, zAttribRe, pzDef); + fprintf(stderr, "getdefs: %s", zErr); + return; + } + } + } eachAttrDone:; + + if (these_are_global_defs) { + *pzOut = NUL; + return; + } + + if (HAVE_OPT(COMMON_ASSIGN)) { + int ct = STACKCT_OPT(COMMON_ASSIGN); + char const ** ppz = STACKLST_OPT(COMMON_ASSIGN); + do { + pzOut += sprintf(pzOut, " %s;\n", *ppz++); + } while (--ct > 0); + } + + if (HAVE_OPT(SRCFILE)) + pzOut += sprintf(pzOut, zSrcFile, OPT_ARG(SRCFILE), pzFile); + + if (HAVE_OPT(LINENUM)) + pzOut += sprintf(pzOut, zLineNum, OPT_ARG(LINENUM), line); + + /* + * IF the preamble had a problem, it is because it could not + * emit the final "#endif\n" directive. Do that now. + */ + if (HADGLITCH(preamble)) + strcpy(pzOut, "};\n#endif\n"); + else strcpy(pzOut, "};\n"); +} + + +/* + * buildPreamble + */ +static tSuccess +buildPreamble(char ** ppzDef, char ** ppzOut, char const * pzFile, int line) +{ + char * pzDef = *ppzDef; + char * pzOut = *ppzOut; + + char zDefText[ MAXNAMELEN ]; + char * pzDefText = zDefText; + char zNameText[ MAXNAMELEN ]; + char * pzNameText = zNameText; + char * pzIfText = NULL; + + /* + * Copy out the name of the entry type + */ + *pzDefText++ = '`'; + while (isalnum(*pzDef) || (*pzDef == '_') || (*pzDef == '.') + || (*pzDef == '[') || (*pzDef == ']')) + *pzDefText++ = *pzDef++; + + *pzDefText = NUL; + + pzDef += strspn(pzDef, "* \t"); + + /* + * Copy out the name for this entry of the above entry type. + */ + while (isalnum(*pzDef) || (*pzDef == '_')) + *pzNameText++ = *pzDef++; + *pzNameText = NUL; + + if ( (zDefText[1] == NUL) + || (zNameText[0] == NUL) ) { + fprintf(stderr, zNoData, pzFile, line); + return FAILURE; + } + + pzDef += strspn(pzDef, " \t"); + + /* + * IF these names are followed by a comma and an "if" clause, + * THEN we emit the definition with "#if..."/"#endif" around it + */ + if (*pzDef == ',') { + pzDef += strspn(pzDef+1, " \t")+1; + if ((pzDef[0] == 'i') && (pzDef[1] == 'f')) + pzIfText = pzDef; + } + + pzDef = strchr(pzDef, '\n'); + if (pzDef == NULL) { + fprintf(stderr, zNoData, pzFile, line); + return FAILURE; + } + + *pzDef = NUL; + + /* + * Now start the output. First, the "#line" directive, + * then any "#ifdef..." line and finally put the + * entry type name into the output. + */ + pzOut += sprintf(pzOut, zLineId, line, pzFile); + if (pzIfText != NULL) + pzOut += sprintf(pzOut, "#%s\n", pzIfText); + { + char* pz = zDefText+1; + while (*pz != NUL) + *pzOut++ = *pz++; + } + + /* + * IF we are indexing the entries, + * THEN build the string by which we are indexing + * and insert the index into the output. + */ + if (pzIndexText != NULL) { + sprintf(pzDefText, " %s'", zNameText); + pzOut = assignIndex(pzOut, zDefText); + } + + /* + * Now insert the name with a consistent name string prefix + * that we use to locate the sort key later. + */ + pzOut += sprintf(pzOut, "%s%s';\n", zNameTag, zNameText); + *ppzOut = pzOut; + *ppzDef = pzDef; + *pzDef = '\n'; /* restore the newline. Used in pattern match */ + + /* + * Returning "PROBLEM" means the caller must emit the "#endif\n" + * at the end of the definition. + */ + return (pzIfText != NULL) ? PROBLEM : SUCCESS; +} + + +/* + * compar_defname + */ +static int +compar_defname(const void* p1, const void* p2) +{ + char const * pzS1 = *(char const * const *)p1; + char const * pz1 = strstr(pzS1, zNameTag); + char const * pzS2 = *(char const * const *)p2; + char const * pz2 = strstr(pzS2, zNameTag); + + if (pz1 == NULL) { + if (strncmp(*(char const * const *)p1, zGlobal, sizeof(zGlobal)-1) == 0) + return -1; + + die(zBogusDef, *(char const * const *)p1); + } + + if (pz2 == NULL) { + if (strncmp(*(char const * const *)p2, zGlobal, sizeof(zGlobal)-1) == 0) + return 1; + + die(zBogusDef, *(char const * const *)p2); + } + + /* + * Back up to the name of the definition + */ + while ((pz1 > pzS1) && (*--pz1 != '\n')) ; + while ((pz2 > pzS2) && (*--pz2 != '\n')) ; + + return strcmp(pz1, pz2); +} + + +/* + * compar_text + * + * merely returns the relative ordering of two input strings. + * The arguments are pointers to pointers to NUL-terminated strings. + * IF the definiton was mal-formed, an error message was printed + * earlier. When we get here, we wil fail to find the "zNameTag" + * string and EXIT_FAILURE. + */ +static int +compar_text(const void* p1, const void* p2) +{ + char* pz1 = strstr(*(char const * const *)p1, zNameTag); + char* pe1; + char* pz2 = strstr(*(char const * const *)p2, zNameTag); + char* pe2; + int res; + + if (pz1 == NULL) { + if (strncmp(*(char const * const *)p1, zGlobal, sizeof(zGlobal)-1) == 0) + return -1; + + die(zBogusDef, *(char const * const *)p1); + } + + if (pz2 == NULL) { + if (strncmp(*(char const * const *)p2, zGlobal, sizeof(zGlobal)-1) == 0) + return 1; + + die(zBogusDef, *(char const * const *)p2); + } + + pz1 += sizeof(zNameTag)-1; + pe1 = strchr(pz1, '\''); + + if (pe1 == NULL) + die(zBogusDef, *(char const * const *)p1); + + pz2 += sizeof(zNameTag)-1; + pe2 = strchr(pz2, '\''); + + if (pe2 == NULL) + die(zBogusDef, *(char const * const *)p2); + + *pe1 = *pe2 = NUL; + + /* + * We know ordering is enabled because we only get called when + * it is enabled. If the option was also specified, then + * we sort without case sensitivity (and we compare '-', '_' + * and '^' as being equal as well). Otherwise, we do a + * strict string comparison. + */ + if (HAVE_OPT(ORDERING)) + res = streqvcmp(pz1, pz2); + else res = strcmp(pz1, pz2); + *pe1 = *pe2 = '\''; + return res; +} + + +/* + * doPreamble + */ +static void +doPreamble(FILE* outFp) +{ + /* + * Emit the "autogen definitions xxx;" line + */ + fprintf(outFp, zAgDef, OPT_ARG(TEMPLATE)); + + if (HAVE_OPT(FILELIST)) { + static char const zFmt[] = "%-12s = '%s';\n"; + char const * pzName = OPT_ARG(FILELIST); + + if ((pzName == NULL) || (*pzName == NUL)) + pzName = "infile"; + + if (HAVE_OPT(INPUT)) { + int ct = STACKCT_OPT(INPUT); + char const ** ppz = STACKLST_OPT(INPUT); + + do { + fprintf(outFp, zFmt, pzName, *ppz++); + } while (--ct > 0); + } + + if (HAVE_OPT(COPY)) { + int ct = STACKCT_OPT(COPY); + char const ** ppz = STACKLST_OPT(COPY); + + do { + fprintf(outFp, zFmt, pzName, *ppz++); + } while (--ct > 0); + } + fputc('\n', outFp); + } + + /* + * IF there are COPY files to be included, + * THEN emit the '#include' directives + */ + if (HAVE_OPT(COPY)) { + int ct = STACKCT_OPT(COPY); + char const ** ppz = STACKLST_OPT(COPY); + do { + fprintf(outFp, "#include %s\n", *ppz++); + } while (--ct > 0); + fputc('\n', outFp); + } + + /* + * IF there are global assignments, then emit them + * (these do not get sorted, so we write directly now.) + */ + if (HAVE_OPT(ASSIGN)) { + int ct = STACKCT_OPT(ASSIGN); + char const ** ppz = STACKLST_OPT(ASSIGN); + do { + fprintf(outFp, "%s;\n", *ppz++); + } while (--ct > 0); + fputc('\n', outFp); + } +} + + +/* + * loadFile + */ +LOCAL char* +loadFile(char const * pzFname) +{ + FILE* fp = fopen(pzFname, "r" FOPEN_BINARY_FLAG); + int res; + char* pzText; + char* pzRead; + size_t rdsz; + + if (fp == (FILE*)NULL) + return NULL; + /* + * Find out how much data we need to read. + * And make sure we are reading a regular file. + */ + { + struct stat stb; + res = fstat(fileno(fp), &stb); + if (res != 0) + fserr_die("stat-ing %s\n", pzFname); + + if (! S_ISREG(stb.st_mode)) { + fprintf(stderr, "error file %s is not a regular file\n", + pzFname); + exit(EXIT_FAILURE); + } + rdsz = stb.st_size; + if (rdsz < 16) + die("Error file %s only contains %d bytes.\n" + "\tit cannot contain autogen definitions\n", + pzFname, (int)rdsz); + } + + /* + * Allocate the space we need for the ENTIRE file. + */ + pzRead = pzText = (char*)malloc(rdsz + 1); + if (pzText == NULL) + die("Error: could not allocate %d bytes\n", (int)rdsz + 1); + + /* + * Read as much as we can get until we have read the file. + */ + do { + size_t rdct = fread((void*)pzRead, (size_t)1, rdsz, fp); + + if (rdct == 0) + fserr_die("reading file %s\n", pzFname); + + pzRead += rdct; + rdsz -= rdct; + } while (rdsz > 0); + + *pzRead = NUL; + fclose(fp); + return pzText; +} + + +/* + * printEntries + */ +static void +printEntries(FILE* fp) +{ + int ct = blkUseCt; + char** ppz = papzBlocks; + + if (ct == 0) + exit(EXIT_FAILURE); + + for (;;) { + char* pz = *(ppz++); + fputs(pz, fp); + free((void*)pz); + if (--ct <= 0) + break; + fputc('\n', fp); + } + free((void*)papzBlocks); +} + + +/* + * processFile + */ +static void +processFile(char const * pzFile) +{ + char* pzText = loadFile(pzFile); /* full text */ + char* pzScan; /* Scanning Pointer */ + char* pzDef; /* Def block start */ + char* pzNext; /* start next search */ + char* pzDta; /* data value */ + int lineNo = 1; + char* pzOut; + regmatch_t matches[MAX_SUBMATCH+1]; + + if (pzText == NULL) + fserr_die("read opening %s\n", pzFile); + + processEmbeddedOptions(pzText); + pzNext = pzText; + + while (pzScan = pzNext, + regexec(&define_re, pzScan, COUNT(matches), matches, 0) == 0) { + + static char const zNoEnd[] = + "Error: definition in %s at line %d has no end\n"; + static char const zNoSubexp[] = + "Warning: entry type not found on line %d in %s:\n\t%s\n"; + + int linesInDef = 0; + + /* + * Make sure there is a subexpression match!! + */ + if (matches[1].rm_so == -1) { + char* pz = NULL; + char ch = NUL; + + pzDef = pzScan + matches[0].rm_so; + if (strlen(pzDef) > 30) { + pz = pzDef + 30; + ch = *pz; + *pz = NUL; + } + + fprintf(stderr, zNoSubexp, lineNo, pzFile, pzDef); + if (pz != NULL) + *pz = ch; + continue; + } + + pzDef = pzScan + matches[0].rm_so + sizeof("/*=") - 1; + pzNext = strstr(pzDef, "=*/"); + if (pzNext == NULL) + die(zNoEnd, pzFile, lineNo); + + *pzNext = NUL; + pzNext += 3; + /* + * Count the number of lines skipped to the start of the def. + */ + for (;;) { + pzScan = strchr(pzScan, '\n'); + if (pzScan++ == NULL) + break; + if (pzScan >= pzDef) + break; + lineNo++; + } + + pzOut = pzDta = (char*)malloc(2 * strlen(pzDef) + 8000); + + /* + * Count the number of lines in the definition itself. + * It will find and stop on the "=* /\n" line. + */ + pzScan = pzDef; + for (;;) { + pzScan = strchr(pzScan, '\n'); + if (pzScan++ == NULL) + break; + linesInDef++; + } + + /* + * OK. We are done figuring out where the boundaries of the + * definition are and where we will resume our processing. + */ + buildDefinition(pzDef, pzFile, lineNo, pzOut); + pzDta = (char*)realloc((void*)pzDta, strlen(pzDta) + 1); + lineNo += linesInDef; + + if (++blkUseCt > blkAllocCt) { + blkAllocCt += 32; + papzBlocks = (char**)realloc((void*)papzBlocks, + blkAllocCt * sizeof(char*)); + if (papzBlocks == (char**)NULL) + die("Realloc error for %d pointers\n", (int)blkAllocCt); + } + papzBlocks[ blkUseCt-1 ] = pzDta; + } + + free((void*)pzText); +} + + +/* + * set_first_idx + * + * Go through all our different kinds of defines. On the first occurrence + * of each different name, check for an index value. If not supplied, + * then insert ``[OPT_VALUE_FIRST_INDEX]'' after the object name. + */ +static void +set_first_idx(void) +{ + char zNm[ 128 ] = { NUL }; + int nmLn = 1; + int ct = blkUseCt; + char** ppz = papzBlocks; + + if (ct == 0) + exit(EXIT_FAILURE); + + for (; --ct >= 0; ppz++) { + char * pzOld = *ppz; + int changed = (strneqvcmp(pzOld, zNm, nmLn) != 0); + char * pzNew; + + /* + * IF the name still matches, then check the following character. + * If it is whitespace or an open bracket, then + * it's the old type. Continue to the next entry. + */ + if (! changed) { + if (isspace(pzOld[ nmLn ]) || (pzOld[nmLn] == '[')) + continue; + } + + pzNew = zNm; + nmLn = 0; + while (isalnum(*pzOld) + || (*pzOld == '_') || (*pzOld == '-') || (*pzOld == '^')) { + nmLn++; + *(pzNew++) = *(pzOld++); + } + *pzNew = NUL; + + /* + * IF the source has specified its own index, then do not + * supply our own new one. + */ + if (*pzOld != '[') { + pzNew = (char*)malloc(strlen(pzOld) + nmLn + 10); + sprintf(pzNew, "%s[%d]%s", zNm, + (int)OPT_VALUE_FIRST_INDEX, pzOld); + free((void*)(*ppz)); + *ppz = pzNew; + } + } +} + +static FILE* +open_ag_file(char ** pzBase) +{ + switch (WHICH_IDX_AUTOGEN) { + case INDEX_OPT_OUTPUT: + { + static char const zFileFmt[] = " * %s\n"; + FILE* fp; + + if (*pzBase != NULL) + free(*pzBase); + + if (strcmp(OPT_ARG(OUTPUT), "-") == 0) + return stdout; + + unlink(OPT_ARG(OUTPUT)); + fp = fopen(OPT_ARG(OUTPUT), "w" FOPEN_BINARY_FLAG); + fprintf(fp, zDne, OPT_ARG(OUTPUT)); + + if (HAVE_OPT(INPUT)) { + int ct = STACKCT_OPT(INPUT); + char const ** ppz = STACKLST_OPT(INPUT); + do { + fprintf(fp, zFileFmt, *ppz++); + } while (--ct > 0); + } + + fputs(" */\n", fp); + return fp; + } + + case INDEX_OPT_AUTOGEN: + if (! ENABLED_OPT(AUTOGEN)) { + if (*pzBase != NULL) + free(*pzBase); + + return stdout; + } + + if ( ( OPT_ARG(AUTOGEN) != NULL) + && (*OPT_ARG(AUTOGEN) != NUL )) + pzAutogen = OPT_ARG(AUTOGEN); + + break; + } + + return NULL; +} + +static FILE* +open_ag_proc_pipe(char ** pzBase) +{ + FILE * agFp; + + int pfd[2]; + + if (pipe(pfd) != 0) + fserr_die("creating pipe\n"); + + agPid = fork(); + + switch (agPid) { + case 0: + /* + * We are the child. Close the write end of the pipe + * and force STDIN to become the read end. + */ + close(pfd[1]); + if (dup2(pfd[0], STDIN_FILENO) != 0) + fserr_die("dup pipe[0]\n"); + break; + + case -1: + fserr_die("on fork()\n"); + + default: + /* + * We are the parent. Close the read end of the pipe + * and get a FILE* pointer for the write file descriptor + */ + close(pfd[0]); + agFp = fdopen(pfd[1], "w" FOPEN_BINARY_FLAG); + if (agFp == (FILE*)NULL) + fserr_die("fdopening pipe[1]\n"); + free(*pzBase); + return agFp; + } + + return NULL; +} + +static void +exec_autogen(char ** pzBase) +{ + char const ** paparg; + char const ** pparg; + int argCt = 5; + + /* + * IF we don't have template search directories, + * THEN allocate the default arg counter of pointers and + * set the program name into it. + * ELSE insert each one into the arg list. + */ + if (! HAVE_OPT(AGARG)) { + paparg = pparg = (char const **)malloc(argCt * sizeof(char*)); + *pparg++ = pzAutogen; + + } else { + int ct = STACKCT_OPT(AGARG); + char const ** ppz = STACKLST_OPT(AGARG); + + argCt += ct; + paparg = pparg = (char const **)malloc(argCt * sizeof(char*)); + *pparg++ = pzAutogen; + + do { + *pparg++ = *ppz++; + } while (--ct > 0); + } + + *pparg++ = *pzBase; + *pparg++ = "--"; + *pparg++ = "-"; + *pparg++ = NULL; + +#ifdef DEBUG + fputc('\n', stderr); + pparg = paparg; + for (;;) { + fputs(*pparg++, stderr); + if (*pparg == NULL) + break; + fputc(' ', stderr); + } + fputc('\n', stderr); + fputc('\n', stderr); +#endif + + execvp(pzAutogen, (char**)(void*)paparg); + fserr_die("exec of %s %s %s %s\n", paparg[0], paparg[1], paparg[2], + paparg[3]); +} + +/* + * startAutogen + */ +static FILE* +startAutogen(void) +{ + char* pz; + FILE* agFp; + char* pzBase = NULL; + + /* + * Compute the base name. + * + * If an argument was specified, use that without question. + * IF a definition pattern is supplied, and it looks like + * a normal name, then use that. + * If neither of these work, then use the current directory name. + */ + if (HAVE_OPT(BASE_NAME)) { + pzBase = malloc(strlen(OPT_ARG(BASE_NAME)) + 3); + strcpy(pzBase, "-b"); + strcpy(pzBase+2, OPT_ARG(BASE_NAME)); + } + else { + /* + * IF we have a definition name pattern, + * THEN copy the leading part that consists of name-like characters. + */ + if (HAVE_OPT(DEFS_TO_GET)) { + char const * pzS = OPT_ARG(DEFS_TO_GET); + pzBase = malloc(strlen(pzS) + 3); + strcpy(pzBase, "-b"); + + pz = pzBase + 2; + while (isalnum(*pzS) || (*pzS == '_')) + *pz++ = *pzS++; + if (pz == pzBase + 2) { + free(pzBase); + pzBase = NULL; + } + else + *pz = NUL; + } + + /* + * IF no pattern or it does not look like a name, ... + */ + if (pzBase == NULL) { + char zSrch[ MAXPATHLEN ]; + if (getcwd(zSrch, sizeof(zSrch)) == NULL) + fserr_die("on getcwd\n"); + + pz = strrchr(zSrch, '/'); + if (pz == NULL) + pz = zSrch; + else pz++; + pzBase = malloc(strlen(pz) + 3); + strcpy(pzBase, "-b"); + strcpy(pzBase+2, pz); + } + } + + /* + * For our template name, we take the argument (if supplied). + * If not, then whatever we decided our base name was will also + * be our template name. + */ + if (! HAVE_OPT(TEMPLATE)) + SET_OPT_TEMPLATE(strdup(pzBase+2)); + + /* + * Now, what kind of output have we? + * If it is a file, open it up and return. + * If it is an alternate autogen program, + * then set it to whatever the argument said it was. + * If the option was not supplied, we default to + * whatever we set the "pzAutogen" pointer to above. + */ + if (HAVE_OPT(AUTOGEN)) { + agFp = open_ag_file(&pzBase); + if (agFp != NULL) + return agFp; + } + + agFp = open_ag_proc_pipe(&pzBase); + if (agFp != NULL) + return agFp; + + exec_autogen(&pzBase); + return (FILE*)NULL; +} + + +/* + * update_db + */ +static void +update_db(void) +{ + FILE* fp; + + if (chmod(OPT_ARG(ORDERING), 0666) == 0) { + fp = fopen(OPT_ARG(ORDERING), "a" FOPEN_BINARY_FLAG); + + } else { + unlink(OPT_ARG(ORDERING)); + fp = fopen(OPT_ARG(ORDERING), "w" FOPEN_BINARY_FLAG); + pzIndexEOF = pzIndexText; + } + + if (fp == (FILE*)NULL) + fserr_die("opening %s for write/append\n", OPT_ARG(ORDERING)); + + fwrite(pzIndexEOF, (size_t)(pzEndIndex - pzIndexEOF), (size_t)1, fp); +#ifdef HAVE_FCHMOD + fchmod(fileno(fp), 0444); + fclose(fp); +#else + fclose(fp); + chmod(OPT_ARG(ORDERING), 0444); +#endif +} + +/* emacs + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of getdefs/getdefs.c */ diff --git a/getdefs/getdefs.h b/getdefs/getdefs.h new file mode 100644 index 0000000..890551b --- /dev/null +++ b/getdefs/getdefs.h @@ -0,0 +1,120 @@ +/* -*- Mode: C -*- + * + * getdefs Copyright (c) 1999-2012 by Bruce Korb - all rights reserved + * + * Time-stamp: "2012-02-28 19:45:07 bkorb" + * Author: Bruce Korb <bkorb@gnu.org> + * + * This file is part of AutoGen. + * AutoGen copyright (c) 1992-2012 by Bruce Korb - all rights reserved + * + * AutoGen 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. + * + * AutoGen 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/>. + */ + +#ifndef GETDEFS_HEADER +#define GETDEFS_HEADER + +#include <sys/wait.h> +#include <utime.h> +#include <stdarg.h> + +#include REGEX_HEADER +#include "ag-char-map.h" +#include "opts.h" + +#define EXPORT +#define MAXNAMELEN 256 +#define MAX_SUBMATCH 1 +#define COUNT(a) (sizeof(a)/sizeof(a[0])) +#define MARK_CHAR ':' + +#define AG_NAME_CHAR(c) (zUserNameCh[(unsigned)(c)] & 2) +#define USER_NAME_CH(c) (zUserNameCh[(unsigned)(c)] & 1) +char zUserNameCh[ 256 ] = { '\0' }; + +/* + * Index database string pointers. + */ +char* pzIndexText = NULL; /* all the text */ +char* pzEndIndex = NULL; /* end of current */ +char* pzIndexEOF = NULL; /* end of file */ +size_t indexAlloc = 0; /* allocation size */ + +/* + * Name of program to process output (normally ``autogen'') + */ +tCC* pzAutogen = "autogen"; + +/* + * const global strings + */ +#define DEF_STRING(n,s) char const n[] = s +DEF_STRING( zGlobal, "\n/* GLOBALDEFS */\n" ); +DEF_STRING( zLineId, "\n#line %d \"%s\"\n" ); +DEF_STRING( zMallocErr, "Error: could not allocate %d bytes for %s\n" ); +DEF_STRING( zAttribRe, "\n[^*\n]*\\*[ \t]*([a-z][a-z0-9_-]*):"); +DEF_STRING( zNameTag, " = {\n name = '" ); +DEF_STRING( zMemberLine, " member = " ); +DEF_STRING( zNoData, "error no data for definition in file %s line %d\n" ); +DEF_STRING( zAgDef, "autogen definitions %s;\n"); +DEF_STRING( zDne, + "/* -*- buffer-read-only: t -*- vi: set ro:\n *\n" + " *\n * DO NOT EDIT THIS FILE (%s)\n *\n" + " * It has been extracted by getdefs from the following files:\n" + " *\n" ); + +/* + * ptr to zero (NUL) terminated definition pattern string. + * + * The pattern we look for starts with the three characters + * '/', '*' and '=' and is followed by two names: + * the name of a group and the name of the entry within the group. + * + * The patterns we accept for output may specify a particular group, + * certain members within certain groups or all members of all groups + */ +regex_t define_re; +regex_t attrib_re; + +/* + * The output file pointer. It may be "stdout". + * It gets closed when we are done. + */ +FILE * evtFp = (FILE*)NULL; + +/* + * The output file modification time. Only used if we + * have specified a real file for output (not stdout). + */ +time_t modtime = 0; + +/* + * The array of pointers to the output blocks. + * We build them first, then sort them, then print them out. + */ +char** papzBlocks = (char**)NULL; +size_t blkUseCt = 0; +size_t blkAllocCt = 0; +pid_t agPid = -1; + +#define LOCAL static +#endif /* GETDEFS_HEADER */ + +/* emacs + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of getdefs/getdefs.h */ diff --git a/getdefs/opts.def b/getdefs/opts.def new file mode 100644 index 0000000..4909a91 --- /dev/null +++ b/getdefs/opts.def @@ -0,0 +1,466 @@ +/* -*- Mode: conf -*- */ + +autogen definitions options; + +/* + * This file is part of AutoGen. + * AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved + * + * AutoGen 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. + * + * AutoGen 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/>. + */ + +copyright = { + date = "1999-2012"; + type = gpl; + owner = "Bruce Korb"; + eaddr = 'autogen-users@lists.sourceforge.net'; +}; + +prog-name = "getdefs"; +prog-title = "AutoGen Definition Extraction Tool"; +package = 'GNU AutoGen'; +version = "1.5"; +homerc = /dev/null; +explain = <<- EndExplanation + If no @code{input} argument is provided or is set to simply "-", and if + @code{stdin} is not a @code{tty}, then the list of input files will be + read from @code{stdin}. + EndExplanation; +guard-option-names; + +flag = { + name = def-selection; + documentation; + descrip = 'Specify which definitions are of interest and ' + 'what to say about them'; +}; + +flag = { + name = "defs_to_get"; + arg-type = string; + arg-name = reg-ex; + descrip = 'Regexp to look for after the "/*="'; + doc = <<- _EOF_ + If you want definitions only from a particular category, or even + with names matching particular patterns, then specify this regular + expression for the text that must follow the @code{/*=}. + _EOF_; // */ +}; + +flag = { + name = subblock; + arg-type = string; + arg-name = sub-def; + max = NOLIMIT; + stack_arg; + descrip = "subblock definition names"; + doc = <<- _EOF_ + This option is used to create shorthand entries for nested definitions. + For example, with: + @table @r + @item using subblock thus + @code{--subblock=arg=argname,type,null} + @item and defining an @code{arg} thus + @code{arg: this, char *} + @item will then expand to: + @code{arg = @{ argname = this; type = "char *"; @};} + @end table + The "this, char *" string is separated at the commas, with the + white space removed. You may use characters other than commas by + starting the value string with a punctuation character other than + a single or double quote character. You may also omit intermediate + values by placing the commas next to each other with no intervening + white space. For example, "+mumble++yes+" will expand to: + @* + @code{arg = @{ argname = mumble; null = "yes"; @};}. + _EOF_; +}; + +flag = { + name = listattr; + arg-type = string; + arg-name = def; + max = NOLIMIT; + stack_arg; + descrip = "attribute with list of values"; + doc = <<- _EOF_ + This option is used to create shorthand entries for definitions + that generally appear several times. That is, they tend to be + a list of values. For example, with: + @* + @code{listattr=foo} defined, the text: + @* + @code{foo: this, is, a, multi-list} will then expand to: + @* + @code{foo = 'this', 'is', 'a', 'multi-list';} + @* + The texts are separated by the commas, with the + white space removed. You may use characters other than commas by + starting the value string with a punctuation character other than + a single or double quote character. + _EOF_; +}; + +flag = { + name = enumerating; + documentation; + descrip = 'specify how to number the definitions'; +}; + +flag = { + name = ordering; + arg-type = string; + arg-optional; + arg-name = file-name; + disable = no; + enabled; + descrip = "Alphabetize or use named file"; + doc = <<- _EOF_ + By default, ordering is alphabetical by the entry name. Use, + @code{no-ordering} if order is unimportant. Use @code{ordering} + with no argument to order without case sensitivity. Use + @code{ordering=<file-name>} if chronological order is important. + getdefs will maintain the text content of @code{file-name}. + @code{file-name} need not exist. + _EOF_; +}; + +flag = { + name = first_index; + arg_type = number; + arg-default = 0; + arg-name = first-index; + descrip = "The first index to apply to groups"; + doc = <<- _EOF_ + By default, the first occurrence of a named definition will have an + index of zero. Sometimes, that needs to be a reserved value. Provide + this option to specify a different starting point. + _EOF_; +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Definition Insertion Options: + */ +flag = { + name = doc_insert; + descrip = "Definition insertion options"; + documentation; +}; + +flag = { + name = filelist; + arg-type = string; + arg-optional; + arg-name = file; + descrip = "Insert source file names into defs"; + doc = <<- _EOF_ + Inserts the name of each input file into the output definitions. + If no argument is supplied, the format will be: + @example + infile = '%s'; + @end example + If an argument is supplied, that string will be used for the entry + name instead of @var{infile}. + _EOF_; +}; + +flag = { + name = assign; + arg-type = string; + arg-name = ag-def; + max = NOLIMIT; + stack_arg; + descrip = "Global assignments"; + doc = <<- _EOF_ + The argument to each copy of this option will be inserted into + the output definitions, with only a semicolon attached. + _EOF_; + +}; + +flag = { + name = common_assign; + arg-type = string; + arg-name = ag-def; + max = NOLIMIT; + stack_arg; + descrip = "Assignments common to all blocks"; + doc = <<- _EOF_ + The argument to each copy of this option will be inserted into + each output definition, with only a semicolon attached. + _EOF_; + +}; + +flag = { + name = copy; + arg-type = string; + arg-name = file; + max = NOLIMIT; + stack_arg; + descrip = "File(s) to copy into definitions"; + doc = <<- _EOF_ + The content of each file named by these options will be inserted into + the output definitions. + _EOF_; + +}; + +flag = { + name = srcfile; + arg-type = string; + arg-optional; + arg-name = file; + descrip = "Insert source file name into each def"; + doc = <<- _EOF_ + Inserts the name of the input file where a definition was found + into the output definition. + If no argument is supplied, the format will be: + @example + srcfile = '%s'; + @end example + If an argument is supplied, that string will be used for the entry + name instead of @var{srcfile}. + _EOF_; + +}; + +flag = { + name = linenum; + arg-type = string; + arg-optional; + arg-name = def-name; + descrip = "Insert source line number into each def"; + doc = <<- _EOF_ + Inserts the line number in the input file where a definition + was found into the output definition. + If no argument is supplied, the format will be: + @example + linenum = '%s'; + @end example + If an argument is supplied, that string will be used for the entry + name instead of @var{linenum}. + _EOF_; + +}; + +flag = { + name = input-files; + documentation; + descrip = 'specify which files to search for markers'; +}; + +flag = { + name = input; + arg-type = string; + arg-name = src-file; + max = NOLIMIT; + settable; + stack_arg; + default; + descrip = "Input file to search for defs"; + + doc = <<- _EOF_ + All files that are to be searched for definitions must be named on + the command line or read from @code{stdin}. If there is only one + @code{input} option and it is the string, "-", then the input file + list is read from @code{stdin}. If a command line argument is not + an option name and does not contain an assignment operator + (@code{=}), then it defaults to being an input file name. + At least one input file must be specified. + _EOF_; +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Definition Output Disposition Options: + */ +flag = { + name = doc_output; + descrip = "Definition output disposition options:"; + documentation; +}; + +flag = { + name = output; + equivalence = "autogen"; + arg-type = string; + arg-name = file; + descrip = "Output file to open"; + doc = <<- _EOF_ + If you are not sending the output to an AutoGen process, + you may name an output file instead. + _EOF_; + +}; + +flag = { + name = "autogen"; + equivalence = "autogen"; + arg-type = string; + arg-optional; + arg-name = ag-cmd; + disable = "no"; + enabled; + descrip = "Invoke AutoGen with defs"; + doc = <<- _EOF_ + This is the default output mode. Specifying @code{no-autogen} is + equivalent to @code{output=-}. If you supply an argument to this + option, that program will be started as if it were AutoGen and + its standard in will be set to the output definitions of this program. + _EOF_; + +}; + +flag = { + name = template; + arg-type = string; + arg-name = file; + settable; + descrip = "Template Name"; + doc = + "Specifies the template name to be used for generating the final output."; +}; + +flag = { + name = agarg; + arg-type = string; + arg-name = ag-opt; + max = NOLIMIT; + stack_arg; + descrip = "AutoGen Argument"; + flags_cant = output; + doc = <<- _EOF_ + This is a pass-through argument. It allows you to specify any + arbitrary argument to be passed to AutoGen. + _EOF_; + +}; + +flag = { + name = base_name; + arg-type = string; + arg-name = name; + descrip = "Base name for output file(s)"; + flags_cant = output; + doc = <<- _EOF_ + When output is going to AutoGen, a base name must either be supplied + or derived. If this option is not supplied, then it is taken from + the @code{template} option. If that is not provided either, then + it is set to the base name of the current directory. + _EOF_; + +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Program Documentation + */ + +/* * * * * MAN PAGE DESCRIPTION * * * * * * * * * * * * * * * * * * * */ + +doc-section = { + ds-type = "SEE ALSO"; + ds-format = texi; + ds-text = <<- _EndOfMan_ + This program is documented more fully in the Getdefs section + of the Add-On chapter in the @code{AutoGen} Info system documentation. + _EndOfMan_; +}; + +/* * * * * DOC DESCRIPTION * * * * * * * * * * * * * * * * * * * */ + +option-doc-format = texi; + +detail = <<- _EOF_ + This program extracts AutoGen definitions from a list of source files. + Definitions are delimited by @code{/*=<entry-type> <entry-name>\n} and + @code{=*/\n}. + _EOF_; + +prog-descrip = <<_EOF_ +This program extracts AutoGen definitions from a list of source files. +Definitions are delimited by @code{/*=<entry-type> <entry-name>\n} and +@code{=*/\n}. From that, this program creates a definition of the following +form: + +@example + #line nnn "source-file-name" + entry_type = @{ + name = entry_name; + ... + @}; +@end example + +@enumerate +@item +The ellipsis @code{...} is filled in by text found between the two +delimiters. Each line of text is stripped of anything before the first +asterisk, then leading asterisks, then any leading or trailing white space. + +@item +If what is left starts with what looks like a name followed by a colon, then +it is interpreted as a name followed by a value. + +@item +If the first character of the value is either a single or double quote, then +you are responsible for quoting the text as it gets inserted into the output +definitions. So, if you want whitespace at the beginnings of the lines of +text, you must do something like this: + +@example + * mumble: + * " this is some\n" + * " indented text." +@end example + +@item +If the @code{<entry-name>} is followed by a comma, the word @code{ifdef} (or +@code{ifndef}) and a name @code{if_name}, then the above entry will be under +@code{ifdef} control. + +@example +/*=group entry_name, ifdef FOO + * attr: attribute value +=*/ +@end example + +Will produce the following: + +@example +#ifdef FOO +#line nnn "source-file-name" +group = @{ + name = entry_name; + attr = 'attribute value'; +@}; +#endif +@end example + +@item +If you use of the @code{subblock} option, you can specify a nested +value, @xref{getdefs subblock}. That is, this text: + +@example + * arg: int, this, what-it-is +@end example + +with the @code{--subblock=arg=type,name,doc} option would yield: + +@example +arg = @{ type = int; name = this; doc = what-it-is; @}; +@end example +@end enumerate +_EOF_; diff --git a/getdefs/proto.h b/getdefs/proto.h new file mode 100644 index 0000000..ce968a2 --- /dev/null +++ b/getdefs/proto.h @@ -0,0 +1,46 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * Prototypes for getdefs + * Generated Sat Aug 11 09:41:49 PDT 2012 + */ +#ifndef GETDEFS_PROTO_H_GUARD +#define GETDEFS_PROTO_H_GUARD 1 + +#ifndef LOCAL +# define LOCAL extern +# define REDEF_LOCAL 1 +#else +# undef REDEF_LOCAL +#endif +/* + * Extracted from gdemit.c + */ +LOCAL char* +emitDefinition(char* pzDef, char* pzOut); + +/* + * Extracted from gdinit.c + */ +LOCAL void +die(char const * fmt, ...); + +LOCAL void +fserr_die(char const * fmt, ...); + +LOCAL void +processEmbeddedOptions(char* pzText); + +LOCAL void +validateOptions(void); + +/* + * Extracted from getdefs.c + */ +LOCAL char* +loadFile(char const * pzFname); + +#ifdef REDEF_LOCAL +# undef LOCAL +# define LOCAL +#endif +#endif /* GETDEFS_PROTO_H_GUARD */ diff --git a/getdefs/test/Makefile.am b/getdefs/test/Makefile.am new file mode 100644 index 0000000..39b97f8 --- /dev/null +++ b/getdefs/test/Makefile.am @@ -0,0 +1,41 @@ +## -*- Mode: Makefile -*- +## +## Makefile.am -- process this file with automake to produce Makefile.in +## +## Author: Bruce Korb <bkorb@gnu.org> +## Time-stamp: "2010-07-18 09:05:44 bkorb" +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +TESTS = cfg.test index.test option.test subblock.test +EXTRA_DIST = defs $(TESTS) +testsubdir = ./testdir + +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) \ + testsubdir=$(testsubdir) srcdir=$(srcdir) \ + GDexe=$(GDexe) AGexe=$(AGexe) CLexe=$(CLexe) + +distclean-local: + -rm -rf $(testsubdir) FAILURES + +check : perm-stamp + +$(TESTS) : perm-stamp + +perm-stamp : + cd $(srcdir) ; chmod +x *.test + +# Makefile.am ends here diff --git a/getdefs/test/Makefile.in b/getdefs/test/Makefile.in new file mode 100644 index 0000000..9a8c02e --- /dev/null +++ b/getdefs/test/Makefile.in @@ -0,0 +1,551 @@ +# Makefile.in generated by automake 1.12.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = getdefs/test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/config/ag_macros.m4 \ + $(top_srcdir)/config/extensions.m4 \ + $(top_srcdir)/config/libopts.m4 \ + $(top_srcdir)/config/libtool.m4 \ + $(top_srcdir)/config/ltoptions.m4 \ + $(top_srcdir)/config/ltsugar.m4 \ + $(top_srcdir)/config/ltversion.m4 \ + $(top_srcdir)/config/lt~obsolete.m4 \ + $(top_srcdir)/config/onceonly.m4 \ + $(top_srcdir)/config/snprintfv.m4 \ + $(top_srcdir)/config/unlocked-io.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = $(am__tty_colors_dummy) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AGEN5_TESTS = @AGEN5_TESTS@ +AG_GUILE = @AG_GUILE@ +AG_LDFLAGS = @AG_LDFLAGS@ +AG_MAJOR_VERSION = @AG_MAJOR_VERSION@ +AG_MINOR_VERSION = @AG_MINOR_VERSION@ +AG_TIMEOUT = @AG_TIMEOUT@ +AG_VERSION = @AG_VERSION@ +AG_XML2 = @AG_XML2@ +AGexe = @AGexe@ +AGnam = @AGnam@ +AMTAR = @AMTAR@ +AO_AGE = @AO_AGE@ +AO_CURRENT = @AO_CURRENT@ +AO_REVISION = @AO_REVISION@ +AO_TEMPLATE_VERSION = @AO_TEMPLATE_VERSION@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CLexe = @CLexe@ +CLnam = @CLnam@ +CONFIG_SHELL = @CONFIG_SHELL@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUG_ENABLED = @DEBUG_ENABLED@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DYNAMIC_AG = @DYNAMIC_AG@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_STATIC = @ENABLE_STATIC@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDexe = @GDexe@ +GDnam = @GDnam@ +GO_AGE = @GO_AGE@ +GO_CURRENT = @GO_CURRENT@ +GO_REVISION = @GO_REVISION@ +GREP = @GREP@ +GUILE_VERSION = @GUILE_VERSION@ +INCLIST = @INCLIST@ +INCSNPRINTFV = @INCSNPRINTFV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBGUILE_CFLAGS = @LIBGUILE_CFLAGS@ +LIBGUILE_LIBS = @LIBGUILE_LIBS@ +LIBGUILE_PATH = @LIBGUILE_PATH@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSNPRINTFV = @LIBSNPRINTFV@ +LIBTOOL = @LIBTOOL@ +LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ +LIBXML2_LIBS = @LIBXML2_LIBS@ +LIBXML2_PATH = @LIBXML2_PATH@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +M4_SRC = @M4_SRC@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPTS_TESTDIR = @OPTS_TESTDIR@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSIX_SHELL = @POSIX_SHELL@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEXI2HTML = @TEXI2HTML@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_aux_dir = @ac_aux_dir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +TESTS = cfg.test index.test option.test subblock.test +EXTRA_DIST = defs $(TESTS) +testsubdir = ./testdir +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) \ + testsubdir=$(testsubdir) srcdir=$(srcdir) \ + GDexe=$(GDexe) AGexe=$(AGexe) CLexe=$(CLexe) + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu getdefs/test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu getdefs/test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +cscope cscopelist: + + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool distclean distclean-generic distclean-libtool \ + distclean-local distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +distclean-local: + -rm -rf $(testsubdir) FAILURES + +check : perm-stamp + +$(TESTS) : perm-stamp + +perm-stamp : + cd $(srcdir) ; chmod +x *.test + +# Makefile.am ends here + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/getdefs/test/cfg.test b/getdefs/test/cfg.test new file mode 100755 index 0000000..1fb6fb0 --- /dev/null +++ b/getdefs/test/cfg.test @@ -0,0 +1,115 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# cfg.test --- test config file processing +# +## Time-stamp: "2011-02-02 12:03:18 bkorb" +## Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +if test -z "$srcdir"; then + srcdir=`echo "$0" | ${SED} 's,[^/]*$,,'` + test -z "$srcdir" && srcdir=. + test "$srcdir" = "$0" && srcdir=. + test "${VERBOSE+set}" != set && VERBOSE=1 +fi +. $srcdir/defs + +# Create the files we need in the test environment +cat > ${testname}.c <<- _EOSource_ + + /*=* global + * + * test: subblock + * doc: we want to see + * just what happens + =*/ + + /*=gfunc in_p + * + * exparg: test-string , string to look for + + arg-name + arg-desc + arg-opt + arg-list + + * exparg: @ string-list @ list of strings to check,, @@ list + * + * opt: 1 + * doc: + * Return SCM_BOOL_T if the first argument is duplicated + * in the second (list) argument. + =*/ + SCM + ag_scm_in_p( SCM obj, SCM list ) + { + } + _EOSource_ + +cat > ${testname}.cfg <<- _EOCfg_ + output ${testname}.out + common-assign stumble = grumble + assign mumble = stumble ; mumble = grumble + template test${testname} + subblock exparg=arg_name,arg_desc,arg_optional,arg_list + _EOCfg_ + +cat > ${testname}.test <<- _EOTestOut_ + /* -*- buffer-read-only: t -*- vi: set ro: + * + * + * DO NOT EDIT THIS FILE (cfg.out) + * + * It has been extracted by getdefs from the following files: + * + * cfg.c + */ + autogen definitions testcfg; + mumble = stumble ; mumble = grumble; + + + /* GLOBALDEFS */ + + #line 2 "cfg.c" + test = 'subblock'; + doc = 'we want to see + just what happens'; + + + #line 9 "cfg.c" + gfunc = { + name = 'in_p'; + exparg = { + arg_name = 'test-string'; + arg_desc = 'string to look for'; + }; + exparg = { + arg_name = 'string-list'; + arg_desc = 'list of strings to check,,'; + arg_list = 'list'; + }; + opt = '1'; + doc = + 'Return SCM_BOOL_T if the first argument is duplicated + in the second (list) argument.'; + stumble = grumble; + }; + _EOTestOut_ + +set -x +${GDexe} load=${testname}.cfg ${testname}.c || \ + failure running ${GDexe} +cmp -s ${testname}.test ${testname}.out || \ + failure "`diff ${testname}.test ${testname}.out`" + +# cfg.test ends here diff --git a/getdefs/test/defs b/getdefs/test/defs new file mode 100644 index 0000000..000590b --- /dev/null +++ b/getdefs/test/defs @@ -0,0 +1,86 @@ +#! /bin/echo this_file_should_be_sourced,_not_executed +# -*- Mode: Shell-script -*- +# +# defs --- define the environment for autogen tests. +# +# Author: Bruce Korb <bkorb@gnu.org> +# Time-stamp: "2011-02-02 12:04:19 bkorb" +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +# Make sure srcdir is an absolute path. Supply the variable +# if it does not exist. We want to be able to run the tests +# stand-alone!! +# +srcdir=${srcdir-.} +if test ! -d $srcdir ; then + echo "defs: installation error" 1>&2 + exit 1 +fi + +# IF the source directory is a Unix or a DOS root directory, ... +# +case "$srcdir" in + /* | [A-Za-z]:\\*) ;; + *) srcdir=`\cd $srcdir && pwd` ;; +esac + +lo_dir=`cd ../../autoopts && pwd` +test -d ${lo_dir}/.libs && lo_dir=${lo_dir}/.libs +LD_LIBRARY_PATH=${lo_dir}:${LD_LIBRARY_PATH-/dev/null} +export LD_LIBRARY_PATH + +for SED in `exec 2>/dev/null;which gsed` \ + /bin/xpg4/bin/sed \ + `which sed` \ + /bin/sed \ + /usr/bin/sed +do test -x "${SED}" && break ; done + +progname=`echo "$0" | ${SED} 's,^.*/,,'` +testname=`echo "$progname" | ${SED} 's,\..*$,,'` +testsubdir=${testsubdir-testdir} + +# User can set VERBOSE to prevent output redirection +case x$VERBOSE in + xNO | xno | x0 | x) + exec > /dev/null 2>&1 + rm -rf $testsubdir + ;; +esac + +test -d $testsubdir || mkdir $testsubdir +cd $testsubdir +if test $? != 0 ; then + echo "Cannot make or change into $testsubdir" + exit 1 +fi + +echo "=== Running $progname" + +# A standard failure function +failure() +{ + cd ${testsubdir} + test -d ../FAILURES || mkdir ../FAILURES + l=`echo *` + ( \cd ../FAILURES ; rm -f $l ) + mv -f * ../FAILURES + echo "$*" + exit 1 +} +# defs ends here diff --git a/getdefs/test/index.test b/getdefs/test/index.test new file mode 100755 index 0000000..35ad971 --- /dev/null +++ b/getdefs/test/index.test @@ -0,0 +1,130 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# subblock.test --- test the subblock parameter to getdefs +# +# Author: Bruce Korb <bkorb@gnu.org> +# Time-stamp: "2011-02-02 12:04:37 bkorb" +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +# Common definitions +if test -z "$srcdir"; then + srcdir=`echo "$0" | ${SED} 's,[^/]*$,,'` + test -z "$srcdir" && srcdir=. + test "$srcdir" = "$0" && srcdir=. + test "${VERBOSE+set}" != set && VERBOSE=1 +fi +. $srcdir/defs + + +# Create the files we need in the test environment +cat > ${testname}.c <<EOF +/*=--subblock=exparg=arg_name,arg_desc,arg_optional,arg_list=*/ +/*=--listattr=foo=*/ + +/*=gfunc xtract + * + * what: extract text from another file + * general_use: + * exparg: file-name, name of file with text + * exparg: marker-fmt, format for marker text + * exparg: caveat, warn about changing marker, opt + * exparg: default, default initial text, opt +=*/ + +/*=gfunc[2] in_p + * + * exparg: test-string , string to look for + + arg-name + arg-desc + arg-opt + arg-list + + * exparg: @ string-list @ list of strings to check,, @@ list + * + * opt: 1 + * doc: Return SCM_BOOL_T if the first argument is duplicated + * in the second (list) argument. + * foo: + bar ++ baz + +=*/ + SCM +ag_scm_in_p( SCM obj, SCM list ) +{ +} +EOF + +cat > ${testname}.test <<_EOF_ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * + * DO NOT EDIT THIS FILE (index.out) + * + * It has been extracted by getdefs from the following files: + * + * index.c + */ +autogen definitions testdir; + +#line 14 "index.c" +gfunc[2] = { + name = 'in_p'; + exparg = { + arg_name = 'test-string'; + arg_desc = 'string to look for'; + }; + exparg = { + arg_name = 'string-list'; + arg_desc = 'list of strings to check,,'; + arg_list = 'list'; + }; + opt = '1'; + doc = 'Return SCM_BOOL_T if the first argument is duplicated +in the second (list) argument.'; + foo = 'bar','','baz'; +}; + + +#line 4 "index.c" +gfunc = { + name = 'xtract'; + what = 'extract text from another file'; + general_use; + exparg = { + arg_name = 'file-name'; + arg_desc = 'name of file with text'; + }; + exparg = { + arg_name = 'marker-fmt'; + arg_desc = 'format for marker text'; + }; + exparg = { + arg_name = 'caveat'; + arg_desc = 'warn about changing marker'; + arg_optional = 'opt'; + }; + exparg = { + arg_name = 'default'; + arg_desc = 'default initial text'; + arg_optional = 'opt'; + }; +}; +_EOF_ + +set -x +${GDexe} output=$testname.out $testname.c || \ + failure running ${GDexe} +cmp -s $testname.test $testname.out || \ + failure "`diff $testname.test $testname.out`" + +# subblock.test ends here diff --git a/getdefs/test/option.test b/getdefs/test/option.test new file mode 100755 index 0000000..83c438c --- /dev/null +++ b/getdefs/test/option.test @@ -0,0 +1,107 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# option.test --- test option extraction +# +# Author: Bruce Korb <bkorb@gnu.org> +# Time-stamp: "2011-02-02 12:04:43 bkorb" +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +# Common definitions +if test -z "$srcdir"; then + srcdir=`echo "$0" | ${SED} 's,[^/]*$,,'` + test -z "$srcdir" && srcdir=. + test "$srcdir" = "$0" && srcdir=. + test "${VERBOSE+set}" != set && VERBOSE=1 +fi +. $srcdir/defs + +# Create the files we need in the test environment +cat > ${testname}.c <<EOF + +/*=* global + * + * test: subblock + * doc: we want to see + * just what happens +=*/ + +/*=--subblock=exparg=arg_name,arg_desc,arg_optional,arg_list=*/ + +/*=gfunc in_p + * + * exparg: test-string , string to look for + + arg-name + arg-desc + arg-opt + arg-list + + * exparg: @ string-list @ list of strings to check,, @@ list + * + * opt: 1 + * doc: + * Return SCM_BOOL_T if the first argument is duplicated + * in the second (list) argument. +=*/ + SCM +ag_scm_in_p( SCM obj, SCM list ) +{ +} +EOF + +cat > ${testname}.test <<_EOF_ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * + * DO NOT EDIT THIS FILE (option.out) + * + * It has been extracted by getdefs from the following files: + * + * option.c + */ +autogen definitions testdir; + +/* GLOBALDEFS */ + +#line 2 "option.c" + test = 'subblock'; + doc = 'we want to see +just what happens'; + + +#line 11 "option.c" +gfunc = { + name = 'in_p'; + exparg = { + arg_name = 'test-string'; + arg_desc = 'string to look for'; + }; + exparg = { + arg_name = 'string-list'; + arg_desc = 'list of strings to check,,'; + arg_list = 'list'; + }; + opt = '1'; + doc = +'Return SCM_BOOL_T if the first argument is duplicated +in the second (list) argument.'; +}; +_EOF_ +set -x +${GDexe} output=${testname}.out ${testname}.c || \ + failure running ${GDexe} +cmp -s ${testname}.test ${testname}.out || \ + failure "`diff ${testname}.test ${testname}.out`" + +# option.test ends here diff --git a/getdefs/test/subblock.test b/getdefs/test/subblock.test new file mode 100755 index 0000000..8b1eb3c --- /dev/null +++ b/getdefs/test/subblock.test @@ -0,0 +1,105 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# subblock.test --- test the subblock parameter to getdefs +# +# Author: Bruce Korb <bkorb@gnu.org> +# Time-stamp: "2011-02-02 12:04:51 bkorb" +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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. +## +## AutoGen 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/>. + +# Common definitions +if test -z "$srcdir"; then + srcdir=`echo "$0" | ${SED} 's,[^/]*$,,'` + test -z "$srcdir" && srcdir=. + test "$srcdir" = "$0" && srcdir=. + test "${VERBOSE+set}" != set && VERBOSE=1 +fi +. $srcdir/defs + + +# Create the files we need in the test environment +cat > $testname.c <<EOF + +/*=* global + * + * test: subblock + * doc: we want to see + * just what happens +=*/ + +/*=gfunc in_p + * + * exparg: test-string , string to look for + + arg-name + arg-desc + arg-opt + arg-list + + * exparg: @ string-list @ list of strings to check,, @@ list + * + * opt: 1 + * doc: Return SCM_BOOL_T if the first argument is duplicated + * in the second (list) argument. +=*/ + SCM +ag_scm_in_p( SCM obj, SCM list ) +{ +} +EOF + +cat > $testname.test <<_EOF_ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * + * DO NOT EDIT THIS FILE (subblock.out) + * + * It has been extracted by getdefs from the following files: + * + * subblock.c + */ +autogen definitions testdir; + +/* GLOBALDEFS */ + +#line 2 "subblock.c" + test = 'subblock'; + doc = 'we want to see +just what happens'; + + +#line 9 "subblock.c" +gfunc = { + name = 'in_p'; + exparg = { + arg_name = 'test-string'; + arg_desc = 'string to look for'; + }; + exparg = { + arg_name = 'string-list'; + arg_desc = 'list of strings to check,,'; + arg_list = 'list'; + }; + opt = '1'; + doc = 'Return SCM_BOOL_T if the first argument is duplicated +in the second (list) argument.'; +}; +_EOF_ + +${GDexe} subblock=exparg=arg_name,arg_desc,arg_optional,arg_list \ + output=$testname.out $testname.c || \ + failure running ${GDexe} +cmp -s $testname.test $testname.out || \ + failure "`diff $testname.test $testname.out`" + +# subblock.test ends here |