revamp of library builds

- remove cross compiler stuff
- make use of Install.py consistent
- provide options for Makefile.serial and Makefile.mpi that match those in src
This commit is contained in:
Axel Kohlmeyer 2017-08-07 17:13:01 -04:00
parent 0a54c34e34
commit 135b1650f1
21 changed files with 231 additions and 335 deletions

1
lib/.gitignore vendored
View File

@ -1,2 +1,3 @@
Makefile.lammps
.depend
Makefile.auto

View File

@ -70,23 +70,31 @@ if not os.path.exists("Makefile.%s" % machine):
lines = open("Makefile.%s" % machine,'r').readlines()
fp = open("Makefile.auto",'w')
has_extramake = False
for line in lines:
words = line.split()
if len(words) == 3 and extraflag and \
words[0] == "EXTRAMAKE" and words[1] == '=':
line = line.replace(words[2],"Makefile.lammps.%s" % suffix)
print >>fp,line,
if len(words) == 3 and words[0] == "EXTRAMAKE" and words[1] == '=':
has_extramake = True
if extraflag:
line = line.replace(words[2],"Makefile.lammps.%s" % suffix)
fp.write(line)
fp.close()
# make the library via Makefile.auto
# make the library via Makefile.auto optionally with parallel make
try:
import multiprocessing
n_cpus = multiprocessing.cpu_count()
except:
n_cpus = 1
print("Building lib%s.a ..." % lib)
cmd = "make -f Makefile.auto clean; make -f Makefile.auto"
cmd = "make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus
txt = subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)
print(txt)
print(txt.decode('UTF-8'))
if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
if not os.path.exists("Makefile.lammps"):
if has_extramake and not os.path.exists("Makefile.lammps"):
print("lib/%s/Makefile.lammps was NOT created" % lib)

71
lib/awpmd/Makefile.mpi Normal file
View File

@ -0,0 +1,71 @@
SHELL = /bin/sh
# which file will be copied to Makefile.lammps
EXTRAMAKE = Makefile.lammps.linalg
# ------ FILES ------
SRC = \
ivutils/src/logexc.cpp \
systems/interact/TCP/wpmd.cpp \
systems/interact/TCP/wpmd_split.cpp
INC = \
cerf.h \
cerf2.h \
cerf_octave.h \
cvector_3.h \
lapack_inter.h \
logexc.h \
pairhash.h \
refobj.h \
tcpdefs.h \
vector_3.h \
wavepacket.h \
wpmd.h \
wpmd_split.h
# ------ DEFINITIONS ------
LIB = libawpmd.a
OBJ = $(SRC:.cpp=.o)
# ------ SETTINGS ------
# include any MPI settings needed for the ATC library to build with
# the same MPI library that LAMMPS is built with
CC = mpicxx
CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
-DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1
ARCHIVE = ar
ARCHFLAG = -rc
DEPFLAGS = -M
#LINK =
#LINKFLAGS =
USRLIB =
SYSLIB =
# ------ MAKE PROCEDURE ------
lib: $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
@cp $(EXTRAMAKE) Makefile.lammps
# ------ COMPILE RULES ------
%.o:%.cpp
$(CC) $(CCFLAGS) -c $< -o $@
%.d:%.cpp
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
# ------ DEPENDENCIES ------
DEPENDS = $(OBJ:.o=.d)
# ------ CLEAN ------
clean:
-rm -f *.d *~ $(OBJ) $(LIB)

View File

@ -36,8 +36,10 @@ OBJ = $(SRC:.cpp=.o)
# include any MPI settings needed for the ATC library to build with
# the same MPI library that LAMMPS is built with
CC = mpic++
CCFLAGS = -O -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include
CC = mpicxx
CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
-DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1
ARCHIVE = ar
ARCHFLAG = -rc
DEPFLAGS = -M
@ -66,4 +68,4 @@ DEPENDS = $(OBJ:.o=.d)
# ------ CLEAN ------
clean:
-rm *.d *~ $(OBJ) $(LIB)
-rm -f *.d *~ $(OBJ) $(LIB)

