Skip to content

Commit

Permalink
Fix build system, minor source code modifications for windows (mingw …
Browse files Browse the repository at this point in the history
…compilers)
  • Loading branch information
rmcgibbo committed Aug 5, 2015
1 parent 03db4b9 commit 7c3caaf
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 60 deletions.
32 changes: 20 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
include config.h

PROGS=antechamber acdoctor am1bcc antechamber_pvt atomtype bondtype charmmgen \
database espgen parmcal parmchk parmchk2 prepgen residuegen sqm teLeap \
tleap translate parmchk_pvt parmchk2_pvt
ifeq ($(OS),Windows_NT)
WRAPPER_SFX=.bat
else
WRAPPER_SFX=
endif

PROGS=antechamber$(WRAPPER_SFX) acdoctor$(SFX) am1bcc$(SFX) antechamber_pvt$(SFX) \
atomtype$(SFX) bondtype$(SFX) charmmgen$(SFX) database$(SFX) espgen$(SFX) \
parmcal$(SFX) parmchk$(WRAPPER_SFX) parmchk2$(WRAPPER_SFX) prepgen$(SFX) \
residuegen$(SFX) sqm$(SFX) teLeap$(SFX) tleap$(WRAPPER_SFX) translate$(SFX) \
parmchk_pvt$(SFX) parmchk2_pvt$(SFX)

all: prep libs
$(MAKE) antechamber
$(MAKE) leap
$(MAKE) sqm

install: all
mkdir -p $(PREFIX)/bin $(PREFIX)/share
cd bin && /bin/mv $(PROGS) $(PREFIX)/bin
$(MKDIR) -p $(PREFIX)/bin $(PREFIX)/share
cd bin && mv $(PROGS) $(PREFIX)/bin
cp -r share/amber/dat $(PREFIX)

prep:
mkdir -p bin
$(MKDIR) -p bin

antechamber::
cd antechamber && $(MAKE) install
Expand All @@ -33,12 +41,12 @@ libs::
cd arpack && $(MAKE) install

clean:
-cd antechamber && $(MAKE) clean
-cd leap && $(MAKE) clean
-cd sqm && $(MAKE) clean
-cd lib && $(MAKE) clean
-cd cifparse && $(MAKE) clean
cd antechamber && $(MAKE) clean
cd leap && $(MAKE) clean
cd sqm && $(MAKE) clean
cd lib && $(MAKE) clean
cd cifparse && $(MAKE) clean

uninstall:
cd $(PREFIX)/bin && rm -f $(PROGS)
rm -fr $(PREFIX)/dat
$(RM) -fr $(PREFIX)/dat
21 changes: 18 additions & 3 deletions antechamber/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,13 @@ $(BINDIR)/antechamber_pvt$(SFX): antechamber.o
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) antechamber.o \
-L$(LIBDIR) -lcifparse $(LM) -o $(BINDIR)/antechamber_pvt$(SFX)

ifeq ($(OS),Windows_NT)
$(BINDIR)/antechamber$(SFX):
/bin/cp -L antechamber $(BINDIR)
cp -L antechamber.bat $(BINDIR)
else
$(BINDIR)/antechamber$(SFX):
cp -L antechamber $(BINDIR)
endif

$(BINDIR)/atomtype$(SFX): atomtype.o
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) atomtype.o $(LM) -o $(BINDIR)/atomtype$(SFX)
Expand Down Expand Up @@ -272,14 +277,24 @@ $(BINDIR)/espgen$(SFX): espgen.o
$(BINDIR)/parmcal$(SFX): parmcal.o
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) parmcal.o $(LM) -o $(BINDIR)/parmcal$(SFX)

ifeq ($(OS),Windows_NT)
$(BINDIR)/parmchk$(SFX):
cp -L parmchk.bat $(BINDIR)
else
$(BINDIR)/parmchk$(SFX):
/bin/cp -L parmchk $(BINDIR)
cp -L parmchk $(BINDIR)
endif

