diff --git a/src/Depend.sh b/src/Depend.sh index b0fe6947ae..9ae724f8a0 100644 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -1,54 +1,101 @@ # Depend.sh = Install/unInstall files for dependent packages -# all packages which contain one or more files that depend on -# other packages should be listed here, in both the 1 and 0 clauses -# this script is invoked after any parent package is installed/uninstalled + +# parent package = has files that files in another package derive from +# child package = has files that derive from files in another package +# all parent/child package dependencies should be listed below + +# this script is invoked after any package is installed/uninstalled # this script re-installs child packages that depend on the parent, # but only if the child package is already installed # this is necessary to insure the child package installs # only child files whose parent package files are now installed -# decisions on installing individual child files are made by +# decisions on (un)installing individual child files are made by # the Install.sh script in the child package -if (test $1 = 1) then +# depend function: args = child-package 0/1 +# checks if child-package is installed, if not just return +# if parent package is being installed, reinstall the child +# if parent package is being uninstalled, uninstall the child, reinstall it - if (test -e pair_lj_cut_gpu.h) then - cd GPU; /bin/sh Install.sh 1; cd .. +depend () { + cd $1 + installed=0 + for file in *.cpp *.h; do + if (test -e ../$file) then + installed=1 + fi + done + cd .. + if (test $installed = 0) then + return fi - if (test -e pair_lj_cut_opt.h) then - cd OPT; /bin/sh Install.sh 1; cd .. - fi - if (test -e cg_cmm_params.h) then - cd USER-CG-CMM; /bin/sh Install.sh 1; cd .. - fi - if (test -e pair_lj_cut_cuda.h) then - cd USER-CUDA; /bin/sh Install.sh 1; cd .. - fi - if (test -e fix_imd.h) then - cd USER-MISC; /bin/sh Install.sh 1; cd .. - fi -# if (test -e thr_omp.h) then -# cd USER-OMP; /bin/sh Install.sh 1; cd .. -# fi -elif (test $1 = 0) then + if (test $2 = 1) then + echo " reinstalling package $1" + cd $1; /bin/sh Install.sh 1; cd .. + elif (test $2 = 0) then + echo " un/reinstalling package $1" + cd $1; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. + fi +} - if (test -e pair_lj_cut_gpu.h) then - cd GPU; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. - fi - if (test -e pair_lj_cut_opt.h) then - cd OPT; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. - fi - if (test -e cg_cmm_params.h) then - cd USER-CG-CMM; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. - fi - if (test -e pair_lj_cut_cuda.h) then - cd USER-CUDA; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. - fi - if (test -e fix_imd.h) then - cd USER-MISC; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. - fi -# if (test -e thr_omp.h) then -# cd USER-OMP; /bin/sh Install.sh 0; /bin/sh Install.sh 1; cd .. -# fi +# add one if statement per parent package +# add one depend() call per child package that depends on that parent +# list of child packages: +# GPU, OPT, USER-CUDA, USER-MISC, USER-OMP +if (test $1 = "ASPHERE") then + depend GPU $2 + depend USER-OMP $2 fi + +if (test $1 = "CLASS2") then + depend GPU $2 + depend USER-CUDA $2 + depend USER-OMP $2 +fi + +if (test $1 = "COLLOID") then + depend GPU $2 + depend USER-OMP $2 +fi + +if (test $1 = "GRANULAR") then + depend USER-CUDA $2 + depend USER-OMP $2 +fi + +if (test $1 = "KSPACE") then + depend GPU $2 + depend OPT $2 + depend USER-CUDA $2 + depend USER-OMP $2 +fi + +if (test $1 = "MANYBODY") then + depend GPU $2 + depend OPT $2 + depend USER-CUDA $2 + depend USER-MISC $2 + depend USER-OMP $2 +fi + +if (test $1 = "PERI") then + depend USER-OMP $2 +fi + +if (test $1 = "RIGID") then + depend USER-OMP $2 +fi + +if (test $1 = "USER-CG-CMM") then + depend GPU $2 + depend USER-CUDA $2 + depend USER-OMP $2 +fi + +if (test $1 = "USER-MISC") then + depend GPU $2 + depend USER-OMP $2 +fi + diff --git a/src/Makefile b/src/Makefile index dfeb994ac8..6b6d174589 100755 --- a/src/Makefile +++ b/src/Makefile @@ -193,7 +193,7 @@ yes-%: echo "Package $(@:yes-%=%) does not exist"; \ else \ echo "Installing package $(@:yes-%=%)"; \ - cd $(YESDIR); $(SHELL) Install.sh 1; cd ..; $(SHELL) Depend.sh 1; \ + cd $(YESDIR); $(SHELL) Install.sh 1; cd ..; $(SHELL) Depend2.sh $(YESDIR) 1; \ fi; no-%: @@ -201,7 +201,7 @@ no-%: echo "Package $(@:no-%=%) does not exist"; \ else \ echo "Uninstalling package $(@:no-%=%)"; \ - cd $(NODIR); $(SHELL) Install.sh 0; cd ..; $(SHELL) Depend.sh 0; \ + cd $(NODIR); $(SHELL) Install.sh 0; cd ..; $(SHELL) Depend2.sh $(NODIR) 0; \ fi; # status = list src files that differ from package files