diff --git a/lib/Makefile.am b/lib/Makefile.am
index 8a94e1e..4d4efe4 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,44 +1,10 @@
+include Makefile.sources
 
 noinst_LTLIBRARIES = libintel_tools.la
 
 AM_CPPFLAGS = -I$(top_srcdir)
 AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS)
 
-libintel_tools_la_SOURCES = 	\
-	debug.h			\
-	drmtest.c		\
-	drmtest.h		\
-	i830_reg.h		\
-	i915_3d.h		\
-	i915_reg.h		\
-	igt_debugfs.c		\
-	igt_debugfs.h		\
-	igt_display.c		\
-	igt_display.h		\
-	instdone.c		\
-	instdone.h		\
-	intel_batchbuffer.c	\
-	intel_batchbuffer.h	\
-	intel_chipset.h		\
-	intel_drm.c		\
-	intel_gpu_tools.h	\
-	intel_mmio.c		\
-	intel_pci.c		\
-	intel_reg.h		\
-	rendercopy_i915.c	\
-	rendercopy_i830.c	\
-	gen6_render.h		\
-	gen7_render.h		\
-	gen8_render.h		\
-	rendercopy_gen6.c	\
-	rendercopy_gen7.c	\
-	rendercopy_gen8.c	\
-	rendercopy.h		\
-	rendercopy.c		\
-	intel_reg_map.c		\
-	intel_dpio.c		\
-	intel_iosf.c		\
-	$(NULL)
-
 LDADD = $(CAIRO_LIBS)
 AM_CFLAGS += $(CAIRO_CFLAGS)
