my $help;
 my $man;
 my $debug;
+my $enable_lineno;
 my $prefix="Documentation/ABI";
 
 #
 
 GetOptions(
        "debug|d+" => \$debug,
+       "enable-lineno" => \$enable_lineno,
        "rst-source!" => \$description_is_rst,
        "dir=s" => \$prefix,
        'help|?' => \$help,
        $data{$nametag}->{file} = $name;
        $data{$nametag}->{filepath} = $file;
        $data{$nametag}->{is_file} = 1;
+       $data{$nametag}->{line_no} = 1;
 
        my $type = $file;
        $type =~ s,.*/(.*)/.*,$1,;
                        if ($tag ne "" && $new_tag) {
                                $tag = $new_tag;
 
+                               $data{$what}->{line_no} = $ln;
+
                                if ($new_what) {
                                        @{$data{$what}->{label}} = @labels if ($data{$nametag}->{what});
                                        @labels = ();
                my $file = $data{$what}->{file};
                my $filepath = $data{$what}->{filepath};
 
+               if ($enable_lineno) {
+                       printf "#define LINENO %s%s#%s\n\n",
+                              $prefix, $data{$what}->{file},
+                              $data{$what}->{line_no};
+               }
+
                my $w = $what;
                $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
 
        }
 }
 
+# Ensure that the prefix will always end with a slash
+# While this is not needed for find, it makes the patch nicer
+# with --enable-lineno
+$prefix =~ s,/?$,/,;
 
 #
 # Parses all ABI files located at $prefix dir
 
 =head1 SYNOPSIS
 
-B<abi_book.pl> [--debug] [--man] [--help] --[(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
+B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help]
+              [--(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
 
 Where <COMMAND> can be:
 
 plain text that may be violating ReST spec, so it requres some escaping
 logic (--no-rst-source).
 
+=item B<--enable-lineno>
+
+Enable output of #define LINENO lines.
+
 =item B<--debug>
 
 Put the script in verbose mode, useful for debugging. Can be called multiple