refactor the gathering of compile time settings after discussion with @sjplimp

- remove feature to record the compilation time and date
- remove 'echo -n' based "progress bar"
- update output format for "lmp_machine -h" to be consistent with help output
- move generation of lmpinstalledpkgs.h to be a separate target depending on
  all sources and headers in src folder. this way it is only regenerated
  when files are modified or packages installed
This commit is contained in:
Axel Kohlmeyer
2018-05-09 21:45:58 -04:00
parent 1f770a6a8f
commit 7f0c88c74b
4 changed files with 25 additions and 31 deletions

1
src/.gitignore vendored
View File

@ -5,7 +5,6 @@
/lmp_* /lmp_*
/style_*.h /style_*.h
/lmpcompiledate.h
/lmpinstalledpkgs.h /lmpinstalledpkgs.h
/*_gpu.h /*_gpu.h

View File

@ -1,7 +1,6 @@
# Make.sh = update Makefile.lib, Makefile.shlib, Makefile.list # Make.sh = update Makefile.lib, Makefile.shlib, Makefile.list
# or style_*.h files # or style_*.h files
# Syntax: sh Make.sh style # Syntax: sh Make.sh style
# sh Make.sh date
# sh Make.sh Makefile.lib # sh Make.sh Makefile.lib
# sh Make.sh Makefile.shlib # sh Make.sh Makefile.shlib
# sh Make.sh Makefile.list # sh Make.sh Makefile.list
@ -56,10 +55,6 @@ style () {
fi fi
} }
if (test $1 = "date") then
echo "static const char lammps_compile_date[] = \"`date`\";" > lmpcompiledate.h
fi
# create individual style files # create individual style files
# called by "make machine" # called by "make machine"
# col 1 = string to search for # col 1 = string to search for

View File

@ -18,7 +18,7 @@ OBJDIR = Obj_$@
OBJSHDIR = Obj_shared_$@ OBJSHDIR = Obj_shared_$@
SRC = $(wildcard *.cpp) SRC = $(wildcard *.cpp)
INC = $(wildcard *.h) INC = $(filter-out lmpinstalledpkgs.h,$(wildcard *.h))
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)
SRCLIB = $(filter-out main.cpp,$(SRC)) SRCLIB = $(filter-out main.cpp,$(SRC))
@ -150,6 +150,18 @@ help:
for file in $$files; do head -1 $$file; done for file in $$files; do head -1 $$file; done
@echo '' @echo ''
lmpinstalledpkgs.h: $(SRC) $(INC)
@echo 'Gathering installed package information (may take a little while)'
@echo 'static const char lammps_installed_packages[] = ' > lmpinstalledpkgs.tmp
@for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \
[ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package/"/' >> lmpinstalledpkgs.tmp || :; done
@echo ';' >> lmpinstalledpkgs.tmp
@if [ -f lmpinstalledpkgs.h ]; \
then test "`diff --brief lmpinstalledpkgs.tmp lmpinstalledpkgs.h`" != "" && \
mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h || rm lmpinstalledpkgs.tmp ; \
else mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h ; fi
# Build LAMMPS in one of 4 modes # Build LAMMPS in one of 4 modes
# exe = exe with static compile in Obj_machine (default) # exe = exe with static compile in Obj_machine (default)
# shexe = exe with shared compile in Obj_shared_machine # shexe = exe with shared compile in Obj_shared_machine
@ -163,17 +175,7 @@ help:
-f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@ -f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@
@if [ ! -d $(objdir) ]; then mkdir $(objdir); fi @if [ ! -d $(objdir) ]; then mkdir $(objdir); fi
@$(SHELL) Make.sh style @$(SHELL) Make.sh style
@$(SHELL) Make.sh date @$(MAKE) $(MFLAGS) lmpinstalledpkgs.h
@echo 'Gathering installed package information'
@echo 'static const char lammps_installed_packages[] = ' > lmpinstalledpkgs.tmp
@for p in $(PACKAGEUC) $(PACKUSERUC); do echo -n '.'; info=$$($(SHELL) Package.sh $$p installed); \
[ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package/"/' >> lmpinstalledpkgs.tmp || :; done
@echo ';' >> lmpinstalledpkgs.tmp
@echo
@if [ -f lmpinstalledpkgs.h ]; \
then test "`diff --brief lmpinstalledpkgs.tmp lmpinstalledpkgs.h`" != "" && \
mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h || rm lmpinstalledpkgs.tmp ; \
else mv lmpinstalledpkgs.tmp lmpinstalledpkgs.h ; fi
@echo 'Compiling LAMMPS for machine $@' @echo 'Compiling LAMMPS for machine $@'
@if [ -f MAKE/MACHINES/Makefile.$@ ]; \ @if [ -f MAKE/MACHINES/Makefile.$@ ]; \
then cp MAKE/MACHINES/Makefile.$@ $(objdir)/Makefile; fi then cp MAKE/MACHINES/Makefile.$@ $(objdir)/Makefile; fi

View File

@ -1048,12 +1048,10 @@ static const char lammps_config_options[]
#endif #endif
"\n"; "\n";
#include "lmpcompiledate.h"
#include "lmpinstalledpkgs.h" #include "lmpinstalledpkgs.h"
void LAMMPS::print_config(FILE *fp) void LAMMPS::print_config(FILE *fp)
{ {
fprintf(fp,"LAMMPS compiled on: %s\n\n",lammps_compile_date);
fputs(lammps_config_options,fp); fputs(lammps_config_options,fp);
fprintf(fp,"Installed packages:%s\n\n",lammps_installed_packages); fprintf(fp,"Installed packages:%s\n\n",lammps_installed_packages);
} }