71
lib/awpmd/Makefile.serial Normal file
View File

@ -0,0 +1,71 @@
SHELL = /bin/sh
# which file will be copied to Makefile.lammps
EXTRAMAKE = Makefile.lammps.linalg
# ------ FILES ------
SRC = \
ivutils/src/logexc.cpp \
systems/interact/TCP/wpmd.cpp \
systems/interact/TCP/wpmd_split.cpp
INC = \
cerf.h \
cerf2.h \
cerf_octave.h \
cvector_3.h \
lapack_inter.h \
logexc.h \
pairhash.h \
refobj.h \
tcpdefs.h \
vector_3.h \
wavepacket.h \
wpmd.h \
wpmd_split.h
# ------ DEFINITIONS ------
LIB = libawpmd.a
OBJ = $(SRC:.cpp=.o)
# ------ SETTINGS ------
# include any MPI settings needed for the ATC library to build with
# the same MPI library that LAMMPS is built with
CC = g++
CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
-I../../src/STUBS
ARCHIVE = ar
ARCHFLAG = -rc
DEPFLAGS = -M
#LINK =
#LINKFLAGS =
USRLIB =
SYSLIB =
# ------ MAKE PROCEDURE ------
lib: $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
@cp $(EXTRAMAKE) Makefile.lammps
# ------ COMPILE RULES ------
%.o:%.cpp
$(CC) $(CCFLAGS) -c $< -o $@
%.d:%.cpp
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
# ------ DEPENDENCIES ------
DEPENDS = $(OBJ:.o=.d)
# ------ CLEAN ------
clean:
-rm -f *.d *~ $(OBJ) $(LIB)

View File

