WSTester updated to work plus hopefully all the other changes that need to go into...
[jabaws.git] / binaries / src / ViennaRNA / m4 / package.m4
1 # This file is part of Autoconf.                       -*- Autoconf -*-
2
3 # ViennaRNA Package 2011 Ronny Lorenz
4 #
5
6 ##-----------------##
7 ## Private macros. ##
8 ##-----------------##
9
10 AC_DEFUN([AC_RNA_TEST_FILE],[
11 AC_MSG_CHECKING([for $1])
12 if test -f $1 ; then
13   AC_MSG_RESULT([yes])
14   $2
15 else
16   AC_MSG_RESULT([no])
17   $3
18 fi
19 ])
20
21 AC_DEFUN([AC_RNA_PACKAGE_IF_ENABLED],[
22 if test "x$with_$1" != xno; then
23   $2
24 fi
25 ])
26
27 #
28 # AC_RNA_ADD_PACKAGE( package-name,
29 #                     package-description,
30 #                     default-on,
31 #                     [action-if-not-default],
32 #                     [action-if-default],
33 #                     [files to check for])
34 #
35 # This macro handles additional package inclusion
36 # Parameters:
37 #       package-name:       a lowercase name of the optional package
38 #                           which is used for $with_package_name variables
39 #                           and --with[out]-package-name options in
40 #                           configure script
41 #                           The package_name must consist of alphanumeric
42 #                           characters including the dash only! Every
43 #                           occuring dash will be replaced by a '-' char
44 #                           in the --with[out]-package-name option
45 #
46 #       package-desciption: a very brief description used for the package
47 #                           specific help output in configure script
48 #
49 #       default-on:         package build | installed by default
50 #                           Values: "yes" or "no"
51 #
52 # Example: AC_RNA_ADD_PACKAGE([foo], [the incredible Foo program], [yes], [with_foo=no], [with_foo=yes], [file1 file2])
53 #
54
55 AC_DEFUN([AC_RNA_ADD_PACKAGE],[
56
57 # announce the option to include it in configure script
58 AC_ARG_WITH(m4_translit([[$1]], [_], [-]),
59             [ifelse([$3], [yes],
60               [AS_HELP_STRING([--without-m4_translit([$1], [_], [-])], [do not build | install $2])],
61               [AS_HELP_STRING([--with-m4_translit([$1], [_], [-])], [build | install $2])])],
62             [$4],
63             [$5])
64
65 # check if enabling the package makes sense at configure-time
66 # and deactivate it if not
67
68 AC_RNA_PACKAGE_IF_ENABLED([$1],[
69   for i in $6; do
70     AC_RNA_TEST_FILE([$i],
71       [with_$1=$with_$1],
72       [with_$1=no])
73   done
74 ])
75
76 ])
77
78
79 # AC_RNA_DOCUMENTATION_INIT(PROJECT_NAME, [config-file], [documentation-output-directory])
80 #
81 #
82 AC_DEFUN([AC_RNA_DOCUMENTATION_INIT],[
83
84 AC_PATH_PROG(doxygen, [doxygen],no)
85 AC_PATH_PROG(pdflatex,[pdflatex],no)
86 AC_PATH_PROG(latex,[latex],no)
87 AC_PATH_PROG(makeindex,[makeindex],no)
88 AC_PATH_PROG(dot,[dot],no)
89 AC_PATH_PROG(egrep,[egrep],no)
90 AC_PATH_PROG(perl,[perl],no)
91
92 DOXYGEN_PDFLATEX_WORKARROUND=yes
93
94 # check whether we are able to generate the doxygen documentation
95 AC_RNA_PACKAGE_IF_ENABLED([doc],[
96   if test "x$doxygen" != xno;
97   then
98     # test for programs necessary in order to use doxygen
99
100     if test "x$DOXYGEN_PDFLATEX_WORKARROUND" = xno;
101     then
102     # this is a workarround for older versions of doxygen as installed e.g. in fc12 where
103     # pdflatex usage does not work
104
105       if test "x$pdflatex" = xno;
106       then
107         if test "x$latex" = xno;
108         then
109           AC_MSG_WARN([neither latex or pdflatex exists on your system!])
110           AC_MSG_WARN([deactivating automatic (re)generation of reference manual!])
111           doxygen=no
112         else
113           _latex_cmd=$latex
114         fi
115       else
116         _latex_cmd=$pdflatex
117       fi
118     else
119       if test "x$latex" = xno;
120       then
121         AC_MSG_WARN([neither latex or pdflatex exists on your system!])
122         AC_MSG_WARN([deactivating automatic (re)generation of reference manual!])
123         doxygen=no
124         _latex_cmd=
125       else
126         AC_MSG_WARN([due to a bug in older versions of doxygen, latex will be used for reference manual generation even if pdflatex is available])
127         _latex_cmd=$latex
128         pdflatex=no
129       fi
130     fi
131
132     if test "x$makeindex" = xno;
133     then
134       AC_MSG_WARN([makeindex command not found on your system!])
135       AC_MSG_WARN([deactivating automatic (re)generation of reference manual!])
136       doxygen=no
137     fi
138
139     if test "x$egrep" = xno;
140     then
141       AC_MSG_WARN([egrep command not found on your system!])
142       AC_MSG_WARN([deactivating automatic (re)generation of reference manual!])
143       doxygen=no
144     fi
145
146     if test "x$dot" = xno;
147     then
148       AC_MSG_WARN([dot command not found on your system!])
149       AC_MSG_WARN([deactivating graph output in reference manual!])
150     fi
151
152     if test "x$perl" = xno;
153     then
154       AC_MSG_WARN([perl command not found on your system!])
155       AC_MSG_WARN([deactivating automatic (re)generation of reference manual!])
156       doxygen=no
157     fi
158
159   fi
160 ])
161
162
163 # setup everything in order to generate the doxygen configfile
164
165 AC_RNA_PACKAGE_IF_ENABLED([doc],[
166
167   AC_SUBST([DOXYGEN_PROJECT_NAME], [$1-$PACKAGE_VERSION])
168   AC_SUBST([DOXYGEN_SRCDIR], [$srcdir])
169   AC_SUBST([DOXYGEN_DOCDIR], [ifelse([$3], [], [doc], [$3])])
170   AC_SUBST([DOXYGEN_CONF], [ifelse([$2], [], [doxygen.conf], [$2])])
171
172
173 # prepare the config file for doxygen if we are able to generate a reference manual
174   if test "x$doxygen" != xno;
175   then
176
177     AC_SUBST([DOXYGEN_CMD_LATEX], [$_latex_cmd])
178     AC_SUBST([DOXYGEN_CMD_MAKEINDEX], [$makeindex])
179     AC_SUBST([DOXYGEN_HAVE_DOT],[ifelse([$dot], [no], [NO], [YES])])
180     AC_SUBST([DOXYGEN_WITH_PDFLATEX], [ifelse([$pdflatex],[no],[NO],[YES])])
181     AC_SUBST([DOXYGEN_GENERATE_HTML], [ifelse([$with_doc_html], [no], [NO], [YES])])
182     AC_SUBST([DOXYGEN_GENERATE_LATEX], [ifelse([$with_doc_pdf], [no], [NO], [YES])])
183
184     AC_CONFIG_FILES([${DOXYGEN_DOCDIR}/${DOXYGEN_CONF}])
185
186   else
187
188 # otherwise check if a generated reference manual already exists
189
190     AC_RNA_PACKAGE_IF_ENABLED([doc_pdf],[
191       AC_RNA_TEST_FILE( [$DOXYGEN_DOCDIR/$DOXYGEN_PROJECT_NAME.pdf],
192                         [with_doc_pdf=yes],
193                         [with_doc_pdf=no])])
194
195     AC_RNA_PACKAGE_IF_ENABLED([doc_html],[
196       AC_RNA_TEST_FILE( [$DOXYGEN_DOCDIR/html/index.html],
197                         [with_doc_html=yes],
198                         [with_doc_html=no])])
199
200     if test "x$with_doc_pdf" = "x$with_doc_html";
201     then
202       if test "x$with_doc_pdf" = xno;
203       then
204         with_doc=no
205       fi
206     fi
207   fi
208 ])
209
210 AC_SUBST([REFERENCE_MANUAL_PDF_NAME], [ifelse([$with_doc_pdf],
211                                               [no],
212                                               [],
213                                               [$DOXYGEN_PROJECT_NAME.pdf])])
214 AC_SUBST([REFERENCE_MANUAL_TAGFILE],  [ifelse([$doxygen],
215                                               [no],
216                                               [],
217                                               [$DOXYGEN_PROJECT_NAME.tag])])
218
219
220 # setup variables used in Makefile.am
221 AM_CONDITIONAL(WITH_REFERENCE_MANUAL, test "x$with_doc" != xno)
222 AM_CONDITIONAL(WITH_REFERENCE_MANUAL_BUILD, test "x$doxygen" != xno)
223 AM_CONDITIONAL(WITH_REFERENCE_MANUAL_PDF, test "x$with_doc_pdf" != xno)
224 AM_CONDITIONAL(WITH_REFERENCE_MANUAL_HTML, test "x$with_doc_html" != xno)
225
226 ])
227
228 ##----------------##
229 ## Public macros. ##
230 ##----------------##
231
232 AC_DEFUN([AC_RNA_INIT],[
233
234 SVM_VERSION=2.91
235 with_pf_float=no
236
237 dnl add packages to the configure process
238
239 AC_RNA_ADD_PACKAGE( [perl],
240                     [Perl interface],
241                     [yes],
242                     [with_perl=no],
243                     [with_perl=yes],
244                     [interfaces/Perl/Makefile.am])
245 AC_RNA_ADD_PACKAGE( [python],
246                     [Python interface],
247                     [no],
248                     [with_python=yes],
249                     [with_python=no],
250                     [interfaces/Python/Makefile.am])
251 AC_RNA_ADD_PACKAGE( [ruby],
252                     [Ruby interface],
253                     [no],
254                     [with_ruby=yes],
255                     [with_ruby=no],
256                     [interfaces/Ruby/Makefile.am])
257 AC_RNA_ADD_PACKAGE( [kinfold],
258                     [Kinfold program],
259                     [yes],
260                     [with_kinfold=no],
261                     [with_kinfold=yes],
262                     [Kinfold/Makefile.am])
263 AC_RNA_ADD_PACKAGE( [forester],
264                     [RNAforester program],
265                     [yes],
266                     [with_forester=no],
267                     [with_forester=yes],
268                     [RNAforester/Makefile.am])
269 AC_RNA_ADD_PACKAGE( [cluster],
270                     [AnalyseSeqs and AnalyseDists],
271                     [no],
272                     [with_cluster=yes],
273                     [with_cluster=no],
274                     [Cluster/Makefile.am])
275 AC_RNA_ADD_PACKAGE( [svm],
276                     [svm classifiers],
277                     [yes],
278                     [with_svm=no],
279                     [with_svm=yes],
280                     [libsvm-${SVM_VERSION}/svm.cpp libsvm-${SVM_VERSION}/svm.h])
281 AC_RNA_ADD_PACKAGE( [doc_pdf],
282                     [PDF RNAlib reference manual],
283                     [yes],
284                     [with_doc_pdf=no],
285                     [with_doc_pdf=yes])
286 AC_RNA_ADD_PACKAGE( [doc_html],
287                     [HTML RNAlib reference manual],
288                     [yes],
289                     [with_doc_html=no],
290                     [with_doc_html=yes])
291 AC_RNA_ADD_PACKAGE( [doc],
292                     [RNAlib reference manual],
293                     [yes],
294                     [ with_doc=no
295                       with_doc_pdf=no
296                       with_doc_html=no],
297                     [with_doc=yes])
298
299 ## begin with initialization according to configure-time specific options
300
301 ## The following test ensures the right type for FLT_OR_DBL in the SWIG RNAlib interface
302 AC_MSG_CHECKING([whether float precision is used for partition function arrays instead of double precision])
303 bla=`${GREP} "^#define LARGE_PF" H/data_structures.h`
304 if test "x$bla" = "x";
305 then
306   with_pf_float=yes
307 fi
308 AC_MSG_RESULT([$with_pf_float])
309
310 # check prerequisites for Perl interface
311 AC_PATH_PROG(PerlCmd, perl)
312 ifelse([$PerlCmd], [],[
313   AC_MSG_WARN([No suitable Perl found -- will not build Perl module])
314   AC_MSG_WARN([You may set the PerlCmd environment variable to point to
315               a suitable perl binary])
316   with_perl="no"
317 ],[
318   if $PerlCmd -e 'require 5.004'; then :
319   else
320     AC_MSG_WARN([You need Perl version 5.004 or higher for the Perl module])
321     with_perl="no"
322   fi
323 ])
324
325
326 # prepare all files for perl interface
327 AC_RNA_PACKAGE_IF_ENABLED([perl],[
328   AC_DEFINE([WITH_PERL_INTERFACE], [1], [Create the perl interface to RNAlib])
329   AC_SUBST([PERL_INTERFACE], [Perl])
330   AC_CONFIG_FILES([interfaces/Perl/Makefile interfaces/Perl/Makefile.PL])
331 ])
332
333 # check prerequisites for Python interface
334 AC_PATH_PROG(PythonCmd, python)
335 ifelse([$PythonCmd], [], [
336   AC_MSG_WARN([No suitable Python found -- will not build Python extension])
337   AC_MSG_WARN([You may set the PythonCmd environment variable to point to
338                 a suitable python binary])
339   with_python="no"
340 ],[
341   version_test=`$PythonCmd interfaces/Python/version_test.py`
342   if test "x$version_test" = "xok"; then :
343   else
344     AC_MSG_WARN([You need Python >= 2.5 and < 3.0 to build the Python extension])
345     AC_MSG_WARN([You may set the PythonCmd environment variable to point to
346                 a suitable python binary])
347     with_python="no"
348   fi
349 ])
350
351 # prepare all files for python interface
352 AC_RNA_PACKAGE_IF_ENABLED([python],[
353   AC_DEFINE([WITH_PYTHON_INTERFACE], [1], [Create the python interface to RNAlib])
354   AC_SUBST([PYTHON_INTERFACE], [Python])
355   AC_CONFIG_FILES([interfaces/Python/Makefile interfaces/Python/setup.py])
356 ])
357
358
359 AC_RNA_PACKAGE_IF_ENABLED([kinfold],[
360   AC_CONFIG_SUBDIRS([Kinfold])
361 ])
362
363 AC_RNA_PACKAGE_IF_ENABLED([forester],[
364   AC_CONFIG_SUBDIRS([RNAforester])
365 ])
366
367 AC_RNA_PACKAGE_IF_ENABLED([cluster],[
368   AC_DEFINE([WITH_CLUSTER], [1], [Analyse{Dists,Seqs}])
369   AC_SUBST([CLUSTER_DIR], [Cluster])
370   AC_CONFIG_FILES([Cluster/Makefile])
371 ])
372
373 AC_RNA_PACKAGE_IF_ENABLED([svm],[
374   AC_SUBST([LIBSVM_DIR], [libsvm-${SVM_VERSION}])
375   AC_SUBST([CXXLD],[${CXX}]) # this is rather a hack for RNALfold.c linking correctly
376   AC_DEFINE([USE_SVM], [1], [Compute z-scores for RNALfold])
377 ])
378
379 AM_CONDITIONAL(WITH_LARGE_PF, test "$with_pf_float" != "yes")
380 AM_CONDITIONAL(MAKE_KINFOLD, test "$with_kinfold" != "no")
381 AM_CONDITIONAL(MAKE_FORESTER, test "$with_forester" != "no")
382 AM_CONDITIONAL(MAKE_CLUSTER, test "$with_cluster" = "yes")
383 AM_CONDITIONAL(WITH_LIBSVM, test "$with_svm" != "no")
384
385 AC_RNA_DOCUMENTATION_INIT([RNAlib])
386
387 AC_CONFIG_FILES([misc/Makefile misc/ViennaRNA.spec misc/PKGBUILD])
388 AC_CONFIG_FILES([interfaces/Makefile])
389 AC_CONFIG_FILES([Makefile RNAlib2.pc Utils/Makefile Progs/Makefile lib/Makefile man/Makefile H/Makefile doc/Makefile])
390
391 AC_CONFIG_FILES([man/cmdlopt.sh],[chmod +x man/cmdlopt.sh])
392
393 ])
394
395 AC_DEFUN([AC_RNA_NOTICE],[
396
397 # get directory paths
398
399 eval _bindir=$(eval printf "%s" $bindir)
400 eval _libdir=$(eval printf "%s" $libdir)
401 eval _includedir=$(eval printf "%s" $includedir)
402 eval _datadir=$(eval printf "%s" $datadir)
403 eval _mandir=$(eval printf "%s" $mandir)
404 eval _docdir=$(eval printf "%s" $docdir)
405 eval _htmldir=$(eval printf "%s" $htmldir)
406 eval _pdfdir=$(eval printf "%s" $pdfdir)
407
408 # Notify the user
409
410 AC_MSG_NOTICE(
411 [
412 Configure successful with the following options:
413
414 RNAlib Interfaces:
415   Perl Interface:       ${with_perl:-yes}
416   Python Interface:     ${with_python:-yes}
417   Ruby Interface:       ${with_ruby:-yes}
418
419 Extra Programs:
420   Analyse{Dists,Seqs}:  ${with_cluster:-no}
421   Kinfold:              ${with_kinfold:-yes}
422   RNAforester:          ${with_forester:-yes}
423
424 Other Options:
425   SVM:                  ${with_svm:-yes}
426   Documentation:        ${with_doc:-no}
427     (HTML):             ${with_doc_html:-no}
428     (PDF):              ${with_doc_pdf:-no}
429 -
430 Files will be installed in the following directories:
431
432   Executables:    $_bindir
433   Libraries:      $_libdir
434   Header files:   $_includedir
435   Extra Data:     $_datadir
436   Man pages:      $_mandir
437   Documentation:  $_docdir
438     (HTML):       $(eval printf "%s" $_htmldir)/html
439     (PDF):        $(eval printf "%s" $_pdfdir)
440 ])
441
442 ])
443
444
445