diff --git a/src/Makefile b/src/Makefile index 02248347fc..d8c6eb487d 100755 --- a/src/Makefile +++ b/src/Makefile @@ -11,16 +11,35 @@ SRC = $(wildcard *.cpp) INC = $(wildcard *.h) OBJ = $(SRC:.cpp=.o) +PACKAGE = asphere class2 colloid dipole dpd granular \ + kspace manybody meam molecule opt poems xtc +PACKUC = $(shell perl -e 'printf("%s", uc("$(PACKAGE)"));') +YESDIR = $(shell perl -e 'printf("%s", uc("$(@:yes-%=%)"));') +NODIR = $(shell perl -e 'printf("%s", uc("$(@:no-%=%)"));') + # Targets help: - @echo 'Type "make target" where target is one of:' + @echo '' + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + @echo 'make makelib update Makefile.lib for library build' + @echo 'make makelist update Makefile.list used by old makes' + @echo '' + @echo 'make package list available packages' + @echo 'make yes-package install a package in src dir' + @echo 'make no-package remove package files from src dir' + @echo 'make yes-all install all packages in src dir' + @echo 'make no-all remove all package files from src dir' + @echo 'make package-status status of all packages' + @echo 'make package-update replace src files with package files' + @echo 'make package-overwrite replace package files with src files' + @echo '' + @echo 'make machine build LAMMPS where machine is one of:' @echo '' @files="`ls MAKE/Makefile.*`"; \ - for file in $$files; do head -1 $$file; done - -clean: - rm -r Obj_* + for file in $$files; do head -1 $$file; done + @echo '' .DEFAULT: @test -f MAKE/Makefile.$@ @@ -31,6 +50,16 @@ clean: $(MAKE) "OBJ = $(OBJ)" "INC = $(INC)" "EXE = ../$(EXE)" ../$(EXE) @if [ -d Obj_$@ ]; then cd Obj_$@; rm $(SRC) $(INC) Makefile*; fi +clean: + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + +clean-all: + rm -r Obj_* + +clean-%: + rm -r Obj_$(@:clean-%=%) + # Update Makefile.lib and Makefile.list makelib: @@ -39,177 +68,51 @@ makelib: makelist: @csh Make.csh Makefile.list -# Packages +# Package management +# status = list differences between src and package files +# update = replace src files with newer package files +# overwrite = overwrite package files with newer src files package: @echo 'Available packages:' - @echo ' asphere, class2, colloid, dipole, dpd, granular,' - @echo ' kspace, manybody, meam, molecule, opt, poems, xtc' - @echo 'make yes-name to include a package' - @echo 'make no-name to exclude a package' - @echo 'make yes-all to include all packages' - @echo 'make no-all to exclude all packages' + @echo $(PACKAGE) + @echo '' + @echo 'make package list available packages' + @echo 'make yes-package install a package in src dir' + @echo 'make no-package remove package files from src dir' + @echo 'make yes-all install all packages in src dir' + @echo 'make no-all remove all package files from src dir' + @echo 'make package-status status of all packages' + @echo 'make package-update replace src files with package files' + @echo 'make package-overwrite replace package files with src files' yes-all: - make yes-asphere yes-class2 yes-colloid yes-dipole \ - yes-dpd yes-granular yes-kspace yes-manybody yes-meam \ - yes-molecule yes-opt yes-poems yes-xtc + @for p in $(PACKAGE); do $(MAKE) yes-$$p; done no-all: - @echo 'Removing files, ignore any rm errors ...' - @cd ASPHERE; csh -f Install.csh 0 - @cd CLASS2; csh -f Install.csh 0 - @cd COLLOID; csh -f Install.csh 0 - @cd DIPOLE; csh -f Install.csh 0 - @cd DPD; csh -f Install.csh 0 - @cd GRANULAR; csh -f Install.csh 0 - @cd KSPACE; csh -f Install.csh 0 - @cd MANYBODY; csh -f Install.csh 0 - @cd MEAM; csh -f Install.csh 0 - @cd MOLECULE; csh -f Install.csh 0 - @cd OPT; csh -f Install.csh 0 - @cd POEMS; csh -f Install.csh 0 - @cd XTC; csh -f Install.csh 0 - @make clean + @for p in $(PACKAGE); do $(MAKE) no-$$p; done -yes-asphere: - @cd ASPHERE; csh -f Install.csh 1 -no-asphere: - @echo 'Removing files, ignore any rm errors ...' - @cd ASPHERE; csh -f Install.csh 0 - @make clean +yes-%: + @if [ ! -e $(YESDIR) ]; then \ + echo "Package $(@:yes-%=%) does not exist"; \ + else \ + echo "Installing package $(@:yes-%=%)"; \ + cd $(YESDIR); csh -f Install.csh 1; \ + fi; -yes-class2: - @cd CLASS2; csh -f Install.csh 1 -no-class2: - @echo 'Removing files, ignore any rm errors ...' - @cd CLASS2; csh -f Install.csh 0 - @make clean +no-%: + @if [ ! -e $(NODIR) ]; then \ + echo "Package $(@:no-%=%) does not exist"; \ + else \ + echo "Uninstalling package $(@:no-%=%), ignore errors"; \ + cd $(NODIR); csh -f Install.csh 0; cd ..; $(MAKE) clean-all; \ + fi; -yes-colloid: - @cd COLLOID; csh -f Install.csh 1 -no-colloid: - @echo 'Removing files, ignore any rm errors ...' - @cd COLLOID; csh -f Install.csh 0 - @make clean - -yes-dipole: - @cd DIPOLE; csh -f Install.csh 1 -no-dipole: - @echo 'Removing files, ignore any rm errors ...' - @cd DIPOLE; csh -f Install.csh 0 - @make clean - -yes-dpd: - @cd DPD; csh -f Install.csh 1 -no-dpd: - @echo 'Removing files, ignore any rm errors ...' - @cd DPD; csh -f Install.csh 0 - @make clean - -yes-granular: - @cd GRANULAR; csh -f Install.csh 1 -no-granular: - @echo 'Removing files, ignore any rm errors ...' - @cd GRANULAR; csh -f Install.csh 0 - @make clean - -yes-kspace: - @cd KSPACE; csh -f Install.csh 1 -no-kspace: - @echo 'Removing files, ignore any rm errors ...' - @cd KSPACE; csh -f Install.csh 0 - @make clean - -yes-manybody: - @cd MANYBODY; csh -f Install.csh 1 -no-manybody: - @echo 'Removing files, ignore any rm errors ...' - @cd MANYBODY; csh -f Install.csh 0 - @make clean - -yes-meam: - @cd MEAM; csh -f Install.csh 1 -no-meam: - @echo 'Removing files, ignore any rm errors ...' - @cd MEAM; csh -f Install.csh 0 - @make clean - -yes-molecule: - @cd MOLECULE; csh -f Install.csh 1 -no-molecule: - @echo 'Removing files, ignore any rm errors ...' - @cd MOLECULE; csh -f Install.csh 0 - @make clean - -yes-opt: - @cd OPT; csh -f Install.csh 1 -no-opt: - @echo 'Removing files, ignore any rm errors ...' - @cd OPT; csh -f Install.csh 0 - @make clean - -yes-poems: - @cd POEMS; csh -f Install.csh 1 -no-poems: - @echo 'Removing files, ignore any rm errors ...' - @cd POEMS; csh -f Install.csh 0 - @make clean - -yes-xtc: - @cd XTC; csh -f Install.csh 1 -no-xtc: - @echo 'Removing files, ignore any rm errors ...' - @cd XTC; csh -f Install.csh 0 - @make clean - -# update src files with package files +package-status: + @for p in $(PACKUC); do csh -f Package.csh $$p status; done package-update: - @csh -f Package.csh ASPHERE update - @csh -f Package.csh CLASS2 update - @csh -f Package.csh COLLOID update - @csh -f Package.csh DIPOLE update - @csh -f Package.csh DPD update - @csh -f Package.csh GRANULAR update - @csh -f Package.csh KSPACE update - @csh -f Package.csh MANYBODY update - @csh -f Package.csh MEAM update - @csh -f Package.csh MOLECULE update - @csh -f Package.csh OPT update - @csh -f Package.csh POEMS update - @csh -f Package.csh XTC update - -# overwrite package files with src files + @for p in $(PACKUC); do csh -f Package.csh $$p update; done package-overwrite: - @csh -f Package.csh ASPHERE overwrite - @csh -f Package.csh CLASS2 overwrite - @csh -f Package.csh COLLOID overwrite - @csh -f Package.csh DIPOLE overwrite - @csh -f Package.csh DPD overwrite - @csh -f Package.csh GRANULAR overwrite - @csh -f Package.csh KSPACE overwrite - @csh -f Package.csh MANYBODY overwrite - @csh -f Package.csh MEAM overwrite - @csh -f Package.csh MOLECULE overwrite - @csh -f Package.csh OPT overwrite - @csh -f Package.csh POEMS overwrite - @csh -f Package.csh XTC overwrite - -# check differences between src and pacakge files - -package-check: - @csh -f Package.csh ASPHERE check - @csh -f Package.csh CLASS2 check - @csh -f Package.csh COLLOID check - @csh -f Package.csh DIPOLE check - @csh -f Package.csh DPD check - @csh -f Package.csh GRANULAR check - @csh -f Package.csh KSPACE check - @csh -f Package.csh MANYBODY check - @csh -f Package.csh MEAM check - @csh -f Package.csh MOLECULE check - @csh -f Package.csh OPT check - @csh -f Package.csh POEMS check - @csh -f Package.csh XTC check + @for p in $(PACKUC); do csh -f Package.csh $$p overwrite; done diff --git a/src/Package.csh b/src/Package.csh index 606da3978a..538572d413 100644 --- a/src/Package.csh +++ b/src/Package.csh @@ -1,6 +1,12 @@ -# Package.csh = copy src files to/from package directories -# called from Makefile -# Syntax: csh Package.csh DIR update/overwrite/check +# Package.csh = package management, called from Makefile +# Syntax: csh Package.csh DIR status/update/overwrite + +# if last arg = "status": +# print installation status of each package +# if package not installed (0-length src/style file), do nothing besides +# check that no package files are in src (except style file) +# flag src files that do not exist or are 0-length +# list package files that are different than src version # if last arg = "update": # if 0-length src/style file doesn't exist, create src/style file @@ -16,12 +22,6 @@ # flag src files that do not exist or are 0-length # overwrite package files that are different than src version -# if last arg = "check": -# if package not installed (0-length src/style file), do nothing besides -# check that no package files are in src (except style file) -# flag src files that do not exist or are 0-length -# list package files that are different than src version - # use diff to compare files # tried using cmp, but it doesn't satisfy if test if one file is # just longer than the other (has new stuff added) @@ -30,7 +30,29 @@ set glob set style = `echo $1 | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` cd $1 -if ($2 == "update") then +if ($2 == "status") then + + if (-z ../style_$style.h) then + echo "Installed NO: package $1" + foreach file (*.cpp *.h) + if (-e ../$file && $file != "style_$style.h") then + echo " src/$file exists but should not" + endif + end + else + echo "Installed YES: package $1" + foreach file (*.cpp *.h) + if (! -e ../$file) then + echo " src/$file does not exist" + else if (-z ../$file) then + echo " src/$file is empty file" + else if (`diff --brief $file ../$file` != "") then + echo " src/$file and $1/$file are different" + endif + end + endif + +else if ($2 == "update") then echo "Updating src from $1 package" @@ -75,27 +97,4 @@ else if ($2 == "overwrite") then end endif -else if ($2 == "check") then - - echo "Checking src versus $1 package" - - if (-z ../style_$style.h) then - echo " $1 package is not installed, no action" - foreach file (*.cpp *.h) - if (-e ../$file && $file != "style_$style.h") then - echo " src/$file exists but should not" - endif - end - else - foreach file (*.cpp *.h) - if (! -e ../$file) then - echo " src/$file does not exist" - else if (-z ../$file) then - echo " src/$file is empty file" - else if (`diff --brief $file ../$file` != "") then - echo " src/$file and $1/$file are different" - endif - end - endif - endif