-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathag_templates.m4
185 lines (157 loc) · 5.89 KB
/
ag_templates.m4
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
#
# Autoconf macros processing a --with-templates option for genom components
#
# --- AG_OPT_TEMPLATES(genom, input.gen) -----------------------------------
#
# Handle recursive template invocation.
#
AC_DEFUN([AG_OPT_TEMPLATES],
[
ag_genom="$1"
ag_input="$2"
# enable --with-templates option
AC_ARG_WITH(templates,
AC_HELP_STRING([--with-templates], [comma separated list of templates.
See genom3 -l for a list of valid choices. Passing a complete path to
a template is also supported]),
[ag_templates="$withval"])
if test "x$ag_templates" = xno; then
ag_templates=
elif test -n "$ag_templates"; then
# user may want to pass options to templates
AC_DISABLE_OPTION_CHECKING
# we may need autoreconf
AC_PATH_PROG(ag_autoreconf, [autoreconf], [no])
# compute AG_TEMPLATES_SUBDIRS
agdir=
oIFS="$IFS"; IFS=","; set -- $ag_templates; IFS="$oIFS"
for t in "$[@]"; do
agdir=$agdir${agdir:+ }./${t#/}
done
AC_SUBST([AG_TEMPLATES_SUBDIRS],[$agdir])
# compute recursive options
_AG_ARGS_SUBDIRS
fi
])
# --- AG_OUTPUT_TEMPLATES --------------------------------------------------
#
# A command to be run _after_ AC_OUTPUT, that generates/autoreconf templates
#
AC_DEFUN([AG_OUTPUT_TEMPLATES],
[
echo "$ag_templates" | tr , '\n' | while read t; do
if test "x$t" = x; then continue; fi
tdir="./${t#/}"
AC_MSG_NOTICE([configuring for $t])
# run genom
AC_MSG_NOTICE([running $ag_genom -C $srcdir $t -C $tdir $ag_input])
eval $ag_genom -C $srcdir $t -C $tdir $ag_input
if test $? != 0; then
rm -rf "$tdir"
AC_MSG_ERROR([cannot generate template $t], 2)
fi
# check for autoconf template (configure.ac)
if test -f "$tdir/configure.ac"; then
if ! test -f "$tdir/configure"; then
AC_MSG_NOTICE([running autoreconf -vi for $t])
if test "$ag_autoreconf" = no; then
AC_MSG_ERROR([autoreconf is missing, please install it], 2)
fi
(cd "$tdir" && $ag_autoreconf -vi)
if test $? -ne 0; then
AC_MSG_ERROR([cannot reconfigure for $t], 2)
fi
fi
# run configure
if test -f "$tdir/configure"; then
AC_MSG_NOTICE(
[running $SHELL configure $ag_sub_configure_args for $t])
if test -f "$tdir/config.status"; then
# otherwise configure will complain...
rm "$tdir/config.status"
fi
# eval makes quoting arguments work
eval "(cd \"$tdir\" && CONFIG_SHELL=$SHELL \
$SHELL configure $ag_sub_configure_args)" ||
AC_MSG_ERROR([configure failed for $t])
fi
fi
AC_MSG_NOTICE([done configuring for $t])
done
])
# --- _AG_ARGS_SUBDIRS -----------------------------------------------------
#
# This mimics _AC_OUTPUT_SUBDIRS by filtering unwanted args for recursive
# configure invocation
#
AC_DEFUN([_AG_ARGS_SUBDIRS],
[
# Remove --srcdir, --disable-option-checking, --with-templates and
# PKG_CONFIG_PATH arguments so they do not pile up. PKG_CONFIG_PATH is
# added explicitly by config.status
#
ag_sub_configure_args=
ag_prev=
eval "set x $ac_configure_args"; shift
for ag_arg in "$[@]"; do
if test -n "$ag_prev"; then ag_prev=; continue; fi
case $ag_arg in
-cache-file|--cache-file|--cache-fil|--cache-fi|--cache-f)
ag_prev=cache_file ;;
--cache-|--cache|--cach|--cac|--ca|--c)
ag_prev=cache_file ;;
-cache-file=*|--cache-file=*|--cache-fil=*|--cache-fi=*)
;;
--cache-f=*|--cache-=*|--cache=*|--cach=*|--cac=*|--ca=*)
;;
--c=*|--config-cache|-C)
;;
-srcdir|--srcdir|--srcdi|--srcd|--src|--sr)
ag_prev=srcdir ;;
-srcdir=*|--srcdir=*|--srcdi=*|--srcd=*|--src=*|--sr=*)
;;
-prefix|--prefix|--prefi|--pref|--pre|--pr|--p)
ag_prev=prefix ;;
-prefix=*|--prefix=*|--prefi=*|--pref=*|--pre=*|--pr=*|--p=*)
;;
--disable-option-checking)
;;
--with-templates)
ag_prev=with_templates ;;
--with-templates=*)
;;
PKG_CONFIG_PATH=*)
;;
*)
case $ag_arg in
*\'*)
ag_arg=`AS_ECHO(["$ag_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
esac
AS_VAR_APPEND([ag_sub_configure_args], [" '$ag_arg'"]) ;;
esac
done
# use parent cache file
case $cache_file in
/*) ag_arg=$cache_file;;
*) ag_arg=$abs_top_build_dir/$cache_file;;
esac
ag_sub_configure_args="$ag_sub_configure_args '--cache-file=$ag_arg'"
# configure in-place
ag_sub_configure_args="$ag_sub_configure_args '--srcdir=.'"
# always append PKG_CONFIG_PATH
ag_arg="$ac_pwd${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH"
for d in $AG_TEMPLATES_SUBDIRS; do
ag_arg="$ac_pwd/$d:$ag_arg"
done
ag_sub_configure_args="$ag_sub_configure_args 'PKG_CONFIG_PATH=$ag_arg'"
# always prepend --prefix to ensure using the same prefix in subdir
# configurations.
ag_arg="--prefix=$prefix"
case $ag_arg in
*\'*) ag_arg=`AS_ECHO(["$ag_arg"]) | sed "s/'/'\\\\\\\\''/g"` ;;
esac
ag_sub_configure_args="'$ag_arg' $ag_sub_configure_args"
# always prepend --disable-option-checking to silence warnings, since
# different subdirs can have different --enable and --with options.
ag_sub_configure_args="'--disable-option-checking' $ag_sub_configure_args"
])