-
Notifications
You must be signed in to change notification settings - Fork 9
/
autogen.sh
executable file
·287 lines (261 loc) · 6.28 KB
/
autogen.sh
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/bin/sh
# Clean
if test "$1" = "-c"
then
rm -rf \
Makefile.in \
aclocal.m4 \
autom4te.cache/ \
configure \
config.log \
agate.h \
ar-lib \
compile \
config.guess \
config.status \
config.sub \
depcomp \
install-sh \
missing \
configure.ac \
m4/ar-lib \
m4/compile \
m4/config.guess \
m4/config.sub \
m4/depcomp \
m4/install-sh \
m4/missing \
src/Makefile \
src/Makefile.am \
src/Makefile.in \
src/*/Makefile \
src/*/Makefile.in \
src/*/Makefile.am \
doc/Makefile.in \
include/Makefile \
include/Makefile.in \
include/Makefile.am \
include/*/Makefile \
include/*/Makefile.in \
include/*/Makefile.am \
FINDSYM/Makefile \
FINDSYM/Makefile.in \
FINDSYM/Makefile.am \
bin/Makefile \
bin/Makefile.in \
bin/Makefile.am \
agate.h.in \
doc/Makefile \
Makefile \
Makefile.in \
Makefile.am \
src/*/*.o \
src/*/*.a \
bin/*.o
find . -name "*~" -exec rm {} \;
find . -name ".deps" -exec rm -rf {} \;
for i in $(ls bin/*.cpp)
do
rm -rf ${i%%.cpp};
done
else
# Generate Makefile.am in include
cd include
echo "" > Makefile.am
for lib in $(find . -type d | sed '1d')
do
echo "${lib##*/}dir=\$(includedir)/$lib" >> Makefile.am
echo "${lib##*/}_HEADERS = \\" >> Makefile.am
for header in $(ls $lib/*.h*)
do
echo " $header \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
echo "" >> Makefile.am
done
cd ..
# Generate Makefile.am in src
cd src
for lib in $(find . -type d | sed '1d')
do
cd $lib
echo "noinst_LTLIBRARIES = lib${lib#./}.la
" > Makefile.am
echo "lib${lib#./}_la_SOURCES = \\" >> Makefile.am
for src in $(ls *.cpp)
do
echo " $src \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
echo "AM_CXXFLAGS = @AM_CXXFLAGS""@
AM_CPPFLAGS = -I\$(top_srcdir)/include @AM_CPPFLAGS@ -DDATADIR=\\\"\$(datadir)\\\"" >> Makefile.am
cd -
done
cd ..
# Generate libagate.so
cd src
echo "lib_LTLIBRARIES = libagate.la
libagate_la_SOURCES =
libagate_la_LIBADD = \\" > Makefile.am
for lib in $(find . -type d | sed '1d')
do
[ $lib = "./qtgui" ] && continue
echo " $lib/lib${lib#./}.la \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
cd ..
# Generate Makefile.am in bin
cd bin
echo "LDADD = \\" > Makefile.am
cat >> Makefile.am << EOF
\$(top_builddir)/src/libagate.la @SPGLIB_LDFLAGS@
EOF
sed -i -e '$s/\\//' Makefile.am
echo "AM_LDFLAGS = @AM_LDFLAGS@
" >> Makefile.am
echo "bin_PROGRAMS = \\" >> Makefile.am
for bin in $(ls *.cpp | grep -v -e qagate -e "qrc*")
do
# name don't start with test or if -t provided
if test "${bin#test}" = "${bin}" -o "$1" = "-t" ; then
echo " ${bin%%.cpp} \\" >> Makefile.am
fi
done
sed -i -e '$s/\\//' Makefile.am
echo "
AM_CXXFLAGS = -I\$(top_srcdir)/include @AM_CXXFLAGS@ \$(QT_CXXFLAGS)" >> Makefile.am
for bin in $(ls *.cpp | grep -v -e qagate -e "qrc*")
do
if test "${bin#test}" = "${bin}" -o "$1" = "-t" ; then
echo "
${bin%%.cpp}_SOURCES = $bin " >> Makefile.am
fi
done
sed -i -e '$s/\\//' Makefile.am
cd ..
# Generate Makefile.am in FINDSYM
cd FINDSYM
cat > Makefile.am << EOF
EXTRA_DIST = \\
const.dat \\
data_images.txt \\
findsym \\
data_diperiodic.txt \\
data_magnetic.txt \\
data_space.txt \\
data_wyckoff.txt \\
symmetry.dat
fsymdatadir = \$(datadir)/@PACKAGE_NAME@/FINDSYM/
fsymdata_DATA = \\
const.dat \\
data_images.txt \\
findsym \\
data_diperiodic.txt \\
data_magnetic.txt \\
data_space.txt \\
data_wyckoff.txt \\
symmetry.dat
install-data-hook:
chmod 755 \$(DESTDIR)/\$(fsymdatadir)/findsym
EOF
cd ..
# Generate Makefile.am in test
cd test
cat > Makefile.am << EOF
LDADD = \
\$(top_builddir)/src/libagate.la @SPGLIB_LDFLAGS@
AM_LDFLAGS = @AM_LDFLAGS@
AM_CXXFLAGS = -I\$(top_srcdir)/include -I\$(top_srcdir)/test/files @AM_CXXFLAGS@
EXTRA_DIST = \\
EOF
for f in `ls files/`
do
echo " files/$f \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
bin=''
for f in `ls *.h`;
do
bin="$bin$IFS${f%%_*}"
done;
bin=$(echo $bin | xargs -n1 | sort -u)
echo "check_PROGRAMS = \\" >> Makefile.am
for b in $bin
do
echo " $b \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
for b in $bin
do
echo "${b}_SOURCES = ${b}.cpp" >> Makefile.am
echo "EXTRA_${b}_SOURCES = \\" >> Makefile.am
for s in `ls ${b}_*.h`
do
echo " $s \\" >> Makefile.am
done
sed -i -e '$s/\\//' Makefile.am
done
echo "TESTS = \$(check_PROGRAMS)" >> Makefile.am
for b in $bin
do
echo "${b}.cpp:\$(EXTRA_${b}_SOURCES)" >> Makefile.am
echo " cxxtestgen --error-printer -o \$@ \$^" >> Makefile.am
done
cat >> Makefile.am << EOF
clean-local: clean-test-files
.PHONY: clean-test-files
clean-test-files:
-rm -rf *.dat *.nc *.in ref* *DDB
EOF
cd ..
# Generate Makefile.am ./
echo "ACLOCAL_AMFLAGS=-I m4
SUBDIRS = @AM_SPGLIB@ \\" > Makefile.am
#for lib in $(find include -type d | sed '1d')
#do
# echo " ${lib} \\" >> Makefile.am
#done
for lib in $(find src -type d | sed '1d')
do
echo " ${lib} \\" >> Makefile.am
done
echo " include src bin doc FINDSYM test" >> Makefile.am
cat >> Makefile.am << EOF
EXTRA_DIST = autogen.sh configure1 configure2 spglib-1.15.0.tar.gz $(if test "$1" = "-t"; then echo "glfw-3.2.1.zip"; fi)
nodist_include_HEADERS = agate.h
clean-local:
find . -name "*~" -exec rm {} \; || echo "Not cleaning"
find . -name "*swp" -exec rm {} \; || echo "Not cleaning"
doc:doc/doxyfile.stamp
doc/doxyfile.stamp:
cd doc && \$(MAKE) doc
doc:doc/doxyfile.stamp
pdf:
cd doc && \$(MAKE) $@
EOF
cp configure1 configure.tmp
for m in $(find include src -name Makefile.am)
do
echo "AC_CONFIG_FILES([${m%%.am}])" >> configure.tmp
done
cat configure.tmp configure2 > configure.ac
rm configure.tmp
LIBTOOLIZE=$(which glibtoolize 2> /dev/null || which libtoolize 2> /dev/null)
if [ -z "$LIBTOOLIZE" ]
then
echo "Missign libtoolize or glibtoolize"
exit 1
fi
#if test "$OSTYPE" = "darwin*"
#then
# LIBTOOLIZE=glibtoolize
#else
# LIBTOOLIZE=libtoolize
#fi
touch agate.h.in
$LIBTOOLIZE && \
aclocal \
&& automake --add-missing \
&& autoconf \
&& autoheader
fi