Newer
Older
ROOT = lmp
EXE = lmp_$@
ARLIB = liblammps_$@.a
SHLIB = liblammps_$@.so
ARLINK = liblammps.a
SHLINK = liblammps.so
OBJDIR = Obj_$@
OBJSHDIR = Obj_shared_$@
SRC = $(wildcard *.cpp)
Axel Kohlmeyer
committed
INC = $(filter-out lmpinstalledpkgs.h,$(wildcard *.h))
SRCLIB = $(filter-out main.cpp,$(SRC))
OBJLIB = $(filter-out main.o,$(OBJ))
# Command-line options for mode: exe (default), shexe, lib, shlib
mode = exe
objdir = $(OBJDIR)
ifeq ($(mode),shexe)
objdir = $(OBJSHDIR)
endif
ifeq ($(mode),lib)
objdir = $(OBJDIR)
endif
ifeq ($(mode),shlib)
objdir = $(OBJSHDIR)
endif
# PACKAGE = standard packages
# PACKUSER = user packagse
# PACKLIB = all packages that require an additional lib
# should be PACKSYS + PACKINT + PACKEXT
# PACKSYS = subset that reqiure a common system library
# include MPIIO and LB b/c require full MPI, not just STUBS
# PACKINT = subset that require an internal (provided) library
# PACKEXT = subset that require an external (downloaded) library
granular kim kokkos kspace latte manybody mc meam message misc \
molecule mpiio mscg opt peri poems \
python qeq reax replica rigid shock snap spin srd voronoi
Axel Kohlmeyer
committed
PACKUSER = user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \
user-intel user-lb user-manifold user-meamc user-meso \
user-mgpt user-misc user-mofff user-molfile \
user-netcdf user-omp user-phonon user-ptm user-qmmm user-qtb \
user-quip user-reaxc user-scafacos user-smd user-smtbq \
user-sph user-tally user-uef user-vtk
PACKLIB = compress gpu kim kokkos latte meam message mpiio mscg poems \
python reax voronoi \
user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \
user-netcdf user-qmmm user-quip user-scafacos user-smd user-vtk
PACKSYS = compress mpiio python user-lb
PACKINT = gpu kokkos meam message poems reax user-atc user-awpmd user-colvars
user-h5md user-molfile user-netcdf user-qmmm user-quip \
user-smd user-vtk
PACKAGEUC = $(shell echo $(PACKAGE) | tr a-z A-Z)
PACKUSERUC = $(shell echo $(PACKUSER) | tr a-z A-Z)
YESDIR = $(shell echo $(@:yes-%=%) | tr a-z A-Z)
NODIR = $(shell echo $(@:no-%=%) | tr a-z A-Z)
LIBDIR = $(shell echo $(@:lib-%=%))
LIBUSERDIR = $(shell echo $(@:lib-user-%=%))
@echo ''
@echo 'make clean-all delete all object files'
@echo 'make clean-machine delete object files for one machine'
@echo 'make tar create lmp_src.tar.gz for src dir and packages'
@echo 'make package list available packages and their dependencies'
@echo 'make package-installed (pi) list of installed packages'
@echo 'make yes-package install a single pgk in src dir'
@echo 'make no-package remove a single pkg from src dir'
@echo 'make yes-all install all pgks in src dir'
@echo 'make no-all remove all pkgs from src dir'
@echo 'make yes-standard (yes-std) install all standard pkgs'
@echo 'make yes-user install all user pkgs'
@echo 'make no-user remove all user pkgs'
@echo 'make yes-lib install all pkgs with libs (included or ext)'
@echo 'make no-lib remove all pkgs with libs (included or ext)'
@echo 'make yes-ext install all pkgs with external libs'
@echo 'make no-ext remove all pkgs with external libs'
@echo ''
@echo 'make lib-package help for download/build/install a package library'
@echo 'make lib-package args="..." download/build/install a package library'
@echo 'make purge purge obsolete copies of source files'
@echo 'make machine build LAMMPS for machine'
@echo 'make mode=lib machine build LAMMPS as static lib for machine'
@echo 'make mode=shlib machine build LAMMPS as shared lib for machine'
@echo 'make mode=shexe machine build LAMMPS as shared exe for machine'
@echo 'make makelist create Makefile.list used by old makes'
@echo 'make -f Makefile.list machine build LAMMPS for machine (old)'
@files="`ls MAKE/OPTIONS/Makefile.*`"; \
for file in $$files; do head -1 $$file; done
@echo ''
@echo ''
@files="`ls MAKE/MACHINES/Makefile.*`"; \
for file in $$files; do head -1 $$file; done
@echo ''
Axel Kohlmeyer
committed
lmpinstalledpkgs.h: $(SRC) $(INC)
@echo 'Gathering installed package information (may take a little while)'
@echo '#ifndef LMP_INSTALLED_PKGS_H' > lmpinstalledpkgs.tmp
@echo '#define LMP_INSTALLED_PKGS_H' >> lmpinstalledpkgs.tmp
Axel Kohlmeyer
committed
@echo 'const char * LAMMPS_NS::LAMMPS::installed_packages[] = {' >> lmpinstalledpkgs.tmp
Axel Kohlmeyer
committed
@for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \
[ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package \(.*\)"/"\1",/' >> lmpinstalledpkgs.tmp || :; done
@echo ' NULL };' >> lmpinstalledpkgs.tmp
Axel Kohlmeyer
committed
@echo '#endif' >> lmpinstalledpkgs.tmp
Axel Kohlmeyer
committed
@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
# exe = exe with static compile in Obj_machine (default)
# shexe = exe with shared compile in Obj_shared_machine
# lib = static lib in Obj_machine
# shlib = shared lib in Obj_shared_machine
@test -f MAKE/Makefile.$@ -o -f MAKE/OPTIONS/Makefile.$@ -o \
-f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@
Axel Kohlmeyer
committed
@$(MAKE) $(MFLAGS) lmpinstalledpkgs.h
Axel Kohlmeyer
committed
@echo 'Compiling LAMMPS for machine $@'
@if [ ! -e Makefile.package ]; \
then cp Makefile.package.empty Makefile.package; fi
@if [ ! -e Makefile.package.settings ]; \
then cp Makefile.package.settings.empty Makefile.package.settings; fi
$(MAKE) $(MFLAGS) "SRC = $(SRC)" "INC = $(INC)" depend || :
endif
ifeq ($(mode),shexe)
@cd $(objdir); \
$(MAKE) $(MFLAGS) "OBJ = $(OBJ)" "INC = $(INC)" \
"EXE = ../$(EXE)" ../$(EXE)
endif
ifeq ($(mode),lib)
@cd $(objdir); \
$(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" "SHFLAGS =" \
"EXE = ../$(ARLIB)" lib
@rm -f $(ARLINK)
@ln -s $(ARLIB) $(ARLINK)
endif
ifeq ($(mode),shlib)
@cd $(objdir); \
$(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" \
"EXE = ../$(SHLIB)" shlib
@rm -f $(SHLINK)
@ln -s $(SHLIB) $(SHLINK)
endif
clean:
@echo 'make clean-all delete all object files'
@echo 'make clean-machine delete object files for one machine'
clean-all:
Axel Kohlmeyer
committed
# include python package settings to
# automatically adapt name of python interpreter
Axel Kohlmeyer
committed
sinclude ../lib/python/Makefile.lammps
# Create a tarball of src dir and packages
tar:
@cd STUBS; $(MAKE) clean
@cd ..; tar cvzf src/$(ROOT)_src.tar.gz \
src/Make* src/Package.sh src/Depend.sh src/Install.sh \
src/MAKE src/DEPEND src/*.cpp src/*.h src/STUBS \
$(patsubst %,src/%,$(PACKAGEUC)) $(patsubst %,src/%,$(PACKUSERUC)) \
--exclude=*/.svn
@cd STUBS; $(MAKE)
@echo "Created $(ROOT)_src.tar.gz"
@echo 'Packages that need system libraries:' $(PACKSYS)
@echo ''
@echo 'Packages that need provided libraries:' $(PACKINT)
@echo ''
@echo 'Packages that need external libraries:' $(PACKEXT)
@echo ''
@echo 'make package list available packages'
@echo 'make package list available packages'
@echo 'make package-status (ps) status of all packages'
@echo 'make package-installed (pi) list of installed packages'
@echo 'make yes-package install a single pgk in src dir'
@echo 'make no-package remove a single pkg from src dir'
@echo 'make yes-all install all pgks in src dir'
@echo 'make no-all remove all pkgs from src dir'
@echo 'make yes-standard (yes-std) install all standard pkgs'
@echo 'make no-standard (no-std) remove all standard pkgs'
@echo 'make yes-user install all user pkgs'
@echo 'make no-user remove all user pkgs'
@echo 'make yes-lib install all pkgs with libs (included or ext)'
@echo 'make no-lib remove all pkgs with libs (included or ext)'
@echo 'make yes-ext install all pkgs with external libs'
@echo 'make no-ext remove all pkgs with external libs'
@echo ''
@echo 'make package-update (pu) replace src files with package files'
@echo 'make package-overwrite replace package files with src files'
@echo 'make package-diff (pd) diff src files against package file'
@echo ''
@echo 'make lib-package build and/or download a package library'
@for p in $(PACKAGE); do $(MAKE) no-$$p; done
yes-user:
@for p in $(PACKUSER); do $(MAKE) yes-$$p; done
no-user:
@for p in $(PACKUSER); do $(MAKE) no-$$p; done
yes-lib:
@for p in $(PACKLIB); do $(MAKE) yes-$$p; done
yes-ext:
@for p in $(PACKEXT); do $(MAKE) yes-$$p; done
no-ext:
@for p in $(PACKEXT); do $(MAKE) no-$$p; done
@if [ ! -e Makefile.package ]; \
then cp Makefile.package.empty Makefile.package; fi
@if [ ! -e Makefile.package.settings ]; \
then cp Makefile.package.settings.empty Makefile.package.settings; fi
@if [ ! -e $(YESDIR) ]; then \
echo "Package $(@:yes-%=%) does not exist"; \
cd $(YESDIR); $(SHELL) Install.sh 1; cd ..; \
$(SHELL) Depend.sh $(YESDIR) 1; \
else \
echo "Installing package $(@:yes-%=%)"; \
cd $(YESDIR); $(SHELL) ../Install.sh 1; cd ..; \
$(SHELL) Depend.sh $(YESDIR) 1; \
fi;
no-%:
@if [ ! -e $(NODIR) ]; then \
echo "Package $(@:no-%=%) does not exist"; \
cd $(NODIR); $(SHELL) Install.sh 0; cd ..; \
$(SHELL) Depend.sh $(NODIR) 0; \
else \
echo "Uninstalling package $(@:no-%=%)"; \
cd $(NODIR); $(SHELL) ../Install.sh 0; cd ..; \
$(SHELL) Depend.sh $(NODIR) 0; \
# download/build/install a package library
Axel Kohlmeyer
committed
# update the timestamp on main.cpp to trigger a relink with "make machine"
lib-%:
@if [ -e ../lib/$(LIBDIR)/Install.py ]; then \
echo "Installing lib $(@:lib-%=%)"; \
Axel Kohlmeyer
committed
( cd ../lib/$(LIBDIR); $(PYTHON) Install.py $(args) ); \
elif [ -e ../lib/$(LIBUSERDIR)/Install.py ]; then \
echo "Installing lib $(@:lib-user-%=%)"; \
Axel Kohlmeyer
committed
( cd ../lib/$(LIBUSERDIR); $(PYTHON) Install.py $(args) ); \
else \
echo "Install script for lib $(@:lib-%=%) does not exist"; \
Axel Kohlmeyer
committed
fi; touch main.cpp
# status = list src files that differ from package files
# installed = list of installed packages
# update = replace src files with newer package files
# overwrite = overwrite package files with newer src files
# diff = show differences between src and package files
package-installed pi:
@for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p installed; done
@for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p installed; done
Axel Kohlmeyer
committed
package-update pu: purge
Axel Kohlmeyer
committed
package-overwrite: purge
@for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p diff; done
@echo ''
@for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p diff; done
purge: Purge.list