--- Makefile.am.orig	2015-12-12 07:25:52.299910471 +0100
+++ Makefile.am	2015-12-12 07:26:15.027143050 +0100
@@ -23,11 +23,11 @@ numastat_CFLAGS = $(AM_CFLAGS) -std=gnu9
 
 numademo_SOURCES = numademo.c stream_lib.c stream_lib.h mt.c mt.h clearcache.c clearcache.h
 numademo_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_STREAM_LIB -DHAVE_MT -DHAVE_CLEAR_CACHE
-numademo_CFLAGS = -O3 -ffast-math -funroll-loops
+numademo_CFLAGS = $(AM_CFLAGS) -O3 -ffast-math -funroll-loops
 if HAVE_TREE_VECTORIZE
 numademo_CFLAGS += -ftree-vectorize
 endif
-numademo_LDADD = libnuma.la -lm
+numademo_LDADD = libnuma.la -lm $(AM_LDFLAGS)
 
 migratepages_SOURCES = migratepages.c util.c
 migratepages_LDADD = libnuma.la