@ -13,7 +13,7 @@ Syntax from lib/colvars dir: python Install.py -m machine -e suffix
specify -m and optionally -e, order does not matter
-m = peform a clean followed by "make -f Makefile.machine"
-m = delete all existing objects, followed by "make -f Makefile.machine"
machine = suffix of a lib/colvars/Makefile.* or of a
src/MAKE/MACHINES/Makefile.* file
-e = set EXTRAMAKE variable in Makefile.machine to Makefile.lammps.suffix
@ -21,7 +21,7 @@ specify -m and optionally -e, order does not matter
Examples:
make lib-colvars args="-m g++" # build COLVARS lib with GNU g++ compiler
make lib-colvars args="-m mpi" # build COLVARS lib with default mpi compiler wrapper
"""
# print error message or help
@ -122,7 +122,7 @@ for line in lines:
fp.write(line)
fp.close()
# make the library via Makefile.auto
# make the library via Makefile.auto optionally with parallel make
try:
import multiprocessing
@ -132,9 +132,9 @@ except:
print("Building lib%s.a ..." % lib)
cmd = ["make -f Makefile.auto clean"]
print(subprocess.check_output(cmd, shell=True).decode())
print(subprocess.check_output(cmd, shell=True).decode('UTF-8'))
cmd = ["make -f Makefile.auto -j%d" % n_cpus]
print(subprocess.check_output(cmd, shell=True).decode())
print(subprocess.check_output(cmd, shell=True).decode('UTF-8'))
if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))

View File

@ -1,5 +0,0 @@
# Settings that the LAMMPS build will import when this package library is used
colvars_SYSINC =
colvars_SYSLIB =
colvars_SYSPATH =

View File

@ -1,31 +0,0 @@
# -*- makefile -*- to build Colvars module with MinGW 32-bit
EXTRAMAKE = Makefile.lammps.empty
COLVARS_LIB = libcolvars.a
COLVARS_OBJ_DIR = Obj_mingw64/
CXX = i686-w64-mingw32-g++
CXXFLAGS = -O2 -march=i686 -mtune=generic -mfpmath=387 -mpc64 \
-fno-rtti -fno-exceptions -finline-functions \
-ffast-math -funroll-loops -fstrict-aliasing \
-Wall -W -Wno-uninitialized
AR = i686-w64-mingw32-ar
ARFLAGS = -rscv
SHELL = /bin/sh
.PHONY: default clean
default: $(COLVARS_OBJ_DIR) $(COLVARS_LIB) Makefile.lammps
include Makefile.common
$(COLVARS_OBJ_DIR):
mkdir $(COLVARS_OBJ_DIR)
clean:
-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
-rmdir $(COLVARS_OBJ_DIR)
Makefile.lammps:
-cp $(EXTRAMAKE) Makefile.lammps

View File

@ -1,13 +0,0 @@
# -*- makefile -*- wrapper for non-MPI libraries
SHELL=/bin/sh
all:
$(MAKE) $(MFLAGS) mingw32-cross
-rm -f Obj_mingw32-mpi
ln -s Obj_mingw32 Obj_mingw32-mpi
clean:
$(MAKE) $(MFLAGS) clean-mingw32-cross
-rm -f Obj_mingw32-mpi

View File

@ -1,31 +0,0 @@
# -*- makefile -*- to build Colvars module with MinGW 32-bit
EXTRAMAKE = Makefile.lammps.empty
COLVARS_LIB = libcolvars.a
COLVARS_OBJ_DIR = Obj_mingw32/
CXX = x86_64-w64-mingw32-g++
CXXFLAGS = -O2 -march=core2 -mtune=core2 -mpc64 -msse2 \
-fno-rtti -fno-exceptions -finline-functions \
-ffast-math -funroll-loops -fstrict-aliasing \
-Wall -W -Wno-uninitialized
AR = x86_64-w64-mingw32-ar
ARFLAGS = -rscv
SHELL = /bin/sh
.PHONY: default clean
default: $(COLVARS_OBJ_DIR) $(COLVARS_LIB) Makefile.lammps
include Makefile.common
$(COLVARS_OBJ_DIR):
mkdir $(COLVARS_OBJ_DIR)
clean:
-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
-rmdir $(COLVARS_OBJ_DIR)
Makefile.lammps:
-cp $(EXTRAMAKE) Makefile.lammps

View File

@ -1,13 +0,0 @@
# -*- makefile -*- wrapper for non-MPI libraries
SHELL=/bin/sh
all:
$(MAKE) $(MFLAGS) mingw64-cross
-rm -f Obj_mingw64-mpi
ln -s Obj_mingw64 Obj_mingw64-mpi
clean:
$(MAKE) $(MFLAGS) clean-mingw64-cross
-rm -f Obj_mingw64-mpi

25
lib/colvars/Makefile.mpi Normal file
View File

@ -0,0 +1,25 @@
# -*- makefile -*- to build Colvars module with default MPI compiler wrapper
EXTRAMAKE = Makefile.lammps.empty
COLVARS_LIB = libcolvars.a
COLVARS_OBJ_DIR =
CXX = mpicxx
CXXFLAGS = -O2 -g -Wall -fPIC -funroll-loops
AR = ar
ARFLAGS = -rscv
SHELL = /bin/sh
.PHONY: default clean
default: $(COLVARS_LIB) Makefile.lammps
include Makefile.common
clean:
-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
Makefile.lammps:
-cp $(EXTRAMAKE) Makefile.lammps

View File

@ -0,0 +1,25 @@
# -*- makefile -*- to build Colvars module with GNU compiler
EXTRAMAKE = Makefile.lammps.empty
COLVARS_LIB = libcolvars.a
COLVARS_OBJ_DIR =
CXX = g++
CXXFLAGS = -O2 -g -Wall -fPIC -funroll-loops
AR = ar
ARFLAGS = -rscv
SHELL = /bin/sh
.PHONY: default clean
default: $(COLVARS_LIB) Makefile.lammps
include Makefile.common
clean:
-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
Makefile.lammps:
-cp $(EXTRAMAKE) Makefile.lammps

View File

@ -9,12 +9,14 @@ HDF5_PATH=/usr
INC=-I include
AR=ar
ARFLAGS=rc
LIB=libch5md.a
# need to build two libraries to not break compatibility and to support Install.py
LIB=libh5md.a libch5md.a
all: lib Makefile.lammps
build:
mkdir -p build
build/ch5md.o: src/ch5md.c | build
$(CC) $(INC) $(CFLAGS) -c $< -o $@
@ -23,8 +25,11 @@ Makefile.lammps:
.PHONY: all lib clean
$(LIB): build/ch5md.o
$(AR) $(ARFLAGS) $(LIB) build/ch5md.o
libch5md.a : build/ch5md.o
$(AR) $(ARFLAGS) $@ build/ch5md.o
libh5md.a : build/ch5md.o
$(AR) $(ARFLAGS) $@ build/ch5md.o
lib: $(LIB)

View File

@ -1,58 +0,0 @@
#!/usr/bin/env python
# install.py tool to do build of the linear algebra library
# used to automate the steps described in the README file in this dir
import sys,commands,os
# help message
help = """
Syntax from src dir: make lib-linalg args="-m machine"
Syntax from lib dir: python Install.py -m machine
-m = peform a clean followed by "make -f Makefile.machine"
machine = suffix of a lib/Makefile.* file
Example:
make lib-linalg args="-m gfortran" # build with GNU Fortran compiler
"""
# print error message or help
def error(str=None):
if not str: print help
else: print "ERROR",str
sys.exit()
# parse args
args = sys.argv[1:]
nargs = len(args)
if nargs == 0: error()
machine = None
iarg = 0
while iarg < nargs:
if args[iarg] == "-m":
if iarg+2 > nargs: error()
machine = args[iarg+1]
iarg += 2
else: error()
# set lib from working dir
cwd = os.getcwd()
lib = os.path.basename(cwd)
# make the library
print "Building lib%s.a ..." % lib
cmd = "make -f Makefile.%s clean; make -f Makefile.%s" % (machine,machine)
txt = commands.getoutput(cmd)
print txt
if os.path.exists("lib%s.a" % lib): print "Build was successful"
else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))

View File

@ -18,10 +18,8 @@ OBJ = $(SRC:.f=.o)
# ------ SETTINGS ------
FC = gfortran
FFLAGS = -O3 -fPIC -march=native -mpc64 \
-ffast-math -funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized -fno-second-underscore
FFLAGS0 = -O0 -fPIC -march=native -mpc64 \
-Wall -W -Wno-uninitialized -fno-second-underscore
FFLAGS = -O3 -fPIC -ffast-math -fstrict-aliasing -fno-second-underscore
FFLAGS0 = -O0 -fPIC -fno-second-underscore
ARCHIVE = ar
AR = ar
ARCHFLAG = -rcs
@ -47,7 +45,7 @@ dlamch.o: dlamch.f
# ------ CLEAN ------
clean:
-rm *.o *.mod *~ $(LIB)
-rm -f *.o *.mod *~ $(LIB)
tar:
-tar -czvf ../linalg.tar.gz $(FILES)

View File

@ -1,67 +0,0 @@
# -*- makefile -*-
# *_________________________________________________________________________*
# * Minimal BLAS/LAPACK Library for use by other LAMMPS packages
SHELL = /bin/sh
# ------ FILES ------
SRC = $(wildcard *.f)
FILES = $(SRC) Makefile.* README
# ------ DEFINITIONS ------
DIR = Obj_mingw32/
LIB = $(DIR)liblinalg.a
OBJ = $(SRC:%.f=$(DIR)%.o)
# ------ SETTINGS ------
FC = i686-w64-mingw32-gfortran
FFLAGS = -O3 -march=i686 -mtune=generic -mfpmath=387 -mpc64 \
-ffast-math -funroll-loops -fstrict-aliasing -Wall -W \
-Wno-uninitialized -fno-second-underscore
FFLAGS0 = -O0 -march=i686 -mtune=generic -mfpmath=387 -mpc64 \
-Wall -W -Wno-uninitialized -fno-second-underscore
ARCHIVE = i686-w64-mingw32-ar
AR = i686-w64-mingw32-ar
ARCHFLAG = -rcs
USRLIB =
SYSLIB =
.PHONY: default clean tar
.SUFFIXES:
.SUFFIXES: .F .f .o
# ------ MAKE PROCEDURE ------
default: $(DIR) $(LIB)
$(LIB): $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
$(DIR):
mkdir $(DIR)
# ------ COMPILE RULES ------
$(DIR)%.o:%.F
$(F90) $(F90FLAGS) -c $< -o $@
$(DIR)%.o:%.f
$(FC) $(FFLAGS) -c $< -o $@
$(DIR)dlamch.o: dlamch.f
$(FC) $(FFLAGS0) -c $< -o $@
# ------ CLEAN ------
clean:
-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-rmdir $(DIR)
tar:
-tar -czvf ../linalg.tar.gz $(FILES)

View File

@ -1,13 +0,0 @@
# -*- makefile -*- wrapper for non-MPI libraries
SHELL=/bin/sh
all:
$(MAKE) $(MFLAGS) mingw32-cross
-rm -f Obj_mingw32-mpi
ln -s Obj_mingw32 Obj_mingw32-mpi
clean:
$(MAKE) $(MFLAGS) clean-mingw32-cross
-rm -f Obj_mingw32-mpi

View File

@ -1,67 +0,0 @@
# -*- makefile -*-
# *_________________________________________________________________________*
# * Minimal BLAS/LAPACK Library for use by other LAMMPS packages
SHELL = /bin/sh
# ------ FILES ------
SRC = $(wildcard *.f)
FILES = $(SRC) Makefile.* README
# ------ DEFINITIONS ------
DIR = Obj_mingw64/
LIB = $(DIR)liblinalg.a
OBJ = $(SRC:%.f=$(DIR)%.o)
# ------ SETTINGS ------
FC = x86_64-w64-mingw32-gfortran
FFLAGS = -O3 -march=core2 -mtune=generic -msse2 -mpc64 \
-ffast-math -funroll-loops -fstrict-aliasing -Wall -W \
-Wno-uninitialized -fno-second-underscore
FFLAGS0 = -O0 -march=core2 -mtune=generic -msse2 -mpc64 \
-Wall -W -Wno-uninitialized -fno-second-underscore
ARCHIVE = x86_64-w64-mingw32-ar
AR = x86_64-w64-mingw32-ar
ARCHFLAG = -rcs
USRLIB =
SYSLIB =
.PHONY: default clean tar
.SUFFIXES:
.SUFFIXES: .F .f .o
# ------ MAKE PROCEDURE ------
default: $(DIR) $(LIB)
$(LIB): $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
$(DIR):
mkdir $(DIR)
# ------ COMPILE RULES ------
$(DIR)%.o:%.F
$(F90) $(F90FLAGS) -c $< -o $@
$(DIR)%.o:%.f
$(FC) $(FFLAGS) -c $< -o $@
$(DIR)dlamch.o: dlamch.f
$(FC) $(FFLAGS0) -c $< -o $@
# ------ CLEAN ------
clean:
-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-rmdir $(DIR)
tar:
-tar -czvf ../linalg.tar.gz $(FILES)

View File

@ -1,13 +0,0 @@
# -*- makefile -*- wrapper for non-MPI libraries
SHELL=/bin/sh
all:
$(MAKE) $(MFLAGS) mingw64-cross
-rm -f Obj_mingw64-mpi
ln -s Obj_mingw64 Obj_mingw64-mpi
clean:
$(MAKE) $(MFLAGS) clean-mingw64-cross
-rm -f Obj_mingw64-mpi

1
lib/linalg/Makefile.serial Symbolic link
View File

@ -0,0 +1 @@
Makefile.gfortran