diff --git a/linux_ppdev.h b/linux_ppdev.h
new file mode 100644
index 00000000..afa3982b
--- /dev/null
+++ b/linux_ppdev.h
@@ -0,0 +1,37 @@
+#ifndef __linux_ppdev_h__
+#define __linux_ppdev_h__
+
+#define OBSOLETE__IOW _IOW
+
+#include <sys/ioctl.h>
+#include <linux/parport.h>
+#include <linux/ppdev.h>
+
+#include <stdlib.h>
+
+#define PPISDATA    PPWDATA
+#define PPIGDATA    PPRDATA
+
+#define PPISCTRL    PPWCONTROL
+#define PPIGCTRL    PPRCONTROL
+
+#define PPISSTATUS  PPWSTATUS
+#define PPIGSTATUS  PPRSTATUS
+
+#define ppi_claim(pgm)                                       \
+  if (ioctl(pgm->fd, PPCLAIM)) {                             \
+    fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \
+            progname, port, strerror(errno));                \
+    close(pgm->fd);                                          \
+    exit(1);                                                 \
+  } 
+
+#define ppi_release(pgm)                                     \
+  if (ioctl(pgm->fd, PPRELEASE)) {                           \
+    fprintf(stderr, "%s: can't release device: %s\n\n",      \
+            progname, strerror(errno));                      \
+    exit(1);                                                 \
+  }
+
+
+#endif /* __linux_ppdev_h__ */
diff --git a/ppi.c b/ppi.c
index fb9d1a6b..ddc327f8 100644
--- a/ppi.c
+++ b/ppi.c
@@ -25,7 +25,12 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+
+#if defined(__FreeBSD__)
 #include <dev/ppbus/ppi.h>
+#elif defined(__linux__)
+#include "linux_ppdev.h"
+#endif
 
 #include "avr.h"
 #include "pindefs.h"
@@ -760,11 +765,15 @@ void ppi_open(PROGRAMMER * pgm, char * port)
               progname, port, strerror(errno));
     exit(1);
   }
+
+  ppi_claim(pgm);
 }
 
 
 void ppi_close(PROGRAMMER * pgm)
 {
+  ppi_release(pgm);
+
   close(pgm->fd);
   pgm->fd = -1;
 }
diff --git a/ppi.h b/ppi.h
index 7b0571c0..bf319462 100644
--- a/ppi.h
+++ b/ppi.h
@@ -29,7 +29,13 @@ void ppi_initpgm        (PROGRAMMER * pgm);
 
 int ppi_getpinmask(int pin);
 
+#if !defined(ppi_claim)
+#  define ppi_claim(pgm)
+#endif
 
+#if !defined(ppi_release)
+#  define ppi_release(pgm)
+#endif
 
 #endif
 
diff --git a/stk500.c b/stk500.c
index 240fb9f5..c68f847d 100644
--- a/stk500.c
+++ b/stk500.c
@@ -36,6 +36,7 @@
 #include <errno.h>
 #include <termios.h>
 #include <sys/time.h>
+#include <inttypes.h>
 
 #include "avr.h"
 #include "pgm.h"