From 432e70051cc388360cbb6b78c83302bdecbbf3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Wed, 26 Mar 2014 15:08:35 +0000 Subject: [PATCH] Makefile: Ignore cuda files if NVCC is not set svn-origin-rev: 13714 --- makefiles/Makefile | 5 ++++- tools/discover_programs.py | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/makefiles/Makefile b/makefiles/Makefile index f905cb18ea..173c5e56ce 100644 --- a/makefiles/Makefile +++ b/makefiles/Makefile @@ -34,10 +34,13 @@ MODDEPS = "lower" include $(CP2KHOME)/arch/$(ARCH).$(ONEVERSION) LIBDIR := $(MAINLIBDIR)/$(ARCH)/$(ONEVERSION) OBJDIR := $(MAINOBJDIR)/$(ARCH)/$(ONEVERSION) +ifeq ($(NVCC),) +DISCOVER_FLAGS = "--ignore-cuda-files" +endif endif # Discover programs ========================================================= -ALL_EXE_FILES = $(sort $(shell $(TOOLSRC)/discover_programs.py $(SRCDIR))) +ALL_EXE_FILES = $(sort $(shell $(TOOLSRC)/discover_programs.py $(SRCDIR) $(DISCOVER_FLAGS) )) EXE_NAMES = $(basename $(notdir $(ALL_EXE_FILES))) # Declare PHONY targets ===================================================== diff --git a/tools/discover_programs.py b/tools/discover_programs.py index c2b6c9dbdc..5da8864e8b 100755 --- a/tools/discover_programs.py +++ b/tools/discover_programs.py @@ -10,12 +10,17 @@ re_main = re.compile(r"\sint\s+main\s*\(") #============================================================================ def main(): - if(len(sys.argv) < 2): - print("Usage: discover_programs.py ") + if(len(sys.argv) not in (2,3)): + print("Usage: discover_programs.py [--ignore-cuda-files]") sys.exit(1) srcdir = sys.argv[1] + ignore_cu_files = False + if(len(sys.argv) > 2): + assert(sys.argv[2] == "--ignore-cuda-files") + ignore_cu_files = True + programs = [] for root, dirs, files in os.walk(srcdir): if(root.endswith("/preprettify")): @@ -29,10 +34,15 @@ def main(): if(is_fortran_program(abs_fn)): programs.append(abs_fn) - elif(fn[-2:]==".c" or fn[-3:]==".cu"): + elif(fn[-2:] == ".c"): if(has_main_function(abs_fn)): programs.append(abs_fn) + elif(fn[-3:] == ".cu" and not ignore_cu_files): + if(has_main_function(abs_fn)): + programs.append(abs_fn) + + print(" ".join(programs))