+
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
new file mode 100644
index 0000000..d71f837
--- /dev/null
+++ b/lib/Makefile.sources
@@ -0,0 +1,36 @@
+libintel_tools_la_SOURCES = 	\
+	debug.h			\
+	drmtest.c		\
+	drmtest.h		\
+	i830_reg.h		\
+	i915_3d.h		\
+	i915_reg.h		\
+	igt_debugfs.c		\
+	igt_debugfs.h		\
+	igt_display.c		\
+	igt_display.h		\
+	instdone.c		\
+	instdone.h		\
+	intel_batchbuffer.c	\
+	intel_batchbuffer.h	\
+	intel_chipset.h		\
+	intel_drm.c		\
+	intel_gpu_tools.h	\
+	intel_mmio.c		\
+	intel_pci.c		\
+	intel_reg.h		\
+	rendercopy_i915.c	\
+	rendercopy_i830.c	\
+	gen6_render.h		\
+	gen7_render.h		\
+	gen8_render.h		\
+	rendercopy_gen6.c	\
+	rendercopy_gen7.c	\
+	rendercopy_gen8.c	\
+	rendercopy.h		\
+	rendercopy.c		\
+	intel_reg_map.c		\
+	intel_dpio.c		\
+	intel_iosf.c		\
+	$(NULL)
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0426ec0..9e1b13f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,185 +1,6 @@
-if BUILD_TESTS
-noinst_PROGRAMS = \
-	gem_stress \
-	ddi_compute_wrpll \
-	$(TESTS_progs) \
-	$(TESTS_progs_M) \
-	$(HANG) \
-	$(TESTS_testsuite)
-	$(NULL)
-
-if HAVE_NOUVEAU
-NOUVEAU_TESTS_M = \
-	prime_nv_api \
-	prime_nv_pcopy \
-	prime_nv_test \
-	$(NULL)
-endif
-
-TESTS_progs_M = \
-	drv_suspend \
-	gem_basic \
-	gem_caching \
-	gem_concurrent_blit \
-	gem_cs_tlb \
-	gem_ctx_bad_exec \
-	gem_dummy_reloc_loop \
-	gem_evict_alignment \
-	gem_evict_everything \
-	gem_exec_bad_domains \
-	gem_exec_nop \
-	gem_fenced_exec_thrash \
-	gem_fence_thrash \
-	gem_flink \
-	gem_flink_race \
-	gem_linear_blits \
-	gem_mmap \
-	gem_mmap_gtt \
-	gem_partial_pwrite_pread \
-	gem_persistent_relocs \
-	gem_pread \
-	gem_pread_after_blit \
-	gem_pwrite \
-	gem_pwrite_pread \
-	gem_readwrite \
-	gem_reloc_overflow \
-	gem_reloc_vs_gpu \
-	gem_ringfill \
-	gem_set_tiling_vs_blt \
-	gem_storedw_batches_loop \
-	gem_tiled_blits \
-	gem_tiled_partial_pwrite_pread \
-	gem_write_read_ring_switch \
-	kms_addfb \
-	kms_cursor_crc \
-	kms_flip \
-	kms_pipe_crc_basic \
-	kms_render \
-	kms_setmode \
-	$(NOUVEAU_TESTS_M) \
-	pm_pc8 \
-	prime_self_import \
-	template \
-	$(NULL)
-
-TESTS_progs = \
-	core_getclient \
-	core_getstats \
-	core_getversion \
-	drm_get_client_auth \
-	drm_vma_limiter \
-	drm_vma_limiter_cached \
-	drm_vma_limiter_cpu \
-	drm_vma_limiter_gtt \
-	gem_bad_length \
-	gem_close_race \
-	gem_cpu_reloc \
-	gem_cs_prefetch \
-	gem_ctx_bad_destroy \
-	gem_ctx_basic \
-	gem_ctx_create \
-	gem_ctx_exec \
-	gem_double_irq_loop \
-	gem_exec_big \
-	gem_exec_blt \
-	gem_exec_faulting_reloc \
-	gem_exec_lut_handle \
-	gem_gtt_cpu_tlb \
-	gem_gtt_speed \
-	gem_hangcheck_forcewake \
-	gem_largeobject \
-	gem_lut_handle \
-	gem_mmap_offset_exhaustion \
-	gem_pin \
-	gem_pipe_control_store_loop \
-	gem_reg_read \
-	gem_render_copy \
-	gem_render_linear_blits \
-	gem_render_tiled_blits \
-	gem_ring_sync_loop \
-	gem_seqno_wrap \
-	gem_set_tiling_vs_gtt \
-	gem_set_tiling_vs_pwrite \
-	gem_storedw_loop_blt \
-	gem_storedw_loop_bsd \
-	gem_storedw_loop_render \
-	gem_storedw_loop_vebox \
-	gem_threaded_access_tiled \
-	gem_tiled_fence_blits \
-	gem_tiled_pread \
-	gem_tiled_pread_pwrite \
-	gem_tiled_swapping \
-	gem_tiling_max_stride \
-	gem_unfence_active_buffers \
-	gem_unref_active_buffers \
-	gem_vmap_blits \
-	gem_wait_render_timeout \
-	gen3_mixed_blits \
-	gen3_render_linear_blits \
-	gen3_render_mixed_blits \
-	gen3_render_tiledx_blits \
-	gen3_render_tiledy_blits \
-	prime_udl \
-	pm_psr \
-	pm_rc6_residency \
-	pm_rps \
-	$(NULL)
-
-# IMPORTANT: The ZZ_ tests need to be run last!
-# ... and make can't deal with inlined comments ...
-TESTS_scripts_M = \
-	$(NULL)
-
-TESTS_scripts = \
-	debugfs_emon_crash \
-	drv_debugfs_reader \
-	drv_hangman \
-	drv_missed_irq_hang \
-	drv_module_reload \
-	kms_sysfs_edid_timing \
-	sysfs_l3_parity \
-	test_rte_check \
-	tools_test \
-	$(NULL)
-
-# This target contains testcases which support automagic subtest enumeration
-# from the piglit testrunner with --list-subtests and running individual
-# subtests with --run-subtest <testname>
-multi_kernel_tests = \
-	$(TESTS_progs_M) \
-	$(TESTS_scripts_M) \
-	$(NULL)
-
-single_kernel_tests = \
-	$(TESTS_progs) \
-	$(TESTS_scripts) \
-	$(NULL)
-
-kernel_tests = \
-	$(single_kernel_tests) \
-	$(multi_kernel_tests) \
-	$(NULL)
-
-TESTS_testsuite = \
-	igt_no_exit \
-	igt_no_exit_list_only \
-	igt_fork_helper \
-	igt_list_only \
-	igt_no_subtest \
-	$(NULL)
-
-TESTS = \
-	$(TESTS_testsuite) \
-	$(NULL)
-
-# Test that exercise specific asserts in the test framework library and are
-# hence expected to fail.
-XFAIL_TESTS = \
-	igt_no_exit \
-	igt_no_exit_list_only \
-	igt_no_subtest \
-	$(NULL)
+include Makefile.sources
 
