diff --git a/ChangeLog b/ChangeLog
index 48ca872d..6617d0d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2007-01-13 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	Move all "extern" declarations into a centreal header file.
+	* Makefile.am: Add new avrdude.h.
+	* avrdude.h: New file.
+	* avr.c: Replace private extern decl's by #include "avrdude.h".
+	* avr910.c: (Ditto.)
+	* avrpart.c: (Ditto.)
+	* bitbang.c: (Ditto.)
+	* butterfly.c: (Ditto.)
+	* config.c: (Ditto.)
+	* config_gram.y: (Ditto.)
+	* fileio.c: (Ditto.)
+	* jtagmkI.c: (Ditto.)
+	* jtagmkII.c: (Ditto.)
+	* lexer.l: (Ditto.)
+	* main.c: (Ditto.)
+	* par.c: (Ditto.)
+	* pgm.c: (Ditto.)
+	* ppi.c: (Ditto.)
+	* ppiwin.c: (Ditto.)
+	* ser_avrdoper.c: (Ditto.)
+	* ser_posix.c: (Ditto.)
+	* ser_win32.c: (Ditto.)
+	* serbb_posix.c: (Ditto.)
+	* serbb_win32.c: (Ditto.)
+	* stk500.c: (Ditto.)
+	* stk500generic.c: (Ditto.)
+	* stk500v2.c: (Ditto.)
+	* term.c: (Ditto.)
+	* usb_libusb.c: (Ditto.)
+	* usbasp.c: (Ditto.)
+
 2007-01-13 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* avrdude.conf.in (ATmega8): Bump the delay values for flash
diff --git a/Makefile.am b/Makefile.am
index bd557830..b2c0c4ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -73,6 +73,7 @@ avrdude_SOURCES = \
 	avr.h \
 	avr910.c \
 	avr910.h \
+	avrdude.h \
 	avrpart.c \
 	avrpart.h \
 	bitbang.c \
diff --git a/avr.c b/avr.c
index 008780f2..108f5337 100644
--- a/avr.c
+++ b/avr.c
@@ -28,6 +28,7 @@
 #include <sys/time.h>
 #include <time.h>
 
+#include "avrdude.h"
 
 #include "avr.h"
 #include "lists.h"
@@ -37,14 +38,6 @@
 
 #define DEBUG 0
 
