forked from prisms-center/CASMcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefiles.function
106 lines (94 loc) · 2.57 KB
/
makefiles.function
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
#Strip all the '/' characters from a string
_smushdir()
{
local name=$1
echo "${name///}"
}
#Print each argument passed followed by '\', except the last member
_echo_with_backslash()
{
local last="${@: -1}"
for e in $@; do
echo -ne $e
#No \ if it's the last file (end of the set)
if [[ $e != $last ]]; then
echo "\\"
fi
done
}
#Create Makemodule.am file for headers, pass clex, monte_carlo, etc as parameter
_simple_include_makemodule()
{
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit
fi
local target=$1
#find all subdirectories inside a particular include set, such as monte_carlo
searchdir=./include/casm/$target
local d
for d in $(find $searchdir -type d); do
#Strip the path from all the slashes to get a unique name
long=$(_smushdir $d)
#Shorten that name so that it doesn't have "includecasm"
basename=${long#*includecasm}include
#If there's no hh files carry on
headers=$(find $d -maxdepth 1 -type f -name "*.hh")
if [[ $(echo $headers | wc -w) == 0 ]]; then
continue
fi
#Declare the directory a set of header files has to go in
echo "${basename}dir=\$(includedir)"/${d#*include\/}
#Begin listing all the header files that go in the directory
echo "${basename}_HEADERS=\\"
_echo_with_backslash $headers
echo -e
echo -e
done
}
_simple_src_makemodule()
{
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit
fi
local target=$1
#find all files inside a particular src folder
searchdir=./src/casm/$target
srcs=$(find $searchdir -type f -name "*.cc")
echo "libcasm_la_SOURCES +=\\"
_echo_with_backslash $srcs
echo -e
}
#Returns names of the subdirectories that can have Makemodule.am files made directly
#via simple_src_makemodule and simple_include_makemodule
_simple_subdirs()
{
echo "\
app\
basis_set\
casm_io\
clex\
clusterography\
completer\
container\
crystallography\
database\
hull\
misc\
monte_carlo\
strain\
symmetry\
system\
"
}
#Create new Makemodule.am files for all the directories from _simple_subdirs
#for both include and src, and overwrite whatever currently exists
_rewrite_simple_makemodules()
{
local d
for d in $(_simple_subdirs); do
_simple_include_makemodule $d > ./include/casm/$d/Makemodule.am
_simple_src_makemodule $d > ./src/casm/$d/Makemodule.am
done
}