+if BUILD_TESTS
 list-single-tests:
 	@echo TESTLIST
 	@echo ${single_kernel_tests}
@@ -190,23 +11,6 @@ list-multi-tests:
 	@echo ${multi_kernel_tests}
 	@echo END TESTLIST
 
-HANG = \
-	gem_bad_batch \
-	gem_hang \
-	gem_bad_blit \
-	gem_bad_address \
-	gem_non_secure_batch \
-	$(NULL)
-
-scripts = \
-	check_drm_clients \
-	ddx_intel_after_fbdev \
-	debugfs_wedged \
-	drm_lib.sh \
-	$(NULL)
-
-IMAGES = pass.png 1080p-left.png 1080p-right.png
-
 EXTRA_PROGRAMS = $(TESTS_progs) $(TESTS_progs_M) $(HANG) $(TESTS_testsuite)
 EXTRA_DIST = $(TESTS_scripts) $(TESTS_scripts_M) $(scripts) $(IMAGES)
 
@@ -220,13 +24,6 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \
 
 LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) 
 
-testdisplay_SOURCES = \
-	testdisplay.c \
-	testdisplay.h \
-	testdisplay_hotplug.c \
-	$(NULL)
-
-TESTS_progs += testdisplay
 LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS)
 AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS)
 
@@ -249,3 +46,4 @@ prime_nv_api_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 prime_nv_pcopy_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_pcopy_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 endif
+
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
new file mode 100644
index 0000000..70809c7
--- /dev/null
+++ b/tests/Makefile.sources
@@ -0,0 +1,206 @@
+noinst_PROGRAMS = \
+	gem_stress \
+	ddi_compute_wrpll \
+	$(TESTS_progs) \
+	$(TESTS_progs_M) \
+	$(HANG) \
+	$(TESTS_testsuite)
+	$(NULL)
+
+if HAVE_NOUVEAU
+NOUVEAU_TESTS_M = \
+	prime_nv_api \
+	prime_nv_pcopy \
+	prime_nv_test \
+	$(NULL)
+endif
+
+TESTS_progs_M = \
+	drv_suspend \
+	gem_basic \
+	gem_caching \
+	gem_concurrent_blit \
+	gem_cs_tlb \
+	gem_ctx_bad_exec \
+	gem_dummy_reloc_loop \
+	gem_evict_alignment \
+	gem_evict_everything \
+	gem_exec_bad_domains \
+	gem_exec_nop \
+	gem_fenced_exec_thrash \
+	gem_fence_thrash \
+	gem_flink \
+	gem_flink_race \
+	gem_linear_blits \
+	gem_mmap \
+	gem_mmap_gtt \
+	gem_partial_pwrite_pread \
+	gem_persistent_relocs \
+	gem_pread \
+	gem_pread_after_blit \
+	gem_pwrite \
+	gem_pwrite_pread \
+	gem_readwrite \
+	gem_reloc_overflow \
+	gem_reloc_vs_gpu \
+	gem_ringfill \
+	gem_set_tiling_vs_blt \
+	gem_storedw_batches_loop \
+	gem_tiled_blits \
+	gem_tiled_partial_pwrite_pread \
+	gem_write_read_ring_switch \
+	kms_addfb \
+	kms_cursor_crc \
+	kms_flip \
+	kms_pipe_crc_basic \
+	kms_render \
+	kms_setmode \
+	$(NOUVEAU_TESTS_M) \
+	pm_pc8 \
+	prime_self_import \
+	template \
+	$(NULL)
+
+TESTS_progs = \
+	core_getclient \
+	core_getstats \
+	core_getversion \
+	drm_get_client_auth \
+	drm_vma_limiter \
+	drm_vma_limiter_cached \
+	drm_vma_limiter_cpu \
+	drm_vma_limiter_gtt \
+	gem_bad_length \
+	gem_close_race \
+	gem_cpu_reloc \
+	gem_cs_prefetch \
+	gem_ctx_bad_destroy \
+	gem_ctx_basic \
+	gem_ctx_create \
+	gem_ctx_exec \
+	gem_double_irq_loop \
+	gem_exec_big \
+	gem_exec_blt \
+	gem_exec_faulting_reloc \
+	gem_exec_lut_handle \
+	gem_gtt_cpu_tlb \
+	gem_gtt_speed \
+	gem_hangcheck_forcewake \
+	gem_largeobject \
+	gem_lut_handle \
+	gem_mmap_offset_exhaustion \
+	gem_pin \
+	gem_pipe_control_store_loop \
+	gem_reg_read \
+	gem_render_copy \
+	gem_render_linear_blits \
+	gem_render_tiled_blits \
+	gem_ring_sync_loop \
+	gem_seqno_wrap \
+	gem_set_tiling_vs_gtt \
+	gem_set_tiling_vs_pwrite \
+	gem_storedw_loop_blt \
+	gem_storedw_loop_bsd \
+	gem_storedw_loop_render \
+	gem_storedw_loop_vebox \
+	gem_threaded_access_tiled \
+	gem_tiled_fence_blits \
+	gem_tiled_pread \
+	gem_tiled_pread_pwrite \
+	gem_tiled_swapping \
+	gem_tiling_max_stride \
+	gem_unfence_active_buffers \
+	gem_unref_active_buffers \
+	gem_vmap_blits \
+	gem_wait_render_timeout \
+	gen3_mixed_blits \
+	gen3_render_linear_blits \
+	gen3_render_mixed_blits \
+	gen3_render_tiledx_blits \
+	gen3_render_tiledy_blits \
+	prime_udl \
+	pm_psr \
+	pm_rc6_residency \
+	pm_rps \
+	$(NULL)
+
+# IMPORTANT: The ZZ_ tests need to be run last!
+# ... and make can't deal with inlined comments ...
+TESTS_scripts_M = \
+	$(NULL)
+
+TESTS_scripts = \
+	debugfs_emon_crash \
+	drv_debugfs_reader \
+	drv_hangman \
+	drv_missed_irq_hang \
+	drv_module_reload \
+	kms_sysfs_edid_timing \
+	sysfs_l3_parity \
+	test_rte_check \
+	tools_test \
+	$(NULL)
+
+# This target contains testcases which support automagic subtest enumeration
+# from the piglit testrunner with --list-subtests and running individual
+# subtests with --run-subtest <testname>
+multi_kernel_tests = \
+	$(TESTS_progs_M) \
+	$(TESTS_scripts_M) \
+	$(NULL)
+
+single_kernel_tests = \
+	$(TESTS_progs) \
+	$(TESTS_scripts) \
+	$(NULL)
+
+kernel_tests = \
+	$(single_kernel_tests) \
+	$(multi_kernel_tests) \
+	$(NULL)
+
+TESTS_testsuite = \
+	igt_no_exit \
+	igt_no_exit_list_only \
+	igt_fork_helper \
+	igt_list_only \
+	igt_no_subtest \
+	$(NULL)
+
+TESTS = \
+	$(TESTS_testsuite) \
+	$(NULL)
+
+# Test that exercise specific asserts in the test framework library and are
+# hence expected to fail.
+XFAIL_TESTS = \
+	igt_no_exit \
+	igt_no_exit_list_only \
+	igt_no_subtest \
+	$(NULL)
+
+HANG = \
+	gem_bad_batch \
+	gem_hang \
+	gem_bad_blit \
+	gem_bad_address \
+	gem_non_secure_batch \
+	$(NULL)
+
+scripts = \
+	check_drm_clients \
+	ddx_intel_after_fbdev \
+	debugfs_wedged \
+	drm_lib.sh \
+	$(NULL)
+
+IMAGES = pass.png 1080p-left.png 1080p-right.png
+
+testdisplay_SOURCES = \
+	testdisplay.c \
+	testdisplay.h \
+	testdisplay_hotplug.c \
+	$(NULL)
+
+TESTS_progs += testdisplay
+
diff --git a/tools/Makefile.am b/tools/Makefile.am
index d430377..151092b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,60 +1,10 @@
+include Makefile.sources
+
 if HAVE_DUMPER
 SUBDIRS = quick_dump
 endif
 
