diff --git a/makefiles/Makefile b/makefiles/Makefile index 67293be056..0a4f29bd1f 100644 --- a/makefiles/Makefile +++ b/makefiles/Makefile @@ -27,6 +27,12 @@ EXEDIR := $(MAINEXEDIR)/$(ARCH) REVISION := $(shell $(CP2KHOME)/tools/get_revision_number $(SRCDIR)) +# Discover programs ========================================================= +ifeq ($(ALL_EXE_FILES),) +export ALL_EXE_FILES := $(sort $(shell $(TOOLSRC)/discover_programs.py $(SRCDIR))) +endif +EXE_NAMES := $(basename $(notdir $(ALL_EXE_FILES))) + # Once we are down to a single version ====================================== # this only happens on stage 3 and 4 ifneq ($(ONEVERSION),) @@ -35,14 +41,10 @@ include $(CP2KHOME)/arch/$(ARCH).$(ONEVERSION) LIBDIR := $(MAINLIBDIR)/$(ARCH)/$(ONEVERSION) OBJDIR := $(MAINOBJDIR)/$(ARCH)/$(ONEVERSION) ifeq ($(NVCC),) -DISCOVER_FLAGS = "--ignore-cuda-files" +EXE_NAMES := $(basename $(notdir $(filter-out %.cu, $(ALL_EXE_FILES)))) endif endif -# Discover programs ========================================================= -ALL_EXE_FILES := $(sort $(shell $(TOOLSRC)/discover_programs.py $(SRCDIR) $(DISCOVER_FLAGS) )) -EXE_NAMES := $(basename $(notdir $(ALL_EXE_FILES))) - # Declare PHONY targets ===================================================== .PHONY : $(VERSION) $(EXE_NAMES) \ dirs makedep default_target all \ diff --git a/tools/discover_programs.py b/tools/discover_programs.py index 5da8864e8b..0829832868 100755 --- a/tools/discover_programs.py +++ b/tools/discover_programs.py @@ -10,16 +10,13 @@ re_main = re.compile(r"\sint\s+main\s*\(") #============================================================================ def main(): - if(len(sys.argv) not in (2,3)): - print("Usage: discover_programs.py [--ignore-cuda-files]") + if(len(sys.argv) != 2): + print("Usage: discover_programs.py ") 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 + sys.stderr.write("Discovering programs ...\n") programs = [] for root, dirs, files in os.walk(srcdir): @@ -34,11 +31,7 @@ def main(): if(is_fortran_program(abs_fn)): programs.append(abs_fn) - elif(fn[-2:] == ".c"): - if(has_main_function(abs_fn)): - programs.append(abs_fn) - - elif(fn[-3:] == ".cu" and not ignore_cu_files): + elif(fn[-2:]==".c" or fn[-3:]==".cu"): if(has_main_function(abs_fn)): programs.append(abs_fn)