xref: /petsc/gmakefile.test (revision 4e278199b78715991f5c71ebbd945c1489263e6c)
1# -*- mode: makefile-gmake -*-
2-include petscdir.mk
3
4.SUFFIXES: .F  .F90 .f90 ${SUFFIXES} .PETSc .C .cc .cpp .cxx .r .rm .so .html .ad .m .tex .mtex .make  .fig .svg .eps .pdf .jpg .png .dvi .ps .F95 .f95 .fiat .cu .kokkos.cxx
5
6CONFIGDIR := $(PETSC_DIR)/config
7
8# TESTSRCDIR is always relative to gmakefile.test
9#  This must be before includes
10mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
11TESTSRCDIR := $(dir $(mkfile_path))src
12
13-include $(PETSC_DIR)/$(PETSC_ARCH)/lib/petsc/conf/petscvariables
14-include $(PETSC_DIR)/lib/petsc/conf/variables
15
16TESTDIR ?= ./$(PETSC_ARCH)/tests
17MODDIR := $(PETSC_DIR)/$(PETSC_ARCH)/include
18TESTLOGTAPFILE ?= $(TESTDIR)/test_$(PETSC_ARCH)_tap.log
19TESTLOGERRFILE ?= $(TESTDIR)/test_$(PETSC_ARCH)_err.log
20EXAMPLESDIR := $(TESTSRCDIR)
21
22pkgs := sys vec mat dm ksp snes ts tao
23
24petscconf      := $(PETSC_DIR)/$(PETSC_ARCH)/include/petscconf.h
25petscvariables := $(PETSC_DIR)/$(PETSC_ARCH)/lib/petsc/conf/petscvariables
26generatedtest  := $(TESTDIR)/testfiles
27
28.SECONDEXPANSION:		# to expand $$(@D)/.DIR
29
30TESTFLAGS :=             # Initialize as simple variable
31
32#workarround old cygwin versions
33ifeq ($(PETSC_CYGWIN_BROKEN_PIPE),1)
34ifeq ($(shell basename $(AR)),ar)
35  V ?=1
36endif
37endif
38V ?= $(if $(findstring s,$(MAKEFLAGS)),0)
39ifeq ($(V),)  # Default
40  quiet_HELP := "Use \"$(MAKE) V=1\" to see verbose compile lines, \"$(MAKE) V=0\" to suppress.\n"
41  quiet = @printf $(quiet_HELP)$(eval quiet_HELP:=)"  %10s %s\n" "$1$2" "$@"; $($1)
42  quiettest = @printf "  %10s %s\n" "TEST" "$(@:$(TESTDIR)/counts/%.counts=%)";
43else ifeq ($(V),0)		# Suppress entire command
44  quiet = @$($1)
45  quiettest = @
46  TESTFLAGS += -o err_only
47else				# Show the full command line
48  quiet = $($1)
49  quiettest =
50  TESTFLAGS += -v
51endif
52
53ifeq ($(FORCE),1)
54  TESTFLAGS += -f    # force test execution
55endif
56ifeq ($(CUDAMEMCHECK),1)
57  TESTFLAGS += -U    # Add cuda-memcheck option to the flags
58endif
59ifeq ($(VALGRIND),1)
60  TESTFLAGS += -V    # Add valgrind option to the flags
61endif
62ifeq ($(DEBUG),1)
63  TESTFLAGS += -d    # Launch test in debugger
64endif
65ifeq ($(REPLACE),1)
66  TESTFLAGS += -m    # Replace results by passing -m to petscdiff
67endif
68ifeq ($(OUTPUT),1)
69  TESTFLAGS += -o 'err_only'    # Show only the errors on stdout
70endif
71ifeq ($(ALT),1)
72  TESTFLAGS += -M    # Replace alt files by passing -M to petscdiff
73endif
74PRINTONLY ?= 0
75ifeq ($(PRINTONLY),1)
76  TESTFLAGS += -p    # Pass -p to petscdiff to print only command
77endif
78ifeq ($(DIFF_NUMBERS),1)
79  TESTFLAGS += -j    # Pass -j to petscdiff to diff the actual numbers
80endif
81ifdef OPTIONS
82  TESTFLAGS += -a '$(OPTIONS)'   # override arguments
83endif
84ifdef EXTRA_OPTIONS
85  TESTFLAGS += -e '$(EXTRA_OPTIONS)'  # add extra arguments
86endif
87ifdef NP
88  TESTFLAGS += -n $(NP)  # set number of processes
89endif
90# Override the default timeout that may be found at the top of config/petsc_harness.sh
91# This must be an integer.  It is given in seconds.
92ifdef TIMEOUT
93  TESTFLAGS += -t $(TIMEOUT)  # Override the default timeout
94endif
95
96$(generatedtest) : $(petscconf) $(petscvariables) $(CONFIGDIR)/gmakegentest.py $(TESTDIR)/.DIR | $$(@D)/.DIR
97	$(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR)
98
99ifneq ($(filter-out clean check info,$(MAKECMDGOALS:clean%=clean)),)
100include $(generatedtest)
101endif
102
103ifeq ($(PETSC_LANGUAGE),CXXONLY)
104  cc_name := CXX
105else
106  cc_name := CC
107endif
108
109PETSC_COMPILE.c = $(call quiet,$(cc_name)) -c $(PCC_FLAGS) $(PFLAGS) $(CCPPFLAGS) $(C_DEPFLAGS)
110PETSC_COMPILE.cxx = $(call quiet,CXX) -c $(CXX_FLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(CXX_DEPFLAGS)
111PETSC_COMPILE.cu = $(call quiet,CUDAC) -c $(CUDAC_FLAGS) $(CUFLAGS) --compiler-options="${PETSC_CCPPFLAGS} $(CUDACPPFLAGS) $(CUDA_CXXFLAGS)"
112PETSC_COMPILE.hip.cpp = $(call quiet,HIPC) -c $(HIPC_FLAGS) $(HIPFLAGS) $(HIPPPFLAGS) $(HIPOPTFLAGS) $(HIPC_DEPFLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(CXX_DEPFLAGS)
113PETSC_COMPILE.sycl.cpp = $(call quiet,SYCLCPP) -c $(SYCLCPP_FLAGS) $(SYCLCPPFLAGS) $(SYCLCPPCPPFLAGS) $(SYCLCPP_DEPFLAGS)
114PETSC_GENDEPS.cu = $(call quiet,CUDAC,.dep) --generate-dependencies --output-directory=$(@D) $(CUDAC_FLAGS) $(CUFLAGS)  --compiler-options="${PETSC_CCPPFLAGS} $(CUDA_CXXFLAGS)"
115PETSC_COMPILE.F = $(call quiet,FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS)
116
117ifneq ($(KOKKOS_USE_CUDA_COMPILER),)
118  # Kokkos requires nvcc to be in PATH and the C++ compiler to be given in an environmental variable
119  PETSC_COMPILE.kokkos.cxx = PATH=$(PATH):`dirname $(CUDAC)` NVCC_WRAPPER_DEFAULT_COMPILER=$(CXX_LINKER) $(KOKKOS_BIN)/nvcc_wrapper --expt-extended-lambda -c $(CUDAC_FLAGS) $(CUFLAGS) ${PETSC_CCPPFLAGS} $(CUDACPPFLAGS) $(CUDA_CXXFLAGS)
120  PETSC_LINK.kokkos.cxx = PATH=$(PATH):`dirname $(CUDAC)` NVCC_WRAPPER_DEFAULT_COMPILER=$(CXX_LINKER) $(KOKKOS_BIN)/nvcc_wrapper --expt-extended-lambda $(CUDAC_FLAGS) $(CXX_LINKER_FLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(LDFLAGS)
121else ifneq ($(KOKKOS_USE_HIP_COMPILER),)
122  PETSC_COMPILE.kokkos.cxx = $(PETSC_COMPILE.hip.cpp)
123  PETSC_LINK.kokkos.cxx = MPICH_CXX="$(HIPC)" OMPI_CXX="$(HIPC)" $(CXXLINKER) $(HIPFLAGS) $(CXXFLAGS) $(PETSC_CCPPFLAGS) $(CPPFLAGS) $(LDFLAGS)
124else
125  PETSC_COMPILE.kokkos.cxx = $(PETSC_COMPILE.cxx)
126  PETSC_LINK.kokkos.cxx = $(CXXLINKER) $(CXXFLAGS) $(PETSC_CCPPFLAGS) $(CPPFLAGS) $(LDFLAGS)
127endif
128
129testlangs := c cu cxx F F90 kokkos.cxx hip.cpp sycl.cpp
130$(foreach lang, $(testlangs), $(eval \
131  testexe.$(lang) = $(foreach pkg, $(pkgs), $(testsrcs-$(pkg).$(lang):%.$(lang)=$(TESTDIR)/%))))
132concattestlang = $(foreach lang, $(2), $(testsrcs-$(1).$(lang):%.$(lang)=$(TESTDIR)/%.o))
133testsrcs.o := $(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),$(testlangs)))
134testsrcs-rel := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), $(testsrcs-$(pkg).$(lang))))
135testsrcs := $(foreach sfile, $(testsrcs-rel), $(TESTSRCDIR)/$(sfile))
136
137# workaround win32fe failure
138ifneq (,$(findstring win32fe,$(call quiet,$(cc_name))))
139$(TESTDIR)/ts/tutorials/multirate/ex6: | $(TESTDIR)/ts/tutorials/multirate/ex5
140$(TESTDIR)/ts/tutorials/multirate/ex8: | $(TESTDIR)/ts/tutorials/multirate/ex6
141endif
142
143# Refresh testfiles when sources change, but don't balk if the source file is nonexistent (deleted)
144$(generatedtest) : $(testsrcs)
145$(testsrcs) :
146
147$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.c | $$(@D)/.DIR
148	$(PETSC_COMPILE.c) $(abspath $<) -o $@
149
150$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.kokkos.cxx | $$(@D)/.DIR
151	$(PETSC_COMPILE.kokkos.cxx) $(abspath $<) -o $@
152
153$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cxx | $$(@D)/.DIR
154	$(PETSC_COMPILE.cxx) $(abspath $<) -o $@
155
156$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cu | $$(@D)/.DIR
157	$(PETSC_COMPILE.cu) $(abspath $<) -o $@ # Compile first so that if there is an error, it comes from a normal compile
158	@$(PETSC_GENDEPS.cu) $(abspath $<) -o $(@:%.o=%.d) # Generate the dependencies for later
159
160# Test modules go in the same directory as the target *.o
161TESTMODDIR = $(@D)
162FCMOD = cd
163$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F | $$(@D)/.DIR
164ifeq ($(FC_MODULE_OUTPUT_FLAG),)
165	$(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@)
166else
167	$(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR)
168endif
169	-@$(GFORTRAN_DEP_CLEANUP)
170
171$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F90 | $$(@D)/.DIR
172ifeq ($(FC_MODULE_OUTPUT_FLAG),)
173	$(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@)
174else
175	$(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR)
176endif
177	-@$(GFORTRAN_DEP_CLEANUP)
178
179#   This is a hack to fix a broken gfortran.
180define GFORTRAN_DEP_CLEANUP
181  if test -e "$(@:%.o=%.d)" && head -1 "$(@:%.o=%.d)" | fgrep -q -v : ; then\
182    echo "$(@): \\" > $(@:%.o=%.dtemp) ; \
183    tr '\n' '@' < $(@:%.o=%.d) | cut -d: -f2- | tr '@' '\n' >> $(@:%.o=%.dtemp) ; \
184    mv $(@:%.o=%.dtemp) $(@:%.o=%.d); \
185  fi
186endef
187
188# link line constructed differently for gmakefile vs gmakefile.test invocation
189ifeq ($(libpetscall),)
190PETSC_TEST_LIB = $(PETSC_LIB)
191else
192PETSC_TEST_LIB = $(C_SH_LIB_PATH) $(PETSC_EXTERNAL_LIB_BASIC)
193endif
194
195# manually list some some library dependencies to check for circular dependencies
196$(TESTDIR)/sys/tests/ex9: PETSC_TEST_LIB = $(PETSC_SYS_LIB)
197$(TESTDIR)/vec/vec/tests/ex1: PETSC_TEST_LIB = $(PETSC_VEC_LIB)
198$(TESTDIR)/mat/tests/ex1: PETSC_TEST_LIB = $(PETSC_MAT_LIB)
199$(TESTDIR)/dm/tests/ex1: PETSC_TEST_LIB = $(PETSC_DM_LIB)
200$(TESTDIR)/ksp/ksp/tests/ex1: PETSC_TEST_LIB = $(PETSC_KSP_LIB)
201$(TESTDIR)/snes/tests/ex1: PETSC_TEST_LIB = $(PETSC_SNES_LIB)
202$(TESTDIR)/ts/tests/ex2: PETSC_TEST_LIB = $(PETSC_TS_LIB)
203$(TESTDIR)/tao/tutorials/ex1: PETSC_TEST_LIB = $(PETSC_TAO_LIB)
204
205# if run with MACOS_FIREWALL=1 or MACOS_FIREWALL_REFRESH=1, ensure mpiexec.hydra and test executable is on firewall list
206ifeq ($(MACOS_FIREWALL_REFRESH),1)
207# MACOS_FIREWALL_REFRESH=1 imply MACOS_FIREWALL=1
208MACOS_FIREWALL := 1
209endif
210
211ifeq ($(MACOS_FIREWALL),1)
212MACOS_FIREWALL_MPIEXEC := $(shell $(PYTHON) -c "import os; print(os.path.realpath('$(MPIEXEC)'))")
213FW := /usr/libexec/ApplicationFirewall/socketfilterfw
214ifeq ($(MACOS_FIREWALL_REFRESH),1)
215define macos-firewall-register
216  @APP=$(call abspath, $(1)); \
217    echo "MACOS_FIREWALL_REFRESH set => refresh firewall rule"; \
218    if ! sudo -n true 2>/dev/null; then echo "Asking for sudo password to add new firewall rule for\n  $$APP:"; fi; \
219    sudo $(FW) --remove $$APP && \
220    sudo $(FW) --add $$APP && \
221    sudo $(FW) --blockapp $$APP
222endef
223else
224define macos-firewall-register
225  @APP=$(call abspath, $(1)); \
226    ANS=`$(FW) --getappblocked $$APP`; \
227    if ! echo $$ANS | grep "$$APP" &> /dev/null; then \
228      if ! sudo -n true 2>/dev/null; then echo "Asking for sudo password to add new firewall rule for\n  $$APP:"; fi; \
229      sudo $(FW) --add $$APP && \
230      sudo $(FW) --blockapp $$APP; \
231    else \
232      echo $$ANS; \
233    fi
234endef
235endif
236define macos-firewall-fix
237  $(call macos-firewall-register, $(MACOS_FIREWALL_MPIEXEC))
238  $(call macos-firewall-register, $(1))
239endef
240endif
241
242# Test executables
243$(testexe.F) $(testexe.F90) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall)
244	$(call quiet,FLINKER) -o $@ $^ $(PETSC_TEST_LIB)
245	-$(call macos-firewall-fix,$@)
246
247$(testexe.c) $(testexe.cu) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall)
248	$(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB)
249	-$(call macos-firewall-fix,$@)
250
251$(testexe.kokkos.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall)
252	$(call quiet,PETSC_LINK.kokkos.cxx) -o $@ $^ $(PETSC_TEST_LIB)
253	-$(call macos-firewall-fix,$@)
254
255$(testexe.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall)
256	$(call quiet,CXXLINKER) -o $@ $^ $(PETSC_TEST_LIB)
257	-$(call macos-firewall-fix,$@)
258
259# Fortran source files need petsc*.mod, which isn't explicitly managed in the makefile.
260$(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),F F90)) : $(libpetscall)
261
262# Testing convenience targets
263.PHONY: test pre-clean
264
265test: report_tests
266
267pre-clean:
268	@$(RM) -rf $(TESTDIR)/counts $(TESTLOGTAPFILE) $(TESTLOGERRFILE)
269	@touch $(TESTLOGTAPFILE) $(TESTLOGERRFILE)
270	@echo "Using MAKEFLAGS:" ${MAKEFLAGS}
271
272check-test-errors:
273	@grep '^not ok' $(TESTLOGTAPFILE) | grep -v 'Exceeded timeout' | tee $(TESTDIR)/allgtests-tap-err.log
274	@test ! -s $(TESTDIR)/allgtests-tap-err.log
275
276.PHONY: $(foreach pkg, $(pkgs), test-$(pkg) $(foreach lang, $(testlangs), test-$(pkg).$(lang) test-rm-$(pkg).$(lang)))
277testpkgs := $(foreach pkg, $(pkgs), test-$(pkg))
278# Targets to run tests in test-$pkg.$lang and delete the executables, language by language
279$(testpkgs) : test-% : $(foreach lang, $(testlangs), test-rm-%.$(lang))
280# List of raw test run targets
281alltesttargets := $(foreach tp, $(testpkgs), $(foreach lang, $(testlangs), $($(tp).$(lang))))
282
283# Run targets
284$(alltesttargets) : % : $(TESTDIR)/counts/%.counts
285.PHONY: $(alltesttargets)
286
287$(TESTDIR)/counts/%.counts :
288	$(quiettest) $< $(TESTFLAGS)
289
290# Targets to run tests and remove executables, by package-lang pairs.
291# Run the tests in each batch using recursive invocation of make because
292# we need all of them to complete before removing the executables.  Make
293# doesn't guarantee an exploration order for the graph.  Only recursive
294# if there is something to be done.
295alltest-rm := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), test-rm-$(pkg).$(lang)))
296$(alltest-rm) : test-rm-% : test-%
297ifneq ($(NO_RM),1)
298	$(call quiet,RM) $(addprefix $(TESTDIR)/,$(basename $($(@:test-rm-%=testsrcs-%))))
299endif
300
301# Remove intermediate .o files
302# This only removes the files at the end which is insufficient
303#.INTERMEDIATE: $(testsrcs.o:%.o=%)
304
305# all sources should get recompiled when petscvariables changes (i.e when configure is rerun or when petscvariables is manually edited.)
306$(testsrcs.o) : $(petscvariables)
307
308%/.DIR :
309	@mkdir -p $(@D)
310	@touch $@
311
312.PRECIOUS: %/.DIR
313
314.SUFFIXES: # Clear .SUFFIXES because we don't use implicit rules
315.DELETE_ON_ERROR:               # Delete likely-corrupt target file if rule fails
316
317.PHONY: clean cleantest all
318
319cleantest:
320	${RM} -r $(TESTDIR) $(generatedtest)
321
322clean: cleantest
323
324alltest.d := $(testsrcs.o:%.o=%.d)
325# Tell make that alltest.d are all up to date.  Without this, the include
326# below has quadratic complexity, taking more than one second for a
327# do-nothing build of PETSc (much worse for larger projects)
328$(alltest.d) : ;
329
330-include $(alltest.d)
331
332# Tests can be generated by searching -- see documentation below
333showreport=
334ifndef searchin
335   searchin = " "
336endif
337ifdef i
338   searchin = $(i)
339endif
340ifdef gmakesearch
341  TESTTARGETS := $(filter $(gmakesearch),$(alltesttargets))
342  ifdef gmakesearchin
343    TESTTARGETS2 := $(foreach v,$(TESTTARGETS),$(if $(findstring $(gmakesearchin),$(v)),$(v)))
344    TESTTARGETS := $(TESTTARGETS2)
345  endif
346else ifdef gmakesearchin
347  TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(gmakesearchin),$(v)),$(v)))
348else ifdef argsearch
349  TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(argsearch),$($(v)_ARGS)),$(v)))
350else ifdef search
351  TESTTARGETS := $(shell $(PYTHON) config/query_tests.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(search)')
352else ifdef s
353  TESTTARGETS := $(shell $(PYTHON) config/query_tests.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(s)')
354else ifdef test-fail
355  TESTTARGETS := $(shell $(PETSC_ARCH)/tests/echofailures.sh)
356else ifdef query
357  TESTTARGETS := $(shell $(PYTHON) config/query_tests.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(query)' '$(queryval)')
358else ifdef q
359  TESTTARGETS := $(shell $(PYTHON) config/query_tests.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(q)' '$(qv)')
360else                            # No filter - run them all, but delete the executables as we go
361  TESTTARGETS := $(testpkgs)
362  ifneq ($(PRINTONLY),1)
363    showreport = "-s"  # Only show full report when all tests are run
364  endif
365endif
366
367.PHONY: report_tests print-test
368
369print-test:
370	$(info $(TESTTARGETS))
371	@true
372
373show-fail:
374	-@$(PYTHON) $(CONFIGDIR)/report_tests.py -d $(TESTDIR)/counts -f
375
376
377
378# Don't start running tests until starttime has completed
379$(alltesttargets:%=$(TESTDIR)/counts/%.counts) : starttime
380
381# Ensure that libpetsc (if it is a prerequisite) has been built and clean the counts/logs before starting timer
382starttime: pre-clean $(libpetscall)
383	@$(eval STARTTIME := $(shell date +%s))
384
385report_tests: starttime $(TESTTARGETS)
386	@$(eval ENDTIME := $(shell date +%s))
387	-@ elapsed_time=$$(($(ENDTIME)- $(STARTTIME))) && \
388	$(PYTHON) $(CONFIGDIR)/report_tests.py -m $(MAKE) -d $(TESTDIR)/counts -t 5 -e $${elapsed_time} $(showreport)
389
390check_output:
391	$(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR) --check-output
392
393# Do not how how to invoke test from makefile
394HASGMAKEFILE := $(filter gmakefile,$(MAKEFILE_LIST))
395ifeq ($(HASGMAKEFILE),gmakefile)
396helpdeps:=help-make help-targets
397makefile="gmakefile"
398other_help="To see full test help: make -f gmakefile.test help"
399else
400helpdeps:=help-make help-targets help-test
401makefile="gmakefile.test"
402other_help=""
403endif
404
405help: ${helpdeps}
406	-@echo "Above is from: ${helpdeps}"
407	-@echo "${other_help}"
408
409help-make:
410	-@echo
411	-@echo "Basic build usage:"
412	-@echo "   make -f ${makefile} <options>"
413	-@echo
414	-@echo "Options:"
415	-@echo "  V=0           Very quiet builds"
416	-@echo "  V=1           Verbose builds"
417	-@echo
418
419help-targets:
420	-@echo "All makefile targets and their dependencies:"
421	-@grep ^[a-z] ${makefile} | grep : | grep -v =
422	-@echo
423	-@echo
424
425help-test:
426	-@echo "Basic test usage:"
427	-@echo "   make -f ${makefile} test <options>"
428	-@echo
429	-@echo "Options:"
430	-@echo "  V=1               Verbose output (-v to scripts)"
431	-@echo "  NO_RM=1           Do not remove the executables after running"
432	-@echo "  REPLACE=1         Replace the output in PETSC_DIR source tree (-m to test scripts)"
433	-@echo "  OUTPUT=1          Show only the errors on stdout"
434	-@echo "  ALT=1             Replace 'alt' output in PETSC_DIR source tree (-M to test scripts)"
435	-@echo "  DIFF_NUMBERS=1    Diff the numbers in the output (-j to test scripts and petscdiff)"
436	-@echo "  CUDAMEMCHECK=1    Execute the tests using cuda-memcheck (-U to test scripts)"
437	-@echo "  VALGRIND=1        Execute the tests using valgrind (-V to test scripts)"
438	-@echo "  DEBUG=1           Launch tests in the debugger (-d to the scripts)"
439	-@echo "  NP=<num proc>     Set a number of processors to pass to scripts."
440	-@echo "  FORCE=1           Force SKIP or TODO tests to run"
441	-@echo "  PRINTONLY=1       Print the command, but do not run.  For loops print first command"
442	-@echo "  TIMEOUT=<time>    Test timeout limit in seconds (default in config/petsc_harness.sh)"
443	-@echo "  TESTDIR='tests'   Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}"
444	-@echo "                    or $${PREFIX_DIR}/$${TESTDIR}"
445	-@echo "                    or $${PREFIX_DIR}/share/petsc/examples/$${TESTDIR})"
446	-@echo "  TESTBASE='tests'   Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}"
447	-@echo "  OPTIONS='<args>'  Override options to scripts (-a to test scripts)"
448	-@echo "  EXTRA_OPTIONS='<args>'  Add options to scripts (-e to test scripts)"
449	-@echo
450	-@echo "Special options for macOS:"
451	-@echo "  MACOS_FIREWALL=1          Add each built test to the macOS firewall list to prevent popups. Configure --with-macos-firewall-rules to make this default"
452	-@echo "  MACOS_FIREWALL_REFRESH=1  The same, but force re-addition to the list. You need to do cleantest first"
453	-@echo
454	-@echo "Tests can be generated by searching with multiple methods"
455	-@echo "  For general searching (using config/query_test.py):"
456	-@echo "    make -f ${makefile} test search='sys*ex2*'"
457	-@echo "   or the shortcut using s"
458	-@echo "    make -f ${makefile} test s='sys*ex2*'"
459	-@echo "  You can also use the full path to a file directory"
460	-@echo "    make -f ${makefile} test s='src/sys/tests/'"
461	-@echo
462	-@echo "  To search for fields from the original test definitions:"
463	-@echo "    make -f ${makefile} test query='requires' queryval='*MPI_PROCESS_SHARED_MEMORY*'"
464	-@echo "   or the shortcut using q and qv"
465	-@echo "    make -f ${makefile} test q='requires' qv='*MPI_PROCESS_SHARED_MEMORY*'"
466	-@echo "  To filter results from other searches, use searchin"
467	-@echo "    make -f ${makefile} test s='src/sys/tests/' searchin='*options*'"
468	-@echo
469	-@echo "  To re-run the last tests which failed:"
470	-@echo "    make -f ${makefile} test test-fail='1'"
471	-@echo
472	-@echo "  To see which targets match a given pattern (useful for doing a specific target):"
473	-@echo "    make -f ${makefile} print-test search=sys*"
474	-@echo
475	-@echo "  To build an executable, give full path to location:"
476	-@echo '    make -f ${makefile} $${PETSC_ARCH}/tests/sys/tests/ex1'
477	-@echo "  or make the test with NO_RM=1"
478	-@echo
479