-extern char       * progname;
-extern char         progbuf[];
-extern PROGRAMMER * pgm;
-
-
-extern int do_cycles;
-
-
 int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, 
                           unsigned long addr, unsigned char * value)
 {
diff --git a/avr910.c b/avr910.c
index 1d0f4b75..b1fefe26 100644
--- a/avr910.c
+++ b/avr910.c
@@ -33,15 +33,13 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include "avrdude.h"
+
 #include "avr.h"
 #include "pgm.h"
 #include "avr910.h"
 #include "serial.h"
 
-extern char * progname;
-extern int do_cycles;
-extern int ovsigck;
-
 static char has_auto_incr_addr;
 
 
diff --git a/avrdude.h b/avrdude.h
new file mode 100644
index 00000000..fc00f7eb
--- /dev/null
+++ b/avrdude.h
@@ -0,0 +1,33 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Copyright (C) 2007 Joerg Wunsch
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* $Id$ */
+
+#ifndef avrdude_h
+#define avrdude_h
+
+extern char * progname;		/* name of program, for messages */
+extern char progbuf[];		/* spaces same length as progname */
+
+extern int do_cycles;		/* track erase-rewrite cycles (-y) */
+extern int ovsigck;		/* override signature check (-F) */
+extern int verbose;		/* verbosity level (-v, -vv, ...) */
+extern int quell_progress;	/* quiteness level (-q, -qq) */
+
+#endif
diff --git a/avrpart.c b/avrpart.c
index 67fe702b..d737f34d 100644
--- a/avrpart.c
+++ b/avrpart.c
@@ -24,12 +24,10 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "avrdude.h"
 #include "avrpart.h"
 #include "pindefs.h"
 
-extern char * progname;
-
-
 /***
  *** Elementary functions dealing with OPCODE structures
  ***/
diff --git a/bitbang.c b/bitbang.c
index 164cac5a..c532065f 100644
--- a/bitbang.c
+++ b/bitbang.c
@@ -33,16 +33,13 @@
 #  include <sys/time.h>
 #endif
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
 #include "par.h"
 #include "serbb.h"
 
-extern char * progname;
-extern int do_cycles;
-extern int verbose;
-
 static int delay_decrement;
 
 #if !defined(WIN32NATIVE)
diff --git a/butterfly.c b/butterfly.c
index f8582405..85b34b33 100644
--- a/butterfly.c
+++ b/butterfly.c
@@ -44,14 +44,12 @@
 #include <errno.h>
 #include <ctype.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pgm.h"
 #include "butterfly.h"
 #include "serial.h"
 
-extern char * progname;
-extern int do_cycles;
-
 static char has_auto_incr_addr;
 static unsigned buffersize = 0;
 
diff --git a/config.c b/config.c
index 2b59ac15..5114a5a4 100644
--- a/config.c
+++ b/config.c
@@ -45,8 +45,10 @@ AVRMEM     * current_mem;
 LISTID       part_list;
 LISTID       programmers;
 
-int    lineno = 0;
-char * infile = NULL;
+int    lineno;
+char * infile;
+
+extern char * yytext;
 
 #define DEBUG 0
 
@@ -261,8 +263,6 @@ void print_token(TOKEN * tkn)
 void pyytext(void)
 {
 #if DEBUG
-  extern char * yytext;
-
   fprintf(stderr, "TOKEN: \"%s\"\n", yytext);
 #endif
 }
diff --git a/config_gram.y b/config_gram.y
index b182f200..6182a621 100644
--- a/config_gram.y
+++ b/config_gram.y
@@ -27,6 +27,8 @@
 #include <string.h>
 #include <math.h>
 
+#include "avrdude.h"
+
 #include "config.h"
 #include "lists.h"
 #include "par.h"
@@ -49,8 +51,6 @@
     ( *(_lasts) = strtok( (_s), (_sep) ) )
 #endif
 
-extern char * progname;
-
 int yylex(void);
 int yyerror(char * errmsg);
 
diff --git a/fileio.c b/fileio.c
index 2f14b6d3..1b0eac58 100644
--- a/fileio.c
+++ b/fileio.c
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <ctype.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "fileio.h"
 
@@ -46,10 +47,6 @@ struct ihexrec {
 };
 
 
-extern char * progname;
-extern char   progbuf[];
-extern int    quell_progress;
-
 int b2ihex(unsigned char * inbuf, int bufsize, 
              int recsize, int startaddr,
              char * outfile, FILE * outf);
diff --git a/jtagmkI.c b/jtagmkI.c
index 259ce1bc..9fe68f84 100644
--- a/jtagmkI.c
+++ b/jtagmkI.c
@@ -33,14 +33,12 @@
 #include <sys/time.h>
 #include <time.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "crc16.h"
 #include "pgm.h"
 #include "jtagmkI_private.h"
 #include "serial.h"
-extern int    verbose;
-extern char * progname;
-extern int do_cycles;
 
 /*
  * XXX There should really be a programmer-specific private data
diff --git a/jtagmkII.c b/jtagmkII.c
index 4b96c470..6c1a56e3 100644
--- a/jtagmkII.c
+++ b/jtagmkII.c
@@ -41,6 +41,7 @@
 #include <sys/time.h>
 #include <time.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "crc16.h"
 #include "pgm.h"
@@ -50,10 +51,6 @@
 #include "usbdevs.h"
 
 
-extern int    verbose;
-extern char * progname;
-extern int do_cycles;
-
 /*
  * XXX There should really be a programmer-specific private data
  * pointer in struct PROGRAMMER.
diff --git a/lexer.l b/lexer.l
index 94e6c7ac..8d843063 100644
--- a/lexer.l
+++ b/lexer.l
@@ -29,13 +29,12 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include "avrdude.h"
+
 #include "config.h"
 #include "config_gram.h"
 #include "lists.h"
 
-extern int    lineno;
-extern char * infile;
-
 void pyytext(void);
 
 #define YY_NO_UNPUT
diff --git a/main.c b/main.c
index 9b841a6c..e3b8a703 100644
--- a/main.c
+++ b/main.c
@@ -74,9 +74,6 @@ typedef struct update_t {
 /* Get VERSION from ac_cfg.h */
 char * version      = VERSION;
 
-int    verbose;     /* verbose output */
-int    quell_progress; /* un-verebose output */
-int    ovsigck;     /* 1=override sig check, 0=don't */
 char * progname;
 char   progbuf[PATH_MAX]; /* temporary buffer of spaces the same
                              length as progname; used for lining up
@@ -89,7 +86,10 @@ LISTID updates;
 /*
  * global options
  */
-int do_cycles;   /* track erase-rewrite cycles */
+int    do_cycles;   /* track erase-rewrite cycles */
+int    verbose;     /* verbose output */
+int    quell_progress; /* un-verebose output */
+int    ovsigck;     /* 1=override sig check, 0=don't */
 
 
 /*
diff --git a/par.c b/par.c
index 34b9e2a4..6f2452e2 100644
--- a/par.c
+++ b/par.c
@@ -36,16 +36,13 @@
 # include "solaris_ecpp.h"
 #endif
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
 #include "ppi.h"
 #include "bitbang.h"
 
-extern char * progname;
-extern int do_cycles;
-extern int verbose;
-
 #if HAVE_PARPORT
 
 struct ppipins_t {
diff --git a/pgm.c b/pgm.c
index 994d6a38..a26e7a48 100644
--- a/pgm.c
+++ b/pgm.c
@@ -25,10 +25,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "avrdude.h"
 #include "pgm.h"
 
-extern char * progname;
-
 static int  pgm_default_2 (struct programmer_t *, AVRPART *);
 static int  pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
 			   unsigned long addr, unsigned char * value);
diff --git a/ppi.c b/ppi.c
index 8070d668..64295981 100644
--- a/ppi.c
+++ b/ppi.c
@@ -41,13 +41,12 @@
 # include "solaris_ecpp.h"
 #endif
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
 #include "ppi.h"
 
-extern char * progname;
-
 enum {
   PPI_READ,
   PPI_WRITE,
diff --git a/ppiwin.c b/ppiwin.c
index 1f33731c..1c86e959 100644
--- a/ppiwin.c
+++ b/ppiwin.c
@@ -43,13 +43,11 @@ reg = register as defined in an enum in ppi.h. This must be converted
 #include <windows.h>
 #include <sys/time.h>
 #include <windows.h>
+
+#include "avrdude.h"
 #include "serial.h"
 #include "ppi.h"
 
-extern char *progname;
-
-
-
 #define DEVICE_LPT1 "lpt1"
 #define DEVICE_LPT2 "lpt2"
 #define DEVICE_LPT3 "lpt3"
diff --git a/ser_avrdoper.c b/ser_avrdoper.c
index 0d12682b..bbf92c66 100644
--- a/ser_avrdoper.c
+++ b/ser_avrdoper.c
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "avrdude.h"
 #include "serial.h"
 
 /* ------------------------------------------------------------------------ */
@@ -53,9 +54,6 @@
 #define USB_VENDOR_ID   0x16c0
 #define USB_PRODUCT_ID  0x05df
 
-extern char *progname;
-extern int verbose;
-
 static int  reportDataSizes[4] = {13, 29, 61, 125};
 
 static unsigned char    avrdoperRxBuffer[280];  /* buffer for receive data */
diff --git a/ser_posix.c b/ser_posix.c
index c8ce502e..6b8b455c 100644
--- a/ser_posix.c
+++ b/ser_posix.c
@@ -42,11 +42,9 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include "avrdude.h"
 #include "serial.h"
 
-extern char *progname;
-extern int verbose;
-
 long serial_recv_timeout = 5000; /* ms */
 
 struct baud_mapping {
diff --git a/ser_win32.c b/ser_win32.c
index 861e3241..44a6d3fd 100644
--- a/ser_win32.c
+++ b/ser_win32.c
@@ -29,10 +29,9 @@
 #include <windows.h>
 #include <stdio.h>
 #include <ctype.h>   /* for isprint */
-#include "serial.h"
 
-extern char *progname;
-extern int verbose;
+#include "avrdude.h"
+#include "serial.h"
 
 long serial_recv_timeout = 5000; /* ms */
 
diff --git a/serbb_posix.c b/serbb_posix.c
index 4aabe362..fee63d6c 100644
--- a/serbb_posix.c
+++ b/serbb_posix.c
@@ -37,6 +37,7 @@
 #include <sys/ioctl.h>
 #include <termios.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
@@ -44,8 +45,7 @@
 
 #undef DEBUG
 
-extern char *progname;
-struct termios oldmode;
+static struct termios oldmode;
 
 /*
   serial port/pin mapping
diff --git a/serbb_win32.c b/serbb_win32.c
index 628e73f0..7a9bf97f 100644
--- a/serbb_win32.c
+++ b/serbb_win32.c
@@ -32,14 +32,12 @@
 #include <windows.h>
 #include <stdio.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
 #include "bitbang.h"
 
-extern char *progname;
-extern int verbose;
-
 /* cached status lines */
 static int dtr, rts, txd;
 
diff --git a/stk500.c b/stk500.c
index 7116bf2a..d7e68d36 100644
--- a/stk500.c
+++ b/stk500.c
@@ -36,6 +36,7 @@
 #include <errno.h>
 #include <unistd.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pgm.h"
 #include "stk500_private.h"
@@ -43,11 +44,6 @@
 
 #define STK500_XTAL 7372800U
 
-extern int    verbose;
-extern char * progname;
-extern int do_cycles;
-
-
 static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value);
 static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value);
 static void stk500_print_parms1(PROGRAMMER * pgm, char * p);