$(BINDIR)/parmchk_pvt$(SFX): parmchk.o
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) parmchk.o $(LM) -o $(BINDIR)/parmchk_pvt$(SFX)

ifeq ($(OS),Windows_NT)
$(BINDIR)/parmchk2$(SFX):
cp -L parmchk2.bat $(BINDIR)
else
$(BINDIR)/parmchk2$(SFX):
/bin/cp -L parmchk2 $(BINDIR)
cp -L parmchk2 $(BINDIR)
endif

$(BINDIR)/parmchk2_pvt$(SFX): parmchk2.o
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) parmchk2.o $(LM) -o $(BINDIR)/parmchk2_pvt$(SFX)
Expand Down
3 changes: 3 additions & 0 deletions antechamber/antechamber.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:: Point AMBERHOME to the location that has dat/leap
set AMBERHOME=%~dp0\..
%~dp0\antechamber_pvt %*
4 changes: 2 additions & 2 deletions antechamber/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ size_t build_path(char *path, const char *subdir, const char *fname,
char *quote = NULL;
size_t c = 1;
path[0] = '\0';
if (for_system && index(amberhome, ' ') != NULL) {
if (index(amberhome, '"') == NULL)
if (for_system && strchr(amberhome, ' ') != NULL) {
if (strchr(amberhome, '"') == NULL)
quote = "\"";
else
quote = "'";
Expand Down
3 changes: 3 additions & 0 deletions antechamber/parmchk.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:: Point AMBERHOME to the location that has dat/leap
set AMBERHOME=%~dp0\..
%~dp0\parmchk_pvt %*
3 changes: 3 additions & 0 deletions antechamber/parmchk2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:: Point AMBERHOME to the location that has dat/leap
set AMBERHOME=%~dp0\..
%~dp0\parmchk_pvt %*
4 changes: 2 additions & 2 deletions arpack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ $(LIBDIR)/libarpack.a: $(ARPACKLIB)
mv libarpack.a $(LIBDIR)

clean:
-/bin/rm -f *.o _*.f
$(RM) -f *.o _*.f

uninstall:
-rm -f $(LIBDIR)/libarpack.a
$(RM) -f $(LIBDIR)/libarpack.a

10 changes: 5 additions & 5 deletions cifparse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CIFOBS= \
cifparse.o

libcifparse.a: $(CIFOBS)
/bin/rm -f libcifparse.a
rm -f libcifparse.a
$(AR) libcifparse.a $(CIFOBS)
-ranlib libcifparse.a

Expand All @@ -22,7 +22,7 @@ cifp.tab.c: cifparse.y lex.cif.c
$(YACC) -v -d cifparse.y
sed 's/yy/cifp/g' < y.tab.c > cifp.tab.c
sed 's/yy/cifp/g' < y.tab.h > cifp.tab.h
/bin/rm -f y.tab.c y.tab.h
$(RM) -f y.tab.c y.tab.h

cifp.tab.o: cifp.tab.c
$(CC) -c -D$(LEX) $(CNOOPTFLAGS) $(CFLAGS) $(AMBERCFLAGS) cifp.tab.c
Expand All @@ -34,11 +34,11 @@ install: libcifparse.a
mv libcifparse.a $(LIBDIR)

clean:
/bin/rm -f *.o libcifparse.a y.output
/bin/rm -f lex.cif.c cifp.tab.c cifp.tab.h
$(RM) -f *.o libcifparse.a y.output
$(RM) -f lex.cif.c cifp.tab.c cifp.tab.h

uninstall: clean
/bin/rm -f $(LIBDIR)/libcifparse.a
$(RM) -f $(LIBDIR)/libcifparse.a

lex.cif.o: \
cifp.tab.h
31 changes: 25 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from __future__ import with_statement

import os, sys
from distutils.spawn import find_executable
from optparse import OptionParser
on_win = bool(sys.platform == 'win32')

CONFIG_H = """\
# Amber configuration file, created with: %(command)s
Expand Down Expand Up @@ -32,8 +34,7 @@ FLIBSF= -L../lib -larpack -llapack -lblas
# (3) Modify any of the following if you need to change, e.g. to use gcc
# rather than cc, etc.
SHELL=/bin/sh
SHELL=%(shell)s
# Set the C compiler, etc.
# The configure script should be fine, but if you need to hand-edit,
Expand Down Expand Up @@ -73,6 +74,8 @@ YACC= %(yacc)s
AR= ar rv
M4= m4
RANLIB=ranlib
MKDIR = %(mkdir)s
RM = %(rm)s
# Set the C-preprocessor. Code for a small preprocessor is in
# ucpp-1.3; it gets installed as $(BINDIR)/ucpp;
Expand All @@ -96,7 +99,7 @@ C9XCOMPLEX=skip
# For Windows/cygwin, set SFX to ".exe"; for Unix/Linux leave it empty:
# Set OBJSFX to ".obj" instead of ".o" on Windows:
SFX=
SFX=%(sfx)s
OSFX=.o
MV=mv
RM=rm
Expand All @@ -112,7 +115,7 @@ AMBERFFLAGS=$(AMBERBUILDFLAGS)
FREEFORMAT_FLAG= -ffree-form
LM=-lm
FPP=cpp -traditional -P
FPPFLAGS= -DBINTRAJ -DEMIL $(CUSTOMBUILDFLAGS) $(AMBERBUILDFLAGS)
FPPFLAGS= -cpp -DBINTRAJ -DEMIL $(CUSTOMBUILDFLAGS) $(AMBERBUILDFLAGS)
AMBERFPPFLAGS=$(AMBERBUILDFLAGS)
FCREAL8=-fdefault-real-8
NOFORTRANMAIN=-lgfortran -w
Expand Down Expand Up @@ -140,15 +143,21 @@ def which(prog):

# Get the working directory
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
options = dict(basedir=cwd, cc='gcc', cxx='g++', copt='-O3', cxxopt='-O3',
fc='gfortran', fcopt='-O3', mathlib='')
options = dict(basedir=cwd, copt='-O3', cxxopt='-O3', fcopt='-O3', mathlib='')

parser = OptionParser()
parser.add_option('--prefix', dest='prefix', default='/usr/local',
help='Directory to install programs and files to.')
parser.add_option('--yacc', dest='yacc', default=None,
help='Which YACC implementation to use. Looks for byacc '
'first then looks for bison or yacc if not given')
parser.add_option('--cc', dest='cc', default='gcc',
help='Path to C compiler (default=gcc)')
parser.add_option('--cxx', dest='cxx', default='g++',
help='Path to C++ compiler (default=g++)')
parser.add_option('--fc', dest='fc', default='gfortran',
help='Path to fortran compiler (default=gfortran)')


opt, arg = parser.parse_args()

Expand All @@ -165,9 +174,19 @@ else:
if myyacc is None:
sys.exit('Could not find a YACC-compatible parser generator!')

options['cc'] = opt.cc
options['cxx'] = opt.cxx
options['fc'] = opt.fc
options['prefix'] = os.path.abspath(opt.prefix)
options['yacc'] = myyacc
options['command'] = ' '.join(sys.argv)
options['mkdir'] = find_executable('mkdir')
options['rm'] = find_executable('rm')
options['sfx'] = '.exe' if on_win else ''
if on_win:
options['shell'] = 'C:/Windows/System32/cmd.exe'
else:
options['shell'] = '/bin/sh'

if myyacc.endswith('bison'):
options['yacc'] += ' -y'
Expand Down
4 changes: 2 additions & 2 deletions lapack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ skip:
@echo "skipping compilation of LAPACK"

uninstall:
rm -f $(LIBDIR)/liblapack.a
$(RM) -f $(LIBDIR)/liblapack.a

clean:
-/bin/rm -f *.o
$(RM) -f *.o

dlamch.o: dlamch.f
$(FC) -c $(FNOOPTFLAGS) $(FFLAGS) -o $@ $<
15 changes: 11 additions & 4 deletions leap/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
include ../config.h

ifeq ($(OS),Windows_NT)
TLEAP_WRAPPER=tleap.bat
else
TLEAP_WRAPPER=tleap
endif


install:
@echo "Compiling basic programs"
cd src/leap && $(MAKE) installteLeap
@echo "Copying shell script"
cp tleap $(BINDIR)/tleap
chmod +x $(BINDIR)/tleap
cp $(TLEAP_WRAPPER) $(BINDIR)/$(TLEAP_WRAPPER)
chmod +x $(BINDIR)/$(TLEAP_WRAPPER)
$(MAKE) $(MAKE_XLEAP)

uninstall:
cd src/leap && $(MAKE) uninstallteLeap
-rm -f $(BINDIR)/tleap
$(RM) -f $(BINDIR)/tleap
-cd src/leap && $(MAKE) uninstall
-rm -f $(BINDIR)/xleap
$(RM) -f $(BINDIR)/xleap

install_xleap:
cd src/Wc && $(MAKE)
Expand Down
2 changes: 1 addition & 1 deletion leap/src/Xmu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ libXmu.a: $(OBJS)
$(RANLIB) $@

clean:
/bin/rm -f *.o *.a
$(RM) -f *.o *.a
2 changes: 1 addition & 1 deletion leap/src/Xpm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ libXpm.a: $(OBJS)
$(RANLIB) $@

clean:
/bin/rm -f *.o *.a
$(RM) -f *.o *.a
2 changes: 1 addition & 1 deletion leap/src/Xraw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ libXaw.a: $(OBJS)
$(RANLIB) $@

clean:
/bin/rm -f *.o *.a
$(RM) -f *.o *.a
18 changes: 9 additions & 9 deletions leap/src/leap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ install: all
mv XaLeap_wcl $(DATDIR)

uninstall:
-rm -f $(BINDIR)/teLeap$(SFX)
-rm -f $(BINDIR)/xaLeap$(SFX)
-rm -f $(DATDIR)/XaLeap_wcl
$(RM) -f $(BINDIR)/teLeap$(SFX)
$(RM) -f $(BINDIR)/xaLeap$(SFX)
$(RM) -f $(DATDIR)/XaLeap_wcl

installteLeap: t
mv teLeap$(SFX) $(BINDIR)

uninstallteLeap:
-rm -f $(BINDIR)/teLeap$(SFX)
$(RM) -f $(BINDIR)/teLeap$(SFX)

teLeap$(SFX): $(TLEAP_OBJ)
$(CC) $(CFLAGS) $(AMBERCFLAGS) $(LDFLAGS) $(AMBERLDFLAGS) \
Expand Down Expand Up @@ -209,15 +209,15 @@ utilLib2Pdb$(SFX): $(UL2P_OBJ)
$(CC) $(CFLAGS) $(AMBERCFLAGS) -o $@ $(UL2P_OBJ) $(LM)

clean::
-rm -f *.o $(PROGS) *\~
-rm -f XaLeap_wcl
-rm -f *.gprof
-rm -f helptext.c parser.c
$(RM) -f *.o $(PROGS) *\~
$(RM) -f XaLeap_wcl
$(RM) -f *.gprof
$(RM) -f helptext.c parser.c

parser.c: parser.y parser.h
$(YACC) parser.y
@echo "(The warning 'conflicts: 6 shift/reduce' is normal)"
/bin/rm -f parser.c
$(RM) -f parser.c
mv y.tab.c parser.c

helptext.c: helptext.text utilMakeHelp$(SFX)
Expand Down
Loading

0 comments on commit 7c3caaf

Please sign in to comment.