-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure
executable file
·140 lines (120 loc) · 3.65 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
if [[ $1 = "--help" || $1 = "-h" ]] ; then
cat <<EOF
Usage ./configure <OPTIONS>
OPTIONS
--help : Display this message
--with-nlopt=<DIRECTORY> : Path to NLOpt directory
--cxx=<PATH> : C++ compiler
--cxxflags=<FLAGS> : Extra flags to pass to compiler
--ldflags=<FLAGS> : Extra flafs to pass to linker
EOF
exit 0
fi
WHICH_PSI4=$(which psi4)
WHICH_PYTHON=$(which python)
WHICH_PSI4CONFIG=$(which psi4-config)
if [[ "$WHICH_PSI4" = "" ]]; then
echo "Error: psi4: command not found"
exit 1
fi
if [[ "$WHICH_PYTHON" = "" ]]; then
echo "Error: python: command not found"
exit 1
fi
if [[ "$WHICH_PSI4CONFIG" = "" ]]; then
echo "Error: psi4-config: command not found"
echo "You might have too old of a version of psi4"
echo "Upgrade to the latest version with conda"
exit 1
fi
PSI4ROOTDIR="$(dirname ${WHICH_PSI4})/.."
CXX="g++"
CXXFLAGS="$(psi4-config --defines 2>&1 >/dev/null) -D_GLIBCXX_USE_CXX11_ABI=0 -DRESTRICT=__restrict__ -fPIC -std=c++11 -Wno-deprecated-declarations"
LDFLAGS="-lnlopt -Wl,-export-dynamic"
INCLUDES="-Iinclude -I${PSI4ROOTDIR}/include/ -I${PSI4ROOTDIR}/include/psi4 -I${PSI4ROOTDIR}/include/python2.7/ "
while [[ $# > 0 ]]
do
VALUE=""
POS=`echo $1 | awk 'match($0,"="){print RSTART}'`
if [[ $POS -eq 1 ]] ; then
echo "Error: '=' cannot be first character in an argument." > /dev/stderr ; exit 1
elif [[ $POS -gt 1 ]] ; then
((PM1 = $POS - 1))
KEY=${1:0:$PM1}
VALUE=${1:$POS}
if [[ $VALUE = "" ]] ; then
echo "Error: '$1': Expected <var>=<value>, missing <value>." > /dev/stderr ; exit 1
fi
eval VALUE=$VALUE 2> /dev/null
else
KEY=$1
fi
case $KEY in
--cxx)
CXX="${VALUE}"
;;
--cxxflags)
CXXFLAGS="${CXXFLAGS} ${VALUE}"
;;
--ldflags)
LDFLAGS="${LDFLAGS} ${VALUE}"
;;
--with-nlopt)
INCLUDES="${INCLUDES} -I${VALUE}/include"
LDFLAGS="-L${VALUE}/lib ${LDFLAGS}"
;;
*)
echo "Unrecognized OPTION: $1"
exit 1
;;
esac
shift # past argument or value
done
MAKEFILE_CONTENTS=$(cat <<'EOF'
# The name of your plugin. Taken from the directory name.
NAME := $(shell basename `pwd`)
# Used to determine linking flags.
UNAME = $(shell uname)
PSITARGET = $(NAME).so
# Start the compilation rules
default:: $(PSITARGET)
# Add the flags needed for shared library creation
ifeq ($(UNAME), Darwin)
CXXFLAGS += -fno-common
endif
CXXSRC := $(wildcard src/*.cc)
BINOBJ := $(addprefix obj/, $(notdir $(CXXSRC:%.cc=%.o)))
src/gitversion.hpp: .git/HEAD .git/index
echo "const char *GIT_VERSION = \"$(shell git rev-parse --short HEAD)\";" > $@
obj/dotsphere.o: src/dotsphere.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
obj/potential.o: src/potential.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
obj/resp2.o: src/resp2.cc src/gitversion.hpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
obj/vdwsurface.o: src/vdwsurface.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
obj/respfit.o: src/respfit.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(PSITARGET): $(BINOBJ)
$(CXX) -shared -o $@ $^ $(CXXDEFS) $(LDFLAGS)
clean: psiclean
rm -f $(BINOBJ) $(PSITARGET) *.d *.pyc *.test output.dat psi.timer.dat
psiclean:
rm -f `cat psi.*.clean | xargs`
rm -f psi.*.clean psi.*.clean.out timer.dat psi.timer.dat
print-%:
@echo '$*=$($*)'
EOF
)
# rm -f Makefile
cat <<EOF > Makefile
CXX := ${CXX}
CXXFLAGS := ${CXXFLAGS}
LDFLAGS := ${LDFLAGS}
INCLUDES := ${INCLUDES}
${MAKEFILE_CONTENTS}
EOF
echo "Writing Makefile"
mkdir -p obj