diff --git a/stk500generic.c b/stk500generic.c
index db334f23..3ea9d868 100644
--- a/stk500generic.c
+++ b/stk500generic.c
@@ -32,12 +32,11 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "avrdude.h"
 #include "pgm.h"
 #include "stk500.h"
 #include "stk500v2.h"
 
-extern char *progname;
-
 static int stk500generic_open(PROGRAMMER * pgm, char * port)
 {
   stk500_initpgm(pgm);
diff --git a/stk500v2.c b/stk500v2.c
index 94ea11f5..71ce5df1 100644
--- a/stk500v2.c
+++ b/stk500v2.c
@@ -47,6 +47,7 @@
 #include <sys/time.h>
 #include <time.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pgm.h"
 #include "stk500_private.h"	// temp until all code converted
@@ -85,10 +86,6 @@ enum hvmode
 };
 
 
-extern int    verbose;
-extern char * progname;
-extern int do_cycles;
-
 /*
  * See stk500pp_read_byte() for an explanation of the flash and
  * EEPROM page caches.
diff --git a/term.c b/term.c
index 191724ae..00f8ff9b 100644
--- a/term.c
+++ b/term.c
@@ -34,6 +34,7 @@
 #endif
 #endif
 
+#include "avrdude.h"
 #include "avr.h"
 #include "config.h"
 #include "lists.h"
@@ -41,12 +42,6 @@
 #include "pindefs.h"
 #include "ppi.h"
 
-
-extern char       * progname;
-extern char         progbuf[];
-extern PROGRAMMER * pgm;
-
-
 struct command {
   char * name;
   int (*func)(PROGRAMMER * pgm, struct avrpart * p, int argc, char *argv[]);
diff --git a/usb_libusb.c b/usb_libusb.c
index 01031c88..1c648a39 100644
--- a/usb_libusb.c
+++ b/usb_libusb.c
@@ -38,12 +38,10 @@
 
 #include <usb.h>
 
+#include "avrdude.h"
 #include "serial.h"
 #include "usbdevs.h"
 
-extern char *progname;
-extern int verbose;
-
 static char usbbuf[USBDEV_MAX_XFER];
 static int buflen = -1, bufptr;
 
diff --git a/usbasp.c b/usbasp.c
index 654748e8..b8cc9444 100644
--- a/usbasp.c
+++ b/usbasp.c
@@ -33,6 +33,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#include "avrdude.h"
 #include "avr.h"
 #include "pgm.h"
 #include "usbasp.h"
@@ -40,10 +41,6 @@
 #ifdef HAVE_LIBUSB
 #include <usb.h>
 
-extern int    verbose;
-extern char * progname;
-extern int do_cycles;
-
 static usb_dev_handle *usbhandle;
 
 /*
@@ -426,8 +423,6 @@ void usbasp_initpgm(PROGRAMMER * pgm)
 
 #else /* HAVE_LIBUSB */
 
-extern char * progname;
-
 static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
 {
   fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",