-bin_PROGRAMS = 				\
-	intel_disable_clock_gating 	\
-	intel_audio_dump 		\
-	intel_backlight 		\
-	intel_bios_dumper 		\
-	intel_bios_reader 		\
-	intel_error_decode 		\
-	intel_framebuffer_dump 		\
-	intel_gpu_top 			\
-	intel_gpu_time 			\
-	intel_gtt 			\
-	intel_opregion_decode		\
-	intel_perf_counters		\
-	intel_stepping 			\
-	intel_reg_checker 		\
-	intel_reg_dumper 		\
-	intel_reg_snapshot 		\
-	intel_reg_write 		\
-	intel_reg_read 			\
-	intel_forcewaked		\
-	intel_dpio_read			\
-	intel_dpio_write		\
-	intel_l3_parity			\
-	intel_punit_read		\
-	intel_punit_write		\
-	intel_nc_write			\
-	intel_nc_read			\
-	intel_vga_read			\
-	intel_vga_write
-
-noinst_PROGRAMS = 			\
-	intel_dump_decode 		\
-	intel_infoframes		\
-	intel_lid			\
-	intel_panel_fitter
-
-dist_bin_SCRIPTS = intel_gpu_abrt
-
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
 AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS)
 LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS)
 
-intel_dump_decode_SOURCES = 	\
-	intel_dump_decode.c
-
-intel_error_decode_SOURCES =	\
-	intel_error_decode.c
-
-intel_bios_reader_SOURCES =	\
-	intel_bios_reader.c	\
-	intel_bios.h
-
-intel_l3_parity_SOURCES =	\
-	intel_l3_parity.c	\
-	intel_l3_parity.h	\
-	intel_l3_udev_listener.c
diff --git a/tools/Makefile.sources b/tools/Makefile.sources
new file mode 100644
index 0000000..a4664fe
--- /dev/null
+++ b/tools/Makefile.sources
@@ -0,0 +1,53 @@
+bin_PROGRAMS = 				\
+	intel_disable_clock_gating 	\
+	intel_audio_dump 		\
+	intel_backlight 		\
+	intel_bios_dumper 		\
+	intel_bios_reader 		\
+	intel_error_decode 		\
+	intel_framebuffer_dump 		\
+	intel_gpu_top 			\
+	intel_gpu_time 			\
+	intel_gtt 			\
+	intel_opregion_decode		\
+	intel_perf_counters		\
+	intel_stepping 			\
+	intel_reg_checker 		\
+	intel_reg_dumper 		\
+	intel_reg_snapshot 		\
+	intel_reg_write 		\
+	intel_reg_read 			\
+	intel_forcewaked		\
+	intel_dpio_read			\
+	intel_dpio_write		\
+	intel_l3_parity			\
+	intel_punit_read		\
+	intel_punit_write		\
+	intel_nc_write			\
+	intel_nc_read			\
+	intel_vga_read			\
+	intel_vga_write
+
+noinst_PROGRAMS = 			\
+	intel_dump_decode 		\
+	intel_infoframes		\
+	intel_lid			\
+	intel_panel_fitter
+
+dist_bin_SCRIPTS = intel_gpu_abrt
+
+intel_dump_decode_SOURCES = 	\
+	intel_dump_decode.c
+
+intel_error_decode_SOURCES =	\
+	intel_error_decode.c
+
+intel_bios_reader_SOURCES =	\
+	intel_bios_reader.c	\
+	intel_bios.h
+
+intel_l3_parity_SOURCES =	\
+	intel_l3_parity.c	\
+	intel_l3_parity.h	\
+	intel_l3_udev_listener.c
+
