public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Clark Williams <williams@redhat.com>,
	Frank Rowand <frank.rowand@am.sony.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	rt-users <linux-rt-users@vger.kernel.org>
Cc: John Kacur <jkacur@redhat.com>
Subject: [PATCH] RFC - rt-tools: Detect whether numa is available at build time
Date: Sat, 26 May 2012 01:39:49 +0200	[thread overview]
Message-ID: <1337989189-17563-1-git-send-email-jkacur@redhat.com> (raw)

This is a preliminary hack, I need to clean it up a little, but incase you
want to give it a try, here is the alpha version.

Note - I stole this methodology from tools/perf

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 Makefile                 |   33 +++++++++++++++++++++++++++------
 config/feature-tests.mak |    8 ++++++++
 config/utilities.mak     |    7 +++++++
 3 files changed, 42 insertions(+), 6 deletions(-)
 create mode 100644 config/feature-tests.mak
 create mode 100644 config/utilities.mak

diff --git a/Makefile b/Makefile
index 3a82407..33f5027 100644
--- a/Makefile
+++ b/Makefile
@@ -16,9 +16,6 @@ srcdir	?= $(prefix)/src
 
 machinetype = $(shell $(CC) -dumpmachine | \
     sed -e 's/-.*//' -e 's/i.86/i386/' -e 's/mips.*/mips/' -e 's/ppc.*/powerpc/')
-ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),)
-NUMA 	:= 1
-endif
 
 CFLAGS ?= -D_GNU_SOURCE -Wall -Wno-nonnull -Isrc/include
 LDFLAGS ?=
@@ -31,9 +28,33 @@ else
 	CFLAGS	+= -O0 -g
 endif
 
-ifeq ($(NUMA),1)
-	CFLAGS += -DNUMA
-	NUMA_LIBS = -lnuma
+ifeq ("$(origin O)", "command line")
+	OUTPUT := $(O)/
+endif
+
+ifneq ($(OUTPUT),)
+# check that the output directory actually exists
+OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
+$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
+endif
+
+include config/utilities.mak
+include config/feature-tests.mak
+
+ifeq ($(NUMA),0)
+	NO_NUMA=0
+endif
+
+ifdef NO_NUMA
+	CFLAGS += -DNO_NUMA_SUPPORT
+else
+	ifneq ($(call try-cc,$(SOURCE_NUMA),-lnuma),y)
+		msg := $(warning numa not found. Install numactl-devel to build with numa support);
+		CFLAGS += -DNO_NUMA_SUPPORT
+	else
+		CFLAGS += -DNUMA
+		NUMA_LIBS = -lnuma
+	endif
 endif
 
 VPATH	= src/cyclictest:
diff --git a/config/feature-tests.mak b/config/feature-tests.mak
new file mode 100644
index 0000000..8fb61ea
--- /dev/null
+++ b/config/feature-tests.mak
@@ -0,0 +1,8 @@
+ifndef NO_NUMA
+define SOURCE_NUMA
+int main(void)
+{
+	return numa_available();
+}
+endef
+endif
diff --git a/config/utilities.mak b/config/utilities.mak
new file mode 100644
index 0000000..da7c434
--- /dev/null
+++ b/config/utilities.mak
@@ -0,0 +1,7 @@
+# try-cc
+# Usage: option = $(call try-cc, source-to-build, cc-options)
+try-cc = $(shell sh -c						  \
+	'TMP="$(OUTPUT)$(TMPOUT).$$$$";				  \
+	 echo "$(1)" |						  \
+	 $(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
+	 rm -f "$$TMP"')
-- 
1.7.7.6


             reply	other threads:[~2012-05-25 23:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25 23:39 John Kacur [this message]
2012-05-29  0:49 ` [PATCH] RFC - rt-tools: Detect whether numa is available at build time Frank Rowand
2012-05-30 19:58   ` John Kacur
2012-05-30 21:48     ` Frank Rowand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337989189-17563-1-git-send-email-jkacur@redhat.com \
    --to=jkacur@redhat.com \
    --cc=frank.rowand@am.sony.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox