# Help
help:
	@cat $(top_srcdir)/doc/help_make/help_make_src

# ---------------------------------------------------------------------------- #

# Creation of parent subroutines
parents:
	$(PERL) $(top_srcdir)/developers/maintainers/parents.pl -s
	rm -f *.old */*.old

# ---------------------------------------------------------------------------- #

# Beautify ABINIT sources (indentation)
# Note : the _ext, _noabirule should not treated because they are not expected to follow the abirules
# Note : 02_clib only includes C files
# Note : 43_ptgroup should not be treated because the routines have been generated automatically
# Note : 69_wfdesc, 70_gw and 71_bse  should not be treated due a special request of Matteo
# Note : the "Warning" occurences have been eliminated on 10 May 2011.
# Note : the "ERROR" occurences have been eliminated on 25 December 2011, also documenting the solution for each type of problem !!
# Note : 26 Feb 2012 : error messages have been improved, recursive has been allowed.
# Should write the documentation, so that to imitate the "make parents" treatment on shiva ...
# The treatment of $omp is still incorrect !!
#
# 1) ERROR(41_geometry/prt_cif.F90): found end statement at line 273 for '' subroutine symrel2string '' before executable section
#      The structuration between the declarations and the executable section was missing
# 2) ERROR(67_common/mklocl_realspace.F90): found end statement at line 849 for '' subroutine createIonicPotential_new '' instead of '' if construct ''
#      There was a (forbidden) on-line if ... call :
#       if (condition)  call subroutine
#      Solution : replace by
#        if (condition) then
#            call subroutine
#        endif
# 3) ERROR(67_common/rhotov.F90): found end statement at line 412 for '' subroutine rhotov '' instead of '' if construct ''
#      There was a (forbidden) on-line secondary if construct
#        command ; if( condition) command2
#      Solution : replace by
#        command
#        if(condition) command2
# 4) Similar message of error might be caused by sections of the code that start from the first column !! 
#      Solution : by hand, insert a blank. Abiauty will do the rest ...
# 
# When happening in a module, ignore the problems (modules are not yet treated by abiauty).
# 
# 1) ERROR, executable section not found
# 2) ERROR(10_defs/defs_datatypes.F90): found type at line 99 while expecting program/subroutine
# 3) ERROR(10_defs/defs_datatypes.F90): end of file 10_defs/defs_datatypes.F90 hit prematurely while expecting:
#  program/subroutine/function statement
# 4) ERROR(10_defs/defs_wannier90.F90): found end statement at line 62 for '' subroutine wannier_setup '' before executable section
abiauty:
	@echo 'Reporting possible errors in the abiauty procedure' > tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 10_defs >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 11_memory_mpi >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 12_hide_mpi >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 14_hidewrite >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 15_gpu_toolbox >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 16_hideleave >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 18_timing >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 27_toolbox_oop >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 32_util >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 41_geometry >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 41_xc_lowlevel >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 42_libpaw >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 42_nlstrain >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 42_parser >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 43_wvl_wrappers >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 44_abitypes_defs >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 45_geomoptim >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 47_xml >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 49_gw_toolbox_oop >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 51_manage_mpi >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 52_manage_cuda >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 53_abiutil >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 53_ffts >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 53_spacepar >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 56_io_mpi >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 56_mixing >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 56_recipspace >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 56_xc >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 57_iopsp_parser >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 57_iovars >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 61_ionetcdf >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 62_ctqmc >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 62_iowfdenpot >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 62_occeig >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 62_poisson >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 62_wvl_wfs >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 63_bader >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 64_atompaw >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 65_lotf_base >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 65_nonlocal >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 65_psp >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 66_paw >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 66_wfs >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 67_common >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 68_dmft >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 68_lotf >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 68_recursion >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 68_rsprc >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 72_response >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 77_ddb >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 77_suscep >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 79_seqpar_mpi >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 83_cut3d >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 95_drive >> tmp-abiauty.log
	@$(PERL) ../developers/maintainers/abiauty.pl -d 98_main >> tmp-abiauty.log
	grep ERROR tmp-abiauty.log > error_make_abiauty  || true

# ---------------------------------------------------------------------------- #
# Note concerning abirules (as of 5.8.0)
# The order of config.h vs abi_common.h is not preserved.
# This should be corrected by hand. It is to be done, at present,
# in get_irredg, merge_kgirr, setshells, sigma

# Thorough clean-up
maintainer-clean-local:
	rm -f tmp-abiauty.log tmp-abirules.log
	rm -f abirules.log
	find . -name '*.old' -exec rm {} \;
	find . -name '*.orig' -exec rm {} \;
	find . -name '*.rej' -exec rm {} \;
