diff -rc ctags-5.8/EXTENDING.html ctags-5.8.new/EXTENDING.html
*** ctags-5.8/EXTENDING.html	Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/EXTENDING.html	Mon Nov 26 15:42:59 2012
***************
*** 382,386 ****
--- 382,426 ----
  }
  </pre>
  
+ <h2>Integration with GNU GLOBAL</h2>
+ 
+ <p>
+ All ctags parsers are already GNU GLOBAL's parsers as it is.
+ Regarding the preparation procedure, please see 'FAQ' file in GNU GLOBAL package.
+ </p>
+ 
+ <p>
+ To generate reference tags, please use makeSimpleReferenceTag() function
+ instead of makeSimpleTag(). This function does not influence the output
+ of Exuberant Ctags without --gtags option.
+ </p>
+ <p>
+ If a parser supports reference tags, then you can use global command like follows:
+ <pre>
+ $ gtags				# invokes Exuberant Ctags internally
+ $ global -x func
+ 100           util/tools.c    func() {
+ $ global -xr func
+ 250           src/main.c           if (func() == 0) {
+ 350           src/etc.c       int a = func();
+ </pre>
+ 
+ <dl>
+ <dt>global -x  name<dd>print definition tags
+ <dt>global -xr name<dd>print reference tags which are defined
+ <dt>global -xs name<dd>print reference tags which are not defined
+ </dl>
+ </p>
+ 
+ <p>
+ GNU GLOBAL is a source code tagging system that works the same way
+ across diverse environments (emacs, vi, less, bash, web browser, etc).
+ The feature of it is an ability to treat not only definitions but
+ also references. Please see the following site for the detail.
+ <blockquote>
+ http://www.gnu.org/software/global/
+ </blockquote>
+ </p>
+ 
  </body>
  </html>
diff -rc ctags-5.8/ctags.1 ctags-5.8.new/ctags.1
*** ctags-5.8/ctags.1	Fri Jul 10 07:03:54 2009
--- ctags-5.8.new/ctags.1	Mon Nov 26 14:32:44 2012
***************
*** 510,515 ****
--- 510,520 ----
  before the first file name. [Ignored in etags mode]
  
  .TP 5
+ .B \-\-gtags
+ Print a type string at the head of each tag record of cross reference file.
+ This option is used to integrate this program into GNU GLOBAL.
+ 
+ .TP 5
  .B \-\-help
  Prints to standard output a detailed usage description, and then exits.
  
diff -rc ctags-5.8/entry.c ctags-5.8.new/entry.c
*** ctags-5.8/entry.c	Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/entry.c	Mon Nov 26 14:56:36 2012
***************
*** 643,655 ****
  {
  	const char *const line =
  			readSourceLine (TagFile.vLine, tag->filePosition, NULL);
! 	int length;
  
  	if (Option.tagFileFormat == 1)
! 		length = fprintf (TagFile.fp, "%-16s %4lu %-16s ", tag->name,
  				tag->lineNumber, tag->sourceFileName);
  	else
! 		length = fprintf (TagFile.fp, "%-16s %-10s %4lu %-16s ", tag->name,
  				tag->kindName, tag->lineNumber, tag->sourceFileName);
  
  	length += writeCompactSourceLine (TagFile.fp, line);
--- 643,657 ----
  {
  	const char *const line =
  			readSourceLine (TagFile.vLine, tag->filePosition, NULL);
! 	int length = 0;
  
+ 	if (Option.gtags == 1)
+ 		length += fprintf(TagFile.fp, "%c ", tag->type);
  	if (Option.tagFileFormat == 1)
! 		length += fprintf (TagFile.fp, "%-16s %4lu %-16s ", tag->name,
  				tag->lineNumber, tag->sourceFileName);
  	else
! 		length += fprintf (TagFile.fp, "%-16s %-10s %4lu %-16s ", tag->name,
  				tag->kindName, tag->lineNumber, tag->sourceFileName);
  
  	length += writeCompactSourceLine (TagFile.fp, line);
***************
*** 842,847 ****
--- 844,850 ----
  	e->filePosition    = getInputFilePosition ();
  	e->sourceFileName  = getSourceFileTagPath ();
  	e->name            = name;
+ 	e->type            = GTAGS_DEFINITION;
  }
  
  /* vi:set tabstop=4 shiftwidth=4: */
diff -rc ctags-5.8/entry.h ctags-5.8.new/entry.h
*** ctags-5.8/entry.h	Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/entry.h	Mon Nov 26 14:56:17 2012
***************
*** 24,30 ****
  *   MACROS
  */
  #define WHOLE_FILE  -1L
! 
  /*
  *   DATA DECLARATIONS
  */
--- 24,31 ----
  *   MACROS
  */
  #define WHOLE_FILE  -1L
! #define GTAGS_DEFINITION	'D'
! #define GTAGS_REFERENCE		'R'
  /*
  *   DATA DECLARATIONS
  */
***************
*** 65,70 ****
--- 66,72 ----
  	const char *name;             /* name of the tag */
  	const char *kindName;         /* kind of tag */
  	char        kind;             /* single character representation of kind */
+ 	char        type;             /* single character representation of type for gtags */
  	struct {
  		const char* access;
  		const char* fileScope;
diff -rc ctags-5.8/options.c ctags-5.8.new/options.c
*** ctags-5.8/options.c	Wed Sep  5 11:00:44 2007
--- ctags-5.8.new/options.c	Sun Nov 25 09:31:15 2012
***************
*** 148,153 ****
--- 148,154 ----
  	FALSE,      /* --tag-relative */
  	FALSE,      /* --totals */
  	FALSE,      /* --line-directives */
+ 	FALSE,      /* --gtags */
  #ifdef DEBUG
  	0, 0        /* -D, -b */
  #endif
***************
*** 224,229 ****
--- 225,233 ----
  #else
   {0,"       Force output of specified tag file format [2]."},
  #endif
+  {1,"  --gtags=[yes|no]"},
+  {1,"       Print a type string for gtags at the head of each tag."},
+  {1,"       This option is valid only with the -x option. [no]."},
   {1,"  --help"},
   {1,"       Print this option summary."},
   {1,"  --if0=[yes|no]"},
***************
*** 1398,1403 ****
--- 1402,1408 ----
  	{ "file-scope",     &Option.include.fileScope,      FALSE   },
  	{ "file-tags",      &Option.include.fileNames,      FALSE   },
  	{ "filter",         &Option.filter,                 TRUE    },
+ 	{ "gtags",          &Option.gtags,                  FALSE   },
  	{ "if0",            &Option.if0,                    FALSE   },
  	{ "kind-long",      &Option.kindLong,               TRUE    },
  	{ "line-directives",&Option.lineDirectives,         FALSE   },
diff -rc ctags-5.8/options.h ctags-5.8.new/options.h
*** ctags-5.8/options.h	Wed Sep  5 11:00:44 2007
--- ctags-5.8.new/options.h	Sun Nov 25 09:31:22 2012
***************
*** 108,113 ****
--- 108,114 ----
  	boolean tagRelative;    /* --tag-relative file paths relative to tag file */
  	boolean printTotals;    /* --totals  print cumulative statistics */
  	boolean lineDirectives; /* --linedirectives  process #line directives */
+ 	boolean gtags		/* --gtags print a type string for gtags */
  #ifdef DEBUG
  	long debugLevel;        /* -D  debugging output */
  	unsigned long breakLine;/* -b  source line at which to call lineBreak() */
diff -rc ctags-5.8/parse.c ctags-5.8.new/parse.c
*** ctags-5.8/parse.c	Tue Jul 31 14:35:33 2007
--- ctags-5.8.new/parse.c	Mon Nov 26 14:56:58 2012
***************
*** 53,58 ****
--- 53,74 ----
  	}
  }
  
+ extern void makeSimpleReferenceTag (
+ 		const vString* const name, kindOption* const kinds, const int kind)
+ {
+ 	if (kinds [kind].enabled  &&  name != NULL  &&  vStringLength (name) > 0)
+ 	{
+ 	    tagEntryInfo e;
+ 	    initTagEntry (&e, vStringValue (name));
+ 
+ 	    e.kindName = kinds [kind].name;
+ 	    e.kind     = kinds [kind].letter;
+ 	    e.type     = GTAGS_REFERENCE;
+ 
+ 	    makeTagEntry (&e);
+ 	}
+ }
+ 
  /*
  *   parserDescription mapping management
  */
