diff --git a/src/plugins/task/Makefile.am b/src/plugins/task/Makefile.am
index 49a4e426e397a070107a4e6c2716317085cefa9b..d40702f5b2261fa8c69ee309c0665106668a804f 100644
--- a/src/plugins/task/Makefile.am
+++ b/src/plugins/task/Makefile.am
@@ -1,3 +1,7 @@
 # Makefile for task plugins
 
-SUBDIRS = affinity none cgroup cray
+SUBDIRS = cgroup cray none
+
+if HAVE_SCHED_SETAFFINITY
+SUBDIRS += affinity
+endif
diff --git a/src/plugins/task/Makefile.in b/src/plugins/task/Makefile.in
index 9d73d02e2e327af8b442a370b157d62278113840..d857724a546f97519358af0ebf51a2b69c221f62 100644
--- a/src/plugins/task/Makefile.in
+++ b/src/plugins/task/Makefile.in
@@ -90,6 +90,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
+@HAVE_SCHED_SETAFFINITY_TRUE@am__append_1 = affinity
 subdir = src/plugins/task
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/auxdir/ax_check_compile_flag.m4 \
@@ -199,7 +200,7 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = $(SUBDIRS)
+DIST_SUBDIRS = cgroup cray none affinity
 am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
@@ -479,7 +480,7 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = affinity none cgroup cray
+SUBDIRS = cgroup cray none $(am__append_1)
 all: all-recursive
 
 .SUFFIXES: