1AC_DEFUN([RNA_CHECK_BUILD_REQUIREMENTS], [
2
3## Check for any tool required to build source files
4##
5## These tools should only be required for maintainer builds,
6## since the generated files are usually distributed along
7## with the distribution tar ball
8RNA_CHECK_SRC_BUILDERS
9
10## Check for presence of (or capability to generate) the
11## Postscript templates we use for RNA secondary structure-
12## and Dot plots.
13RNA_CHECK_POSTSCRIPT_TEMPLATES
14
15## Check for presence of (or capability to generate) the
16## SVG templates we use for RNA secondary structure-
17## and Dot plots.
18RNA_CHECK_SVG_TEMPLATES
19
20RNA_CHECK_PARAMETER_FILES
21
22])
23
24
25AC_DEFUN([RNA_CHECK_SRC_BUILDERS], [
26    AC_ARG_VAR([XXD], [the 'xxd' program to convert text files into C include header files])
27    AC_PATH_PROG([XXD], [xxd], [no])
28    AC_SUBST([XXD])
29    AM_CONDITIONAL(VRNA_AM_SWITCH_HAS_XXD, test "x$XXD" != "xno")
30
31    AC_ARG_VAR([GENGETOPT], [the 'gengetopt' program to generate command line argument parsers for executable programs])
32    AC_PATH_PROG([GENGETOPT], [gengetopt], [no])
33    AC_SUBST([GENGETOPT])
34    AM_CONDITIONAL(VRNA_AM_SWITCH_HAS_GENGETOPT, test "x$GENGETOPT" != "xno")
35
36    AC_ARG_VAR([HELP2MAN], [the 'help2man' script to generate man pages from command line options of our executable programs])
37    AC_PATH_PROG([HELP2MAN], [help2man], [no])
38    AC_SUBST([HELP2MAN])
39    AM_CONDITIONAL(VRNA_AM_SWITCH_BUILD_MANPAGES, test "x$HELP2MAN" != "xno" && test "x$GENGETOPT" != "xno")
40])
41
42
43AC_DEFUN([RNA_CHECK_POSTSCRIPT_TEMPLATES], [
44    STATIC_FILE_DIR="${srcdir}/src/ViennaRNA/static"
45    POSTSCRIPT_FILE_LIST="$STATIC_FILE_DIR/ps_templates.txt"
46
47    ## load list of postscript template files and replace '\n' by ' '
48    PS_TEMPLATE_FILES=`cat $POSTSCRIPT_FILE_LIST | tr '\012' ' '`
49    ## create list of hex postscript template files
50    PS_TEMPLATE_FILES_HEX=`AS_ECHO("$PS_TEMPLATE_FILES") | sed 's/\.ps/\.hex/g'`
51
52    if test "x$XXD" = "xno"
53    then
54        for template in $PS_TEMPLATE_FILES_HEX
55        do
56            AC_RNA_TEST_FILE($STATIC_FILE_DIR/$template,[],[
57                AC_MSG_ERROR([
58=================================================
59Can't find the postscript hex template
60
61${template}
62
63Make sure you've installed the 'xxd' tool to
64generate it from source!
65=================================================
66])
67            ])
68        done
69    fi
70
71    # prepare substitution string for
72    # templates_postscript.h file
73    PS_TEMPLATE_CONST=""
74    for template in $PS_TEMPLATE_FILES_HEX
75    do
76      # remove the 'postscript/' prefix
77      template_name=`AS_ECHO("$template") | sed 's/postscript\///g'`
78      # remove the trailing .hex
79      template_name=`AS_ECHO("$template_name") | sed 's/\.hex//g'`
80
81      # create a C variable defintion for the template
82      # note [[]] will turn into [] after M4 processed everythin
83      PS_TEMPLATE_CONST="$PS_TEMPLATE_CONST
84static const unsigned char PS_$template_name[[]] = {
85#include \"$template\"
86};
87"
88    done
89
90    # Add templates_postscript.h to the files to be processed by
91    # the configure script
92    AC_CONFIG_FILES([src/ViennaRNA/static/templates_postscript.h])
93
94    # substitute C variable definitions
95    AC_SUBST(PS_TEMPLATE_CONST)
96    # hack to avoid placing the multiline PS_TEMPLATE_CONST into any Makefile
97    _AM_SUBST_NOTMAKE(PS_TEMPLATE_CONST)
98
99    # substitute file list for static/Makefile.am
100    AC_SUBST(PS_TEMPLATE_FILES)
101    AC_SUBST(PS_TEMPLATE_FILES_HEX)
102])
103
104AC_DEFUN([RNA_CHECK_SVG_TEMPLATES], [
105    STATIC_FILE_DIR="${srcdir}/src/ViennaRNA/static"
106    SVG_FILE_LIST="$STATIC_FILE_DIR/svg_templates.txt"
107
108    ## load list of svg template files and replace '\n' by ' '
109    SVG_TEMPLATE_FILES=`cat $SVG_FILE_LIST | tr '\012' ' '`
110    ## create list of hex postscript template files
111    SVG_TEMPLATE_FILES_HEX=`AS_ECHO("$SVG_TEMPLATE_FILES") | sed 's/\.svg/\.hex/g'`
112
113    if test "x$XXD" = "xno"
114    then
115        for template in $SVG_TEMPLATE_FILES_HEX
116        do
117            AC_RNA_TEST_FILE($STATIC_FILE_DIR/$template,[],[
118                AC_MSG_ERROR([
119=================================================
120Can't find the svg hex template
121
122${template}
123
124Make sure you've installed the 'xxd' tool to
125generate it from source!
126=================================================
127])
128            ])
129        done
130    fi
131
132    # prepare substitution string for
133    # templates_svg.h file
134    SVG_TEMPLATE_CONST=""
135    for template in $SVG_TEMPLATE_FILES_HEX
136    do
137      # remove the 'svg/' prefix
138      template_name=`AS_ECHO("$template") | sed 's/svg\///g'`
139      # remove the trailing .hex
140      template_name=`AS_ECHO("$template_name") | sed 's/\.hex//g'`
141
142      # create a C variable defintion for the template
143      # note [[]] will turn into [] after M4 processed everythin
144      SVG_TEMPLATE_CONST="$SVG_TEMPLATE_CONST
145static const char SVG_$template_name[[]] = {
146#include \"$template\"
147};
148"
149    done
150
151    # Add templates_svg.h to the files to be processed by
152    # the configure script
153    AC_CONFIG_FILES([src/ViennaRNA/static/templates_svg.h])
154
155    # substitute C variable definitions
156    AC_SUBST(SVG_TEMPLATE_CONST)
157    # hack to avoid placing the multiline SVG_TEMPLATE_CONST into any Makefile
158    _AM_SUBST_NOTMAKE(SVG_TEMPLATE_CONST)
159
160    # substitute file list for static/Makefile.am
161    AC_SUBST(SVG_TEMPLATE_FILES)
162    AC_SUBST(SVG_TEMPLATE_FILES_HEX)
163])
164
165AC_DEFUN([RNA_CHECK_PARAMETER_FILES], [
166    STATIC_FILE_DIR="${srcdir}/src/ViennaRNA/static"
167    PARAMETER_FILE_LIST="${srcdir}/misc/parameter_files.txt"
168
169    ## load list of energy parameter files and replace '\n' by ' '
170    PARAMETER_FILES=`cat $PARAMETER_FILE_LIST | sed 's/^/misc\//' | tr '\012' ' '`
171    ## create list of hex energy parameter files
172    PARAMETER_FILES_HEX=`AS_ECHO("$PARAMETER_FILES") | sed 's/\.par/\.hex/g'`
173
174    if test "x$XXD" = "xno"
175    then
176        for parfile in $PARAMETER_FILES_HEX
177        do
178            AC_RNA_TEST_FILE($STATIC_FILE_DIR/$parfile,[],[
179                AC_MSG_ERROR([
180=================================================
181Can't find the energy parameter hex file
182
183${parfile}
184
185Make sure you've installed the 'xxd' tool to
186generate it from source!
187=================================================
188])
189            ])
190        done
191    fi
192
193    # prepare substitution string for
194    # templates_postscript.h file
195    ENERGY_PARAMETER_CONST=""
196    for parfile in $PARAMETER_FILES_HEX
197    do
198      # remove the 'parameters/' prefix
199      parfile_name=`AS_ECHO("$parfile") | sed 's/misc\///g'`
200      # remove the trailing .hex
201      parfile_name=`AS_ECHO("$parfile_name") | sed 's/.hex//g'`
202
203      # create a C variable defintion for the template
204      # note [[]] will turn into [] after M4 processed everythin
205      ENERGY_PARAMETER_CONST="$ENERGY_PARAMETER_CONST
206static const unsigned char parameter_set_$parfile_name[[]] = {
207#include \"$parfile\"
208};
209"
210    done
211
212    # Add templates_postscript.h to the files to be processed by
213    # the configure script
214    AC_CONFIG_FILES([src/ViennaRNA/static/energy_parameter_sets.h])
215
216    # substitute C variable definitions
217    AC_SUBST(ENERGY_PARAMETER_CONST)
218    # hack to avoid placing the multiline ENERGY_PARAMETER_CONST into any Makefile
219    _AM_SUBST_NOTMAKE(ENERGY_PARAMETER_CONST)
220
221    # substitute file list for static/Makefile.am
222    AC_SUBST(PARAMETER_FILES)
223    AC_SUBST(PARAMETER_FILES_HEX)
224])
225
226