--- a/mkfs.c
+++ b/mkfs.c
@@ -34,7 +34,7 @@
 #include <getopt.h>
 #include <uuid/uuid.h>
 #include <ctype.h>
-#include <sys/xattr.h>
+#include <attr/xattr.h>
 #include <blkid/blkid.h>
 #include <ftw.h>
 #include "ctree.h"
--- a/props.c
+++ b/props.c
@@ -17,7 +17,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
-#include <sys/xattr.h>
+#include <attr/xattr.h>
 #include <fcntl.h>
 #include <unistd.h>
 
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -39,7 +39,7 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/xattr.h>
+#include <attr/xattr.h>
 #include <uuid/uuid.h>
 
 #include "ctree.h"
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -34,7 +34,7 @@
 #include <regex.h>
 #include <getopt.h>
 #include <sys/types.h>
-#include <sys/xattr.h>
+#include <attr/xattr.h>
 
 #include "ctree.h"
 #include "disk-io.h"
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ TESTS = fsck-tests.sh convert-tests.sh
 INSTALL = install
 prefix ?= /usr/local
 bindir = $(prefix)/bin
-lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L.
+lib_LIBS = -lattr -luuid -lblkid -lm -lz -llzo2 -L.
 libdir ?= $(prefix)/lib
 incdir = $(prefix)/include/btrfs
 LIBS = $(lib_LIBS) $(libs_static)
